能力值:
( LV2,RANK:10 )
|
-
-
给PE文件增加节的时候出现的问题
谢谢LS
不过那里找不到答案。
我调试的时候,发现新加的节,也就是在创建内存映射的时候增加的那部分映射无法读。有朋友知道这是什么原因么?
|
能力值:
( LV2,RANK:10 )
|
-
-
给PE文件增加节的时候出现的问题
下面是增加节表 各个参数的代码
if(i>=10)
{//有空间增加节表,开始增加
pFH->NumberOfSections=pFH->NumberOfSections+1;
DWORD dwNewSecAlign = getAlign(pLastSecH->VirtualAddress + pLastSecH->Misc.VirtualSize,pOH->SectionAlignment);//新加节对齐后的内存RVA
DWORD dwNewFileAlign = getAlign(pLastSecH->PointerToRawData+pLastSecH->SizeOfRawData,pOH->FileAlignment);//新加节对齐后的文件RVA
pOH->SizeOfImage += getAlign(0x00001000,pOH->SectionAlignment);
memcpy(pAddSecH->Name,".new",8); //给新块命名
pAddSecH->VirtualAddress = dwNewSecAlign;
pAddSecH->Misc.VirtualSize = 0x00001000;
pAddSecH->PointerToRawData = dwNewFileAlign;
pAddSecH->SizeOfRawData = getAlign(0x00001000,pOH->FileAlignment);
pAddSecH->Characteristics = 0xE0000020; //Characteristics
lpSec=(LPVOID)((DWORD)ImageBase +pAddSecH->VirtualAddress );//新块的绝对地址,也即代码块的起始地址
::memcpy(lpSec,pdata,sizeof(pdata));//将要添加的数据复制进新的节,pdata是一个数组
|