能力值:
( LV2,RANK:10 )
|
-
-
2 楼
一般是先通过CreateFile得到文件句柄,然后CreateFileMapping创建文件映像,最后MapViewOfFile得到映像基址,代码如下:
HANDLE hFile, hMapping;
void *pMem;
hFile = CreateFile(pFilename, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
//pFilename是文件路径,char *类型
if ( hFile == INVALID_HANDLE_VALUE )
{
printf("打开文件失败, 错误代号# %08x\n", GetLastError());
return;
}
hMapping = CreateFileMapping(hFile, NULL, PAGE_READWRITE, 0, 0, NULL);
if ( hMapping == 0 )
{
printf("创建文件映射失败, 错误代号# %08x\n", GetLastError());
CloseHandle(hFile);
return;
}
pMem = MapViewOfFile(hMapping, FILE_MAP_ALL_ACCESS, 0, 0, 0);
if ( pMem == 0)
{
printf("无法映射文件视图, 错误代号# %08x\n", GetLastError());
CloseHandle(hMapping);
CloseHandle(hFile);
return;
}
ImageBase = (PIMAGE_DOS_HEADER)pMem;
|
能力值:
( LV2,RANK:10 )
|
-
-
3 楼
ImageBase = (PIMAGE_DOS_HEADER)pMem;
相当于你的 pDH = (PIMAGE_DOS_HEADER)ImageBase;
|
能力值:
( LV2,RANK:10 )
|
-
-
4 楼
我不够快。。。。。我的kx
摘自加解密
BOOL LoadFileR(LPTSTR lpFilename,PMAP_FILE_STRUCT pstMapFile)
{
HANDLE hFile;
HANDLE hMapping;
LPVOID ImageBase;
memset(pstMapFile,0,sizeof(MAP_FILE_STRUCT));
hFile=CreateFile(lpFilename,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,0);
if (!hFile)
return FALSE;
hMapping=CreateFileMapping(hFile,NULL,PAGE_READONLY,0,0,NULL);
if(!hMapping)
{
CloseHandle(hFile);
return FALSE;
}
ImageBase=MapViewOfFile(hMapping,FILE_MAP_READ,0,0,0);
if(!ImageBase)
{
CloseHandle(hMapping);
CloseHandle(hFile);
return FALSE;
}
pstMapFile->hFile=hFile;
pstMapFile->hMapping=hMapping;
pstMapFile->ImageBase=ImageBase;
return TRUE;
}
|
能力值:
( LV2,RANK:10 )
|
-
-
5 楼
泥芭...老是能和你撞上~
|
能力值:
( LV2,RANK:10 )
|
-
-
6 楼
LS,让KX给我吧
|
|
|