getting a module handle from other process

2020-06-27 02:00发布

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.

标签: c++ module
1条回答
不美不萌又怎样
2楼-- · 2020-06-27 02:34

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;
查看更多
登录 后发表回答