Hi,
I'm going over the list of loaded modules as present in PEB->Ldr->InMemoryOrderModuleList, which points to the _LDR_DATA_TABLE_ENTRY data structure as presented below. The InMemoryOrderLinks contains Flink/Blink to the next/previous loaded module. Basically I would like to hook the EntryPoint of the DLL. I imagine, the loader loading the A.dll, which depends upoen B.dll, which depends upon C.dll, so when the C.dll's DllMain is called, the modules A.dll and B.dll are already present in the InMemoryOrderLinks, but their DllMain's have not been called yet. Therefore, from C.dll, I would like to hook the EntryPoint of the A.dll in order for my function to be called, from where I would jump to the original entry point.
I'm going over the list of loaded modules as present in PEB->Ldr->InMemoryOrderModuleList, which points to the _LDR_DATA_TABLE_ENTRY data structure as presented below. The InMemoryOrderLinks contains Flink/Blink to the next/previous loaded module. Basically I would like to hook the EntryPoint of the DLL. I imagine, the loader loading the A.dll, which depends upoen B.dll, which depends upon C.dll, so when the C.dll's DllMain is called, the modules A.dll and B.dll are already present in the InMemoryOrderLinks, but their DllMain's have not been called yet. Therefore, from C.dll, I would like to hook the EntryPoint of the A.dll in order for my function to be called, from where I would jump to the original entry point.
Code: Select all
I would like to know whether the EntryPoint contains a 32-bit address on 32-bit systems and 64-bit address of 64-bit systems. At the http://phrack.org/issues/65/10.html, the following is written:typedef struct _LDR_DATA_TABLE_ENTRY {
LIST_ENTRY InLoadOrderLinks;
LIST_ENTRY InMemoryOrderLinks;
LIST_ENTRY InInitializationOrderLinks;
PVOID DllBase;
PVOID EntryPoint;
ULONG SizeOfImage;
UNICODE_STRING FullDllName;
UNICODE_STRING BaseDllName;
ULONG Flags;
WORD LoadCount;
WORD TlsIndex;
ULONG SectionPointer;
ULONG CheckSum;
ULONG TimeDateStamp;
ULONG EntryPointActivationContext;
ULONG PatchInformation;
LIST_ENTRY ForwarderLinks;
LIST_ENTRY ServiceTagLinks;
ULONG ContextInformation;
ULONG OriginalBase;
ULONG LoadTime1;
ULONG LoadTime2;
} LDR_DATA_TABLE_ENTRY, *PLDR_DATA_TABLE_ENTRY;
- BaseAddress: The base of the module in memory.This makes me think that the actual address is stored in the EntryPoint and not the offset, but I would like to be sure before proceeding, because I want this to work on both 32-bit as well as 64-bit operating systems. Does anybody know whether EntryPoint contains 64-bit address on 64-bit systems and how does the loaded calculate this address: in PE structure the entry point field specifies the offset into the current module where the entry point is located, but is the EntryPoint in the _LDR_DATA_TABLE_ENTRY an actual address or an offset?
- EntryPoint : Address where the module's first instruction to
be executed can be found.
- SizeOfImage: Size of the module in memory.