ReactOS  0.4.15-dev-1397-g19779b3
GetObject.c File Reference
#include "precomp.h"
Include dependency graph for GetObject.c:

Go to the source code of this file.

Macros

#define INVALID_POINTER   ((PVOID)(ULONG_PTR)0xdeadbeefdeadbeefULL)
 

Functions

void Test_General (void)
 
void Test_Bitmap (void)
 
void Test_Dibsection (void)
 
void Test_Palette (void)
 
void Test_Brush (void)
 
void Test_DIBBrush (void)
 
void Test_Pen (void)
 
void Test_ExtPen (void)
 
void Test_Font (void)
 
void Test_Colorspace (void)
 
void Test_MetaDC (void)
 
void Test_Region (void)
 
 START_TEST (GetObject)
 

Macro Definition Documentation

◆ INVALID_POINTER

#define INVALID_POINTER   ((PVOID)(ULONG_PTR)0xdeadbeefdeadbeefULL)

Definition at line 10 of file GetObject.c.

Function Documentation

◆ START_TEST()

START_TEST ( GetObject  )

Definition at line 702 of file GetObject.c.

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 }
void Test_Dibsection(void)
Definition: GetObject.c:228
void Test_Colorspace(void)
Definition: GetObject.c:649
void Test_General(void)
Definition: GetObject.c:13
void Test_Region(void)
Definition: GetObject.c:692
void Test_ExtPen(void)
Definition: GetObject.c:450
void Test_Palette(void)
Definition: GetObject.c:271
void Test_Pen(void)
Definition: GetObject.c:417
void Test_Brush(void)
Definition: GetObject.c:311
void Test_Font(void)
Definition: GetObject.c:531
void Test_MetaDC(void)
Definition: GetObject.c:671
void Test_Bitmap(void)
Definition: GetObject.c:186
void Test_DIBBrush(void)
Definition: GetObject.c:365

◆ Test_Bitmap()

void Test_Bitmap ( void  )

Definition at line 186 of file GetObject.c.

187 {
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 
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 
225 }
int WINAPI GetObjectA(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
Definition: bufpool.h:45
Definition: uimain.c:88
#define FillMemory(BUF, SIZ, MASK)
Definition: strucsup.c:31
#define SetLastError(x)
Definition: compat.h:611
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define GDI_OBJECT_TYPE_BITMAP
Definition: gdi.h:48
unsigned char BYTE
Definition: xxhash.c:193
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
#define ok(value,...)
Definition: atltest.h:57
Definition: bl.h:1331
#define NULL
Definition: types.h:112
static HBITMAP bitmap
Definition: clipboard.c:1344
static HBITMAP
Definition: button.c:44
static HBITMAP hBitmap
Definition: timezone.c:26
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)

Referenced by START_TEST().

◆ Test_Brush()

void Test_Brush ( void  )

Definition at line 311 of file GetObject.c.

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 
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 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
int WINAPI GetObjectA(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_SUCCESS
Definition: deptool.c:10
#define RGB(r, g, b)
Definition: precomp.h:62
UINT lbStyle
Definition: wingdi.h:1746
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define WHITE_BRUSH
Definition: wingdi.h:901
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define GDI_OBJECT_TYPE_BRUSH
Definition: gdi.h:52
#define ULL(a, b)
Definition: format_msg.c:27
COLORREF lbColor
Definition: wingdi.h:1747
unsigned short WORD
Definition: ntddk_ex.h:93
#define FillMemory(BUF, SIZ, MASK)
Definition: strucsup.c:31
#define SetLastError(x)
Definition: compat.h:611
#define GetObject
Definition: wingdi.h:4467
unsigned __int64 ULONG64
Definition: imports.h:198
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)

Referenced by START_TEST().

◆ Test_Colorspace()

void Test_Colorspace ( void  )

Definition at line 649 of file GetObject.c.

650 {
651  UCHAR buffer[1000];
652 
655  //ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 0, NULL) == 60, "\n");// FIXME: what structure? fails on win7
665 
666  //ok_long(GetObjectA((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 328, NULL), 0); // FIXME: fails on WHS
667  //ok_err(ERROR_INSUFFICIENT_BUFFER);
668 }
int WINAPI GetObjectA(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_SUCCESS
Definition: deptool.c:10
GLuint buffer
Definition: glext.h:5915
#define GDI_OBJECT_TYPE_COLORSPACE
Definition: gdi.h:56
#define SetLastError(x)
Definition: compat.h:611
unsigned char UCHAR
Definition: xmlstorage.h:181
#define ok_err(error)
Definition: atltest.h:124
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by START_TEST().

◆ Test_DIBBrush()

void Test_DIBBrush ( void  )

Definition at line 365 of file GetObject.c.

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);
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 
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);
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 
412  DeleteObject(hBrush);
413 
414 }
#define BS_DIBPATTERN
Definition: wingdi.h:1091
#define ERROR_SUCCESS
Definition: deptool.c:10
#define DIB_PAL_COLORS
Definition: wingdi.h:365
UINT lbStyle
Definition: wingdi.h:1746
struct tagBITMAPINFOHEADER BITMAPINFOHEADER
ULONG_PTR lbHatch
Definition: wingdi.h:1748
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define ok_long(expression, result)
Definition: atltest.h:133
uint32_t ULONG_PTR
Definition: typedefs.h:65
COLORREF lbColor
Definition: wingdi.h:1747
unsigned short WORD
Definition: ntddk_ex.h:93
#define FillMemory(BUF, SIZ, MASK)
Definition: strucsup.c:31
#define SetLastError(x)
Definition: compat.h:611
#define GetObject
Definition: wingdi.h:4467
#define ok_err(error)
Definition: atltest.h:124
unsigned char BYTE
Definition: xxhash.c:193
#define ok(value,...)
Definition: atltest.h:57
HBRUSH WINAPI CreateDIBPatternBrushPt(_In_ const VOID *pvPackedDIB, _In_ UINT uUsage)
#define BI_RGB
Definition: precomp.h:47

Referenced by START_TEST().

◆ Test_Dibsection()

void Test_Dibsection ( void  )

Definition at line 228 of file GetObject.c.

229 {
230  BITMAPINFO bmi = {{sizeof(BITMAPINFOHEADER), 10, 9, 1, 16, BI_RGB, 0, 10, 10, 0,0}};
232  BITMAP bitmap;
233  DIBSECTION dibsection;
234  PVOID pData;
235  HDC hDC;
236 
237  FillMemory(&dibsection, sizeof(DIBSECTION), 0x77);
238  hDC = GetDC(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 
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));
267  ReleaseDC(0, hDC);
268 }
int WINAPI GetObjectA(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
#define ERROR_SUCCESS
Definition: deptool.c:10
HDC WINAPI GetDC(_In_opt_ HWND)
struct tagBITMAPINFOHEADER BITMAPINFOHEADER
static HDC
Definition: imagelist.c:92
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define ok_long(expression, result)
Definition: atltest.h:133
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
Definition: uimain.c:88
#define FillMemory(BUF, SIZ, MASK)
Definition: strucsup.c:31
#define SetLastError(x)
Definition: compat.h:611
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define GetObject
Definition: wingdi.h:4467
#define ok_err(error)
Definition: atltest.h:124
static HDC hDC
Definition: 3dtext.c:33
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:197
#define ok(value,...)
Definition: atltest.h:57
Definition: bl.h:1331
#define NULL
Definition: types.h:112
static HBITMAP bitmap
Definition: clipboard.c:1344
static HBITMAP
Definition: button.c:44
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
#define DIB_RGB_COLORS
Definition: wingdi.h:366
#define BI_RGB
Definition: precomp.h:47
static HBITMAP hBitmap
Definition: timezone.c:26

Referenced by START_TEST().

◆ Test_ExtPen()

void Test_ExtPen ( void  )

Definition at line 450 of file GetObject.c.

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 
464  ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 0, NULL) == 0, "\n");
467  ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 0, NULL) == 0, "\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 
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());
490  ok(GetObject(hPen, 4, &extlogpen) == 0, "\n");
491  ok(GetLastError() == ERROR_SUCCESS, "got %ld\n", GetLastError());
493  ok(GetObject((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 0, &extlogpen) == 0, "\n");
494  ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %ld\n", GetLastError());
496  ok(GetObject((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 4, &extlogpen) == 0, "\n");
497  ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %ld\n", GetLastError());
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 }
int WINAPI GetObjectA(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
COLORREF elpColor
Definition: wingdi.h:1944
#define GDI_HANDLE_GET_INDEX(h)
Definition: gdi.h:28
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD elpWidth
Definition: wingdi.h:1942
#define RGB(r, g, b)
Definition: precomp.h:62
UINT lbStyle
Definition: wingdi.h:1746
ULONG_PTR lbHatch
Definition: wingdi.h:1748
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define PS_GEOMETRIC
Definition: wingdi.h:582
ULONG_PTR elpHatch
Definition: wingdi.h:1945
#define GDI_OBJECT_TYPE_EXTPEN
Definition: gdi.h:55
DWORD elpNumEntries
Definition: wingdi.h:1946
#define ERROR_NOACCESS
Definition: winerror.h:578
DWORD elpPenStyle
Definition: wingdi.h:1941
#define GDI_HANDLE_GET_TYPE(h)
Definition: gdi.h:31
COLORREF lbColor
Definition: wingdi.h:1747
unsigned long DWORD
Definition: ntddk_ex.h:95
#define FillMemory(BUF, SIZ, MASK)
Definition: strucsup.c:31
#define SetLastError(x)
Definition: compat.h:611
#define GetObject
Definition: wingdi.h:4467
#define PS_DASH
Definition: wingdi.h:586
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
UINT elpBrushStyle
Definition: wingdi.h:1943
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
HPEN WINAPI ExtCreatePen(_In_ DWORD iPenStyle, _In_ DWORD cWidth, _In_ const LOGBRUSH *plbrush, _In_ DWORD cStyle, _In_reads_opt_(cStyle) const DWORD *pstyle)
#define BS_SOLID
Definition: wingdi.h:1085
#define PS_USERSTYLE
Definition: wingdi.h:591
#define CONST
Definition: pedump.c:81

Referenced by START_TEST().

◆ Test_Font()

void Test_Font ( void  )

Definition at line 531 of file GetObject.c.

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,
553  ANTIALIASED_QUALITY, DEFAULT_PITCH, "testfont");
554  ok(hFont != 0, "\n");
555 
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 
646 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
int WINAPI GetObjectA(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
struct tagENUMLOGFONTEXW ENUMLOGFONTEXW
#define ANTIALIASED_QUALITY
Definition: wingdi.h:439
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define OUT_CHARACTER_PRECIS
Definition: wingdi.h:416
HFONT hFont
Definition: main.c:53
#define FALSE
Definition: types.h:117
#define CLIP_CHARACTER_PRECIS
Definition: wingdi.h:426
#define DEFAULT_PITCH
Definition: wingdi.h:442
unsigned long DWORD
Definition: ntddk_ex.h:95
#define FillMemory(BUF, SIZ, MASK)
Definition: strucsup.c:31
#define SetLastError(x)
Definition: compat.h:611
int ret
unsigned char BYTE
Definition: xxhash.c:193
HFONT WINAPI CreateFontA(_In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_opt_ LPCSTR)
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define FW_NORMAL
Definition: wingdi.h:372
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define ANSI_CHARSET
Definition: wingdi.h:382
#define GDI_OBJECT_TYPE_FONT
Definition: gdi.h:50

Referenced by START_TEST().

◆ Test_General()

void Test_General ( void  )

Definition at line 13 of file GetObject.c.

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 */
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");
36  ok(GetObjectA((HANDLE)0x00010000, 0, NULL) == 0, "\n");
39  ok(GetObjectA((HANDLE)0x00020000, 0, NULL) == 0, "\n");
40  ok(GetLastError() == ERROR_SUCCESS, "\n");
42  ok(GetObjectA((HANDLE)0x00030000, 0, NULL) == 0, "\n");
43  ok(GetLastError() == ERROR_SUCCESS, "\n");
45  ok(GetObjectA((HANDLE)0x00040000, 0, NULL) == 0, "\n");
48  ok(GetObjectA((HANDLE)0x00060000, 0, NULL) == 0, "\n");
49  ok(GetLastError() == ERROR_SUCCESS, "\n");
51  ok(GetObjectA((HANDLE)0x00070000, 0, NULL) == 0, "\n");
52  ok(GetLastError() == ERROR_SUCCESS, "\n");
54  ok(GetObjectA((HANDLE)0x000B0000, 0, NULL) == 0, "\n");
55  ok(GetLastError() == ERROR_SUCCESS, "\n");
57  ok(GetObjectA((HANDLE)0x000C0000, 0, NULL) == 0, "\n");
58  ok(GetLastError() == ERROR_SUCCESS, "\n");
60  ok(GetObjectA((HANDLE)0x000D0000, 0, NULL) == 0, "\n");
61  ok(GetLastError() == ERROR_SUCCESS, "\n");
63  ok(GetObjectA((HANDLE)0x000E0000, 0, NULL) == 0, "\n");
64  ok(GetLastError() == ERROR_SUCCESS, "\n");
66  ok(GetObjectA((HANDLE)0x000F0000, 0, NULL) == 0, "\n");
67  ok(GetLastError() == ERROR_SUCCESS, "\n");
69  ok(GetObjectA((HANDLE)0x00110000, 0, NULL) == 0, "\n");
70  ok(GetLastError() == ERROR_SUCCESS, "\n");
72  ok(GetObjectA((HANDLE)0x00120000, 0, NULL) == 0, "\n");
73  ok(GetLastError() == ERROR_SUCCESS, "\n");
75  ok(GetObjectA((HANDLE)0x00130000, 0, NULL) == 0, "\n");
76  ok(GetLastError() == ERROR_SUCCESS, "\n");
78  ok(GetObjectA((HANDLE)0x00140000, 0, NULL) == 0, "\n");
79  ok(GetLastError() == ERROR_SUCCESS, "\n");
81  ok(GetObjectA((HANDLE)0x00150000, 0, NULL) == 0, "\n");
82  ok(GetLastError() == ERROR_SUCCESS, "\n");
84  ok(GetObjectA((HANDLE)0x00160000, 0, NULL) == 0, "\n");
85  ok(GetLastError() == ERROR_SUCCESS, "\n");
87  ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_DC, 0, NULL) == 0, "\n");
90  ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_DC, 0, NULL) == 0, "\n");
99  ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_EMF, 0, NULL) == 0, "\n");
102  ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_EMF, 0, NULL) == 0, "\n");
116 
117  /* Test need of alignment */
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);
130  ok((GetLastError() == 0xbadbad00) || (GetLastError() == ERROR_NOACCESS), "wrong error: %ld\n", GetLastError());
131  SetLastError(0xbadbad00);
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);
139  ok(GetLastError() == 0xbadbad00, "wrong error: %ld\n", GetLastError());
141  _SEH2_TRY
142  {
144  }
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);
178  ok_err(0xbadbad00);
179  SetLastError(0xbadbad00);
180  ok(GetObjectW(GetStockObject(21), 0, &TestStruct) == 0, "\n");
181  ok_err(0xbadbad00);
182 
183 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
int WINAPI GetObjectA(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
#define ERROR_SUCCESS
Definition: deptool.c:10
#define RGB(r, g, b)
Definition: precomp.h:62
#define GDI_OBJECT_TYPE_ENHMETAFILE
Definition: gdi.h:59
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define WHITE_BRUSH
Definition: wingdi.h:901
#define GDI_OBJECT_TYPE_REGION
Definition: gdi.h:47
static HPEN hpen
#define ok_long(expression, result)
Definition: atltest.h:133
#define PS_GEOMETRIC
Definition: wingdi.h:582
int32_t INT
Definition: typedefs.h:58
_SEH2_TRY
Definition: create.c:4226
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define PS_SOLID
Definition: wingdi.h:585
#define ERROR_NOACCESS
Definition: winerror.h:578
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define SYSTEM_FONT
Definition: wingdi.h:910
void * PVOID
Definition: retypes.h:9
#define SetLastError(x)
Definition: compat.h:611
#define GetObject
Definition: wingdi.h:4467
int ret
#define GDI_OBJECT_TYPE_DC
Definition: gdi.h:46
#define GDI_OBJECT_TYPE_METAFILE
Definition: gdi.h:58
#define ok_err(error)
Definition: atltest.h:124
unsigned char BYTE
Definition: xxhash.c:193
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
_SEH2_END
Definition: create.c:4400
#define INVALID_POINTER
Definition: GetObject.c:10
#define BLACK_PEN
Definition: wingdi.h:902
#define GDI_OBJECT_TYPE_EMF
Definition: gdi.h:53
#define ok(value,...)
Definition: atltest.h:57
Definition: bl.h:1331
#define NULL
Definition: types.h:112
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
HPEN WINAPI ExtCreatePen(_In_ DWORD iPenStyle, _In_ DWORD cWidth, _In_ const LOGBRUSH *plbrush, _In_ DWORD cStyle, _In_reads_opt_(cStyle) const DWORD *pstyle)
#define BS_SOLID
Definition: wingdi.h:1085
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6

Referenced by START_TEST().

◆ Test_MetaDC()

void Test_MetaDC ( void  )

Definition at line 671 of file GetObject.c.

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 
682 
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 }
int WINAPI GetObjectA(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
#define ERROR_SUCCESS
Definition: deptool.c:10
static HDC
Definition: imagelist.c:92
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
GLuint buffer
Definition: glext.h:5915
#define SetLastError(x)
Definition: compat.h:611
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define GDI_OBJECT_TYPE_METADC
Definition: gdi.h:57
#define CreateMetaFile
Definition: wingdi.h:4446
unsigned char BYTE
Definition: xxhash.c:193
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define GDI_HANDLE_TYPE_MASK
Definition: gdi.h:17

Referenced by START_TEST().

◆ Test_Palette()

void Test_Palette ( void  )

Definition at line 271 of file GetObject.c.

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 
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 }
int WINAPI GetObjectA(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
WORD palVersion
Definition: wingdi.h:1832
#define GDI_OBJECT_TYPE_PALETTE
Definition: gdi.h:49
HPALETTE WINAPI CreatePalette(_In_reads_(_Inexpressible_(2 *sizeof(WORD)+plpal->palNumEntries *sizeof(PALETTEENTRY))) const LOGPALETTE *)
unsigned short WORD
Definition: ntddk_ex.h:93
#define FillMemory(BUF, SIZ, MASK)
Definition: strucsup.c:31
#define SetLastError(x)
Definition: compat.h:611
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define GetObject
Definition: wingdi.h:4467
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
WORD palNumEntries
Definition: wingdi.h:1833
#define PC_EXPLICIT
Definition: wingdi.h:879

Referenced by START_TEST().

◆ Test_Pen()

void Test_Pen ( void  )

Definition at line 417 of file GetObject.c.

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;
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 }
int WINAPI GetObjectA(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
#define ERROR_SUCCESS
Definition: deptool.c:10
#define RGB(r, g, b)
Definition: precomp.h:62
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define PS_SOLID
Definition: wingdi.h:585
UINT lopnStyle
Definition: wingdi.h:1844
#define GDI_OBJECT_TYPE_PEN
Definition: gdi.h:54
#define FillMemory(BUF, SIZ, MASK)
Definition: strucsup.c:31
#define SetLastError(x)
Definition: compat.h:611
#define GetObject
Definition: wingdi.h:4467
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
#define ok(value,...)
Definition: atltest.h:57
Definition: bl.h:1331
#define NULL
Definition: types.h:112

Referenced by START_TEST().

◆ Test_Region()

void Test_Region ( void  )

Definition at line 692 of file GetObject.c.

693 {
694  HRGN hRgn;
695  hRgn = CreateRectRgn(0,0,5,5);
697  ok(GetObjectW(hRgn, 0, NULL) == 0, "\n");
700 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
static HRGN hRgn
Definition: mapping.c:33
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
#define SetLastError(x)
Definition: compat.h:611
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112

Referenced by START_TEST().