ReactOS 0.4.16-dev-2110-ge3521eb
gditools.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  MYPAL
 

Functions

BOOL GdiToolsInit (void)
 
PENTRY GdiQueryTable (VOID)
 
BOOL GdiIsHandleValid (_In_ HGDIOBJ hobj)
 
BOOL GdiIsHandleValidEx (_In_ HGDIOBJ hobj, _In_ GDILOOBJTYPE ObjectType)
 
PVOID GdiGetHandleUserData (_In_ HGDIOBJ hobj)
 
BOOL ChangeScreenBpp (_In_ ULONG cBitsPixel, _Out_ PULONG pcOldBitsPixel)
 

Variables

HBITMAP ghbmp1
 
HBITMAP ghbmp1_InvCol
 
HBITMAP ghbmp1_RB
 
HBITMAP ghbmp4
 
HBITMAP ghbmp8
 
HBITMAP ghbmp16
 
HBITMAP ghbmp24
 
HBITMAP ghbmp32
 
HBITMAP ghbmpDIB1
 
HBITMAP ghbmpDIB1_InvCol
 
HBITMAP ghbmpDIB1_RB
 
HBITMAP ghbmpDIB4
 
HBITMAP ghbmpDIB8
 
HBITMAP ghbmpDIB16
 
HBITMAP ghbmpDIB24
 
HBITMAP ghbmpDIB32
 
HDC ghdcDIB1
 
HDC ghdcDIB1_InvCol
 
HDC ghdcDIB1_RB
 
HDC ghdcDIB4
 
HDC ghdcDIB8
 
HDC ghdcDIB16
 
HDC ghdcDIB24
 
HDC ghdcDIB32
 
PVOID gpvDIB1
 
PVOID gpvDIB1_InvCol
 
PVOID gpvDIB1_RB
 
PVOID gpvDIB4
 
PVOID gpvDIB8
 
PVOID gpvDIB16
 
PVOID gpvDIB24
 
PVOID gpvDIB32
 
HDC ghdcInfo
 
PULONG pulDIB4Bits
 
HPALETTE ghpal
 
ULONG(* gpDIB32 )[8][8]
 
MYPAL gpal
 

Function Documentation

◆ ChangeScreenBpp()

BOOL ChangeScreenBpp ( _In_ ULONG  cBitsPixel,
_Out_ PULONG  pcOldBitsPixel 
)

Definition at line 110 of file gditools.c.

113{
114 DEVMODEW dm = { .dmSize = sizeof(dm) };
115
117 {
118 printf("EnumDisplaySettingsW failed\n");
119 return FALSE;
120 }
121
122 *pcOldBitsPixel = dm.dmBitsPerPel;
123
124 if (dm.dmBitsPerPel != cBitsPixel)
125 {
126 dm.dmBitsPerPel = cBitsPixel;
128 {
129 printf("Failed to change display settings to %lu bpp. Current bpp: %u\n", cBitsPixel, *pcOldBitsPixel);
130 return FALSE;
131 }
132 }
133
134 return TRUE;
135}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define printf
Definition: freeldr.h:97
DWORD dmBitsPerPel
Definition: wingdi.h:2093
WORD dmSize
Definition: wingdi.h:2066
LONG WINAPI ChangeDisplaySettingsExW(LPCWSTR lpszDeviceName, LPDEVMODEW lpDevMode, HWND hwnd, DWORD dwflags, LPVOID lParam)
Definition: display.c:585
BOOL WINAPI EnumDisplaySettingsW(LPCWSTR lpszDeviceName, DWORD iModeNum, LPDEVMODEW lpDevMode)
Definition: display.c:408
#define DISP_CHANGE_SUCCESSFUL
Definition: winuser.h:190
#define CDS_UPDATEREGISTRY
Definition: winuser.h:181
#define ENUM_CURRENT_SETTINGS
Definition: winuser.h:179
#define CDS_GLOBAL
Definition: winuser.h:184

Referenced by START_TEST().

◆ GdiGetHandleUserData()

PVOID GdiGetHandleUserData ( _In_ HGDIOBJ  hobj)

Definition at line 94 of file gditools.c.

