Is there a way to get the handle of a module which I know its name from another process using C++?
GetModuleHandle
and GetModuleHandleEx
are good only getting the handle from the same process.
Asked
Active
Viewed 4,370 times
2

Idov
- 5,006
- 17
- 69
- 106
-
CreateToolhelp32Snapshot + Module32First/Next – Hans Passant Dec 09 '11 at 15:57
-
There is an answer at http://stackoverflow.com/questions/865152/how-can-i-get-a-process-handle-by-its-name-in-c from a previous post. – Software_Designer Dec 09 '11 at 16:51
1 Answers
1
You can use ReadProcessMemory and PEB_LDR_DATA
typedef struct _PEB_LDR_DATA {
BYTE Reserved1[8];
PVOID Reserved2[3];
LIST_ENTRY InMemoryOrderModuleList;
} PEB_LDR_DATA, *PPEB_LDR_DATA;
The LIST_ENTRY is a linked list that contains your dll name and base address of where the dll is loaded.
typedef struct _LDR_DATA_TABLE_ENTRY {
PVOID Reserved1[2];
LIST_ENTRY InMemoryOrderLinks;
PVOID Reserved2[2];
PVOID DllBase;
PVOID EntryPoint;
PVOID Reserved3;
UNICODE_STRING FullDllName;
BYTE Reserved4[8];
PVOID Reserved5[3];
union {
ULONG CheckSum;
PVOID Reserved6;
};
ULONG TimeDateStamp;
} LDR_DATA_TABLE_ENTRY, *PLDR_DATA_TABLE_ENTRY;

parapura rajkumar
- 24,045
- 1
- 55
- 85