ReactOS 0.4.16-dev-2206-gc56950d
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 /* Validate input parameters */
98 if ((InSize < 0) || (OutSize < 0) || (UnsafeInData == NULL && InSize != 0))
99 {
101 return -1;
102 }
103
104 if (hDC == NULL)
105 {
106 if (pDriver)
107 {
108 /* FIXME : Get the pdev from its name */
110 return -1;
111 }
112
113 ppdev = EngpGetPDEV(NULL);
114 if (!ppdev)
115 {
117 return -1;
118 }
119
120 /* We're using the primary surface of the pdev. Lock it */
122
123 psurf = ppdev->pSurface;
124 if (!psurf)
125 {
127 PDEVOBJ_vRelease(ppdev);
128 return 0;
129 }
131 }
132 else
133 {
134 PDC pDC = DC_LockDc(hDC);
135 if (pDC == NULL)
136 {
138 return -1;
139 }
140
141 /* Get the PDEV from the DC */
142 ppdev = pDC->ppdev;
143 PDEVOBJ_vReference(ppdev);
144
146
147 /* Check if we have a surface */
148 psurf = pDC->dclevel.pSurface;
149 if (!psurf)
150 {
152 PDEVOBJ_vRelease(ppdev);
153 DC_UnlockDc(pDC);
154 return 0;
155 }
157
158 /* We're done with the DC */
159 DC_UnlockDc(pDC);
160 }
161
162 /* See if we actually have a driver function to call */
163 if (ppdev->DriverFunctions.Escape == NULL)
164 {
165 Result = 0;
166 goto Exit;
167 }
168
169 if (InSize)
170 {
171 SafeInData = ExAllocatePoolWithTag(PagedPool, InSize, GDITAG_TEMP);
172 if (SafeInData == NULL)
173 {
175 goto Exit;
176 }
178 {
179 ProbeForRead(UnsafeInData, InSize, 1);
180 RtlCopyMemory(SafeInData, UnsafeInData, InSize);
181 }
183 {
186 _SEH2_YIELD(goto Exit);
187 }
188 _SEH2_END;
189 }
190
191 if (OutSize)
192 {
193 if (UnsafeOutData != NULL)
194 {
196 {
197 ProbeForWrite(UnsafeOutData, OutSize, 1);
198 }
200 {
203 _SEH2_YIELD(goto Exit);
204 }
205 _SEH2_END;
206 }
207
208 SafeOutData = ExAllocatePoolZero(PagedPool, OutSize, GDITAG_TEMP);
209 if (SafeOutData == NULL)
210 {
212 goto Exit;
213 }
214 }
215
216 /* Finally call the driver */
218 &psurf->SurfObj,
219 Escape,
220 InSize,
221 SafeInData,
222 OutSize,
223 SafeOutData);
224
225 if (OutSize != 0 && UnsafeOutData != NULL && SafeOutData != NULL)
226 {
228 {
229 RtlCopyMemory(UnsafeOutData, SafeOutData, OutSize);
230 }
232 {
235 Result = -1;
236 }
237 _SEH2_END;
238 }
239
240Exit:
243 PDEVOBJ_vRelease(ppdev);
244
245 if (SafeInData != NULL)
246 {
247 ExFreePoolWithTag(SafeInData, GDITAG_TEMP);
248 }
249
250 if (SafeOutData != NULL)
251 {
252 ExFreePoolWithTag(SafeOutData, GDITAG_TEMP);
253 }
254
255 return Result;
256}
257
258INT
261 IN HDC hdc,
262 IN DOCINFOW *pdi,
263 OUT BOOL *pbBanding,
264 IN INT iJob)
265{
267 return 0;
268}
269
270INT
273{
275 return 0;
276}
277/* EOF */
static HDC hDC
Definition: 3dtext.c:33
LONG NTSTATUS
Definition: precomp.h:26
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
HDC dc
Definition: cylfrac.c:34
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 APIENTRY
Definition: api.h:79
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
return ret
Definition: mutex.c:146
#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
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:90
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
HDC hdc
Definition: main.c:9
FORCEINLINE PVOID ExAllocatePoolZero(ULONG PoolType, SIZE_T NumberOfBytes, ULONG Tag)
Definition: precomp.h:45
static HDC
Definition: imagelist.c:88
#define FASTCALL
Definition: nt_native.h:50
PPDEVOBJ NTAPI EngpGetPDEV(_In_opt_ PUNICODE_STRING pustrDeviceName)
Definition: pdevobj.c:815
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:181
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:82
#define _SEH2_END
Definition: pseh2_64.h:171
#define _SEH2_TRY
Definition: pseh2_64.h:71
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:184
#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
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:272
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:260
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:1032
#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