Author: tkreuzer Date: Mon Dec 28 20:24:57 2015 New Revision: 70457
URL: http://svn.reactos.org/svn/reactos?rev=70457&view=rev Log: [GDITOOLS] Add a library with some helper routines for GDI tests
Added: trunk/rostests/apitests/gditools/ trunk/rostests/apitests/gditools/CMakeLists.txt (with props) trunk/rostests/apitests/gditools/gditools.c (with props) trunk/rostests/apitests/gditools/gditools.h (with props)
Added: trunk/rostests/apitests/gditools/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gditools/CMakeLis... ============================================================================== --- trunk/rostests/apitests/gditools/CMakeLists.txt (added) +++ trunk/rostests/apitests/gditools/CMakeLists.txt [iso-8859-1] Mon Dec 28 20:24:57 2015 @@ -0,0 +1,5 @@ + +include_directories(${REACTOS_SOURCE_DIR}/win32ss/include) + +add_library(gditools + gditools.c)
Propchange: trunk/rostests/apitests/gditools/CMakeLists.txt ------------------------------------------------------------------------------ svn:eol-style = native
Added: trunk/rostests/apitests/gditools/gditools.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gditools/gditools... ============================================================================== --- trunk/rostests/apitests/gditools/gditools.c (added) +++ trunk/rostests/apitests/gditools/gditools.c [iso-8859-1] Mon Dec 28 20:24:57 2015 @@ -0,0 +1,82 @@ + + +/* SDK/DDK/NDK Headers. */ +#define WIN32_NO_STATUS +#include <windef.h> +#include <winbase.h> +#include <wingdi.h> +#include <winddi.h> +#include <prntfont.h> + +#define NTOS_MODE_USER +#include <ndk/ntndk.h> + +/* Public Win32K Headers */ +#include <ntgdityp.h> +#include <ntgdi.h> +#include <ntgdihdl.h> + +PENTRY +GdiQueryTable( + VOID) +{ + PTEB pTeb = NtCurrentTeb(); + PPEB pPeb = pTeb->ProcessEnvironmentBlock; + return pPeb->GdiSharedHandleTable; +} + +BOOL +GdiIsHandleValid( + _In_ HGDIOBJ hobj) +{ + PENTRY pentHmgr = GdiQueryTable(); + USHORT Index = (ULONG_PTR)hobj & 0xFFFF; + PENTRY pentry = &pentHmgr[Index]; + + if ((pentry->einfo.pobj == NULL) || + ((LONG_PTR)pentry->einfo.pobj > 0) || + (pentry->FullUnique != (USHORT)((ULONG_PTR)hobj >> 16))) + { + return FALSE; + } + + return TRUE; +} + +BOOL +GdiIsHandleValidEx( + _In_ HGDIOBJ hobj, + _In_ GDILOOBJTYPE ObjectType) +{ + PENTRY pentHmgr = GdiQueryTable(); + USHORT Index = (ULONG_PTR)hobj & 0xFFFF; + PENTRY pentry = &pentHmgr[Index]; + + if ((pentry->einfo.pobj == NULL) || + ((LONG_PTR)pentry->einfo.pobj > 0) || + (pentry->FullUnique != (USHORT)((ULONG_PTR)hobj >> 16)) || + (pentry->Objt != (UCHAR)(ObjectType >> 16)) || + (pentry->Flags != (UCHAR)(ObjectType >> 24))) + { + return FALSE; + } + + return TRUE; +} + +PVOID +GdiGetHandleUserData( + _In_ HGDIOBJ hobj) +{ + PENTRY pentHmgr = GdiQueryTable(); + USHORT Index = (ULONG_PTR)hobj; + PENTRY pentry = &pentHmgr[Index]; + + if (!GdiIsHandleValid(hobj)) + { + return NULL; + } + + return pentry->pUser; +} +
Propchange: trunk/rostests/apitests/gditools/gditools.c ------------------------------------------------------------------------------ svn:eol-style = native
Added: trunk/rostests/apitests/gditools/gditools.h URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gditools/gditools... ============================================================================== --- trunk/rostests/apitests/gditools/gditools.h (added) +++ trunk/rostests/apitests/gditools/gditools.h [iso-8859-1] Mon Dec 28 20:24:57 2015 @@ -0,0 +1,20 @@ + +#pragma once + +PENTRY +GdiQueryTable( + VOID); + +BOOL +GdiIsHandleValid( + _In_ HGDIOBJ hobj); + +BOOL +GdiIsHandleValidEx( + _In_ HGDIOBJ hobj, + _In_ GDILOOBJTYPE ObjectType); + +PVOID +GdiGetHandleUserData( + _In_ HGDIOBJ hobj); +
Propchange: trunk/rostests/apitests/gditools/gditools.h ------------------------------------------------------------------------------ svn:eol-style = native