GetProcAddress
GetProcAddress returns the address of the specified exported dynamic-link library (DLL) function.
Syntax
FARPROC GetProcAddress(
HMODULE hModule,
LPCSTR lpProcName
);
Parameters
hModule
A handle to the RTDLL module that contains the function. The LoadLibrary function returns this handle.
lpProcName
A pointer to a null-terminated string containing the function name, or the function's ordinal value.
Return Value
If the function succeeds, it returns the address of the RTDLL's exported function. If the function fails, it returns NULL.
To get extended error information, call GetLastError.
Remarks
GetProcAddress is used to retrieve addresses of exported functions in RTDLLs.
The spelling and case of the function name pointed to by lpProcName must be identical to that in the EXPORTS statement of the source RTDLL's module-definition (.DEF) file. The exported names of Win32 API functions may differ from the names used when calling these functions in the code. This difference is hidden by macros used in the SDK header files. For more information, see Win32 Function Prototypes.
The lpProcName parameter can identify the RTDLL function by specifying an ordinal value associated with the function in the EXPORTS statement.
GetProcAddress verifies that the specified ordinal is in the range 1 through the highest ordinal value exported in the .DEF file. The function then uses the ordinal as an index to read the function's address from a function table. If the .DEF file does not number the functions consecutively from 1 to N (where N is the number of exported functions), an error can occur where GetProcAddress returns an invalid, non-NULL address, even though there is no function with the specified ordinal.
In cases where the function may not exist, the function should be specified by name rather than by ordinal value.
Process Environment: The following information applies to the Process environment:
- Function lookup by ordinal value is not presently supported.
- If the exported routine name is decorated (e.g., _<fname>@<# argument bytes> as in the __stdcall convention) the decorated name must be specified in the call to GetProcAddress.
- DEF files are not supported.
Requirements
Minimum supported version | Header | Library |
---|---|---|
eRTOS 1.0 SDK |
windows.h | rtkrnl.lib |
See Also: