1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
#ifdef _WIN64
TCHAR buf[MAX_PATH];
GetSystemWow64Directory(buf, MAX_PATH);
strcat_s(buf, "\\kernel32.dll");
HANDLE hMapObject, hFile; //File Mapping Object
LPVOID lpBase; //Pointer to the base memory of mapped file
hFile = CreateFile(buf, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile)
{
hMapObject = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
if (hMapObject)
{
lpBase = MapViewOfFile(hMapObject, FILE_MAP_READ, 0, 0, 0);
if (lpBase)
{
IMAGE_DOS_HEADER * dosheader = (IMAGE_DOS_HEADER *)lpBase;
IMAGE_OPTIONAL_HEADER * opthdr = (IMAGE_OPTIONAL_HEADER *)
((BYTE*)lpBase + dosheader->e_lfanew + 24);
IMAGE_EXPORT_DIRECTORY *exp = (IMAGE_EXPORT_DIRECTORY *)((BYTE*)lpBase
+ opthdr->DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress);
ULONG *addressoffunctions = (ULONG*)((BYTE*)lpBase + exp->AddressOfFunctions);
ULONG * addressofnames = (ULONG*)((BYTE*)lpBase + exp->AddressOfNames);
printf("\nStart");
for (DWORD x = 0; x < exp->NumberOfFunctions; x++)
{
printf("\nAddr: 0x%x (0x%x) - Name: %s", (BYTE*)lpBase + addressoffunctions[x], addressoffunctions[x], (BYTE*)lpBase + addressofnames[x]);
}
}
}
}
#endif
|