Author: tkreuzer
Date: Thu Jun 3 21:35:05 2010
New Revision: 47549
URL:
http://svn.reactos.org/svn/reactos?rev=47549&view=rev
Log:
[GDI32API]
add IsHandleValid and use it SelectObject test
Modified:
trunk/rostests/apitests/gdi32api/gdi32api.c
trunk/rostests/apitests/gdi32api/gdi32api.h
trunk/rostests/apitests/gdi32api/tests/SelectObject.c
Modified: trunk/rostests/apitests/gdi32api/gdi32api.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32api/gdi32ap…
==============================================================================
--- trunk/rostests/apitests/gdi32api/gdi32api.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/gdi32api/gdi32api.c [iso-8859-1] Thu Jun 3 21:35:05 2010
@@ -18,6 +18,22 @@
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,
Modified: trunk/rostests/apitests/gdi32api/gdi32api.h
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32api/gdi32ap…
==============================================================================
--- trunk/rostests/apitests/gdi32api/gdi32api.h [iso-8859-1] (original)
+++ trunk/rostests/apitests/gdi32api/gdi32api.h [iso-8859-1] Thu Jun 3 21:35:05 2010
@@ -20,6 +20,7 @@
extern HINSTANCE g_hInstance;
extern PGDI_TABLE_ENTRY GdiHandleTable;
+BOOL IsHandleValid(HGDIOBJ hobj);
#endif /* _GDITEST_H */
Modified: trunk/rostests/apitests/gdi32api/tests/SelectObject.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32api/tests/S…
==============================================================================
--- trunk/rostests/apitests/gdi32api/tests/SelectObject.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/gdi32api/tests/SelectObject.c [iso-8859-1] Thu Jun 3 21:35:05
2010
@@ -82,6 +82,8 @@
DeleteObject(hOldObj);
RTEST((UINT_PTR)SelectObject(hDC, hNewObj) == SIMPLEREGION); // ??? Why this?
DeleteObject(hNewObj);
+ TEST(IsHandleValid(hNewObj) == TRUE);
+
RTEST(GetLastError() == ERROR_SUCCESS);
/* Test BITMAP */