20楼#
发布于:2009-01-21 15:15
指的是这个:
// 打开指定文件 HANDLE hFile = CreateFile(argv[1], GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { printf("CreateFile Failed\n"); return 0; } // 创建文件映射 HANDLE hMap = CreateFileMapping(hFile, NULL, PAGE_READWRITE, NULL, NULL, NULL); if (hMap == INVALID_HANDLE_VALUE) { printf("CreateFileMapping Failed\n"); return 0; } // 获取文件的映射句柄 LPVOID lpBase = MapViewOfFile(hMap, FILE_MAP_WRITE, 0, 0, 0); if (lpBase == NULL) { printf("MapViewOfFile Failed\n"); return 0; } // 将映射基址为PE结构 IMAGE_DOS_HEADER* dosHeader; IMAGE_NT_HEADERS* ntHeader; dosHeader = (IMAGE_DOS_HEADER *) lpBase; // 判断文件是否PE结构 if (dosHeader->e_magic != IMAGE_DOS_SIGNATURE) { printf("This is not a windows file\n"); return 0; } // 判断是否win32文件 ntHeader = (IMAGE_NT_HEADERS *) ((BYTE *) lpBase + dosHeader->e_lfanew); if (ntHeader->Signature != IMAGE_NT_SIGNATURE) { printf("This is not a win32 file\n"); return 0; } AddImportDll(hFile, (DWORD)lpBase, ntHeader, DLL_NAME, FUNC_NAME); |
|
|
上一页
下一页