Lazy WinAPI
Macros | Functions
Process

Interactions with Windows Processes. More...

Macros

#define Process_self()   GetCurrentProcess()
 Alias to GetCurrentProcess() More...
 
#define Process_self_pid()   GetCurrentProcessId()
 Alias to GetCurrentProcessId() More...
 
#define Process_open(_pid, _access_rights)   OpenProcess(_access_rights, 0, _pid)
 Macro wrapper to open process. More...
 
#define Process_close(_handle)   CloseHandle(_handle)
 Alias to CloseHandle(). More...
 

Functions

uint32_t Process_get_window_pid (const HWND window)
 Get pid of window. More...
 
uint32_t Process_get_window_tid (const HWND window)
 Get tid of window. More...
 
const uint8_t * Process_read_mem (HANDLE process, uintptr_t base, uint8_t *buffer, size_t size)
 Reads memory of a process. More...
 
bool Process_write_mem (HANDLE process, uintptr_t base, const uint8_t *buffer, size_t size)
 Write into memory of a process. More...
 
const wchar_t * Process_get_exe_path (HANDLE process, wchar_t *buffer, size_t size)
 Retrieves full path to process's binary. More...
 

Detailed Description

Interactions with Windows Processes.

Macro Definition Documentation

#define Process_close (   _handle)    CloseHandle(_handle)

Alias to CloseHandle().

Parameters
[in]_handleProcess handle from Process_open()
#define Process_open (   _pid,
  _access_rights 
)    OpenProcess(_access_rights, 0, _pid)

Macro wrapper to open process.

Note
See information about access rights.
Parameters
[in]_pidProcess identifier.
[in]_access_rightsBit mask that specifies desired access rights.
Returns
Handle to opened process.
#define Process_self ( )    GetCurrentProcess()

Alias to GetCurrentProcess()

Returns
Handle to current process.
#define Process_self_pid ( )    GetCurrentProcessId()

Alias to GetCurrentProcessId()

Returns
Pid of current process.

Function Documentation

const wchar_t* Process_get_exe_path ( HANDLE  process,
wchar_t *  buffer,
size_t  size 
)

Retrieves full path to process's binary.

Note
Requires access rights either PROCESS_QUERY_INFORMATION or PROCESS_QUERY_LIMITED_INFORMATION
Parameters
[in]processHandle to process.
[out]bufferBuffer to hold result.
[in]sizeSize of buffer. Result is truncated by it.
Returns
Pointer to buffer.
Return values
NULLOn failure.
uint32_t Process_get_window_pid ( const HWND  window)

Get pid of window.

Note
If you need both pid & tid then use directly GetWindowThreadProcessId
Parameters
[in]windowA handle to the window.
uint32_t Process_get_window_tid ( const HWND  window)

Get tid of window.

Note
If you need both pid & tid then use directly GetWindowThreadProcessId
Parameters
[in]windowA handle to the window.
const uint8_t* Process_read_mem ( HANDLE  process,
uintptr_t  base,
uint8_t *  buffer,
size_t  size 
)

Reads memory of a process.

Parameters
[in]processHandle to the process.
[in]baseA pointer to the base address in the specified process from which to read.
[out]bufferMemory to hold read result.
[in]sizeNumber of bytes to read.
Returns
buffer on success.
Return values
NULLon failure.
bool Process_write_mem ( HANDLE  process,
uintptr_t  base,
const uint8_t *  buffer,
size_t  size 
)

Write into memory of a process.

Parameters
[in]processHandle to the process.
[in]baseA pointer to the base address in the specified process from which to write.
[in]bufferData to write.
[in]sizeNumber of bytes to write.
Return values
trueOn success.
falseOn failure.