Skip to content

Instantly share code, notes, and snippets.

@kmdnet
Created September 12, 2016 05:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmdnet/8be48f6171ca33c368ff8c90d126ef60 to your computer and use it in GitHub Desktop.
Save kmdnet/8be48f6171ca33c368ff8c90d126ef60 to your computer and use it in GitHub Desktop.
#include<Windows.h>
#include<winternl.h>
#include<stdio.h>
void GetKernel32BaseAddress() {
PPEB pPeb; // PEB
PLDR_DATA_TABLE_ENTRY pLdrDataTableEntry;
PLIST_ENTRY pListEntry;
pPeb = (PPEB)__readfsdword(0x30);
pLdrDataTableEntry = (PLDR_DATA_TABLE_ENTRY)pPeb->Ldr->InMemoryOrderModuleList.Flink;
pListEntry = pPeb->Ldr->InMemoryOrderModuleList.Flink;
pListEntry = pListEntry->Flink;
pListEntry = pListEntry->Flink;
pLdrDataTableEntry = (PLDR_DATA_TABLE_ENTRY)(pListEntry->Flink);
printf("Kernel32.dll : 0x%p\n", pLdrDataTableEntry->Reserved2[0]);
}
int main(void) {
GetKernel32BaseAddress();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment