Allow the PE sections to cross a page boundary.

committer: mfx <mfx> 1142603590 +0000
This commit is contained in:
Markus F.X.J. Oberhumer 2006-03-17 13:53:10 +00:00
parent 609307668b
commit d5c0533b74
3 changed files with 12 additions and 11 deletions

View File

@ -1930,18 +1930,19 @@ void PackW32Pe::pack(OutputFile *fo)
if (swri >= 0x1000)
throwCantPack("swri >= 0x1000! Send a bug report please!");
patch_le32(loader, codesize, "SWRI", swri);
patch_le32(loader, codesize, "IMGL", 0x1000); // one page
patch_le32(loader, codesize, "IMGB", 0u - rvamin);
#else
// make sure we only touch exactly one page
// make sure we only touch the minimum number of pages
const unsigned addr = 0u - rvamin + swri;
patch_le32(loader, codesize, "SWRI", addr & 0xfff); // page offset
patch_le32(loader, codesize, "IMGB", addr &~ 0xfff); // page mask
// check whether osection[0].flags and osection[1].flags
// are on the same page
if ((swri & ~0xfff) != ((swri + sizeof(pe_section_t)) & ~0xfff))
throwCantPack("DEPHAK: page crossing problem! "
"Send a bug report please!");
if ((addr & 0xfff) + 0x28 >= 0x1000)
patch_le32(loader, codesize, "IMGL", 0x2000); // two pages
else
patch_le32(loader, codesize, "IMGL", 0x1000); // one page
patch_le32(loader, codesize, "IMGB", addr &~ 0xfff); // page mask
#endif
patch_le32(loader, codesize, "VPRO", myimport + get_le32(oimpdlls + 16) + 8);
}

View File

@ -203,7 +203,7 @@ relhi0:
%ifdef __PEDEPHAK__
mov ebp, [esi + 'VPRO'] ; VirtualProtect
lea edi, [esi + 'IMGB']
mov ebx, 0x1000
mov ebx, 'IMGL' ; 0x1000 or 0x2000
push eax ; provide 4 bytes stack

View File

@ -28,8 +28,8 @@
#define NRV_LOADER_SIZE 4365
#define NRV_LOADER_ADLER32 0x1dcf1745
#define NRV_LOADER_CRC32 0xc6ba51c8
#define NRV_LOADER_ADLER32 0xf651185e
#define NRV_LOADER_CRC32 0x6461513e
unsigned char nrv_loader[4365] = {
128,124, 36, 8, 1, 15,133, 0, 0, 0, 0, 96,190, 69, 83, 73, /* 0x 0 */
@ -102,8 +102,8 @@ unsigned char nrv_loader[4365] = {
224, 16,102,139, 7,131,199, 2, 9,192,117, 0,139, 7,131,199, /* 0x 430 */
4,235, 0,135,254,141,143, 68, 69, 76, 84,169,102, 1, 12, 7, /* 0x 440 */
173, 9,192,117,247,193,233, 16,169,102, 1, 12, 7,173, 9,192, /* 0x 450 */
117,247,139,174, 86, 80, 82, 79,141,190, 73, 77, 71, 66,187, 0, /* 0x 460 */
16, 0, 0, 80, 84,106, 4, 83, 87,255,213,141,135, 83, 87, 82, /* 0x 470 */
117,247,139,174, 86, 80, 82, 79,141,190, 73, 77, 71, 66,187, 73, /* 0x 460 */
77, 71, 76, 80, 84,106, 4, 83, 87,255,213,141,135, 83, 87, 82, /* 0x 470 */
73,128, 32,127,128, 96, 40,127, 88, 80, 84, 80, 83, 87,255,213, /* 0x 480 */
88, 97,141, 68, 36,128,106, 0, 57,196,117,250,131,236,128,141, /* 0x 490 */
68, 36,128,106, 0, 57,196,117,250,131,236,128, 49,192, 64,194, /* 0x 4a0 */