Overview
This page documents utility functions for working with processes, including checking if a process is alive, getting architecture information, and managing command line arguments.LM_IsProcessAlive
Checks if a given process is alive based on its PID and start time.Function Signature
Parameters
The process that will be checked. Both the PID and start time are used to verify the process is the same instance.
Return Value
Returns
LM_TRUE if the process specified by the input lm_process_t is alive, or LM_FALSE otherwise.Example
Notes
- This function checks both PID and start time to avoid false positives from PID reuse
- More reliable than just checking if a PID exists
- Useful for monitoring target processes in injectors or debuggers
LM_GetBits
Returns the size of a pointer in bits, which corresponds to the current process’s bits (32 bits or 64 bits).Function Signature
Parameters
This function takes no parameters.Return Value
Returns the size of a pointer in bits. Typically
32 or 64.Example
Notes
- Returns the architecture of the current process, not the system
- Useful for determining pointer sizes and offsets
- A 32-bit process on a 64-bit system will return
32
LM_GetSystemBits
Returns the system architecture bits (32 bits or 64 bits).Function Signature
Parameters
This function takes no parameters.Return Value
Returns the system bits. Typically
32 or 64.Example
Notes
- Returns the architecture of the operating system, not the current process
- On Windows, useful for detecting WoW64 (32-bit process on 64-bit Windows)
- The system bits are always >= the process bits
LM_GetCommandLine
Retrieves the command line arguments of a process.Function Signature
Parameters
The process to retrieve the command line from.
Return Value
Returns an allocated NULL-terminated array of strings containing the command line arguments, or
NULL if it fails. The returned array must be freed with LM_FreeCommandLine.Example
Notes
- WARNING: On Windows, this function requires reading process memory
- Always free the returned buffer with
LM_FreeCommandLine - May require elevated privileges on some systems
- Returns
NULLon failure
LM_FreeCommandLine
Frees a command line buffer obtained fromLM_GetCommandLine.
Function Signature
Parameters
The allocated command line buffer to free.
Return Value
This function does not return a value.Example
Notes
- Always call this function to free memory allocated by
LM_GetCommandLine - Safe to call with
NULLpointer (no-op) - Failure to free will cause memory leaks
Complete Example
Here’s a complete example demonstrating all utility functions:See Also
- LM_GetProcess - Get information about the current process
- LM_GetProcessEx - Get information about a process by PID
- LM_FindProcess - Find a process by name
- LM_EnumProcesses - Enumerate all processes