[PATCH 2/2] ntdll: allow HeapSize to work with global GMEM_MOVEABLE pointers
This patch attempts to address the problem by patching RtlSizeHeap() to subtract 8 (8 being HGLOBAL_STORAGE) from the pointer if it doesn't seem like a valid pointer, to cater to GMEM_MOVEABLE pointers actually starting 8 bytes earlier. I am not familiar with the internals of Windows' memory management so this might not be the best solution, but all the heap tests pass so it can't be that wrong either ;). It certainly gets wxWidgets applications working. Signed-off-by: Damjan Jovanovic <damjan.jov(a)gmail.com> --- dlls/kernel32/tests/heap.c | 2 +- dlls/ntdll/heap.c | 50 ++++++++++++++++++++++++-------------- 2 files changed, 33 insertions(+), 19 deletions(-)
Damjan Jovanovic <damjan.jov(a)gmail.com> wrote:
This patch attempts to address the problem by patching RtlSizeHeap() to subtract 8 (8 being HGLOBAL_STORAGE) from the pointer if it doesn't seem like a valid pointer, to cater to GMEM_MOVEABLE pointers actually starting 8 bytes earlier.
Probably fixing GlobalAlloc() instead would be more correct. -- Dmitry.
On Sat, Oct 26, 2019 at 8:55 AM Dmitry Timoshkov <dmitry(a)baikal.ru> wrote:
Damjan Jovanovic <damjan.jov(a)gmail.com> wrote:
This patch attempts to address the problem by patching RtlSizeHeap() to subtract 8 (8 being HGLOBAL_STORAGE) from the pointer if it doesn't seem like a valid pointer, to cater to GMEM_MOVEABLE pointers actually starting 8 bytes earlier.
Probably fixing GlobalAlloc() instead would be more correct.
You're right. I am currently investigating global memory layout in different Windows versions. Please ignore this patch.
participants (2)
-
Damjan Jovanovic -
Dmitry Timoshkov