// kuretrievefun.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "Windows.h"
int _tmain(int argc, _TCHAR* argv[])
{
void *hFile = CreateFile("f:\\user32d.dll",GENERIC_ALL,0,0,OPEN_EXISTING,0,0);
void *hMap = CreateFileMapping(hFile,0,PAGE_READWRITE,0,0,0);
ULONG pFile = (ULONG)/*
MapViewOfFile(hMap,FILE_MAP_ALL_ACCESS,0,0,0);//*/
LoadLibrary("user32.dll");
if(pFile == 0) {
Beep(1000,100);
}
printf("%x\n",pFile);
IMAGE_DOS_HEADER *dos_hdr;
IMAGE_NT_HEADERS *nt_hdr;
IMAGE_IMPORT_DESCRIPTOR *importdes;
dos_hdr = (IMAGE_DOS_HEADER*)pFile;
nt_hdr = (IMAGE_NT_HEADERS*)((ULONG)pFile + dos_hdr->e_lfanew);
//printf("%x\n",nt_hdr->Signature);
//printf("%x\n",nt_hdr->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress);
importdes = (IMAGE_IMPORT_DESCRIPTOR*)(pFile + nt_hdr->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress);
//printf("%s\n",importdes);
while(importdes->FirstThunk) {
char *ku = (char*)((ULONG)pFile + importdes->Name);
printf("%s\n",ku);
importdes++;
//break;
}
return 0;
}
上面,如果用 LoadLibrary 的话就没有问题,但用 MapViewOfFile 的话就会说内存访问错误,请教请教....
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课