2

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.

Idov
  • 4,870
  • 14
  • 63
  • 103

1 Answers1

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
  • 23,647
  • 1
  • 53
  • 83