Add information letting us know creation deletion of services has worked.
[reactos.git] / reactos / subsys / win32k / objects / print.c
1 /*
2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 /* $Id$ */
20
21 #include <w32k.h>
22
23 #define NDEBUG
24 #include <debug.h>
25
26 INT
27 STDCALL
28 NtGdiAbortDoc(HDC hDC)
29 {
30 UNIMPLEMENTED;
31 return 0;
32 }
33
34 INT
35 STDCALL
36 NtGdiEndDoc(HDC hDC)
37 {
38 UNIMPLEMENTED;
39 return 0;
40 }
41
42 INT
43 STDCALL
44 NtGdiEndPage(HDC hDC)
45 {
46 UNIMPLEMENTED;
47 return 0;
48 }
49
50 INT
51 FASTCALL
52 IntGdiEscape(PDC dc,
53 INT Escape,
54 INT InSize,
55 LPCSTR InData,
56 LPVOID OutData)
57 {
58 if (Escape == QUERYESCSUPPORT)
59 return FALSE;
60
61 UNIMPLEMENTED;
62 return SP_ERROR;
63 }
64
65 INT
66 STDCALL
67 NtGdiEscape(HDC hDC,
68 INT Escape,
69 INT InSize,
70 LPCSTR InData,
71 LPVOID OutData)
72 {
73 PDC dc;
74 INT ret;
75
76 dc = DC_LockDc(hDC);
77 if (dc == NULL)
78 {
79 SetLastWin32Error(ERROR_INVALID_HANDLE);
80 return SP_ERROR;
81 }
82
83 /* TODO FIXME - don't pass umode buffer to an Int function */
84 ret = IntGdiEscape(dc, Escape, InSize, InData, OutData);
85
86 DC_UnlockDc( dc );
87 return ret;
88 }
89
90 INT
91 STDCALL
92 IntEngExtEscape(
93 SURFOBJ *Surface,
94 INT Escape,
95 INT InSize,
96 LPVOID InData,
97 INT OutSize,
98 LPVOID OutData)
99 {
100 if (Escape == QUERYESCSUPPORT)
101 return FALSE;
102
103 DPRINT1("IntEngExtEscape is unimplemented. - Keep going and have a nice day\n");
104 return -1;
105 }
106
107 INT
108 STDCALL
109 IntGdiExtEscape(
110 PDC dc,
111 INT Escape,
112 INT InSize,
113 LPCSTR InData,
114 INT OutSize,
115 LPSTR OutData)
116 {
117 BITMAPOBJ *BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
118 INT Result;
119
120 /* FIXME - Handle BitmapObj == NULL !!!!!! */
121
122 if ( NULL == dc->DriverFunctions.Escape )
123 {
124 Result = IntEngExtEscape(
125 &BitmapObj->SurfObj,
126 Escape,
127 InSize,
128 (PVOID)InData,
129 OutSize,
130 (PVOID)OutData);
131 }
132 else
133 {
134 Result = dc->DriverFunctions.Escape(
135 &BitmapObj->SurfObj,
136 Escape,
137 InSize,
138 (PVOID)InData,
139 OutSize,
140 (PVOID)OutData );
141 }
142 BITMAPOBJ_UnlockBitmap(BitmapObj);
143
144 return Result;
145 }
146
147 INT
148 STDCALL
149 NtGdiExtEscape(
150 HDC hDC,
151 INT Escape,
152 INT InSize,
153 LPCSTR UnsafeInData,
154 INT OutSize,
155 LPSTR UnsafeOutData)
156 {
157 PDC pDC = DC_LockDc(hDC);
158 LPVOID SafeInData = NULL;
159 LPVOID SafeOutData = NULL;
160 NTSTATUS Status = STATUS_SUCCESS;
161 INT Result;
162
163 if ( pDC == NULL )
164 {
165 SetLastWin32Error(ERROR_INVALID_HANDLE);
166 return -1;
167 }
168 if ( pDC->IsIC )
169 {
170 DC_UnlockDc(pDC);
171 return 0;
172 }
173
174 if ( InSize && UnsafeInData )
175 {
176 _SEH_TRY
177 {
178 ProbeForRead(UnsafeInData,
179 InSize,
180 1);
181 }
182 _SEH_HANDLE
183 {
184 Status = _SEH_GetExceptionCode();
185 }
186 _SEH_END;
187
188 if (!NT_SUCCESS(Status))
189 {
190 DC_UnlockDc(pDC);
191 SetLastNtError(Status);
192 return -1;
193 }
194
195 SafeInData = ExAllocatePoolWithTag ( PagedPool, InSize, TAG_PRINT );
196 if ( !SafeInData )
197 {
198 DC_UnlockDc(pDC);
199 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
200 return -1;
201 }
202
203 _SEH_TRY
204 {
205 /* pointers were already probed! */
206 RtlCopyMemory(SafeInData,
207 UnsafeInData,
208 InSize);
209 }
210 _SEH_HANDLE
211 {
212 Status = _SEH_GetExceptionCode();
213 }
214 _SEH_END;
215
216 if ( !NT_SUCCESS(Status) )
217 {
218 ExFreePool ( SafeInData );
219 DC_UnlockDc(pDC);
220 SetLastNtError(Status);
221 return -1;
222 }
223 }
224
225 if ( OutSize && UnsafeOutData )
226 {
227 _SEH_TRY
228 {
229 ProbeForWrite(UnsafeOutData,
230 OutSize,
231 1);
232 }
233 _SEH_HANDLE
234 {
235 Status = _SEH_GetExceptionCode();
236 }
237 _SEH_END;
238
239 if (!NT_SUCCESS(Status))
240 {
241 SetLastNtError(Status);
242 goto freeout;
243 }
244
245 SafeOutData = ExAllocatePoolWithTag ( PagedPool, OutSize, TAG_PRINT );
246 if ( !SafeOutData )
247 {
248 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
249 freeout:
250 if ( SafeInData )
251 ExFreePool ( SafeInData );
252 DC_UnlockDc(pDC);
253 return -1;
254 }
255 }
256
257 Result = IntGdiExtEscape ( pDC, Escape, InSize, SafeInData, OutSize, SafeOutData );
258
259 DC_UnlockDc(pDC);
260
261 if ( SafeInData )
262 ExFreePool ( SafeInData );
263
264 if ( SafeOutData )
265 {
266 _SEH_TRY
267 {
268 /* pointers were already probed! */
269 RtlCopyMemory(UnsafeOutData,
270 SafeOutData,
271 OutSize);
272 }
273 _SEH_HANDLE
274 {
275 Status = _SEH_GetExceptionCode();
276 }
277 _SEH_END;
278
279 ExFreePool ( SafeOutData );
280 if ( !NT_SUCCESS(Status) )
281 {
282 SetLastNtError(Status);
283 return -1;
284 }
285 }
286
287 return Result;
288 }
289
290 INT
291 STDCALL
292 NtGdiSetAbortProc(HDC hDC,
293 ABORTPROC AbortProc)
294 {
295 UNIMPLEMENTED;
296 return 0;
297 }
298
299 INT
300 STDCALL
301 NtGdiStartDoc(HDC hDC,
302 CONST LPDOCINFOW di)
303 {
304 UNIMPLEMENTED;
305 return 0;
306 }
307
308 INT
309 STDCALL
310 NtGdiStartPage(HDC hDC)
311 {
312 UNIMPLEMENTED;
313 return 0;
314 }
315 /* EOF */