1 /*
2  * PROJECT:         ReactOS api tests
3  * LICENSE:         GPL - See COPYING in the top level directory
4  * PURPOSE:         Test for GetObject
5  * PROGRAMMERS:     Timo Kreuzer
6  */
7 
8 #include "precomp.h"
9 
10 #define INVALID_POINTER ((PVOID)(ULONG_PTR)0xdeadbeefdeadbeefULL)
11 
12 void
13 Test_General(void)
14 {
15     struct
16     {
17         LOGBRUSH logbrush;
18         BYTE additional[600];
19     } TestStruct;
20     PLOGBRUSH plogbrush;
21     HBRUSH hBrush;
22     HPEN hpen;
23     INT ret;
24 
25     /* Test null pointer and invalid handles */
26     SetLastError(ERROR_SUCCESS);
27     ok(GetObjectA(0, 0, NULL) == 0, "\n");
28     ok(GetObjectA((HANDLE)-1, 0, NULL) == 0, "\n");
29 
30     /* Test invalid habdles of different types */
31     ok(GetObjectA((HANDLE)0x00380000, 0, NULL) == 0, "\n");
32     ok(GetLastError() == ERROR_SUCCESS, "\n");
33     ok(GetObjectA((HANDLE)0x00380000, 10, &TestStruct) == 0, "\n");
34     ok(GetLastError() == ERROR_SUCCESS, "\n");
35     SetLastError(ERROR_SUCCESS);
36     ok(GetObjectA((HANDLE)0x00010000, 0, NULL) == 0, "\n");
37     ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
38     SetLastError(ERROR_SUCCESS);
39     ok(GetObjectA((HANDLE)0x00020000, 0, NULL) == 0, "\n");
40     ok(GetLastError() == ERROR_SUCCESS, "\n");
41     SetLastError(ERROR_SUCCESS);
42     ok(GetObjectA((HANDLE)0x00030000, 0, NULL) == 0, "\n");
43     ok(GetLastError() == ERROR_SUCCESS, "\n");
44     SetLastError(ERROR_SUCCESS);
45     ok(GetObjectA((HANDLE)0x00040000, 0, NULL) == 0, "\n");
46     ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
47     SetLastError(ERROR_SUCCESS);
48     ok(GetObjectA((HANDLE)0x00060000, 0, NULL) == 0, "\n");
49     ok(GetLastError() == ERROR_SUCCESS, "\n");
50     SetLastError(ERROR_SUCCESS);
51     ok(GetObjectA((HANDLE)0x00070000, 0, NULL) == 0, "\n");
52     ok(GetLastError() == ERROR_SUCCESS, "\n");
53     SetLastError(ERROR_SUCCESS);
54     ok(GetObjectA((HANDLE)0x000B0000, 0, NULL) == 0, "\n");
55     ok(GetLastError() == ERROR_SUCCESS, "\n");
56     SetLastError(ERROR_SUCCESS);
57     ok(GetObjectA((HANDLE)0x000C0000, 0, NULL) == 0, "\n");
58     ok(GetLastError() == ERROR_SUCCESS, "\n");
59     SetLastError(ERROR_SUCCESS);
60     ok(GetObjectA((HANDLE)0x000D0000, 0, NULL) == 0, "\n");
61     ok(GetLastError() == ERROR_SUCCESS, "\n");
62     SetLastError(ERROR_SUCCESS);
63     ok(GetObjectA((HANDLE)0x000E0000, 0, NULL) == 0, "\n");
64     ok(GetLastError() == ERROR_SUCCESS, "\n");
65     SetLastError(ERROR_SUCCESS);
66     ok(GetObjectA((HANDLE)0x000F0000, 0, NULL) == 0, "\n");
67     ok(GetLastError() == ERROR_SUCCESS, "\n");
68     SetLastError(ERROR_SUCCESS);
69     ok(GetObjectA((HANDLE)0x00110000, 0, NULL) == 0, "\n");
70     ok(GetLastError() == ERROR_SUCCESS, "\n");
71     SetLastError(ERROR_SUCCESS);
72     ok(GetObjectA((HANDLE)0x00120000, 0, NULL) == 0, "\n");
73     ok(GetLastError() == ERROR_SUCCESS, "\n");
74     SetLastError(ERROR_SUCCESS);
75     ok(GetObjectA((HANDLE)0x00130000, 0, NULL) == 0, "\n");
76     ok(GetLastError() == ERROR_SUCCESS, "\n");
77     SetLastError(ERROR_SUCCESS);
78     ok(GetObjectA((HANDLE)0x00140000, 0, NULL) == 0, "\n");
79     ok(GetLastError() == ERROR_SUCCESS, "\n");
80     SetLastError(ERROR_SUCCESS);
81     ok(GetObjectA((HANDLE)0x00150000, 0, NULL) == 0, "\n");
82     ok(GetLastError() == ERROR_SUCCESS, "\n");
83     SetLastError(ERROR_SUCCESS);
84     ok(GetObjectA((HANDLE)0x00160000, 0, NULL) == 0, "\n");
85     ok(GetLastError() == ERROR_SUCCESS, "\n");
86     SetLastError(ERROR_SUCCESS);
87     ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_DC, 0, NULL) == 0, "\n");
88     ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
89     SetLastError(ERROR_SUCCESS);
90     ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_DC, 0, NULL) == 0, "\n");
91     ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
92     SetLastError(ERROR_SUCCESS);
93     ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_REGION, 0, NULL) == 0, "\n");
94     ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
95     SetLastError(ERROR_SUCCESS);
96     ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_REGION, 0, NULL) == 0, "\n");
97     ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
98     SetLastError(ERROR_SUCCESS);
99     ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_EMF, 0, NULL) == 0, "\n");
100     ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
101     SetLastError(ERROR_SUCCESS);
102     ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_EMF, 0, NULL) == 0, "\n");
103     ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
104     SetLastError(ERROR_SUCCESS);
105     ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_METAFILE, 0, NULL) == 0, "\n");
106     ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
107     SetLastError(ERROR_SUCCESS);
108     ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_METAFILE, 0, NULL) == 0, "\n");
109     ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
110     SetLastError(ERROR_SUCCESS);
111     ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_ENHMETAFILE, 0, NULL) == 0, "\n");
112     ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
113     SetLastError(ERROR_SUCCESS);
114     ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_ENHMETAFILE, 0, NULL) == 0, "\n");
115     ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
116 
117     /* Test need of alignment */
118     SetLastError(ERROR_SUCCESS);
119     hBrush = GetStockObject(WHITE_BRUSH);
120     plogbrush = (PVOID)((ULONG_PTR)&TestStruct.logbrush);
121     ok(GetObject(hBrush, sizeof(LOGBRUSH), plogbrush) == sizeof(LOGBRUSH), "\n");
122     plogbrush = (PVOID)((ULONG_PTR)&TestStruct.logbrush + 2);
123     ok(GetObject(hBrush, sizeof(LOGBRUSH), plogbrush) == sizeof(LOGBRUSH), "\n");
124     plogbrush = (PVOID)((ULONG_PTR)&TestStruct.logbrush + 1);
125     //ok(GetObject(hBrush, sizeof(LOGBRUSH), plogbrush) == 0, "\n"); // fails on win7
126 
127     /* Test invalid buffer */
128     SetLastError(0xbadbad00);
129     ok(GetObjectA(GetStockObject(WHITE_BRUSH), sizeof(LOGBRUSH), INVALID_POINTER) == 0, "\n");
130     ok((GetLastError() == 0xbadbad00) || (GetLastError() == ERROR_NOACCESS), "wrong error: %ld\n", GetLastError());
131     SetLastError(0xbadbad00);
132     ok(GetObjectW(GetStockObject(BLACK_PEN), sizeof(LOGPEN), INVALID_POINTER) == 0, "\n");
133     ok((GetLastError() == 0xbadbad00) || (GetLastError() == ERROR_NOACCESS), "wrong error: %ld\n", GetLastError());
134     SetLastError(0xbadbad00);
135     ok(GetObjectW(GetStockObject(21), sizeof(BITMAP), INVALID_POINTER) == 0, "\n");
136     ok((GetLastError() == 0xbadbad00) || (GetLastError() == ERROR_NOACCESS), "wrong error: %ld\n", GetLastError());
137     SetLastError(0xbadbad00);
138     ok(GetObjectW(GetStockObject(SYSTEM_FONT), sizeof(LOGFONT), INVALID_POINTER) == 0, "\n");
139     ok(GetLastError() == 0xbadbad00, "wrong error: %ld\n", GetLastError());
140     SetLastError(ERROR_SUCCESS);
141     _SEH2_TRY
142     {
143         ret = GetObjectA(GetStockObject(SYSTEM_FONT), sizeof(LOGFONT), INVALID_POINTER);
144     }
145     _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
146     {
147         ret = -1;
148     }
149     _SEH2_END
150     ok(ret == -1, "should have got an exception\n");
151 
152     ok(GetObjectW(GetStockObject(SYSTEM_FONT), 0x50000000, &TestStruct) == 356, "\n");
153     ok(GetObjectW(GetStockObject(WHITE_BRUSH), 0x50000000, &TestStruct) == sizeof(LOGBRUSH), "\n");
154 
155 
156     /* Test buffer size of 0 */
157     SetLastError(0xbadbad00);
158     hBrush = CreateSolidBrush(123);
159     ok(hBrush != NULL, "Failed to create brush\n");
160     ok_long(GetObjectA(hBrush, 0, &TestStruct), sizeof(LOGBRUSH));
161     ok_err(0xbadbad00);
162     DeleteObject(hBrush);
163     SetLastError(0xbadbad00);
164     hpen = CreatePen(PS_SOLID, 1, 123);
165     ok(hpen != NULL, "Failed to create pen\n");
166     ok_long(GetObjectA(hpen, 0, &TestStruct), 0);
167     ok((GetLastError() == 0xbadbad00) || (GetLastError() == ERROR_NOACCESS), "wrong error: %ld\n", GetLastError());
168     SetLastError(0xbadbad00);
169     TestStruct.logbrush.lbStyle = BS_SOLID;
170     TestStruct.logbrush.lbColor = RGB(1,2,3);
171     TestStruct.logbrush.lbHatch = 0;
172     hpen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID, 1, &TestStruct.logbrush, 0, NULL);
173     ok(hpen != NULL, "Failed to create pen\n");
174     ok_long(GetObjectA(hpen, 0, &TestStruct), 0);
175     ok((GetLastError() == 0xbadbad00) || (GetLastError() == ERROR_NOACCESS), "wrong error: %ld\n", GetLastError());
176     SetLastError(0xbadbad00);
177     ok(GetObjectW(GetStockObject(SYSTEM_FONT), 0, &TestStruct) == 0, "\n");
178     ok_err(0xbadbad00);
179     SetLastError(0xbadbad00);
180     ok(GetObjectW(GetStockObject(21), 0, &TestStruct) == 0, "\n");
181     ok_err(0xbadbad00);
182 
183 }
184 
185 void
186 Test_Bitmap(void)
187 {
188     HBITMAP hBitmap;
189     BITMAP bitmap;
190     DIBSECTION dibsection;
191     BYTE bData[100] = {0};
192     BYTE Buffer[100] = {48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,0};
193 
194     FillMemory(&bitmap, sizeof(BITMAP), 0x77);
195     hBitmap = CreateBitmap(10,10,1,8,bData);
196     ok(hBitmap != 0, "CreateBitmap failed, skipping tests.\n");
197     if (!hBitmap) return;
198 
199     SetLastError(ERROR_SUCCESS);
200     ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_BITMAP, 0, NULL) == sizeof(BITMAP), "\n");
201     ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_BITMAP, 0, NULL) == sizeof(BITMAP), "\n");
202     ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_BITMAP, sizeof(BITMAP), NULL) == sizeof(BITMAP), "\n");
203     ok(GetLastError() == ERROR_SUCCESS, "\n");
204     ok(GetObjectA(hBitmap, sizeof(DIBSECTION), NULL) == sizeof(BITMAP), "\n");
205     ok(GetObjectA(hBitmap, 0, NULL) == sizeof(BITMAP), "\n");
206     ok(GetObjectA((HANDLE)((UINT_PTR)hBitmap & 0x0000ffff), 0, NULL) == sizeof(BITMAP), "\n");
207     ok(GetObjectW((HANDLE)((UINT_PTR)hBitmap & 0x0000ffff), 0, NULL) == sizeof(BITMAP), "\n");
208     ok(GetLastError() == ERROR_SUCCESS, "\n");
209     ok(GetObjectA(hBitmap, 5, NULL) == sizeof(BITMAP), "\n");
210     ok(GetObjectA(hBitmap, -5, NULL) == sizeof(BITMAP), "\n");
211     ok(GetObjectA(hBitmap, 0, Buffer) == 0, "\n");
212     ok(GetObjectA(hBitmap, 5, Buffer) == 0, "\n");
213     ok(GetLastError() == ERROR_SUCCESS, "\n");
214     ok(GetObjectA(hBitmap, sizeof(BITMAP), &bitmap) == sizeof(BITMAP), "\n");
215     ok(GetObjectA(hBitmap, sizeof(BITMAP)+2, &bitmap) == sizeof(BITMAP), "\n");
216     ok(GetObjectA(hBitmap, sizeof(DIBSECTION), &dibsection) == sizeof(BITMAP), "\n");
217     ok(GetObjectA(hBitmap, -5, &bitmap) == sizeof(BITMAP), "\n");
218     ok(GetLastError() == ERROR_SUCCESS, "\n");
219     ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_BITMAP, sizeof(BITMAP), &bitmap) == 0, "\n");
220     ok(GetLastError() == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", GetLastError());
221 
222     // todo: test invalid handle + buffer
223 
224     DeleteObject(hBitmap);
225 }
226 
227 void
228 Test_Dibsection(void)
229 {
230     BITMAPINFO bmi = {{sizeof(BITMAPINFOHEADER), 10, 9, 1, 16, BI_RGB, 0, 10, 10, 0,0}};
231     HBITMAP hBitmap;
232     BITMAP bitmap;
233     DIBSECTION dibsection;
234     PVOID pData;
235     HDC hDC;
236 
237     FillMemory(&dibsection, sizeof(DIBSECTION), 0x77);
238     hDC = GetDC(0);
239     hBitmap = CreateDIBSection(hDC, &bmi, DIB_RGB_COLORS, &pData, NULL, 0);
240     ok(hBitmap != 0, "CreateDIBSection failed with %ld, skipping tests.\n", GetLastError());
241     if (!hBitmap) return;
242 
243     ok(GetObjectA((HANDLE)((UINT_PTR)hBitmap & 0x0000ffff), 0, NULL) == sizeof(BITMAP), "\n");
244     ok(GetObjectW((HANDLE)((UINT_PTR)hBitmap & 0x0000ffff), 0, NULL) == sizeof(BITMAP), "\n");
245 
246     SetLastError(ERROR_SUCCESS);
247     ok_long(GetObject(hBitmap, sizeof(DIBSECTION), NULL), sizeof(BITMAP));
248     ok_long(GetObject(hBitmap, 0, NULL), sizeof(BITMAP));
249     ok_long(GetObject(hBitmap, 5, NULL), sizeof(BITMAP));
250     ok_long(GetObject(hBitmap, -5, NULL), sizeof(BITMAP));
251     ok_long(GetObject(hBitmap, 0, &dibsection), 0);
252     ok_long(GetObject(hBitmap, 5, &dibsection), 0);
253     ok_long(GetObject(hBitmap, sizeof(BITMAP), &bitmap), sizeof(BITMAP));
254     ok_long(GetObject(hBitmap, sizeof(BITMAP)+2, &bitmap), sizeof(BITMAP));
255     ok_long(bitmap.bmType, 0);
256     ok_long(bitmap.bmWidth, 10);
257     ok_long(bitmap.bmHeight, 9);
258     ok_long(bitmap.bmWidthBytes, 20);
259     ok_long(bitmap.bmPlanes, 1);
260     ok_long(bitmap.bmBitsPixel, 16);
261     ok(bitmap.bmBits == pData, "\n");
262     ok_long(GetObject(hBitmap, sizeof(DIBSECTION), &dibsection), sizeof(DIBSECTION));
263     ok_long(GetObject(hBitmap, sizeof(DIBSECTION)+2, &dibsection), sizeof(DIBSECTION));
264     ok_long(GetObject(hBitmap, -5, &dibsection), sizeof(DIBSECTION));
265     ok_err(ERROR_SUCCESS);
266     DeleteObject(hBitmap);
267     ReleaseDC(0, hDC);
268 }
269 
270 void
271 Test_Palette(void)
272 {
273     LOGPALETTE logpal;
274     HPALETTE hPalette;
275     WORD wPalette;
276 
277     FillMemory(&wPalette, sizeof(WORD), 0x77);
278     logpal.palVersion = 0x0300;
279     logpal.palNumEntries = 1;
280     logpal.palPalEntry[0].peRed = 0;
281     logpal.palPalEntry[0].peGreen = 0;
282     logpal.palPalEntry[0].peBlue = 0;
283     logpal.palPalEntry[0].peFlags = PC_EXPLICIT;
284     hPalette = CreatePalette(&logpal);
285     ok(hPalette != 0, "CreatePalette failed, skipping tests.\n");
286     if (!hPalette) return;
287 
288     ok(GetObjectA((HANDLE)((UINT_PTR)hPalette & 0x0000ffff), 0, NULL) == sizeof(WORD), "\n");
289     ok(GetObjectW((HANDLE)((UINT_PTR)hPalette & 0x0000ffff), 0, NULL) == sizeof(WORD), "\n");
290 
291     SetLastError(ERROR_SUCCESS);
292     ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_PALETTE, 0, NULL) == sizeof(WORD), "\n");
293     ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_PALETTE, 0, NULL) == sizeof(WORD), "\n");
294     ok(GetObject(hPalette, sizeof(WORD), NULL) == sizeof(WORD), "\n");
295     ok(GetObject(hPalette, 0, NULL) == sizeof(WORD), "\n");
296     ok(GetObject(hPalette, 5, NULL) == sizeof(WORD), "\n");
297     ok(GetObject(hPalette, -5, NULL) == sizeof(WORD), "\n");
298     ok(GetObject(hPalette, sizeof(WORD), &wPalette) == sizeof(WORD), "\n");
299     ok(GetObject(hPalette, sizeof(WORD)+2, &wPalette) == sizeof(WORD), "\n");
300     ok(GetObject(hPalette, 0, &wPalette) == 0, "\n");
301     ok(GetObject(hPalette, 1, &wPalette) == 0, "\n");
302     ok(GetObject(hPalette, -1, &wPalette) == sizeof(WORD), "\n");
303     ok(GetLastError() == ERROR_SUCCESS, "\n");
304     DeleteObject(hPalette);
305     ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_PALETTE, sizeof(WORD), &wPalette) == 0, "\n");
306     ok(GetLastError() == ERROR_SUCCESS, "\n");
307 
308 }
309 
310 void
311 Test_Brush(void)
312 {
313     LOGBRUSH logbrush;
314     HBRUSH hBrush;
315 
316     FillMemory(&logbrush, sizeof(LOGBRUSH), 0x77);
317     hBrush = CreateSolidBrush(RGB(1,2,3));
318     ok(hBrush != 0, "CreateSolidBrush failed, skipping tests.\n");
319     if (!hBrush) return;
320 
321     SetLastError(ERROR_SUCCESS);
322     ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_BRUSH, 0, NULL) == sizeof(LOGBRUSH), "\n");
323     ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_BRUSH, 0, NULL) == sizeof(LOGBRUSH), "\n");
324     ok(GetObject(hBrush, sizeof(WORD), NULL) == sizeof(LOGBRUSH), "\n");
325     ok(GetObject(hBrush, 0, NULL) == sizeof(LOGBRUSH), "\n");
326     ok(GetObject(hBrush, 5, NULL) == sizeof(LOGBRUSH), "\n");
327     ok(GetObject(hBrush, -5, NULL) == sizeof(LOGBRUSH), "\n");
328 
329     //ok(GetObject(hBrush, 0, &logbrush) == 0, "\n"); fails on win7
330     ok(logbrush.lbStyle == 0x77777777, "\n");
331     ok(GetObject(hBrush, 5, &logbrush) == sizeof(LOGBRUSH), "\n");
332     ok(logbrush.lbStyle == 0, "\n");
333     ok(logbrush.lbColor == 0x77777701, "\n");
334 
335     ok(GetObject(hBrush, sizeof(LOGBRUSH), &logbrush) == sizeof(LOGBRUSH), "\n");
336     ok(GetObject(hBrush, sizeof(LOGBRUSH) - 1, &logbrush) == sizeof(LOGBRUSH), "\n");
337     ok(GetObject(hBrush, 1, &logbrush) == sizeof(LOGBRUSH), "\n");
338     ok(GetObject(hBrush, sizeof(LOGBRUSH)+2, &logbrush) == sizeof(LOGBRUSH), "\n");
339     ok(GetObject(hBrush, -1, &logbrush) == sizeof(LOGBRUSH), "\n");
340     // TODO: test all members
341 
342     ok(GetLastError() == ERROR_SUCCESS, "\n");
343     DeleteObject(hBrush);
344 
345     ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_BRUSH, sizeof(LOGBRUSH), &logbrush) == 0, "\n");
346     ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
347 }
348 
349 void
350 Test_DIBBrush(void)
351 {
352     struct
353     {
354         BITMAPINFOHEADER bmiHeader;
355         WORD wColors[4];
356         BYTE jBuffer[16];
357     } PackedDIB =
358     {
359         {sizeof(BITMAPINFOHEADER), 4, 4, 1, 8, BI_RGB, 0, 1, 1, 4, 0},
360         {1, 7, 3, 1},
361         {0,1,2,3,  1,2,3,0,  2,3,0,1,  3,0,1,2},
362     };
363     LOGBRUSH logbrush;
364     HBRUSH hBrush;
365 
366     /* Create a DIB brush */
367     hBrush = CreateDIBPatternBrushPt(&PackedDIB, DIB_PAL_COLORS);
368     ok(hBrush != 0, "CreateSolidBrush failed, skipping tests.\n");
369     if (!hBrush) return;
370 
371     FillMemory(&logbrush, sizeof(LOGBRUSH), 0x77);
372     SetLastError(ERROR_SUCCESS);
373 
374     ok_long(GetObject(hBrush, sizeof(LOGBRUSH), &logbrush), sizeof(LOGBRUSH));
375     ok_long(logbrush.lbStyle, BS_DIBPATTERN);
376     ok_long(logbrush.lbColor, 0);
377     ok_long(logbrush.lbHatch, (ULONG_PTR)&PackedDIB);
378 
379     ok_err(ERROR_SUCCESS);
380     DeleteObject(hBrush);
381 
382 
383     /* Create a DIB brush with undocumented iUsage 2 */
384     hBrush = CreateDIBPatternBrushPt(&PackedDIB, 2);
385     ok(hBrush != 0, "CreateSolidBrush failed, skipping tests.\n");
386     if (!hBrush) return;
387 
388     FillMemory(&logbrush, sizeof(LOGBRUSH), 0x77);
389     SetLastError(ERROR_SUCCESS);
390 
391     ok_long(GetObject(hBrush, sizeof(LOGBRUSH), &logbrush), sizeof(LOGBRUSH));
392     ok_long(logbrush.lbStyle, BS_DIBPATTERN);
393     ok_long(logbrush.lbColor, 0);
394     ok_long(logbrush.lbHatch, (ULONG_PTR)&PackedDIB);
395 
396     ok_err(ERROR_SUCCESS);
397     DeleteObject(hBrush);
398 
399 }
400 
401 void
402 Test_Pen(void)
403 {
404     LOGPEN logpen;
405     HPEN hPen;
406 
407     FillMemory(&logpen, sizeof(LOGPEN), 0x77);
408     hPen = CreatePen(PS_SOLID, 3, RGB(4,5,6));
409     ok(hPen != 0, "CreatePen failed, skipping tests.\n");
410     if (!hPen) return;
411     SetLastError(ERROR_SUCCESS);
412     ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_PEN, 0, NULL) == sizeof(LOGPEN), "\n");
413     ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_PEN, 0, NULL) == sizeof(LOGPEN), "\n");
414     ok(GetObject(hPen, sizeof(BITMAP), NULL) == sizeof(LOGPEN), "\n");
415     ok(GetObject(hPen, 0, NULL) == sizeof(LOGPEN), "\n");
416     ok(GetObject(hPen, 5, NULL) == sizeof(LOGPEN), "\n");
417     ok(GetObject(hPen, -5, NULL) == sizeof(LOGPEN), "\n");
418     ok(GetObject(hPen, sizeof(LOGPEN), &logpen) == sizeof(LOGPEN), "\n");
419     ok(GetObject(hPen, sizeof(LOGPEN)-1, &logpen) == 0, "\n");
420     ok(GetObject(hPen, sizeof(LOGPEN)+2, &logpen) == sizeof(LOGPEN), "\n");
421     ok(GetObject(hPen, 0, &logpen) == 0, "\n");
422     ok(GetObject(hPen, -5, &logpen) == sizeof(LOGPEN), "\n");
423     //ok(GetLastError() == ERROR_SUCCESS, "\n"); fails on win7
424 
425     /* test if the fields are filled correctly */
426     ok(logpen.lopnStyle == PS_SOLID, "\n");
427 
428     ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_PEN, sizeof(LOGPEN), &logpen) == 0, "\n");
429     ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
430 
431     DeleteObject(hPen);
432 }
433 
434 void
435 Test_ExtPen(void)
436 {
437     HPEN hPen;
438     EXTLOGPEN extlogpen;
439     LOGBRUSH logbrush;
440     DWORD dwStyles[17] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
441     struct
442     {
443         EXTLOGPEN extlogpen;
444         DWORD dwStyles[50];
445     } elpUserStyle;
446     int i;
447 
448     SetLastError(ERROR_SUCCESS);
449     ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 0, NULL) == 0, "\n");
450     ok(GetLastError() == ERROR_INVALID_PARAMETER, "\n");
451     SetLastError(ERROR_SUCCESS);
452     ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 0, NULL) == 0, "\n");
453     ok(GetLastError() == ERROR_INVALID_PARAMETER, "\n");
454 
455     FillMemory(&extlogpen, sizeof(EXTLOGPEN), 0x77);
456     logbrush.lbStyle = BS_SOLID;
457     logbrush.lbColor = RGB(1,2,3);
458     logbrush.lbHatch = 22;
459     hPen = ExtCreatePen(PS_GEOMETRIC | PS_DASH, 5, &logbrush, 0, NULL);
460 
461     SetLastError(ERROR_SUCCESS);
462     ok(GDI_HANDLE_GET_TYPE(hPen) == GDI_OBJECT_TYPE_EXTPEN, "\n");
463     ok(GetObject(hPen, sizeof(EXTLOGPEN), NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
464     ok(GetObject(hPen, 0, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
465     ok(GetObject((HANDLE)GDI_HANDLE_GET_INDEX(hPen), 0, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
466     ok(GetObject(hPen, 5, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
467     ok(GetObject(hPen, -5, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
468     ok(GetLastError() == ERROR_SUCCESS, "\n");
469     ok(GetObject((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 0, NULL) == 0, "\n");
470     ok(GetLastError() ==  ERROR_INVALID_PARAMETER, "got %ld\n", GetLastError());
471     SetLastError(0xbadbad00);
472     ok(GetObject(hPen, 0, &extlogpen) == 0, "\n");
473     ok((GetLastError() == 0xbadbad00) || (GetLastError() == ERROR_NOACCESS), "wrong error: %ld\n", GetLastError());
474     SetLastError(ERROR_SUCCESS);
475     ok(GetObject(hPen, 4, &extlogpen) == 0, "\n");
476     ok(GetLastError() == ERROR_SUCCESS, "got %ld\n", GetLastError());
477     SetLastError(ERROR_SUCCESS);
478     ok(GetObject((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 0, &extlogpen) == 0, "\n");
479     ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %ld\n", GetLastError());
480     SetLastError(ERROR_SUCCESS);
481     ok(GetObject((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 4, &extlogpen) == 0, "\n");
482     ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %ld\n", GetLastError());
483     SetLastError(ERROR_SUCCESS);
484     ok(GetObject(hPen,  sizeof(EXTLOGPEN) - 5, &extlogpen) == 0, "\n");
485     ok(GetLastError() == ERROR_SUCCESS, "got %ld\n", GetLastError());
486 
487     /* Nothing should be filled */
488     ok(extlogpen.elpPenStyle == 0x77777777, "\n");
489     ok(extlogpen.elpWidth == 0x77777777, "\n");
490 
491     ok(GetObject(hPen, sizeof(EXTLOGPEN), &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
492     ok(GetObject(hPen, sizeof(EXTLOGPEN)-sizeof(DWORD), &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
493     ok(GetObject(hPen, sizeof(EXTLOGPEN)-sizeof(DWORD)-1, &extlogpen) == 0, "\n");
494     ok(GetObject(hPen, sizeof(EXTLOGPEN)+2, &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
495     ok(GetObject(hPen, -5, &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
496 
497     /* test if the fields are filled correctly */
498     ok(extlogpen.elpPenStyle == (PS_GEOMETRIC | PS_DASH), "\n");
499     ok(extlogpen.elpWidth == 5, "\n");
500     ok(extlogpen.elpBrushStyle == 0, "\n");
501     ok(extlogpen.elpColor == RGB(1,2,3), "\n");
502     ok(extlogpen.elpHatch == 22, "\n");
503     ok(extlogpen.elpNumEntries == 0, "\n");
504     DeleteObject(hPen);
505 
506     /* A maximum of 16 Styles is allowed */
507     hPen = ExtCreatePen(PS_GEOMETRIC | PS_USERSTYLE, 5, &logbrush, 16, (CONST DWORD*)&dwStyles);
508     ok(GetObject(hPen, 0, NULL) == sizeof(EXTLOGPEN) + 15*sizeof(DWORD), "\n");
509     ok(GetObject(hPen, sizeof(EXTLOGPEN) + 15*sizeof(DWORD), &elpUserStyle) == sizeof(EXTLOGPEN) + 15*sizeof(DWORD), "\n");
510     for (i = 0; i <= 15; i++)
511         ok(((EXTLOGPEN*)&elpUserStyle)->elpStyleEntry[i] == i, "%d\n", i);
512     DeleteObject(hPen);
513 }
514 
515 void
516 Test_Font(void)
517 {
518     HFONT hFont;
519     union
520     {
521         LOGFONTA logfonta;
522         LOGFONTW logfontw;
523         EXTLOGFONTA extlogfonta;
524         EXTLOGFONTW extlogfontw;
525         ENUMLOGFONTEXA enumlogfontexa;
526         ENUMLOGFONTEXW enumlogfontexw;
527         ENUMLOGFONTEXDVA enumlogfontexdva;
528         ENUMLOGFONTEXDVW enumlogfontexdvw;
529         ENUMLOGFONTA enumlogfonta;
530         ENUMLOGFONTW enumlogfontw;
531         BYTE bData[270];
532     } u;
533     int ret;
534 
535     FillMemory(&u, sizeof(u), 0x77);
536     hFont = CreateFontA(8, 8, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
537         ANSI_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS,
538         ANTIALIASED_QUALITY, DEFAULT_PITCH, "testfont");
539     ok(hFont != 0, "\n");
540 
541     SetLastError(ERROR_SUCCESS);
542     ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, 0, NULL) == sizeof(LOGFONTA), "\n");
543     ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, 0, NULL) == sizeof(LOGFONTW), "\n");
544     ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(LOGFONTA), NULL) == sizeof(LOGFONTA), "\n"); // 60
545     ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTA), NULL) == sizeof(LOGFONTA), "\n"); // 156
546     ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXA), NULL) == sizeof(LOGFONTA), "\n"); // 188
547     ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(EXTLOGFONTA), NULL) == sizeof(LOGFONTA), "\n"); // 192
548     ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXDVA), NULL) == sizeof(LOGFONTA), "\n"); // 260
549     ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXDVA)+1, NULL) == sizeof(LOGFONTA), "\n"); // 260
550     ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(LOGFONTW), NULL) == sizeof(LOGFONTW), "\n"); // 92
551     ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTW), NULL) == sizeof(LOGFONTW), "\n"); // 284
552     ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(EXTLOGFONTW), NULL) == sizeof(LOGFONTW), "\n"); // 320
553     ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXW), NULL) == sizeof(LOGFONTW), "\n"); // 348
554     ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXDVW), NULL) == sizeof(LOGFONTW), "\n"); // 420
555     ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXDVW)+1, NULL) == sizeof(LOGFONTW), "\n"); // 356!
556     ok(GetLastError() == ERROR_SUCCESS, "got %ld\n", GetLastError());
557 
558     ok(GetObjectA(hFont, sizeof(LOGFONTA), NULL) == sizeof(LOGFONTA), "\n");
559     ok(GetObjectA(hFont, 0, NULL) == sizeof(LOGFONTA), "\n");
560     ok(GetObjectA(hFont, 5, NULL) == sizeof(LOGFONTA), "\n");
561     ok(GetObjectA(hFont, -5, NULL) == sizeof(LOGFONTA), "\n");
562     ok(GetObjectA(hFont, 0, &u.logfonta) == 0, "\n");
563     ok(u.logfonta.lfHeight == 0x77777777, "\n");
564 
565     ok(GetObjectA(hFont, 5, &u.logfonta) == 5, "\n");
566     ok(u.logfonta.lfHeight == 8, "\n");
567     ok(u.logfonta.lfWidth == 0x77777708, "\n");
568 
569     ok(GetObjectA(hFont, 0, &u.logfonta) == 0, "\n");
570     ok(GetObjectA(hFont, -1, &u.logfonta) == sizeof(ENUMLOGFONTEXDVA), "\n");
571     ok(GetObjectA(hFont, 1, &u.logfonta) == 1, "\n"); // 1 -> 1
572     ok(GetObjectA(hFont, sizeof(LOGFONTA) - 1, &u.logfonta) == sizeof(LOGFONTA) - 1, "\n"); // 59 -> 59
573     ok(GetObjectA(hFont, sizeof(LOGFONTA), &u.logfonta) == sizeof(LOGFONTA), "\n"); // 60 -> 60
574     ok(GetObjectA(hFont, sizeof(LOGFONTA) + 1, &u.logfonta) == sizeof(LOGFONTA) + 1, "\n"); // 61 -> 61
575     ok(GetObjectA(hFont, sizeof(LOGFONTW) - 1, &u.logfontw) == sizeof(LOGFONTW) - 1, "\n"); // 91 -> 91
576     ok(GetObjectA(hFont, sizeof(LOGFONTW), &u.logfontw) == sizeof(LOGFONTA), "\n"); // 92 -> 60
577     ok(GetObjectA(hFont, sizeof(LOGFONTW) + 1, &u.logfontw) == sizeof(LOGFONTW) + 1, "\n"); // 93 -> 93
578     ok(GetObjectA(hFont, sizeof(EXTLOGFONTA), &u.extlogfonta) == sizeof(EXTLOGFONTA), "\n"); // 192 -> 192
579     ok(GetObjectA(hFont, sizeof(EXTLOGFONTA)+1, &u.extlogfonta) == sizeof(EXTLOGFONTA)+1, "\n"); // 192+1 -> 192+1
580     ok(GetObjectA(hFont, sizeof(EXTLOGFONTA)+16*4, &u.extlogfonta) == sizeof(EXTLOGFONTA)+16*4, "\n"); // 192+1 -> 192+1
581     ok(GetObjectA(hFont, sizeof(EXTLOGFONTW), &u.extlogfontw) == sizeof(ENUMLOGFONTEXDVA), "\n"); // 320 -> 260
582     ok(GetObjectA(hFont, 261, &u.bData) == 260, "\n"); // no
583 
584     ok(GetObjectA(hFont, sizeof(ENUMLOGFONTEXDVA) - 1, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXDVA) - 1, "\n"); // 419
585     ok(GetObjectA(hFont, sizeof(ENUMLOGFONTEXDVA), &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXDVA), "\n"); // 420
586     ok(GetObjectA(hFont, sizeof(ENUMLOGFONTEXDVA)+1, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXDVA), "\n"); // 356!
587 
588     /* LOGFONT / GetObjectW */
589     FillMemory(&u.logfontw, sizeof(LOGFONTW), 0x77);
590 
591     ok(GetObjectW(hFont, sizeof(LOGFONTW), NULL) == sizeof(LOGFONTW), "1\n");
592     ok(GetObjectW(hFont, 0, NULL) == sizeof(LOGFONTW), "\n");
593     ok(GetObjectW(hFont, 5, NULL) == sizeof(LOGFONTW), "\n");
594     ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXA), NULL) == sizeof(LOGFONTW), "\n");
595     ok(GetObjectW(hFont, -5, NULL) == sizeof(LOGFONTW), "\n");
596     ok(GetObjectW(hFont, 0, &u.logfontw) == 0, "\n");
597     ok(u.logfontw.lfHeight == 0x77777777, "\n");
598 
599     ok(GetObjectW(hFont, 5, &u.logfontw) == 5, "\n");
600     ok(u.logfontw.lfHeight == 8, "\n");
601     ok(u.logfontw.lfWidth == 0x77777708, "\n");
602 
603     ok(GetObjectA(hFont, sizeof(LOGFONTA), &u.logfonta) == sizeof(LOGFONTA), "\n"); // 60
604     ok(u.logfonta.lfHeight == 8, "\n");
605     ok(GetObjectA(hFont, sizeof(ENUMLOGFONTA), &u.enumlogfonta) == sizeof(ENUMLOGFONTA), "\n"); // 156
606     ok(GetObjectA(hFont, sizeof(ENUMLOGFONTEXA), &u.enumlogfontexa) == sizeof(ENUMLOGFONTEXA), "\n"); // 188
607     ok(GetObjectA(hFont, sizeof(EXTLOGFONTA), &u.extlogfonta) == sizeof(EXTLOGFONTA), "\n"); // 192
608     ok(GetObjectA(hFont, sizeof(ENUMLOGFONTEXDVA), &u.enumlogfontexdva) == sizeof(ENUMLOGFONTEXDVA), "\n"); // 260
609     ok(GetObjectA(hFont, sizeof(ENUMLOGFONTEXDVA)+1, &u.enumlogfontexdva) == sizeof(ENUMLOGFONTEXDVA), "\n"); // 260
610 
611     ok(GetObjectW(hFont, sizeof(LOGFONTW), &u.logfontw) == sizeof(LOGFONTW), "\n"); // 92
612     ok(GetObjectW(hFont, sizeof(LOGFONTW) + 1, &u.logfontw) == sizeof(LOGFONTW) + 1, "\n"); // 92
613     ok(GetObjectW(hFont, sizeof(LOGFONTW) - 1, &u.logfontw) == sizeof(LOGFONTW) - 1, "\n"); // 92
614     ok(GetObjectW(hFont, sizeof(ENUMLOGFONTW), &u.enumlogfontw) == sizeof(ENUMLOGFONTW), "\n"); // 284
615     ok(GetObjectW(hFont, sizeof(EXTLOGFONTW), &u.extlogfontw) == sizeof(EXTLOGFONTW), "\n"); // 320
616     ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXW), &u.enumlogfontexw) == sizeof(ENUMLOGFONTEXW), "\n"); // 348
617     ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXW) + 1, &u.enumlogfontexw) == sizeof(ENUMLOGFONTEXW) + 1, "\n"); // 348
618     ok(GetObjectW(hFont, 355, &u.enumlogfontexdvw) == 355, "\n"); // 419
619 
620     ok(GetObjectW(hFont, 356, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); // 419
621     ret = sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD);
622     ret = GetObjectW(hFont, 357, &u.enumlogfontexdvw);
623     ok(ret == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n");
624     ok(GetObjectW(hFont, 357, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); // 419
625     ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXDVW) - 1, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); // 419
626     ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXDVW), &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); // 420
627     ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXDVW)+1, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); // 356!
628     ok(GetLastError() == ERROR_SUCCESS, "got %ld\n", GetLastError());
629 
630     DeleteObject(hFont);
631 }
632 
633 void
634 Test_Colorspace(void)
635 {
636     UCHAR buffer[1000];
637 
638     SetLastError(ERROR_SUCCESS);
639     GetObjectA((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 0, NULL);
640     //ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 0, NULL) == 60, "\n");// FIXME: what structure? fails on win7
641     ok_err(ERROR_INSUFFICIENT_BUFFER);
642     SetLastError(ERROR_SUCCESS);
643     ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 0, NULL) == 0, "\n");
644     ok_err(ERROR_INSUFFICIENT_BUFFER);
645     SetLastError(ERROR_SUCCESS);
646     ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 327, buffer) == 0, "\n");
647     ok_err(ERROR_INSUFFICIENT_BUFFER);
648     ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 328, buffer) == 0, "\n");
649     ok_err(ERROR_INVALID_PARAMETER);
650 
651     //ok_long(GetObjectA((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 328, NULL), 0); // FIXME: fails on WHS
652     //ok_err(ERROR_INSUFFICIENT_BUFFER);
653 }
654 
655 void
656 Test_MetaDC(void)
657 {
658     /* Windows does not SetLastError() on a metadc, but it doesn't seem to do anything with it */
659     HDC hMetaDC;
660     BYTE buffer[1000];
661 
662     hMetaDC = CreateMetaFile(NULL);
663     ok(hMetaDC != 0, "CreateMetaFile failed, skipping tests.\n");
664     if(!hMetaDC) return;
665 
666     ok(((UINT_PTR)hMetaDC & GDI_HANDLE_TYPE_MASK) == GDI_OBJECT_TYPE_METADC, "\n");
667 
668     SetLastError(ERROR_SUCCESS);
669     ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_METADC, 0, NULL) == 0, "\n");
670     ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_METADC, 100, &buffer) == 0, "\n");
671     ok(GetObjectA(hMetaDC, 0, NULL) == 0, "\n");
672     ok(GetObjectA(hMetaDC, 1000, &buffer) == 0, "\n");
673     ok(GetLastError() == ERROR_SUCCESS, "got %ld\n", GetLastError());
674 }
675 
676 void
677 Test_Region(void)
678 {
679     HRGN hRgn;
680     hRgn = CreateRectRgn(0,0,5,5);
681     SetLastError(ERROR_SUCCESS);
682     ok(GetObjectW(hRgn, 0, NULL) == 0, "\n");
683     ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
684     DeleteObject(hRgn);
685 }
686 
687 START_TEST(GetObject)
688 {
689 
690     Test_Font();
691     Test_Colorspace();
692     Test_General();
693     Test_Bitmap();
694     Test_Dibsection();
695     Test_Palette();
696     Test_Brush();
697     Test_DIBBrush();
698     Test_Pen();
699     Test_ExtPen(); // not implemented yet in ROS
700     Test_MetaDC();
701     Test_Region();
702 }
703 
704