ReactOS  0.4.15-dev-1201-gb2cf5a4
wingl.c File Reference
#include <win32k.h>
#include <debug.h>
Include dependency graph for wingl.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static INT FASTCALL IntGetipfdDevMax (PDC pdc)
 
 _Success_ (return !=0)
 
BOOL APIENTRY NtGdiSetPixelFormat (_In_ HDC hdc, _In_ INT ipfd)
 
BOOL APIENTRY NtGdiSwapBuffers (_In_ HDC hdc)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file wingl.c.

Function Documentation

◆ _Success_()

_Success_ ( return = 0)

Definition at line 41 of file wingl.c.

50 {
51  PDC pdc;
52  PPDEVOBJ ppdev;
53  INT Ret = 0;
54  PIXELFORMATDESCRIPTOR pfdSafe;
55 
56  if ((ppfd == NULL) && (cjpfd != 0)) return 0;
57 
58  pdc = DC_LockDc(hdc);
59  if (!pdc)
60  {
62  return 0;
63  }
64 
65  if (!pdc->ipfdDevMax)
66  {
67  if (!IntGetipfdDevMax(pdc))
68  {
69  /* EngSetLastError ? */
70  goto Exit;
71  }
72  }
73 
74  if (!ppfd)
75  {
76  Ret = pdc->ipfdDevMax;
77  goto Exit;
78  }
79 
80  if ((ipfd < 1) || (ipfd > pdc->ipfdDevMax))
81  {
83  goto Exit;
84  }
85 
86  ppdev = pdc->ppdev;
87 
88  if (ppdev->flFlags & PDEV_META_DEVICE)
89  {
91  goto Exit;
92  }
93 
95  {
97  ppdev->dhpdev,
98  ipfd,
99  sizeof(pfdSafe),
100  &pfdSafe);
101  }
102 
103  if (Ret && cjpfd)
104  {
105  _SEH2_TRY
106  {
107  cjpfd = min(cjpfd, sizeof(PIXELFORMATDESCRIPTOR));
108  ProbeForWrite(ppfd, cjpfd, 1);
109  RtlCopyMemory(ppfd, &pfdSafe, cjpfd);
110  }
112  {
114  }
115  _SEH2_END;
116  }
117 
118 Exit:
119  DC_UnlockDc(pdc);
120  return Ret;
121 }
DHPDEV dhpdev
Definition: pdevobj.h:121
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
_In_ INT ipfd
Definition: ntgdi.h:474
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
_In_ LONG _In_ ULONG _Out_opt_ PIXELFORMATDESCRIPTOR * ppfd
Definition: winddi.h:3488
int32_t INT
Definition: typedefs.h:58
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
PFN_DrvDescribePixelFormat DescribePixelFormat
Definition: ntgdityp.h:624
_SEH2_TRY
Definition: create.c:4226
_In_ LONG _In_ ULONG cjpfd
Definition: winddi.h:3488
DRIVER_FUNCTIONS DriverFunctions
Definition: pdevobj.h:138
FLONG flFlags
Definition: pdevobj.h:89
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
static INT FASTCALL IntGetipfdDevMax(PDC pdc)
Definition: wingl.c:17
Definition: polytest.cpp:40
static void Exit(void)
Definition: sock.c:1331
HDC hdc
Definition: main.c:9
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
_SEH2_END
Definition: create.c:4400
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
#define min(a, b)
Definition: monoChain.cc:55
#define UNIMPLEMENTED
Definition: debug.h:115
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

◆ IntGetipfdDevMax()

static INT FASTCALL IntGetipfdDevMax ( PDC  pdc)
static

Definition at line 17 of file wingl.c.

18 {
19  INT Ret = 0;
20  PPDEVOBJ ppdev = pdc->ppdev;
21 
22  if (ppdev->flFlags & PDEV_META_DEVICE)
23  {
24  return 0;
25  }
26 
28  {
30  ppdev->dhpdev,
31  1,
32  0,
33  NULL);
34  }
35 
36  if (Ret) pdc->ipfdDevMax = Ret;
37 
38  return Ret;
39 }
DHPDEV dhpdev
Definition: pdevobj.h:121
int32_t INT
Definition: typedefs.h:58
PFN_DrvDescribePixelFormat DescribePixelFormat
Definition: ntgdityp.h:624
DRIVER_FUNCTIONS DriverFunctions
Definition: pdevobj.h:138
FLONG flFlags
Definition: pdevobj.h:89
smooth NULL
Definition: ftsmooth.c:416

Referenced by _Success_(), and NtGdiSetPixelFormat().

◆ NtGdiSetPixelFormat()

BOOL APIENTRY NtGdiSetPixelFormat ( _In_ HDC  hdc,
_In_ INT  ipfd 
)

Definition at line 126 of file wingl.c.

