fix(windows): sentrytool fails on mem realloc

Fixes #4002.

We needed to reseat the pointers after the realloc as the base address
changed; this only affected us occasionally but nasty when it did!
This commit is contained in:
Marc Durdin 2020-12-16 11:34:39 +11:00
parent e571113b22
commit 023a70aadd

View file

@ -265,6 +265,9 @@ begin
s.SetSize(SectionOffset + SectionRawSize);
FillChar((PByte(s.Memory) + SectionOffset)^, SectionRawSize, 0);
nh32 := PImageNtHeaders(NativeUInt(nh32)-NativeUInt(dh)+NativeUInt(s.Memory));
section := PImageSectionHeader(NativeUInt(section)-NativeUInt(dh)+NativeUInt(s.Memory));
// Increment the number of sections
Inc(nh32.FileHeader.NumberOfSections);
@ -324,6 +327,9 @@ begin
s.SetSize(SectionOffset + SectionRawSize);
FillChar((PByte(s.Memory) + SectionOffset)^, SectionRawSize, 0);
nh64 := PImageNtHeaders64(NativeUInt(nh64)-NativeUInt(dh)+NativeUInt(s.Memory));
section := PImageSectionHeader(NativeUInt(section)-NativeUInt(dh)+NativeUInt(s.Memory));
// Increment the number of sections
Inc(nh64.FileHeader.NumberOfSections);