Commit 0f6e9084 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

ntdll: Check block user flags in RtlSetUserValueHeap.

Adding the same user flags as native, for Global/Local allocs, and returning the pointer from Global/LocalHandle by default. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53741
parent 2ed75be4
......@@ -343,7 +343,7 @@ UINT WINAPI LocalFlags( HLOCAL handle )
*/
HLOCAL WINAPI LocalHandle( const void *ptr )
{
HLOCAL handle;
HLOCAL handle = (HANDLE)ptr;
ULONG flags;
TRACE_(globalmem)( "ptr %p\n", ptr );
......
......@@ -835,7 +835,7 @@ HGLOBAL WINAPI DECLSPEC_HOTPATCH GlobalFree( HLOCAL handle )
*/
HLOCAL WINAPI DECLSPEC_HOTPATCH LocalAlloc( UINT flags, SIZE_T size )
{
DWORD heap_flags = HEAP_ADD_USER_INFO;
DWORD heap_flags = 0x200 | HEAP_ADD_USER_INFO;
HANDLE heap = GetProcessHeap();
struct mem_entry *mem;
HLOCAL handle;
......@@ -974,7 +974,7 @@ LPVOID WINAPI DECLSPEC_HOTPATCH LocalLock( HLOCAL handle )
*/
HLOCAL WINAPI DECLSPEC_HOTPATCH LocalReAlloc( HLOCAL handle, SIZE_T size, UINT flags )
{
DWORD heap_flags = HEAP_ADD_USER_INFO | HEAP_NO_SERIALIZE;
DWORD heap_flags = 0x200 | HEAP_ADD_USER_INFO | HEAP_NO_SERIALIZE;
HANDLE heap = GetProcessHeap();
struct mem_entry *mem;
HLOCAL ret = 0;
......
......@@ -2044,7 +2044,7 @@ BOOLEAN WINAPI RtlGetUserInfoHeap( HANDLE handle, ULONG flags, void *ptr, void *
BOOLEAN WINAPI RtlSetUserValueHeap( HANDLE handle, ULONG flags, void *ptr, void *user_value )
{
struct block *block;
BOOLEAN ret = TRUE;
BOOLEAN ret = FALSE;
struct heap *heap;
SUBHEAP *subheap;
char *tmp;
......@@ -2054,17 +2054,22 @@ BOOLEAN WINAPI RtlSetUserValueHeap( HANDLE handle, ULONG flags, void *ptr, void
if (!(heap = unsafe_heap_from_handle( handle ))) return TRUE;
heap_lock( heap, flags );
if (!(block = unsafe_block_from_ptr( heap, ptr, &subheap ))) ret = FALSE;
if (!(block = unsafe_block_from_ptr( heap, ptr, &subheap )))
WARN( "Failed to find block %p in heap %p\n", ptr, handle );
else if (!(block_get_flags( block ) & BLOCK_FLAG_USER_INFO))
WARN( "Block %p wasn't allocated with user info\n", ptr );
else if (!subheap)
{
ARENA_LARGE *large = CONTAINING_RECORD( block, ARENA_LARGE, block );
large->user_value = user_value;
ret = TRUE;
}
else
{
tmp = (char *)block + block_get_size( block ) - block->tail_size + sizeof(void *);
if ((heap_get_flags( heap, flags ) & HEAP_TAIL_CHECKING_ENABLED) || RUNNING_ON_VALGRIND) tmp += ALIGNMENT;
*(void **)tmp = user_value;
ret = TRUE;
}
heap_unlock( heap, flags );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment