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