RtEnumProcessModules

The RtEnumProcessModules function retrieves a handle for each module in a specified process.

Syntax

Copy
BOOL RtEnumProcessModules(
    HANDLE hProcess,
    HMODULE *lphModule,
    DWORD cb,
    LPDWORD lpcbNeeded,
);

Parameters

hProcess

A handle to the process.

lphModule

An array that receives the list of module handles.

cb

The size of lphModule array, in bytes.

lpcbNeeded

The number of bytes required to store all module handles in the lphModule array.

Return Value

If the function succeeds, it returns TRUE. If the function fails, it returns FALSE..

To get extended error information, call GetLastError.

Remarks

The RtEnumProcessModules function is primarily designed for use by debuggers and similar applications that must extract module information from another process. If the module list in the target process is corrupted or not yet initialized, or if the module list changes during the function call due to RTDLLs being loaded or unloaded, RtEnumProcessModules may fail or return incorrect information.

It is best to specify a large array of HMODULE values, because it is hard to predict how many modules there will be in the process at the time you call RtEnumProcessModules. To determine if the lphModule array is too small to hold all module handles for the process, compare the value returned in lpcbNeeded with the value specified in cb. If lpcbNeeded is greater than cb, increase the size of the array and call RtEnumProcessModules again.

To determine how many modules were enumerated by the call to RtEnumProcessModules, divide the resulting value in the lpcbNeeded parameter by sizeof(HMODULE).

Do not call RtCloseHandle on any of the handles returned by this function. The information comes from a snapshot, so there are no resources to be freed.

RtEnumProcessModules will always return lpcbNeeded for a valid hProcess handle and will attempt to fill the lphModule array with as much information as allowed by parameter cb. The function will not fail on account of lpcbNeeded exceeding the size of the lphModule array.

Requirements

Minimum supported version Header Library

eRTOS 1.0 SDK

Rtapi.h rtkrnl.lib