[GDI32API]

add IsHandleValid and use it SelectObject test

svn path=/trunk/; revision=47549
This commit is contained in:
Timo Kreuzer 2010-06-03 19:35:05 +00:00
parent 10dc21e801
commit 4e381837a0
3 changed files with 19 additions and 0 deletions

View file

@ -18,6 +18,22 @@ MyGdiQueryTable()
return pPeb->GdiSharedHandleTable;
}
BOOL
IsHandleValid(HGDIOBJ hobj)
{
USHORT Index = (ULONG_PTR)hobj;
PGDI_TABLE_ENTRY pentry = &GdiHandleTable[Index];
if (pentry->KernelData == NULL ||
pentry->KernelData < (PVOID)0x80000000 ||
(USHORT)pentry->FullUnique != (USHORT)((ULONG_PTR)hobj >> 16))
{
return FALSE;
}
return TRUE;
}
int APIENTRY
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,

View file

@ -20,6 +20,7 @@
extern HINSTANCE g_hInstance;
extern PGDI_TABLE_ENTRY GdiHandleTable;
BOOL IsHandleValid(HGDIOBJ hobj);
#endif /* _GDITEST_H */

View file

@ -82,6 +82,8 @@ Test_SelectObject(PTESTINFO pti)
DeleteObject(hOldObj);
RTEST((UINT_PTR)SelectObject(hDC, hNewObj) == SIMPLEREGION); // ??? Why this?
DeleteObject(hNewObj);
TEST(IsHandleValid(hNewObj) == TRUE);
RTEST(GetLastError() == ERROR_SUCCESS);
/* Test BITMAP */