[GDI32API]
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Thu, 3 Jun 2010 19:35:05 +0000 (19:35 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Thu, 3 Jun 2010 19:35:05 +0000 (19:35 +0000)
add IsHandleValid and use it SelectObject test

svn path=/trunk/; revision=47549

rostests/apitests/gdi32api/gdi32api.c
rostests/apitests/gdi32api/gdi32api.h
rostests/apitests/gdi32api/tests/SelectObject.c

index ab88895..245c401 100644 (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,
index 73ec2a9..8811be1 100644 (file)
@@ -20,6 +20,7 @@
 
 extern HINSTANCE g_hInstance;
 extern PGDI_TABLE_ENTRY GdiHandleTable;
+BOOL IsHandleValid(HGDIOBJ hobj);
 
 #endif /* _GDITEST_H */
 
index 0df71e9..cb476f8 100644 (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 */