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), 0); 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 /* Test handle fixup */ 349 hBrush = (HBRUSH)((ULONG_PTR)GetStockObject(WHITE_BRUSH) & 0xFFFF); 350 ok(GetObjectW(hBrush, sizeof(LOGBRUSH), &logbrush) == sizeof(LOGBRUSH), 351 "GetObject(0x%p, ...) failed.\n", hBrush); 352 353 #ifdef _WIN64 354 /* Test upper 32 bits */ 355 hBrush = (HBRUSH)((ULONG64)GetStockObject(WHITE_BRUSH) | 0xFFFFFFFF00000000ULL); 356 ok(GetObjectW(hBrush, sizeof(LOGBRUSH), &logbrush) == sizeof(LOGBRUSH), 357 "GetObject(0x%p, ...) failed.\n", hBrush); 358 hBrush = (HBRUSH)((ULONG64)GetStockObject(WHITE_BRUSH) | 0x537F9F2F00000000ULL); 359 ok(GetObjectW(hBrush, sizeof(LOGBRUSH), &logbrush) == sizeof(LOGBRUSH), 360 "GetObject(0x%p, ...) failed.\n", hBrush); 361 #endif 362 } 363 364 void 365 Test_DIBBrush(void) 366 { 367 struct 368 { 369 BITMAPINFOHEADER bmiHeader; 370 WORD wColors[4]; 371 BYTE jBuffer[16]; 372 } PackedDIB = 373 { 374 {sizeof(BITMAPINFOHEADER), 4, 4, 1, 8, BI_RGB, 0, 1, 1, 4, 0}, 375 {1, 7, 3, 1}, 376 {0,1,2,3, 1,2,3,0, 2,3,0,1, 3,0,1,2}, 377 }; 378 LOGBRUSH logbrush; 379 HBRUSH hBrush; 380 381 /* Create a DIB brush */ 382 hBrush = CreateDIBPatternBrushPt(&PackedDIB, DIB_PAL_COLORS); 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 /* Create a DIB brush with undocumented iUsage 2 */ 399 hBrush = CreateDIBPatternBrushPt(&PackedDIB, 2); 400 ok(hBrush != 0, "CreateSolidBrush failed, skipping tests.\n"); 401 if (!hBrush) return; 402 403 FillMemory(&logbrush, sizeof(LOGBRUSH), 0x77); 404 SetLastError(ERROR_SUCCESS); 405 406 ok_long(GetObject(hBrush, sizeof(LOGBRUSH), &logbrush), sizeof(LOGBRUSH)); 407 ok_long(logbrush.lbStyle, BS_DIBPATTERN); 408 ok_long(logbrush.lbColor, 0); 409 ok_long(logbrush.lbHatch, (ULONG_PTR)&PackedDIB); 410 411 ok_err(ERROR_SUCCESS); 412 DeleteObject(hBrush); 413 414 } 415 416 void 417 Test_Pen(void) 418 { 419 LOGPEN logpen; 420 HPEN hPen; 421 422 FillMemory(&logpen, sizeof(LOGPEN), 0x77); 423 hPen = CreatePen(PS_SOLID, 3, RGB(4,5,6)); 424 ok(hPen != 0, "CreatePen failed, skipping tests.\n"); 425 if (!hPen) return; 426 SetLastError(ERROR_SUCCESS); 427 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_PEN, 0, NULL) == sizeof(LOGPEN), "\n"); 428 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_PEN, 0, NULL) == sizeof(LOGPEN), "\n"); 429 ok(GetObject(hPen, sizeof(BITMAP), NULL) == sizeof(LOGPEN), "\n"); 430 ok(GetObject(hPen, 0, NULL) == sizeof(LOGPEN), "\n"); 431 ok(GetObject(hPen, 5, NULL) == sizeof(LOGPEN), "\n"); 432 ok(GetObject(hPen, -5, NULL) == sizeof(LOGPEN), "\n"); 433 ok(GetObject(hPen, sizeof(LOGPEN), &logpen) == sizeof(LOGPEN), "\n"); 434 ok(GetObject(hPen, sizeof(LOGPEN)-1, &logpen) == 0, "\n"); 435 ok(GetObject(hPen, sizeof(LOGPEN)+2, &logpen) == sizeof(LOGPEN), "\n"); 436 ok(GetObject(hPen, 0, &logpen) == 0, "\n"); 437 ok(GetObject(hPen, -5, &logpen) == sizeof(LOGPEN), "\n"); 438 //ok(GetLastError() == ERROR_SUCCESS, "\n"); fails on win7 439 440 /* test if the fields are filled correctly */ 441 ok(logpen.lopnStyle == PS_SOLID, "\n"); 442 443 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_PEN, sizeof(LOGPEN), &logpen) == 0, "\n"); 444 ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError()); 445 446 DeleteObject(hPen); 447 } 448 449 void 450 Test_ExtPen(void) 451 { 452 HPEN hPen; 453 EXTLOGPEN extlogpen; 454 LOGBRUSH logbrush; 455 DWORD dwStyles[17] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}; 456 struct 457 { 458 EXTLOGPEN extlogpen; 459 DWORD dwStyles[50]; 460 } elpUserStyle; 461 int i; 462 463 SetLastError(ERROR_SUCCESS); 464 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 0, NULL) == 0, "\n"); 465 ok(GetLastError() == ERROR_INVALID_PARAMETER, "\n"); 466 SetLastError(ERROR_SUCCESS); 467 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 0, NULL) == 0, "\n"); 468 ok(GetLastError() == ERROR_INVALID_PARAMETER, "\n"); 469 470 FillMemory(&extlogpen, sizeof(EXTLOGPEN), 0x77); 471 logbrush.lbStyle = BS_SOLID; 472 logbrush.lbColor = RGB(1,2,3); 473 logbrush.lbHatch = 22; 474 hPen = ExtCreatePen(PS_GEOMETRIC | PS_DASH, 5, &logbrush, 0, NULL); 475 476 SetLastError(ERROR_SUCCESS); 477 ok(GDI_HANDLE_GET_TYPE(hPen) == GDI_OBJECT_TYPE_EXTPEN, "\n"); 478 ok(GetObject(hPen, sizeof(EXTLOGPEN), NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n"); 479 ok(GetObject(hPen, 0, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n"); 480 ok(GetObject((HANDLE)GDI_HANDLE_GET_INDEX(hPen), 0, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n"); 481 ok(GetObject(hPen, 5, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n"); 482 ok(GetObject(hPen, -5, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n"); 483 ok(GetLastError() == ERROR_SUCCESS, "\n"); 484 ok(GetObject((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 0, NULL) == 0, "\n"); 485 ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %ld\n", GetLastError()); 486 SetLastError(0xbadbad00); 487 ok(GetObject(hPen, 0, &extlogpen) == 0, "\n"); 488 ok((GetLastError() == 0xbadbad00) || (GetLastError() == ERROR_NOACCESS), "wrong error: %ld\n", GetLastError()); 489 SetLastError(ERROR_SUCCESS); 490 ok(GetObject(hPen, 4, &extlogpen) == 0, "\n"); 491 ok(GetLastError() == ERROR_SUCCESS, "got %ld\n", GetLastError()); 492 SetLastError(ERROR_SUCCESS); 493 ok(GetObject((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 0, &extlogpen) == 0, "\n"); 494 ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %ld\n", GetLastError()); 495 SetLastError(ERROR_SUCCESS); 496 ok(GetObject((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 4, &extlogpen) == 0, "\n"); 497 ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %ld\n", GetLastError()); 498 SetLastError(ERROR_SUCCESS); 499 ok(GetObject(hPen, sizeof(EXTLOGPEN) - 5, &extlogpen) == 0, "\n"); 500 ok(GetLastError() == ERROR_SUCCESS, "got %ld\n", GetLastError()); 501 502 /* Nothing should be filled */ 503 ok(extlogpen.elpPenStyle == 0x77777777, "\n"); 504 ok(extlogpen.elpWidth == 0x77777777, "\n"); 505 506 ok(GetObject(hPen, sizeof(EXTLOGPEN), &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n"); 507 ok(GetObject(hPen, sizeof(EXTLOGPEN)-sizeof(DWORD), &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n"); 508 ok(GetObject(hPen, sizeof(EXTLOGPEN)-sizeof(DWORD)-1, &extlogpen) == 0, "\n"); 509 ok(GetObject(hPen, sizeof(EXTLOGPEN)+2, &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n"); 510 ok(GetObject(hPen, -5, &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n"); 511 512 /* test if the fields are filled correctly */ 513 ok(extlogpen.elpPenStyle == (PS_GEOMETRIC | PS_DASH), "\n"); 514 ok(extlogpen.elpWidth == 5, "\n"); 515 ok(extlogpen.elpBrushStyle == 0, "\n"); 516 ok(extlogpen.elpColor == RGB(1,2,3), "\n"); 517 ok(extlogpen.elpHatch == 22, "\n"); 518 ok(extlogpen.elpNumEntries == 0, "\n"); 519 DeleteObject(hPen); 520 521 /* A maximum of 16 Styles is allowed */ 522 hPen = ExtCreatePen(PS_GEOMETRIC | PS_USERSTYLE, 5, &logbrush, 16, (CONST DWORD*)&dwStyles); 523 ok(GetObject(hPen, 0, NULL) == sizeof(EXTLOGPEN) + 15*sizeof(DWORD), "\n"); 524 ok(GetObject(hPen, sizeof(EXTLOGPEN) + 15*sizeof(DWORD), &elpUserStyle) == sizeof(EXTLOGPEN) + 15*sizeof(DWORD), "\n"); 525 for (i = 0; i <= 15; i++) 526 ok(((EXTLOGPEN*)&elpUserStyle)->elpStyleEntry[i] == i, "%d\n", i); 527 DeleteObject(hPen); 528 } 529 530 void 531 Test_Font(void) 532 { 533 HFONT hFont; 534 union 535 { 536 LOGFONTA logfonta; 537 LOGFONTW logfontw; 538 EXTLOGFONTA extlogfonta; 539 EXTLOGFONTW extlogfontw; 540 ENUMLOGFONTEXA enumlogfontexa; 541 ENUMLOGFONTEXW enumlogfontexw; 542 ENUMLOGFONTEXDVA enumlogfontexdva; 543 ENUMLOGFONTEXDVW enumlogfontexdvw; 544 ENUMLOGFONTA enumlogfonta; 545 ENUMLOGFONTW enumlogfontw; 546 BYTE bData[270]; 547 } u; 548 int ret; 549 550 FillMemory(&u, sizeof(u), 0x77); 551 hFont = CreateFontA(8, 8, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, 552 ANSI_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, 553 ANTIALIASED_QUALITY, DEFAULT_PITCH, "testfont"); 554 ok(hFont != 0, "\n"); 555 556 SetLastError(ERROR_SUCCESS); 557 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, 0, NULL) == sizeof(LOGFONTA), "\n"); 558 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, 0, NULL) == sizeof(LOGFONTW), "\n"); 559 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(LOGFONTA), NULL) == sizeof(LOGFONTA), "\n"); // 60 560 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTA), NULL) == sizeof(LOGFONTA), "\n"); // 156 561 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXA), NULL) == sizeof(LOGFONTA), "\n"); // 188 562 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(EXTLOGFONTA), NULL) == sizeof(LOGFONTA), "\n"); // 192 563 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXDVA), NULL) == sizeof(LOGFONTA), "\n"); // 260 564 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXDVA)+1, NULL) == sizeof(LOGFONTA), "\n"); // 260 565 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(LOGFONTW), NULL) == sizeof(LOGFONTW), "\n"); // 92 566 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTW), NULL) == sizeof(LOGFONTW), "\n"); // 284 567 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(EXTLOGFONTW), NULL) == sizeof(LOGFONTW), "\n"); // 320 568 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXW), NULL) == sizeof(LOGFONTW), "\n"); // 348 569 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXDVW), NULL) == sizeof(LOGFONTW), "\n"); // 420 570 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXDVW)+1, NULL) == sizeof(LOGFONTW), "\n"); // 356! 571 ok(GetLastError() == ERROR_SUCCESS, "got %ld\n", GetLastError()); 572 573 ok(GetObjectA(hFont, sizeof(LOGFONTA), NULL) == sizeof(LOGFONTA), "\n"); 574 ok(GetObjectA(hFont, 0, NULL) == sizeof(LOGFONTA), "\n"); 575 ok(GetObjectA(hFont, 5, NULL) == sizeof(LOGFONTA), "\n"); 576 ok(GetObjectA(hFont, -5, NULL) == sizeof(LOGFONTA), "\n"); 577 ok(GetObjectA(hFont, 0, &u.logfonta) == 0, "\n"); 578 ok(u.logfonta.lfHeight == 0x77777777, "\n"); 579 580 ok(GetObjectA(hFont, 5, &u.logfonta) == 5, "\n"); 581 ok(u.logfonta.lfHeight == 8, "\n"); 582 ok(u.logfonta.lfWidth == 0x77777708, "\n"); 583 584 ok(GetObjectA(hFont, 0, &u.logfonta) == 0, "\n"); 585 ok(GetObjectA(hFont, -1, &u.logfonta) == sizeof(ENUMLOGFONTEXDVA), "\n"); 586 ok(GetObjectA(hFont, 1, &u.logfonta) == 1, "\n"); // 1 -> 1 587 ok(GetObjectA(hFont, sizeof(LOGFONTA) - 1, &u.logfonta) == sizeof(LOGFONTA) - 1, "\n"); // 59 -> 59 588 ok(GetObjectA(hFont, sizeof(LOGFONTA), &u.logfonta) == sizeof(LOGFONTA), "\n"); // 60 -> 60 589 ok(GetObjectA(hFont, sizeof(LOGFONTA) + 1, &u.logfonta) == sizeof(LOGFONTA) + 1, "\n"); // 61 -> 61 590 ok(GetObjectA(hFont, sizeof(LOGFONTW) - 1, &u.logfontw) == sizeof(LOGFONTW) - 1, "\n"); // 91 -> 91 591 ok(GetObjectA(hFont, sizeof(LOGFONTW), &u.logfontw) == sizeof(LOGFONTA), "\n"); // 92 -> 60 592 ok(GetObjectA(hFont, sizeof(LOGFONTW) + 1, &u.logfontw) == sizeof(LOGFONTW) + 1, "\n"); // 93 -> 93 593 ok(GetObjectA(hFont, sizeof(EXTLOGFONTA), &u.extlogfonta) == sizeof(EXTLOGFONTA), "\n"); // 192 -> 192 594 ok(GetObjectA(hFont, sizeof(EXTLOGFONTA)+1, &u.extlogfonta) == sizeof(EXTLOGFONTA)+1, "\n"); // 192+1 -> 192+1 595 ok(GetObjectA(hFont, sizeof(EXTLOGFONTA)+16*4, &u.extlogfonta) == sizeof(EXTLOGFONTA)+16*4, "\n"); // 192+1 -> 192+1 596 ok(GetObjectA(hFont, sizeof(EXTLOGFONTW), &u.extlogfontw) == sizeof(ENUMLOGFONTEXDVA), "\n"); // 320 -> 260 597 ok(GetObjectA(hFont, 261, &u.bData) == 260, "\n"); // no 598 599 ok(GetObjectA(hFont, sizeof(ENUMLOGFONTEXDVA) - 1, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXDVA) - 1, "\n"); // 419 600 ok(GetObjectA(hFont, sizeof(ENUMLOGFONTEXDVA), &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXDVA), "\n"); // 420 601 ok(GetObjectA(hFont, sizeof(ENUMLOGFONTEXDVA)+1, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXDVA), "\n"); // 356! 602 603 /* LOGFONT / GetObjectW */ 604 FillMemory(&u.logfontw, sizeof(LOGFONTW), 0x77); 605 606 ok(GetObjectW(hFont, sizeof(LOGFONTW), NULL) == sizeof(LOGFONTW), "1\n"); 607 ok(GetObjectW(hFont, 0, NULL) == sizeof(LOGFONTW), "\n"); 608 ok(GetObjectW(hFont, 5, NULL) == sizeof(LOGFONTW), "\n"); 609 ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXA), NULL) == sizeof(LOGFONTW), "\n"); 610 ok(GetObjectW(hFont, -5, NULL) == sizeof(LOGFONTW), "\n"); 611 ok(GetObjectW(hFont, 0, &u.logfontw) == 0, "\n"); 612 ok(u.logfontw.lfHeight == 0x77777777, "\n"); 613 614 ok(GetObjectW(hFont, 5, &u.logfontw) == 5, "\n"); 615 ok(u.logfontw.lfHeight == 8, "\n"); 616 ok(u.logfontw.lfWidth == 0x77777708, "\n"); 617 618 ok(GetObjectA(hFont, sizeof(LOGFONTA), &u.logfonta) == sizeof(LOGFONTA), "\n"); // 60 619 ok(u.logfonta.lfHeight == 8, "\n"); 620 ok(GetObjectA(hFont, sizeof(ENUMLOGFONTA), &u.enumlogfonta) == sizeof(ENUMLOGFONTA), "\n"); // 156 621 ok(GetObjectA(hFont, sizeof(ENUMLOGFONTEXA), &u.enumlogfontexa) == sizeof(ENUMLOGFONTEXA), "\n"); // 188 622 ok(GetObjectA(hFont, sizeof(EXTLOGFONTA), &u.extlogfonta) == sizeof(EXTLOGFONTA), "\n"); // 192 623 ok(GetObjectA(hFont, sizeof(ENUMLOGFONTEXDVA), &u.enumlogfontexdva) == sizeof(ENUMLOGFONTEXDVA), "\n"); // 260 624 ok(GetObjectA(hFont, sizeof(ENUMLOGFONTEXDVA)+1, &u.enumlogfontexdva) == sizeof(ENUMLOGFONTEXDVA), "\n"); // 260 625 626 ok(GetObjectW(hFont, sizeof(LOGFONTW), &u.logfontw) == sizeof(LOGFONTW), "\n"); // 92 627 ok(GetObjectW(hFont, sizeof(LOGFONTW) + 1, &u.logfontw) == sizeof(LOGFONTW) + 1, "\n"); // 92 628 ok(GetObjectW(hFont, sizeof(LOGFONTW) - 1, &u.logfontw) == sizeof(LOGFONTW) - 1, "\n"); // 92 629 ok(GetObjectW(hFont, sizeof(ENUMLOGFONTW), &u.enumlogfontw) == sizeof(ENUMLOGFONTW), "\n"); // 284 630 ok(GetObjectW(hFont, sizeof(EXTLOGFONTW), &u.extlogfontw) == sizeof(EXTLOGFONTW), "\n"); // 320 631 ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXW), &u.enumlogfontexw) == sizeof(ENUMLOGFONTEXW), "\n"); // 348 632 ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXW) + 1, &u.enumlogfontexw) == sizeof(ENUMLOGFONTEXW) + 1, "\n"); // 348 633 ok(GetObjectW(hFont, 355, &u.enumlogfontexdvw) == 355, "\n"); // 419 634 635 ok(GetObjectW(hFont, 356, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); // 419 636 ret = sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD); 637 ret = GetObjectW(hFont, 357, &u.enumlogfontexdvw); 638 ok(ret == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); 639 ok(GetObjectW(hFont, 357, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); // 419 640 ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXDVW) - 1, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); // 419 641 ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXDVW), &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); // 420 642 ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXDVW)+1, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); // 356! 643 ok(GetLastError() == ERROR_SUCCESS, "got %ld\n", GetLastError()); 644 645 DeleteObject(hFont); 646 } 647 648 void 649 Test_Colorspace(void) 650 { 651 UCHAR buffer[1000]; 652 653 SetLastError(ERROR_SUCCESS); 654 GetObjectA((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 0, NULL); 655 //ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 0, NULL) == 60, "\n");// FIXME: what structure? fails on win7 656 ok_err(ERROR_INSUFFICIENT_BUFFER); 657 SetLastError(ERROR_SUCCESS); 658 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 0, NULL) == 0, "\n"); 659 ok_err(ERROR_INSUFFICIENT_BUFFER); 660 SetLastError(ERROR_SUCCESS); 661 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 327, buffer) == 0, "\n"); 662 ok_err(ERROR_INSUFFICIENT_BUFFER); 663 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 328, buffer) == 0, "\n"); 664 ok_err(ERROR_INVALID_PARAMETER); 665 666 //ok_long(GetObjectA((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 328, NULL), 0); // FIXME: fails on WHS 667 //ok_err(ERROR_INSUFFICIENT_BUFFER); 668 } 669 670 void 671 Test_MetaDC(void) 672 { 673 /* Windows does not SetLastError() on a metadc, but it doesn't seem to do anything with it */ 674 HDC hMetaDC; 675 BYTE buffer[1000]; 676 677 hMetaDC = CreateMetaFile(NULL); 678 ok(hMetaDC != 0, "CreateMetaFile failed, skipping tests.\n"); 679 if(!hMetaDC) return; 680 681 ok(((UINT_PTR)hMetaDC & GDI_HANDLE_TYPE_MASK) == GDI_OBJECT_TYPE_METADC, "\n"); 682 683 SetLastError(ERROR_SUCCESS); 684 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_METADC, 0, NULL) == 0, "\n"); 685 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_METADC, 100, &buffer) == 0, "\n"); 686 ok(GetObjectA(hMetaDC, 0, NULL) == 0, "\n"); 687 ok(GetObjectA(hMetaDC, 1000, &buffer) == 0, "\n"); 688 ok(GetLastError() == ERROR_SUCCESS, "got %ld\n", GetLastError()); 689 } 690 691 void 692 Test_Region(void) 693 { 694 HRGN hRgn; 695 hRgn = CreateRectRgn(0,0,5,5); 696 SetLastError(ERROR_SUCCESS); 697 ok(GetObjectW(hRgn, 0, NULL) == 0, "\n"); 698 ok(GetLastError() == ERROR_INVALID_HANDLE, "\n"); 699 DeleteObject(hRgn); 700 } 701 702 START_TEST(GetObject) 703 { 704 705 Test_Font(); 706 Test_Colorspace(); 707 Test_General(); 708 Test_Bitmap(); 709 Test_Dibsection(); 710 Test_Palette(); 711 Test_Brush(); 712 Test_DIBBrush(); 713 Test_Pen(); 714 Test_ExtPen(); // not implemented yet in ROS 715 Test_MetaDC(); 716 Test_Region(); 717 } 718 719