Rémi Bernon : kernelbase: Use RtlSetUserValueHeap to store HLOCAL.
Alexandre Julliard
julliard at winehq.org
Thu Jun 9 16:28:34 CDT 2022
Module: wine
Branch: master
Commit: 64efaf26b75cd83cc624cdf6c1490755c62f56a3
URL: https://source.winehq.org/git/wine.git/?a=commit;h=64efaf26b75cd83cc624cdf6c1490755c62f56a3
Author: Rémi Bernon <rbernon at codeweavers.com>
Date: Thu Jun 9 12:09:26 2022 +0200
kernelbase: Use RtlSetUserValueHeap to store HLOCAL.
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
dlls/kernelbase/memory.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/dlls/kernelbase/memory.c b/dlls/kernelbase/memory.c
index 776f0aafa18..409b35089e3 100644
--- a/dlls/kernelbase/memory.c
+++ b/dlls/kernelbase/memory.c
@@ -44,6 +44,9 @@ WINE_DECLARE_DEBUG_CHANNEL(virtual);
WINE_DECLARE_DEBUG_CHANNEL(globalmem);
+BOOLEAN WINAPI RtlSetUserValueHeap( HANDLE handle, ULONG flags, void *ptr, void *user_value );
+
+
/***********************************************************************
* Virtual memory functions
***********************************************************************/
@@ -842,6 +845,7 @@ HLOCAL WINAPI DECLSPEC_HOTPATCH LocalAlloc( UINT flags, SIZE_T size )
if (!(flags & LMEM_MOVEABLE)) /* pointer */
{
ptr = HeapAlloc( heap, heap_flags, size );
+ if (ptr) RtlSetUserValueHeap( heap, heap_flags, ptr, ptr );
TRACE_(globalmem)( "return %p\n", ptr );
return ptr;
}
@@ -869,6 +873,7 @@ HLOCAL WINAPI DECLSPEC_HOTPATCH LocalAlloc( UINT flags, SIZE_T size )
else
{
if (!(ptr = HeapAlloc( heap, heap_flags, size + HLOCAL_STORAGE ))) goto failed;
+ RtlSetUserValueHeap( heap, heap_flags, ptr, handle );
*(HLOCAL *)ptr = handle;
mem->ptr = (char *)ptr + HLOCAL_STORAGE;
}
@@ -1014,6 +1019,7 @@ HLOCAL WINAPI DECLSPEC_HOTPATCH LocalReAlloc( HLOCAL handle, SIZE_T size, UINT f
/* reallocate fixed memory */
if (!(flags & LMEM_MOVEABLE)) heap_flags |= HEAP_REALLOC_IN_PLACE_ONLY;
ret = HeapReAlloc( GetProcessHeap(), heap_flags, ptr, size );
+ if (ret) RtlSetUserValueHeap( GetProcessHeap(), heap_flags, ret, ret );
}
else if ((mem = unsafe_mem_from_HLOCAL( handle )))
{
@@ -1027,6 +1033,7 @@ HLOCAL WINAPI DECLSPEC_HOTPATCH LocalReAlloc( HLOCAL handle, SIZE_T size, UINT f
if ((ptr = HeapReAlloc( GetProcessHeap(), heap_flags, (char *)mem->ptr - HLOCAL_STORAGE,
size + HLOCAL_STORAGE )))
{
+ RtlSetUserValueHeap( GetProcessHeap(), heap_flags, ptr, handle );
mem->ptr = (char *)ptr + HLOCAL_STORAGE;
ret = handle;
}
@@ -1035,6 +1042,7 @@ HLOCAL WINAPI DECLSPEC_HOTPATCH LocalReAlloc( HLOCAL handle, SIZE_T size, UINT f
{
if ((ptr = HeapAlloc( GetProcessHeap(), heap_flags, size + HLOCAL_STORAGE )))
{
+ RtlSetUserValueHeap( GetProcessHeap(), heap_flags, ptr, handle );
*(HLOCAL *)ptr = handle;
mem->ptr = (char *)ptr + HLOCAL_STORAGE;
ret = handle;
More information about the wine-cvs
mailing list