Include flag changes when protecting rwcseg

This commit is contained in:
Silent 2017-04-27 22:12:48 +02:00
parent fa1d50b62c
commit 6bcd33ea54

View file

@ -200,6 +200,22 @@ void PatchIAT()
{
DWORD dwProtect;
VirtualProtect((LPVOID)((ptrdiff_t)hInstance + pSection->VirtualAddress), pSection->Misc.VirtualSize, PAGE_EXECUTE_READ, &dwProtect);
if ( (pSection->Characteristics & IMAGE_SCN_CNT_CODE) == 0 )
{
pSection->Characteristics |= IMAGE_SCN_CNT_CODE;
ntHeader->OptionalHeader.SizeOfCode += pSection->Misc.VirtualSize;
}
if ( (pSection->Characteristics & IMAGE_SCN_CNT_INITIALIZED_DATA) != 0 )
{
pSection->Characteristics &= ~(IMAGE_SCN_CNT_INITIALIZED_DATA);
ntHeader->OptionalHeader.SizeOfInitializedData -= pSection->Misc.VirtualSize;
}
if ( (pSection->Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 )
{
pSection->Characteristics &= ~(IMAGE_SCN_CNT_UNINITIALIZED_DATA);
ntHeader->OptionalHeader.SizeOfUninitializedData -= pSection->Misc.VirtualSize;
}
break;
}
}