mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-05 18:01:34 +00:00
kernel32: GlobalSize() should also work with GMEM_MOVEABLE data pointers received from GlobalLock().
This commit is contained in:
parent
43c648ecdc
commit
fed025fd42
2 changed files with 37 additions and 1 deletions
|
@ -820,6 +820,12 @@ SIZE_T WINAPI GlobalSize(HGLOBAL hmem)
|
|||
if(ISPOINTER(hmem))
|
||||
{
|
||||
retval=HeapSize(GetProcessHeap(), 0, hmem);
|
||||
|
||||
if (retval == (DWORD)-1) /* It might be a GMEM_MOVEABLE data pointer */
|
||||
{
|
||||
retval = HeapSize(GetProcessHeap(), 0, (char*)(hmem) - HGLOBAL_STORAGE);
|
||||
if (retval != (DWORD)-1) retval -= HGLOBAL_STORAGE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -85,7 +85,7 @@ static void test_heap(void)
|
|||
UINT flags;
|
||||
HGLOBAL gbl;
|
||||
HGLOBAL hsecond;
|
||||
SIZE_T size;
|
||||
SIZE_T size, size2;
|
||||
|
||||
/* Heap*() functions */
|
||||
mem = HeapAlloc(GetProcessHeap(), 0, 0);
|
||||
|
@ -403,6 +403,36 @@ static void test_heap(void)
|
|||
"MAGIC_DEAD)\n", mem, GetLastError(), GetLastError());
|
||||
|
||||
GlobalFree(gbl);
|
||||
|
||||
/* trying to get size from data pointer (GMEM_MOVEABLE) */
|
||||
gbl = GlobalAlloc(GMEM_MOVEABLE, 0x123);
|
||||
ok(gbl != NULL, "returned NULL\n");
|
||||
mem = GlobalLock(gbl);
|
||||
ok(mem != NULL, "returned NULL.\n");
|
||||
ok(gbl != mem, "unexpectedly equal.\n");
|
||||
|
||||
size = GlobalSize(gbl);
|
||||
size2 = GlobalSize(mem);
|
||||
ok(size == 0x123, "got %lu\n", size);
|
||||
ok(size2 == 0x123, "got %lu\n", size2);
|
||||
|
||||
GlobalFree(gbl);
|
||||
|
||||
/* trying to get size from data pointer (GMEM_FIXED) */
|
||||
gbl = GlobalAlloc(GMEM_FIXED, 0x123);
|
||||
ok(gbl != NULL, "returned NULL\n");
|
||||
mem = GlobalLock(gbl);
|
||||
ok(mem != NULL, "returned NULL.\n");
|
||||
ok(gbl == mem, "got %p, %p.\n", gbl, mem);
|
||||
|
||||
size = GlobalSize(gbl);
|
||||
ok(size == 0x123, "got %lu\n", size);
|
||||
|
||||
GlobalFree(gbl);
|
||||
|
||||
size = GlobalSize((void *)0xdeadbee0);
|
||||
ok(size == 0, "got %lu\n", size);
|
||||
|
||||
}
|
||||
|
||||
static void test_obsolete_flags(void)
|
||||
|
|
Loading…
Reference in a new issue