-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Description
using MemoryModule will cause access violation for large application built with runtime packages.
This happen to FixPtr function in ExecuteTLS.
This is due to the code was allocated via VirtualAlloc to allocate memory at arbitrary position:
// reserve memory for image of library
// XXX: is it correct to commit the complete memory region at once?
// calling DllEntry raises an exception if we don't...
code := VirtualAlloc(Pointer(old_header.OptionalHeader.ImageBase),
old_header.OptionalHeader.SizeOfImage,
MEM_RESERVE or MEM_COMMIT,
PAGE_READWRITE);
if code = nil then
begin
// try to allocate memory at arbitrary position
code := VirtualAlloc(nil,
old_header.OptionalHeader.SizeOfImage,
MEM_RESERVE or MEM_COMMIT,
PAGE_READWRITE);
if code = nil then
begin
SetLastError(ERROR_OUTOFMEMORY);
Exit;
end;
end;And it further affect in ExecuteTLS:
callback := FixPtr(callback);
I refer to c version of MemoryModule: https://github.com/fancycode/MemoryModule/blob/master/MemoryModule.c
It seems calling FixPtr isn't require.
pult
Metadata
Metadata
Assignees
Labels
No labels