129 {
130  PDC pdc;
131  PPDEVOBJ ppdev;
132  HWND hWnd;
133  PWNDOBJ pWndObj;
134  SURFOBJ *pso = NULL;
135  BOOL Ret = FALSE;
136 
137  DPRINT1("Setting pixel format from win32k!\n");
138 
139  pdc = DC_LockDc(hdc);
140  if (!pdc)
141  {
143  return FALSE;
144  }
145 
146  if (!pdc->ipfdDevMax)
147  IntGetipfdDevMax(pdc);
148 
149  if ( ipfd < 1 ||
150  ipfd > pdc->ipfdDevMax )
151  {
153  goto Exit;
154  }
155 
157  hWnd = UserGethWnd(hdc, &pWndObj);
158  UserLeave();
159 
160  if (!hWnd)
161  {
163  goto Exit;
164  }
165 
166  ppdev = pdc->ppdev;
167 
168  /*
169  WndObj is needed so exit on NULL pointer.
170  */
171  if (pWndObj)
172  pso = pWndObj->psoOwner;
173  else
174  {
176  goto Exit;
177  }
178 
179  if (ppdev->flFlags & PDEV_META_DEVICE)
180  {
182  goto Exit;
183  }
184 
185  if (ppdev->DriverFunctions.SetPixelFormat)
186  {
187  Ret = ppdev->DriverFunctions.SetPixelFormat(
188  pso,
189  ipfd,
190  hWnd);
191  }
192 
193 Exit:
194  DC_UnlockDc(pdc);
195  return Ret;
196 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
SURFOBJ * psoOwner
Definition: winddi.h:1230
_In_ INT ipfd
Definition: ntgdi.h:474
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
HWND hWnd
Definition: settings.c:17
PFN_DrvSetPixelFormat SetPixelFormat
Definition: ntgdityp.h:623
DRIVER_FUNCTIONS DriverFunctions
Definition: pdevobj.h:138
FLONG flFlags
Definition: pdevobj.h:89
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
_In_ HANDLE _In_ SURFOBJ * pso
Definition: winddi.h:3664
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
static INT FASTCALL IntGetipfdDevMax(PDC pdc)
Definition: wingl.c:17
Definition: polytest.cpp:40
static void Exit(void)
Definition: sock.c:1331
#define ERROR_INVALID_WINDOW_STYLE
Definition: winerror.h:1181
HDC hdc
Definition: main.c:9
HWND FASTCALL UserGethWnd(HDC, PWNDOBJ *)
Definition: windc.c:952
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
#define DPRINT1
Definition: precomp.h:8
#define ERROR_INVALID_PIXEL_FORMAT
Definition: winerror.h:1179
#define UNIMPLEMENTED
Definition: debug.h:115
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

◆ NtGdiSwapBuffers()

BOOL APIENTRY NtGdiSwapBuffers ( _In_ HDC  hdc)

Definition at line 200 of file wingl.c.

202 {
203  PDC pdc;
204  PPDEVOBJ ppdev;
205  HWND hWnd;
206  PWNDOBJ pWndObj;
207  SURFOBJ *pso = NULL;
208  BOOL Ret = FALSE;
209 
210  pdc = DC_LockDc(hdc);
211  if (!pdc)
212  {
214  return FALSE;
215  }
216 
218  hWnd = UserGethWnd(hdc, &pWndObj);
219  UserLeave();
220 
221  if (!hWnd)
222  {
224  goto Exit;
225  }
226 
227  ppdev = pdc->ppdev;
228 
229  /*
230  WndObj is needed so exit on NULL pointer.
231  */
232  if (pWndObj)
233  pso = pWndObj->psoOwner;
234  else
235  {
237  goto Exit;
238  }
239 
240  if (ppdev->flFlags & PDEV_META_DEVICE)
241  {
243  goto Exit;
244  }
245 
246  if (ppdev->DriverFunctions.SwapBuffers)
247  {
248  Ret = ppdev->DriverFunctions.SwapBuffers(pso, pWndObj);
249  }
250 
251 Exit:
252  DC_UnlockDc(pdc);
253  return Ret;
254 }
PFN_DrvSwapBuffers SwapBuffers
Definition: ntgdityp.h:625
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
SURFOBJ * psoOwner
Definition: winddi.h:1230
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
HWND hWnd
Definition: settings.c:17
DRIVER_FUNCTIONS DriverFunctions
Definition: pdevobj.h:138
FLONG flFlags
Definition: pdevobj.h:89
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
_In_ HANDLE _In_ SURFOBJ * pso
Definition: winddi.h:3664
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
Definition: polytest.cpp:40
static void Exit(void)
Definition: sock.c:1331
#define ERROR_INVALID_WINDOW_STYLE
Definition: winerror.h:1181
HDC hdc
Definition: main.c:9
HWND FASTCALL UserGethWnd(HDC, PWNDOBJ *)
Definition: windc.c:952
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
#define ERROR_INVALID_PIXEL_FORMAT
Definition: winerror.h:1179
#define UNIMPLEMENTED
Definition: debug.h:115
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27