Commit 5e32cad3 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

kernel32: Use RtlGetUserInfoHeap in GlobalHandle.

parent bffeff38
...@@ -47,6 +47,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(globalmem); ...@@ -47,6 +47,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(globalmem);
static HANDLE systemHeap; /* globally shared heap */ static HANDLE systemHeap; /* globally shared heap */
BOOLEAN WINAPI RtlGetUserInfoHeap( HANDLE handle, ULONG flags, void *ptr, void **user_value, ULONG *user_flags );
/*********************************************************************** /***********************************************************************
* HEAP_CreateSystemHeap * HEAP_CreateSystemHeap
...@@ -171,7 +172,6 @@ C_ASSERT(sizeof(struct mem_entry) == 2 * sizeof(void *)); ...@@ -171,7 +172,6 @@ C_ASSERT(sizeof(struct mem_entry) == 2 * sizeof(void *));
struct kernelbase_global_data *kernelbase_global_data; struct kernelbase_global_data *kernelbase_global_data;
#define POINTER_TO_HANDLE( p ) (*(((const HGLOBAL *)( p )) - 2))
/* align the storage needed for the HLOCAL on an 8-byte boundary thus /* align the storage needed for the HLOCAL on an 8-byte boundary thus
* LocalAlloc/LocalReAlloc'ing with LMEM_MOVEABLE of memory with * LocalAlloc/LocalReAlloc'ing with LMEM_MOVEABLE of memory with
* size = 8*k, where k=1,2,3,... allocs exactly the given size. * size = 8*k, where k=1,2,3,... allocs exactly the given size.
...@@ -255,6 +255,7 @@ HGLOBAL WINAPI GlobalHandle( const void *ptr ) ...@@ -255,6 +255,7 @@ HGLOBAL WINAPI GlobalHandle( const void *ptr )
struct mem_entry *mem; struct mem_entry *mem;
HGLOBAL handle; HGLOBAL handle;
LPCVOID test; LPCVOID test;
ULONG flags;
TRACE_(globalmem)( "ptr %p\n", ptr ); TRACE_(globalmem)( "ptr %p\n", ptr );
...@@ -279,7 +280,12 @@ HGLOBAL WINAPI GlobalHandle( const void *ptr ) ...@@ -279,7 +280,12 @@ HGLOBAL WINAPI GlobalHandle( const void *ptr )
handle = (HGLOBAL)ptr; /* valid fixed block */ handle = (HGLOBAL)ptr; /* valid fixed block */
break; break;
} }
handle = POINTER_TO_HANDLE( ptr ); if (!RtlGetUserInfoHeap( GetProcessHeap(), HEAP_NO_SERIALIZE, (char *)ptr - HLOCAL_STORAGE, &handle, &flags ))
{
SetLastError( ERROR_INVALID_HANDLE );
handle = 0;
}
break;
} }
else handle = (HGLOBAL)ptr; else handle = (HGLOBAL)ptr;
......
...@@ -1494,6 +1494,8 @@ static void test_GlobalAlloc(void) ...@@ -1494,6 +1494,8 @@ static void test_GlobalAlloc(void)
ptr = GlobalLock( mem ); ptr = GlobalLock( mem );
ok( !!ptr, "GlobalLock failed, error %lu\n", GetLastError() ); ok( !!ptr, "GlobalLock failed, error %lu\n", GetLastError() );
ok( ptr != mem, "got unexpected ptr %p\n", ptr ); ok( ptr != mem, "got unexpected ptr %p\n", ptr );
tmp_mem = GlobalHandle( ptr );
ok( tmp_mem == mem, "GlobalHandle returned unexpected handle\n" );
flags = GlobalFlags( mem ); flags = GlobalFlags( mem );
ok( flags == 1, "GlobalFlags returned %#x, error %lu\n", flags, GetLastError() ); ok( flags == 1, "GlobalFlags returned %#x, error %lu\n", flags, GetLastError() );
tmp_ptr = GlobalLock( mem ); tmp_ptr = GlobalLock( mem );
...@@ -1698,6 +1700,8 @@ static void test_GlobalAlloc(void) ...@@ -1698,6 +1700,8 @@ static void test_GlobalAlloc(void)
ok( !!mem, "GlobalAlloc failed, error %lu\n", GetLastError() ); ok( !!mem, "GlobalAlloc failed, error %lu\n", GetLastError() );
ret = GlobalUnlock( mem ); ret = GlobalUnlock( mem );
ok( ret, "GlobalUnlock failed, error %lu\n", GetLastError() ); ok( ret, "GlobalUnlock failed, error %lu\n", GetLastError() );
tmp_mem = GlobalHandle( mem );
ok( tmp_mem == mem, "GlobalHandle returned unexpected handle\n" );
mem = GlobalFree( mem ); mem = GlobalFree( mem );
ok( !mem, "GlobalFree failed, error %lu\n", GetLastError() ); ok( !mem, "GlobalFree failed, error %lu\n", GetLastError() );
...@@ -1867,6 +1871,8 @@ static void test_LocalAlloc(void) ...@@ -1867,6 +1871,8 @@ static void test_LocalAlloc(void)
ptr = LocalLock( mem ); ptr = LocalLock( mem );
ok( !!ptr, "LocalLock failed, error %lu\n", GetLastError() ); ok( !!ptr, "LocalLock failed, error %lu\n", GetLastError() );
ok( ptr != mem, "got unexpected ptr %p\n", ptr ); ok( ptr != mem, "got unexpected ptr %p\n", ptr );
tmp_mem = LocalHandle( ptr );
ok( tmp_mem == mem, "LocalHandle returned unexpected handle\n" );
flags = LocalFlags( mem ); flags = LocalFlags( mem );
ok( flags == 1, "LocalFlags returned %#x, error %lu\n", flags, GetLastError() ); ok( flags == 1, "LocalFlags returned %#x, error %lu\n", flags, GetLastError() );
tmp_ptr = LocalLock( mem ); tmp_ptr = LocalLock( mem );
...@@ -2030,6 +2036,8 @@ static void test_LocalAlloc(void) ...@@ -2030,6 +2036,8 @@ static void test_LocalAlloc(void)
ret = LocalUnlock( mem ); ret = LocalUnlock( mem );
ok( !ret, "LocalUnlock succeeded\n" ); ok( !ret, "LocalUnlock succeeded\n" );
ok( GetLastError() == ERROR_NOT_LOCKED, "got error %lu\n", GetLastError() ); ok( GetLastError() == ERROR_NOT_LOCKED, "got error %lu\n", GetLastError() );
tmp_mem = LocalHandle( mem );
ok( tmp_mem == mem, "LocalHandle returned unexpected handle\n" );
mem = LocalFree( mem ); mem = LocalFree( mem );
ok( !mem, "LocalFree failed, error %lu\n", GetLastError() ); ok( !mem, "LocalFree failed, error %lu\n", GetLastError() );
......
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