能力值:
( LV2,RANK:10 )
|
-
-
2 楼
抱歉,不想看代码,我可以给你我的代码看下 void MoveRelocationTable(LPVOID pFileBuffer,DWORD FOA)
{
//初始化部分
PIMAGE_DOS_HEADER pDosHeader = NULL;
PIMAGE_NT_HEADERS pNTHeader = NULL;
PIMAGE_FILE_HEADER pPEHeader = NULL;
PIMAGE_OPTIONAL_HEADER32 pOptionHeader = NULL;
PIMAGE_DATA_DIRECTORY pDataDirectory = NULL;
PIMAGE_BASE_RELOCATION pBaseRelocation = NULL;
PIMAGE_BASE_RELOCATION pCopyPlace = NULL;
PIMAGE_BASE_RELOCATION pNewExportDirectory = NULL;
PIMAGE_SECTION_HEADER pSectionHeader = NULL;
//初始化地址指针
pDosHeader = (PIMAGE_DOS_HEADER)pFileBuffer;
pNTHeader = (PIMAGE_NT_HEADERS)((DWORD)pFileBuffer+pDosHeader->e_lfanew);
pPEHeader = (PIMAGE_FILE_HEADER)(((DWORD)pNTHeader) + 4);
pOptionHeader = (PIMAGE_OPTIONAL_HEADER32)((DWORD)pPEHeader + IMAGE_SIZEOF_FILE_HEADER);
//获取节表起始地址
pSectionHeader = (PIMAGE_SECTION_HEADER)((DWORD)pOptionHeader + pPEHeader->SizeOfOptionalHeader);
//获取节表数量
DWORD NumberOfSection = pPEHeader->NumberOfSections;
pSectionHeader = pSectionHeader + (NumberOfSection-1);
DWORD VirtualAddress = pSectionHeader->VirtualAddress;
pDataDirectory = pOptionHeader->DataDirectory;
pDataDirectory += 5;
printf("Relocation_Table: %x %x\n", pDataDirectory->VirtualAddress, pDataDirectory->Size);
pBaseRelocation = (PIMAGE_BASE_RELOCATION)((DWORD)pFileBuffer + getFOA(pDataDirectory->VirtualAddress));
pCopyPlace = (PIMAGE_BASE_RELOCATION)((DWORD)pFileBuffer + FOA);
DWORD i = 0;
DWORD length = 0;//记录长度
do{
DWORD SizeOfBlock = pBaseRelocation->SizeOfBlock;
DWORD realAddr = (DWORD)pFileBuffer + getFOA(pBaseRelocation->VirtualAddress);
memcpy((DWORD)pCopyPlace+length, pBaseRelocation, SizeOfBlock);
pBaseRelocation = (DWORD)pBaseRelocation + SizeOfBlock;
length += SizeOfBlock;
}while(pBaseRelocation->VirtualAddress!=0 && pBaseRelocation->SizeOfBlock!=0);
//增加结束标志
memcpy((DWORD)pCopyPlace+length,pBaseRelocation, sizeof(PIMAGE_BASE_RELOCATION));
//新增节的地址
pDataDirectory->VirtualAddress = VirtualAddress;
printf("%x\n", pDataDirectory->VirtualAddress);
printf("%x\n", getFOA(pDataDirectory->VirtualAddress));
}
|
能力值:
( LV8,RANK:130 )
|
-
-
3 楼
感谢
|
能力值:
( LV3,RANK:20 )
|
-
-
4 楼
TopGreen
抱歉,不想看代码,我可以给你我的代码看下void MoveRelocationTable(LPVOID pFileBuffer,DWORD FOA ...
谢谢
|
能力值:
( LV3,RANK:20 )
|
-
-
5 楼
你修复重定位了吗?
|
能力值:
( LV3,RANK:20 )
|
-
-
6 楼
TopGreen
抱歉,不想看代码,我可以给你我的代码看下void MoveRelocationTable(LPVOID pFileBuffer,DWORD FOA ...
你修复重定位了吗?
|
能力值:
( LV2,RANK:10 )
|
-
-
7 楼
AMask
你修复重定位了吗?
修复了,https://noone-hub.gitee.io/posts/6fd44671/ 看下博客吧,密码1234
|
|
|