ReactOS 0.4.15-dev-7842-g558ab78
print.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS win32 kernel mode subsystem
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: win32ss/gdi/ntgdi/print.c
5 * PURPOSE: Print functions
6 * PROGRAMMER:
7 */
8
9#include <win32k.h>
10
11#define NDEBUG
12#include <debug.h>
13
14INT
17{
19 return 0;
20}
21
22INT
25{
27 return 0;
28}
29
30INT
33{
35 return 0;
36}
37
38INT
41 INT Escape,
42 INT InSize,
43 LPCSTR InData,
44 LPVOID OutData)
45{
47 return FALSE;
48
50 return SP_ERROR;
51}
52
53INT
56 INT Escape,
57 INT InSize,
58 LPCSTR InData,
59 LPVOID OutData)
60{
61 PDC dc;
62 INT ret;
63
64 dc = DC_LockDc(hDC);
65 if (dc == NULL)
66 {
68 return SP_ERROR;
69 }
70
71 /* TODO: FIXME: Don't pass umode buffer to an Int function */
72 ret = IntGdiEscape(dc, Escape, InSize, InData, OutData);
73
74 DC_UnlockDc( dc );
75 return ret;
76}
77
78INT
81 HDC hDC,
83 IN INT nDriver,
84 INT Escape,
85 INT InSize,
86 OPTIONAL LPSTR UnsafeInData,
87 INT OutSize,
88 OPTIONAL LPSTR UnsafeOutData)
89{
90 LPVOID SafeInData = NULL;
91 LPVOID SafeOutData = NULL;
93 INT Result;
94 PPDEVOBJ ppdev;
95 PSURFACE psurf;
96
97 if (hDC == NULL)
98 {
99 if (pDriver)
100 {
101 /* FIXME : Get the pdev from its name */
103 return -1;
104 }
105
106 ppdev = EngpGetPDEV(NULL);
107 if (!ppdev)
108 {
110 return -1;
111 }
112
113 /* We're using the primary surface of the pdev. Lock it */
115
116 psurf = ppdev->pSurface;
117 if (!psurf)
118 {
120 PDEVOBJ_vRelease(ppdev);
121 return 0;
122 }
124 }
125 else
126 {
127 PDC pDC = DC_LockDc(hDC);
128 if ( pDC == NULL )
129 {
131 return -1;
132 }
133
134 /* Get the PDEV from the DC */
135 ppdev = pDC->ppdev;
136 PDEVOBJ_vReference(ppdev);
137
138 /* Check if we have a surface */
139 psurf = pDC->dclevel.pSurface;
140 if (!psurf)
141 {
142 DC_UnlockDc(pDC);
143 PDEVOBJ_vRelease(ppdev);
144 return 0;
145 }
147
148 /* We're done with the DC */
149 DC_UnlockDc(pDC);
150 }
151
152 /* See if we actually have a driver function to call */
153 if (ppdev->DriverFunctions.Escape == NULL)
154 {
155 Result = 0;
156 goto Exit;
157 }
158
159 if ( InSize && UnsafeInData )
160 {
162 {
163 ProbeForRead(UnsafeInData,
164 InSize,
165 1);
166 }
168 {
170 }
171 _SEH2_END;
172
173 if (!NT_SUCCESS(Status))
174 {
175 Result = -1;
176 goto Exit;
177 }
178
179 SafeInData = ExAllocatePoolWithTag ( PagedPool, InSize, GDITAG_TEMP );
180 if ( !SafeInData )
181 {
183 Result = -1;
184 goto Exit;
185 }
186
188 {
189 /* Pointers were already probed! */
190 RtlCopyMemory(SafeInData,
191 UnsafeInData,
192 InSize);
193 }
195 {
197 }
198 _SEH2_END;
199
200 if ( !NT_SUCCESS(Status) )
201 {
203 Result = -1;
204 goto Exit;
205 }
206 }
207
208 if ( OutSize && UnsafeOutData )
209 {
211 {
212 ProbeForWrite(UnsafeOutData,
213 OutSize,
214 1);
215 }
217 {
219 }
220 _SEH2_END;
221
222 if (!NT_SUCCESS(Status))
223 {
225 Result = -1;
226 goto Exit;
227 }
228
229 SafeOutData = ExAllocatePoolWithTag ( PagedPool, OutSize, GDITAG_TEMP );
230 if ( !SafeOutData )
231 {
233 Result = -1;
234 goto Exit;
235 }
236 }
237
238 /* Finally call the driver */
240 &psurf->SurfObj,
241 Escape,
242 InSize,
243 SafeInData,
244 OutSize,
245 SafeOutData );
246
247Exit:
248 if (hDC == NULL)
249 {
251 }
253 PDEVOBJ_vRelease(ppdev);
254
255 if ( SafeInData )
256 {
257 ExFreePoolWithTag ( SafeInData ,GDITAG_TEMP );
258 }
259
260 if ( SafeOutData )
261 {
262 if (Result > 0)
263 {
265 {
266 /* Pointers were already probed! */
267 RtlCopyMemory(UnsafeOutData, SafeOutData, OutSize);
268 }
270 {
272 }
273 _SEH2_END;
274
275 if ( !NT_SUCCESS(Status) )
276 {
278 Result = -1;
279 }
280 }
281
282 ExFreePoolWithTag ( SafeOutData, GDITAG_TEMP );
283 }
284
285 return Result;
286}
287
288INT
291 IN HDC hdc,
292 IN DOCINFOW *pdi,
293 OUT BOOL *pbBanding,
294 IN INT iJob)
295{
297 return 0;
298}
299
300INT
303{
305 return 0;
306}
307/* EOF */
static HDC hDC
Definition: 3dtext.c:33
LONG NTSTATUS
Definition: precomp.h:26
#define UNIMPLEMENTED
Definition: debug.h:115
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:238
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:220
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define APIENTRY
Definition: api.h:79
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
unsigned int BOOL
Definition: ntddk_ex.h:94
STRING Escape(const STRING &str)
Definition: fontsub.cpp:1030
FxDriver * pDriver
VOID WINAPI EngReleaseSemaphore(IN HSEMAPHORE hsem)
Definition: eng.c:235
Status
Definition: gdiplustypes.h:25
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
static const WCHAR dc[]
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
#define FASTCALL
Definition: nt_native.h:50
PPDEVOBJ NTAPI EngpGetPDEV(_In_opt_ PUNICODE_STRING pustrDeviceName)
Definition: pdevobj.c:799
VOID NTAPI PDEVOBJ_vRelease(_Inout_ PPDEVOBJ ppdev)
Definition: pdevobj.c:105
FORCEINLINE VOID PDEVOBJ_vReference(_In_ PPDEVOBJ ppdev)
Definition: pdevobj.h:160
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:159
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
#define STATUS_SUCCESS
Definition: shellext.h:65
static void Exit(void)
Definition: sock.c:1330
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
Definition: polytest.cpp:41
PFN_DrvEscape Escape
Definition: ntgdityp.h:593
PSURFACE pSurface
Definition: pdevobj.h:124
DRIVER_FUNCTIONS DriverFunctions
Definition: pdevobj.h:137
HSEMAPHORE hsemDevLock
Definition: pdevobj.h:89
SURFOBJ SurfObj
Definition: surface.h:8
int32_t INT
Definition: typedefs.h:58
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define IN
Definition: typedefs.h:39
uint16_t * PWCHAR
Definition: typedefs.h:56
#define OUT
Definition: typedefs.h:40
int ret
VOID FASTCALL SetLastNtError(_In_ NTSTATUS Status)
Definition: error.c:31
#define SURFACE_ShareUnlockSurface(pBMObj)
Definition: surface.h:102
FORCEINLINE VOID SURFACE_ShareLockByPointer(PSURFACE psurf)
Definition: surface.h:95
INT APIENTRY NtGdiEndPage(HDC hDC)
Definition: print.c:32
INT APIENTRY NtGdiStartPage(HDC hDC)
Definition: print.c:302
INT APIENTRY NtGdiAbortDoc(HDC hDC)
Definition: print.c:16
INT APIENTRY NtGdiEndDoc(HDC hDC)
Definition: print.c:24
INT APIENTRY NtGdiEscape(HDC hDC, INT Escape, INT InSize, LPCSTR InData, LPVOID OutData)
Definition: print.c:55
INT APIENTRY NtGdiStartDoc(IN HDC hdc, IN DOCINFOW *pdi, OUT BOOL *pbBanding, IN INT iJob)
Definition: print.c:290
INT FASTCALL IntGdiEscape(PDC dc, INT Escape, INT InSize, LPCSTR InData, LPVOID OutData)
Definition: print.c:40
INT APIENTRY NtGdiExtEscape(HDC hDC, IN OPTIONAL PWCHAR pDriver, IN INT nDriver, INT Escape, INT InSize, OPTIONAL LPSTR UnsafeInData, INT OutSize, OPTIONAL LPSTR UnsafeOutData)
Definition: print.c:80
#define GDITAG_TEMP
Definition: tags.h:167
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG _Out_ DEVINFO * pdi
Definition: winddi.h:3554
ENGAPI VOID APIENTRY EngAcquireSemaphore(_Inout_ HSEMAPHORE hsem)
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:22
#define ERROR_BAD_DEVICE
Definition: winerror.h:703
#define SP_ERROR
Definition: wingdi.h:318
#define QUERYESCSUPPORT
Definition: wingdi.h:1001
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
const char * LPCSTR
Definition: xmlstorage.h:183
char * LPSTR
Definition: xmlstorage.h:182