96{
97 PENTRY pentHmgr = GdiQueryTable();
98 USHORT Index = (ULONG_PTR)hobj;
99 PENTRY pentry = &pentHmgr[Index];
100
101 if (!GdiIsHandleValid(hobj))
102 {
103 return NULL;
104 }
105
106 return pentry->pUser;
107}
#define ULONG_PTR
Definition: config.h:101
PENTRY GdiQueryTable(VOID)
Definition: gditools.c:46
BOOL GdiIsHandleValid(_In_ HGDIOBJ hobj)
Definition: gditools.c:55
unsigned short USHORT
Definition: pedump.c:61
Definition: ntgdihdl.h:218
PVOID pUser
Definition: ntgdihdl.h:238
_In_ WDFCOLLECTION _In_ ULONG Index

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 55 of file gditools.c.

57{
58 PENTRY pentHmgr = GdiQueryTable();
59 USHORT Index = (ULONG_PTR)hobj & 0xFFFF;
60 PENTRY pentry = &pentHmgr[Index];
61
62 if ((pentry->einfo.pobj == NULL) ||
63 ((LONG_PTR)pentry->einfo.pobj > 0) ||
64 (pentry->FullUnique != (USHORT)((ULONG_PTR)hobj >> 16)))
65 {
66 return FALSE;
67 }
68
69 return TRUE;
70}
union _ENTRY::_EINFO einfo
USHORT FullUnique
Definition: ntgdihdl.h:235
#define LONG_PTR
Definition: treelist.c:79
uint32_t ULONG_PTR
Definition: typedefs.h:65
struct _BASEOBJECT * pobj
Definition: ntgdihdl.h:221

Referenced by GdiGetHandleUserData(), and START_TEST().

◆ GdiIsHandleValidEx()

BOOL GdiIsHandleValidEx ( _In_ HGDIOBJ  hobj,
_In_ GDILOOBJTYPE  ObjectType 
)

Definition at line 73 of file gditools.c.

76{
77 PENTRY pentHmgr = GdiQueryTable();
78 USHORT Index = (ULONG_PTR)hobj & 0xFFFF;
79 PENTRY pentry = &pentHmgr[Index];
80
81 if ((pentry->einfo.pobj == NULL) ||
82 ((LONG_PTR)pentry->einfo.pobj > 0) ||
83 (pentry->FullUnique != (USHORT)((ULONG_PTR)hobj >> 16)) ||
84 (pentry->Objt != (UCHAR)(ObjectType >> 16)) ||
85 (pentry->Flags != (UCHAR)(ObjectType >> 24)))
86 {
87 return FALSE;
88 }
89
90 return TRUE;
91}
ObjectType
Definition: metafile.c:81
UCHAR Objt
Definition: ntgdihdl.h:236
UCHAR Flags
Definition: ntgdihdl.h:237
unsigned char UCHAR
Definition: xmlstorage.h:181

◆ GdiQueryTable()

PENTRY GdiQueryTable ( VOID  )

Definition at line 46 of file gditools.c.

48{
49 PTEB pTeb = NtCurrentTeb();
50 PPEB pPeb = pTeb->ProcessEnvironmentBlock;
51 return pPeb->GdiSharedHandleTable;
52}
#define NtCurrentTeb
PVOID GdiSharedHandleTable
Definition: ntddk_ex.h:292
Definition: compat.h:836
PPEB ProcessEnvironmentBlock
Definition: ntddk_ex.h:337

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

◆ GdiToolsInit()

BOOL GdiToolsInit ( void  )

Definition at line 229 of file gditools.c.

