ReactOS  0.4.14-dev-384-g5b37caa
gditools.c File Reference
#include <windef.h>
#include <winbase.h>
#include <wingdi.h>
#include <winddi.h>
#include <prntfont.h>
#include <ndk/ntndk.h>
#include <ntgdityp.h>
#include <ntgdi.h>
#include <ntgdihdl.h>
Include dependency graph for gditools.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define NTOS_MODE_USER
 

Functions

PENTRY GdiQueryTable (VOID)
 
BOOL GdiIsHandleValid (_In_ HGDIOBJ hobj)
 
BOOL GdiIsHandleValidEx (_In_ HGDIOBJ hobj, _In_ GDILOOBJTYPE ObjectType)
 
PVOID GdiGetHandleUserData (_In_ HGDIOBJ hobj)
 

Macro Definition Documentation

◆ NTOS_MODE_USER

#define NTOS_MODE_USER

Definition at line 11 of file gditools.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 4 of file gditools.c.

Function Documentation

◆ GdiGetHandleUserData()

PVOID GdiGetHandleUserData ( _In_ HGDIOBJ  hobj)

Definition at line 68 of file gditools.c.

70 {
71  PENTRY pentHmgr = GdiQueryTable();
72  USHORT Index = (ULONG_PTR)hobj;
73  PENTRY pentry = &pentHmgr[Index];
74 
75  if (!GdiIsHandleValid(hobj))
76  {
77  return NULL;
78  }
79 
80  return pentry->pUser;
81 }
PVOID pUser
Definition: ntgdihdl.h:251
BOOL GdiIsHandleValid(_In_ HGDIOBJ hobj)
Definition: gditools.c:29
smooth NULL
Definition: ftsmooth.c:416
static const UCHAR Index[8]
Definition: usbohci.c:18
PENTRY GdiQueryTable(VOID)
Definition: gditools.c:20
unsigned short USHORT
Definition: pedump.c:61
#define ULONG_PTR
Definition: config.h:101
Definition: ntgdihdl.h:230

Referenced by CancelDC(), CreateCompatibleBitmap(), CreateCompatibleDC(), CreatePen(), GdiDeleteBrushOrPen(), GetBrushOrgEx(), GetColorSpace(), IntCreateDICW(), SetBrushOrgEx(), SetDIBitsToDevice(), START_TEST(), and StretchDIBits().

◆ GdiIsHandleValid()

BOOL GdiIsHandleValid ( _In_ HGDIOBJ  hobj)

Definition at line 29 of file gditools.c.

31 {
32  PENTRY pentHmgr = GdiQueryTable();
33  USHORT Index = (ULONG_PTR)hobj & 0xFFFF;
34  PENTRY pentry = &pentHmgr[Index];
35 
36  if ((pentry->einfo.pobj == NULL) ||
37  ((LONG_PTR)pentry->einfo.pobj > 0) ||
38  (pentry->FullUnique != (USHORT)((ULONG_PTR)hobj >> 16)))
39  {
40  return FALSE;
41  }
42 
43  return TRUE;
44 }
#define LONG_PTR
Definition: treelist.c:79
#define TRUE
Definition: types.h:120
struct _BASEOBJECT * pobj
Definition: ntgdihdl.h:234
union _ENTRY::_EINFO einfo
uint32_t ULONG_PTR
Definition: typedefs.h:63
smooth NULL
Definition: ftsmooth.c:416
static const UCHAR Index[8]
Definition: usbohci.c:18
PENTRY GdiQueryTable(VOID)
Definition: gditools.c:20
unsigned short USHORT
Definition: pedump.c:61
USHORT FullUnique
Definition: ntgdihdl.h:248
#define ULONG_PTR
Definition: config.h:101
Definition: ntgdihdl.h:230

Referenced by GdiGetHandleUserData(), and START_TEST().

◆ GdiIsHandleValidEx()

BOOL GdiIsHandleValidEx ( _In_ HGDIOBJ  hobj,
_In_ GDILOOBJTYPE  ObjectType 
)

Definition at line 47 of file gditools.c.

50 {
51  PENTRY pentHmgr = GdiQueryTable();
52  USHORT Index = (ULONG_PTR)hobj & 0xFFFF;
53  PENTRY pentry = &pentHmgr[Index];
54 
55  if ((pentry->einfo.pobj == NULL) ||
56  ((LONG_PTR)pentry->einfo.pobj > 0) ||
57  (pentry->FullUnique != (USHORT)((ULONG_PTR)hobj >> 16)) ||
58  (pentry->Objt != (UCHAR)(ObjectType >> 16)) ||
59  (pentry->Flags != (UCHAR)(ObjectType >> 24)))
60  {
61  return FALSE;
62  }
63 
64  return TRUE;
65 }
ObjectType
Definition: metafile.c:80
#define LONG_PTR
Definition: treelist.c:79
#define TRUE
Definition: types.h:120
UCHAR Objt
Definition: ntgdihdl.h:249
struct _BASEOBJECT * pobj
Definition: ntgdihdl.h:234
UCHAR Flags
Definition: ntgdihdl.h:250
union _ENTRY::_EINFO einfo
uint32_t ULONG_PTR
Definition: typedefs.h:63
smooth NULL
Definition: ftsmooth.c:416
static const UCHAR Index[8]
Definition: usbohci.c:18
unsigned char UCHAR
Definition: xmlstorage.h:181
PENTRY GdiQueryTable(VOID)
Definition: gditools.c:20
unsigned short USHORT
Definition: pedump.c:61
USHORT FullUnique
Definition: ntgdihdl.h:248
#define ULONG_PTR
Definition: config.h:101
Definition: ntgdihdl.h:230

◆ GdiQueryTable()

PENTRY GdiQueryTable ( VOID  )

Definition at line 20 of file gditools.c.

22 {
23  PTEB pTeb = NtCurrentTeb();
24  PPEB pPeb = pTeb->ProcessEnvironmentBlock;
25  return pPeb->GdiSharedHandleTable;
26 }
PPEB ProcessEnvironmentBlock
Definition: ntddk_ex.h:337
PVOID GdiSharedHandleTable
Definition: ntddk_ex.h:292
Definition: compat.h:492
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420

Referenced by GdiGetHandleUserData(), GdiIsHandleValid(), and GdiIsHandleValidEx().