230{
231 /* Initialize a logical palette */
233 if (!ghpal)
234 {
235 printf("failed to create a palette\n");
236 return FALSE;
237 }
238
239 if (!InitPerBitDepth(1, 9, 9, &ghbmp1, &ghdcDIB1, &ghbmpDIB1, &gpvDIB1, 0) ||
242 !InitPerBitDepth(4, 5, 5, &ghbmp4, &ghdcDIB4, &ghbmpDIB4, &gpvDIB4, 0) ||
243 !InitPerBitDepth(8, 5, 5, &ghbmp8, &ghdcDIB8, &ghbmpDIB8, &gpvDIB8, 0) ||
244 !InitPerBitDepth(16, 8, 8, &ghbmp16, &ghdcDIB16, &ghbmpDIB16, &gpvDIB16, 0) ||
245 !InitPerBitDepth(24, 8, 8, &ghbmp24, &ghdcDIB24, &ghbmpDIB24, &gpvDIB24, 0) ||
247 {
248 printf("failed to create objects\n");
249 return FALSE;
250 }
251
253
254 /* Create an Info-DC */
255 ghdcInfo = CreateDCW(L"DISPLAY", NULL, NULL, NULL);
256 if (!ghdcInfo)
257 {
258 printf("failed to create info DC\n");
259 return FALSE;
260 }
261
262 return TRUE;
263}
#define L(x)
Definition: resources.c:13
HBITMAP ghbmp24
Definition: gditools.c:22
HBITMAP ghbmpDIB8
Definition: gditools.c:23
HBITMAP ghbmp4
Definition: gditools.c:22
HBITMAP ghbmpDIB1_InvCol
Definition: gditools.c:23
HDC ghdcDIB8
Definition: gditools.c:24
PVOID gpvDIB8
Definition: gditools.c:25
HDC ghdcDIB16
Definition: gditools.c:24
HBITMAP ghbmpDIB24
Definition: gditools.c:23
ULONG(* gpDIB32)[8][8]
Definition: gditools.c:26
#define FL_RED_BLUE
Definition: gditools.c:138
HDC ghdcInfo
Definition: gditools.c:28
HBITMAP ghbmpDIB1
Definition: gditools.c:23
PVOID gpvDIB1_RB
Definition: gditools.c:25
PVOID gpvDIB1
Definition: gditools.c:25
HBITMAP ghbmpDIB1_RB
Definition: gditools.c:23
HDC ghdcDIB32
Definition: gditools.c:24
HPALETTE ghpal
Definition: gditools.c:27
PVOID gpvDIB1_InvCol
Definition: gditools.c:25
HBITMAP ghbmpDIB16
Definition: gditools.c:23
static BOOL InitPerBitDepth(_In_ ULONG cBitsPerPixel, _In_ ULONG cx, _In_ ULONG cy, _Out_opt_ HBITMAP *phbmpDDB, _Out_ HDC *phdcDIB, _Out_ HBITMAP *phbmpDIB, _Out_ PVOID *ppvBits, _In_ ULONG flags)
Definition: gditools.c:142
HBITMAP ghbmp1
Definition: gditools.c:22
PVOID gpvDIB4
Definition: gditools.c:25
PVOID gpvDIB32
Definition: gditools.c:25
PVOID gpvDIB24
Definition: gditools.c:25
HDC ghdcDIB1
Definition: gditools.c:24
HBITMAP ghbmpDIB32
Definition: gditools.c:23
HBITMAP ghbmp8
Definition: gditools.c:22
HDC ghdcDIB1_RB
Definition: gditools.c:24
MYPAL gpal
Definition: gditools.c:30
#define FL_INVERT_COLORS
Definition: gditools.c:137
HDC ghdcDIB4
Definition: gditools.c:24
PVOID gpvDIB16
Definition: gditools.c:25
HBITMAP ghbmp32
Definition: gditools.c:22
HDC ghdcDIB24
Definition: gditools.c:24
HDC ghdcDIB1_InvCol
Definition: gditools.c:24
HBITMAP ghbmp16
Definition: gditools.c:22
HBITMAP ghbmpDIB4
Definition: gditools.c:23
HPALETTE WINAPI CreatePalette(_In_reads_(_Inexpressible_(2 *sizeof(WORD)+plpal->palNumEntries *sizeof(PALETTEENTRY))) const LOGPALETTE *)
HDC WINAPI CreateDCW(_In_opt_ LPCWSTR pszDriver, _In_opt_ LPCWSTR pszDevice, _In_opt_ LPCWSTR psz, _In_opt_ const DEVMODEW *pdmInit)

Referenced by START_TEST().

Variable Documentation

◆ ghbmp1

HBITMAP ghbmp1
extern

Definition at line 22 of file gditools.c.

Referenced by GdiToolsInit(), and START_TEST().

◆ ghbmp16

HBITMAP ghbmp16

Definition at line 4 of file gditools.h.

◆ ghbmp1_InvCol

HBITMAP ghbmp1_InvCol

Definition at line 4 of file gditools.h.

◆ ghbmp1_RB

HBITMAP ghbmp1_RB

Definition at line 4 of file gditools.h.

◆ ghbmp24

HBITMAP ghbmp24

Definition at line 4 of file gditools.h.

◆ ghbmp32

HBITMAP ghbmp32

Definition at line 4 of file gditools.h.

◆ ghbmp4

HBITMAP ghbmp4

Definition at line 4 of file gditools.h.

◆ ghbmp8

HBITMAP ghbmp8

Definition at line 4 of file gditools.h.

◆ ghbmpDIB1

HBITMAP ghbmpDIB1
extern

Definition at line 23 of file gditools.c.

Referenced by GdiToolsInit().

◆ ghbmpDIB16

HBITMAP ghbmpDIB16

Definition at line 5 of file gditools.h.

◆ ghbmpDIB1_InvCol

HBITMAP ghbmpDIB1_InvCol

Definition at line 5 of file gditools.h.

◆ ghbmpDIB1_RB

HBITMAP ghbmpDIB1_RB

Definition at line 5 of file gditools.h.

◆ ghbmpDIB24

HBITMAP ghbmpDIB24

Definition at line 5 of file gditools.h.

◆ ghbmpDIB32

HBITMAP ghbmpDIB32

Definition at line 5 of file gditools.h.

◆ ghbmpDIB4

HBITMAP ghbmpDIB4

Definition at line 5 of file gditools.h.

◆ ghbmpDIB8

HBITMAP ghbmpDIB8

Definition at line 5 of file gditools.h.

◆ ghdcDIB1

◆ ghdcDIB16

HDC ghdcDIB16

Definition at line 6 of file gditools.h.

◆ ghdcDIB1_InvCol

HDC ghdcDIB1_InvCol

Definition at line 6 of file gditools.h.

◆ ghdcDIB1_RB

HDC ghdcDIB1_RB

Definition at line 6 of file gditools.h.

◆ ghdcDIB24

HDC ghdcDIB24

Definition at line 6 of file gditools.h.

◆ ghdcDIB32

HDC ghdcDIB32

Definition at line 6 of file gditools.h.

◆ ghdcDIB4

HDC ghdcDIB4

Definition at line 6 of file gditools.h.

◆ ghdcDIB8

HDC ghdcDIB8

Definition at line 6 of file gditools.h.

◆ ghdcInfo

HDC ghdcInfo
extern

Definition at line 28 of file gditools.c.

Referenced by GdiToolsInit(), and Test_NtGdiSetPixel_generic().

◆ ghpal

◆ gpal

MYPAL gpal
extern

Definition at line 30 of file gditools.c.

Referenced by GdiToolsInit().

◆ gpDIB32

◆ gpvDIB1

PVOID gpvDIB1
extern

Definition at line 25 of file gditools.c.

Referenced by GdiToolsInit(), Test_NtGdiSetPixel_1Bpp(), and Test_PaintRgn().

◆ gpvDIB16

PVOID gpvDIB16

Definition at line 7 of file gditools.h.

◆ gpvDIB1_InvCol

PVOID gpvDIB1_InvCol

Definition at line 7 of file gditools.h.

◆ gpvDIB1_RB

PVOID gpvDIB1_RB

Definition at line 7 of file gditools.h.

◆ gpvDIB24

PVOID gpvDIB24

Definition at line 7 of file gditools.h.

◆ gpvDIB32

PVOID gpvDIB32

Definition at line 7 of file gditools.h.

◆ gpvDIB4

PVOID gpvDIB4

Definition at line 7 of file gditools.h.

◆ gpvDIB8

PVOID gpvDIB8

Definition at line 7 of file gditools.h.

◆ pulDIB4Bits

PULONG pulDIB4Bits
extern