ReactOS  0.4.14-dev-315-gbb6fece
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 687 of file GetObject.c.

688 {
689 
690  Test_Font();
691  Test_Colorspace();
692  Test_General();
693  Test_Bitmap();
694  Test_Dibsection();
695  Test_Palette();
696  Test_Brush();
697  Test_DIBBrush();
698  Test_Pen();
699  Test_ExtPen(); // not implemented yet in ROS
700  Test_MetaDC();
701  Test_Region();
702 }
void Test_Dibsection(void)
Definition: GetObject.c:228
void Test_Colorspace(void)
Definition: GetObject.c:634
void Test_General(void)
Definition: GetObject.c:13
void Test_Region(void)
Definition: GetObject.c:677
void Test_ExtPen(void)
Definition: GetObject.c:435
void Test_Palette(void)
Definition: GetObject.c:271
void Test_Pen(void)
Definition: GetObject.c:402
void Test_Brush(void)
Definition: GetObject.c:311
void Test_Font(void)
Definition: GetObject.c:516
void Test_MetaDC(void)
Definition: GetObject.c:656
void Test_Bitmap(void)
Definition: GetObject.c:186
void Test_DIBBrush(void)
Definition: GetObject.c:350

◆ 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:1059
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
Definition: uimain.c:88
#define FillMemory(BUF, SIZ, MASK)
Definition: strucsup.c:31
#define SetLastError(x)
Definition: compat.h:409
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define GDI_OBJECT_TYPE_BITMAP
Definition: gdi.h:48
unsigned char BYTE
Definition: mem.h:68
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
static HBITMAP bitmap
Definition: clipboard.c:1344
static HBITMAP
Definition: button.c:44
static HBITMAP hBitmap
Definition: timezone.c:35
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 }
int WINAPI GetObjectA(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define ERROR_SUCCESS
Definition: deptool.c:10
UINT lbStyle
Definition: wingdi.h:1742
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define GDI_OBJECT_TYPE_BRUSH
Definition: gdi.h:52
smooth NULL
Definition: ftsmooth.c:416
#define RGB(r, g, b)
Definition: wingdi.h:2935
COLORREF lbColor
Definition: wingdi.h:1743
unsigned short WORD
Definition: ntddk_ex.h:93
#define FillMemory(BUF, SIZ, MASK)
Definition: strucsup.c:31
#define SetLastError(x)
Definition: compat.h:409
#define GetObject
Definition: wingdi.h:4463
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
#define ok(value,...)
Definition: atltest.h:57
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)

Referenced by START_TEST().

◆ Test_Colorspace()

void Test_Colorspace ( void  )

Definition at line 634 of file GetObject.c.

635 {
636  UCHAR buffer[1000];
637 
640  //ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 0, NULL) == 60, "\n");// FIXME: what structure? fails on win7
650 
651  //ok_long(GetObjectA((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 328, NULL), 0); // FIXME: fails on WHS
652  //ok_err(ERROR_INSUFFICIENT_BUFFER);
653 }
int WINAPI GetObjectA(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define ERROR_SUCCESS
Definition: deptool.c:10
GLuint buffer
Definition: glext.h:5915
#define GDI_OBJECT_TYPE_COLORSPACE
Definition: gdi.h:56
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:409
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 ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by START_TEST().

◆ Test_DIBBrush()

void Test_DIBBrush ( void  )

Definition at line 350 of file GetObject.c.

351 {
352  struct
353  {
354  BITMAPINFOHEADER bmiHeader;
355  WORD wColors[4];
356  BYTE jBuffer[16];
357  } PackedDIB =
358  {
359  {sizeof(BITMAPINFOHEADER), 4, 4, 1, 8, BI_RGB, 0, 1, 1, 4, 0},
360  {1, 7, 3, 1},
361  {0,1,2,3, 1,2,3,0, 2,3,0,1, 3,0,1,2},
362  };
363  LOGBRUSH logbrush;
364  HBRUSH hBrush;
365 
366  /* Create a DIB brush */
367  hBrush = CreateDIBPatternBrushPt(&PackedDIB, DIB_PAL_COLORS);
368  ok(hBrush != 0, "CreateSolidBrush failed, skipping tests.\n");
369  if (!hBrush) return;
370 
371  FillMemory(&logbrush, sizeof(LOGBRUSH), 0x77);
373 
374  ok_long(GetObject(hBrush, sizeof(LOGBRUSH), &logbrush), sizeof(LOGBRUSH));
375  ok_long(logbrush.lbStyle, BS_DIBPATTERN);
376  ok_long(logbrush.lbColor, 0);
377  ok_long(logbrush.lbHatch, (ULONG_PTR)&PackedDIB);
378 
380  DeleteObject(hBrush);
381 
382 
383  /* Create a DIB brush with undocumented iUsage 2 */
384  hBrush = CreateDIBPatternBrushPt(&PackedDIB, 2);
385  ok(hBrush != 0, "CreateSolidBrush failed, skipping tests.\n");
386  if (!hBrush) return;
387 
388  FillMemory(&logbrush, sizeof(LOGBRUSH), 0x77);
390 
391  ok_long(GetObject(hBrush, sizeof(LOGBRUSH), &logbrush), sizeof(LOGBRUSH));
392  ok_long(logbrush.lbStyle, BS_DIBPATTERN);
393  ok_long(logbrush.lbColor, 0);
394  ok_long(logbrush.lbHatch, (ULONG_PTR)&PackedDIB);
395 
397  DeleteObject(hBrush);
398 
399 }
#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:1742
struct tagBITMAPINFOHEADER BITMAPINFOHEADER
ULONG_PTR lbHatch
Definition: wingdi.h:1744
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define ok_long(expression, result)
Definition: atltest.h:133
uint32_t ULONG_PTR
Definition: typedefs.h:63
COLORREF lbColor
Definition: wingdi.h:1743
unsigned short WORD
Definition: ntddk_ex.h:93
#define FillMemory(BUF, SIZ, MASK)
Definition: strucsup.c:31
#define SetLastError(x)
Definition: compat.h:409
#define GetObject
Definition: wingdi.h:4463
unsigned char BYTE
Definition: mem.h:68
#define ok_err(error)
Definition: atltest.h:124
#define ok(value,...)
Definition: atltest.h:57
HBRUSH WINAPI CreateDIBPatternBrushPt(_In_ const VOID *pvPackedDIB, _In_ UINT uUsage)
#define BI_RGB
Definition: precomp.h:34

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:1059
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define ok_long(expression, result)
Definition: atltest.h:133
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
smooth NULL
Definition: ftsmooth.c:416
Definition: uimain.c:88
#define FillMemory(BUF, SIZ, MASK)
Definition: strucsup.c:31
#define SetLastError(x)
Definition: compat.h:409
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define GetObject
Definition: wingdi.h:4463
#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
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:34
static HBITMAP hBitmap
Definition: timezone.c:35

Referenced by START_TEST().

◆ Test_ExtPen()

void Test_ExtPen ( void  )

Definition at line 435 of file GetObject.c.

436 {
437  HPEN hPen;
438  EXTLOGPEN extlogpen;
439  LOGBRUSH logbrush;
440  DWORD dwStyles[17] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
441  struct
442  {
443  EXTLOGPEN extlogpen;
444  DWORD dwStyles[50];
445  } elpUserStyle;
446  int i;
447 
449  ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 0, NULL) == 0, "\n");
452  ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 0, NULL) == 0, "\n");
454 
455  FillMemory(&extlogpen, sizeof(EXTLOGPEN), 0x77);
456  logbrush.lbStyle = BS_SOLID;
457  logbrush.lbColor = RGB(1,2,3);
458  logbrush.lbHatch = 22;
459  hPen = ExtCreatePen(PS_GEOMETRIC | PS_DASH, 5, &logbrush, 0, NULL);
460 
463  ok(GetObject(hPen, sizeof(EXTLOGPEN), NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
464  ok(GetObject(hPen, 0, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
465  ok(GetObject((HANDLE)GDI_HANDLE_GET_INDEX(hPen), 0, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
466  ok(GetObject(hPen, 5, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
467  ok(GetObject(hPen, -5, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
468  ok(GetLastError() == ERROR_SUCCESS, "\n");
469  ok(GetObject((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 0, NULL) == 0, "\n");
470  ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %ld\n", GetLastError());
471  SetLastError(0xbadbad00);
472  ok(GetObject(hPen, 0, &extlogpen) == 0, "\n");
473  ok((GetLastError() == 0xbadbad00) || (GetLastError() == ERROR_NOACCESS), "wrong error: %ld\n", GetLastError());
475  ok(GetObject(hPen, 4, &extlogpen) == 0, "\n");
476  ok(GetLastError() == ERROR_SUCCESS, "got %ld\n", GetLastError());
478  ok(GetObject((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 0, &extlogpen) == 0, "\n");
479  ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %ld\n", GetLastError());
481  ok(GetObject((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 4, &extlogpen) == 0, "\n");
482  ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %ld\n", GetLastError());
484  ok(GetObject(hPen, sizeof(EXTLOGPEN) - 5, &extlogpen) == 0, "\n");
485  ok(GetLastError() == ERROR_SUCCESS, "got %ld\n", GetLastError());
486 
487  /* Nothing should be filled */
488  ok(extlogpen.elpPenStyle == 0x77777777, "\n");
489  ok(extlogpen.elpWidth == 0x77777777, "\n");
490 
491  ok(GetObject(hPen, sizeof(EXTLOGPEN), &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
492  ok(GetObject(hPen, sizeof(EXTLOGPEN)-sizeof(DWORD), &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
493  ok(GetObject(hPen, sizeof(EXTLOGPEN)-sizeof(DWORD)-1, &extlogpen) == 0, "\n");
494  ok(GetObject(hPen, sizeof(EXTLOGPEN)+2, &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
495  ok(GetObject(hPen, -5, &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
496 
497  /* test if the fields are filled correctly */
498  ok(extlogpen.elpPenStyle == (PS_GEOMETRIC | PS_DASH), "\n");
499  ok(extlogpen.elpWidth == 5, "\n");
500  ok(extlogpen.elpBrushStyle == 0, "\n");
501  ok(extlogpen.elpColor == RGB(1,2,3), "\n");
502  ok(extlogpen.elpHatch == 22, "\n");
503  ok(extlogpen.elpNumEntries == 0, "\n");
504  DeleteObject(hPen);
505 
506  /* A maximum of 16 Styles is allowed */
507  hPen = ExtCreatePen(PS_GEOMETRIC | PS_USERSTYLE, 5, &logbrush, 16, (CONST DWORD*)&dwStyles);
508  ok(GetObject(hPen, 0, NULL) == sizeof(EXTLOGPEN) + 15*sizeof(DWORD), "\n");
509  ok(GetObject(hPen, sizeof(EXTLOGPEN) + 15*sizeof(DWORD), &elpUserStyle) == sizeof(EXTLOGPEN) + 15*sizeof(DWORD), "\n");
510  for (i = 0; i <= 15; i++)
511  ok(((EXTLOGPEN*)&elpUserStyle)->elpStyleEntry[i] == i, "%d\n", i);
512  DeleteObject(hPen);
513 }
int WINAPI GetObjectA(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
COLORREF elpColor
Definition: wingdi.h:1940
#define GDI_HANDLE_GET_INDEX(h)
Definition: gdi.h:28
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD elpWidth
Definition: wingdi.h:1938
UINT lbStyle
Definition: wingdi.h:1742
ULONG_PTR lbHatch
Definition: wingdi.h:1744
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define PS_GEOMETRIC
Definition: wingdi.h:582
ULONG_PTR elpHatch
Definition: wingdi.h:1941
#define GDI_OBJECT_TYPE_EXTPEN
Definition: gdi.h:55
DWORD elpNumEntries
Definition: wingdi.h:1942
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
#define ERROR_NOACCESS
Definition: winerror.h:578
DWORD elpPenStyle
Definition: wingdi.h:1937
smooth NULL
Definition: ftsmooth.c:416
#define GDI_HANDLE_GET_TYPE(h)
Definition: gdi.h:31
#define RGB(r, g, b)
Definition: wingdi.h:2935
COLORREF lbColor
Definition: wingdi.h:1743
unsigned long DWORD
Definition: ntddk_ex.h:95
#define FillMemory(BUF, SIZ, MASK)
Definition: strucsup.c:31
#define SetLastError(x)
Definition: compat.h:409
#define GetObject
Definition: wingdi.h:4463
#define PS_DASH
Definition: wingdi.h:586
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
UINT elpBrushStyle
Definition: wingdi.h:1939
#define ok(value,...)
Definition: atltest.h:57
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 516 of file GetObject.c.

517 {
518  HFONT hFont;
519  union
520  {
521  LOGFONTA logfonta;
522  LOGFONTW logfontw;
523  EXTLOGFONTA extlogfonta;
524  EXTLOGFONTW extlogfontw;
525  ENUMLOGFONTEXA enumlogfontexa;
526  ENUMLOGFONTEXW enumlogfontexw;
527  ENUMLOGFONTEXDVA enumlogfontexdva;
528  ENUMLOGFONTEXDVW enumlogfontexdvw;
529  ENUMLOGFONTA enumlogfonta;
530  ENUMLOGFONTW enumlogfontw;
531  BYTE bData[270];
532  } u;
533  int ret;
534 
535  FillMemory(&u, sizeof(u), 0x77);
536  hFont = CreateFontA(8, 8, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
538  ANTIALIASED_QUALITY, DEFAULT_PITCH, "testfont");
539  ok(hFont != 0, "\n");
540 
542  ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, 0, NULL) == sizeof(LOGFONTA), "\n");
543  ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, 0, NULL) == sizeof(LOGFONTW), "\n");
544  ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(LOGFONTA), NULL) == sizeof(LOGFONTA), "\n"); // 60
545  ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTA), NULL) == sizeof(LOGFONTA), "\n"); // 156
546  ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXA), NULL) == sizeof(LOGFONTA), "\n"); // 188
547  ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(EXTLOGFONTA), NULL) == sizeof(LOGFONTA), "\n"); // 192
548  ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXDVA), NULL) == sizeof(LOGFONTA), "\n"); // 260
549  ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXDVA)+1, NULL) == sizeof(LOGFONTA), "\n"); // 260
550  ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(LOGFONTW), NULL) == sizeof(LOGFONTW), "\n"); // 92
551  ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTW), NULL) == sizeof(LOGFONTW), "\n"); // 284
552  ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(EXTLOGFONTW), NULL) == sizeof(LOGFONTW), "\n"); // 320
553  ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXW), NULL) == sizeof(LOGFONTW), "\n"); // 348
554  ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXDVW), NULL) == sizeof(LOGFONTW), "\n"); // 420
555  ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXDVW)+1, NULL) == sizeof(LOGFONTW), "\n"); // 356!
556  ok(GetLastError() == ERROR_SUCCESS, "got %ld\n", GetLastError());
557 
558  ok(GetObjectA(hFont, sizeof(LOGFONTA), NULL) == sizeof(LOGFONTA), "\n");
559  ok(GetObjectA(hFont, 0, NULL) == sizeof(LOGFONTA), "\n");
560  ok(GetObjectA(hFont, 5, NULL) == sizeof(LOGFONTA), "\n");
561  ok(GetObjectA(hFont, -5, NULL) == sizeof(LOGFONTA), "\n");
562  ok(GetObjectA(hFont, 0, &u.logfonta) == 0, "\n");
563  ok(u.logfonta.lfHeight == 0x77777777, "\n");
564 
565  ok(GetObjectA(hFont, 5, &u.logfonta) == 5, "\n");
566  ok(u.logfonta.lfHeight == 8, "\n");
567  ok(u.logfonta.lfWidth == 0x77777708, "\n");
568 
569  ok(GetObjectA(hFont, 0, &u.logfonta) == 0, "\n");
570  ok(GetObjectA(hFont, -1, &u.logfonta) == sizeof(ENUMLOGFONTEXDVA), "\n");
571  ok(GetObjectA(hFont, 1, &u.logfonta) == 1, "\n"); // 1 -> 1
572  ok(GetObjectA(hFont, sizeof(LOGFONTA) - 1, &u.logfonta) == sizeof(LOGFONTA) - 1, "\n"); // 59 -> 59
573  ok(GetObjectA(hFont, sizeof(LOGFONTA), &u.logfonta) == sizeof(LOGFONTA), "\n"); // 60 -> 60
574  ok(GetObjectA(hFont, sizeof(LOGFONTA) + 1, &u.logfonta) == sizeof(LOGFONTA) + 1, "\n"); // 61 -> 61
575  ok(GetObjectA(hFont, sizeof(LOGFONTW) - 1, &u.logfontw) == sizeof(LOGFONTW) - 1, "\n"); // 91 -> 91
576  ok(GetObjectA(hFont, sizeof(LOGFONTW), &u.logfontw) == sizeof(LOGFONTA), "\n"); // 92 -> 60
577  ok(GetObjectA(hFont, sizeof(LOGFONTW) + 1, &u.logfontw) == sizeof(LOGFONTW) + 1, "\n"); // 93 -> 93
578  ok(GetObjectA(hFont, sizeof(EXTLOGFONTA), &u.extlogfonta) == sizeof(EXTLOGFONTA), "\n"); // 192 -> 192
579  ok(GetObjectA(hFont, sizeof(EXTLOGFONTA)+1, &u.extlogfonta) == sizeof(EXTLOGFONTA)+1, "\n"); // 192+1 -> 192+1
580  ok(GetObjectA(hFont, sizeof(EXTLOGFONTA)+16*4, &u.extlogfonta) == sizeof(EXTLOGFONTA)+16*4, "\n"); // 192+1 -> 192+1
581  ok(GetObjectA(hFont, sizeof(EXTLOGFONTW), &u.extlogfontw) == sizeof(ENUMLOGFONTEXDVA), "\n"); // 320 -> 260
582  ok(GetObjectA(hFont, 261, &u.bData) == 260, "\n"); // no
583 
584  ok(GetObjectA(hFont, sizeof(ENUMLOGFONTEXDVA) - 1, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXDVA) - 1, "\n"); // 419
585  ok(GetObjectA(hFont, sizeof(ENUMLOGFONTEXDVA), &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXDVA), "\n"); // 420
586  ok(GetObjectA(hFont, sizeof(ENUMLOGFONTEXDVA)+1, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXDVA), "\n"); // 356!
587 
588  /* LOGFONT / GetObjectW */
589  FillMemory(&u.logfontw, sizeof(LOGFONTW), 0x77);
590 
591  ok(GetObjectW(hFont, sizeof(LOGFONTW), NULL) == sizeof(LOGFONTW), "1\n");
592  ok(GetObjectW(hFont, 0, NULL) == sizeof(LOGFONTW), "\n");
593  ok(GetObjectW(hFont, 5, NULL) == sizeof(LOGFONTW), "\n");
594  ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXA), NULL) == sizeof(LOGFONTW), "\n");
595  ok(GetObjectW(hFont, -5, NULL) == sizeof(LOGFONTW), "\n");
596  ok(GetObjectW(hFont, 0, &u.logfontw) == 0, "\n");
597  ok(u.logfontw.lfHeight == 0x77777777, "\n");
598 
599  ok(GetObjectW(hFont, 5, &u.logfontw) == 5, "\n");
600  ok(u.logfontw.lfHeight == 8, "\n");
601  ok(u.logfontw.lfWidth == 0x77777708, "\n");
602 
603  ok(GetObjectA(hFont, sizeof(LOGFONTA), &u.logfonta) == sizeof(LOGFONTA), "\n"); // 60
604  ok(u.logfonta.lfHeight == 8, "\n");
605  ok(GetObjectA(hFont, sizeof(ENUMLOGFONTA), &u.enumlogfonta) == sizeof(ENUMLOGFONTA), "\n"); // 156
606  ok(GetObjectA(hFont, sizeof(ENUMLOGFONTEXA), &u.enumlogfontexa) == sizeof(ENUMLOGFONTEXA), "\n"); // 188
607  ok(GetObjectA(hFont, sizeof(EXTLOGFONTA), &u.extlogfonta) == sizeof(EXTLOGFONTA), "\n"); // 192
608  ok(GetObjectA(hFont, sizeof(ENUMLOGFONTEXDVA), &u.enumlogfontexdva) == sizeof(ENUMLOGFONTEXDVA), "\n"); // 260
609  ok(GetObjectA(hFont, sizeof(ENUMLOGFONTEXDVA)+1, &u.enumlogfontexdva) == sizeof(ENUMLOGFONTEXDVA), "\n"); // 260
610 
611  ok(GetObjectW(hFont, sizeof(LOGFONTW), &u.logfontw) == sizeof(LOGFONTW), "\n"); // 92
612  ok(GetObjectW(hFont, sizeof(LOGFONTW) + 1, &u.logfontw) == sizeof(LOGFONTW) + 1, "\n"); // 92
613  ok(GetObjectW(hFont, sizeof(LOGFONTW) - 1, &u.logfontw) == sizeof(LOGFONTW) - 1, "\n"); // 92
614  ok(GetObjectW(hFont, sizeof(ENUMLOGFONTW), &u.enumlogfontw) == sizeof(ENUMLOGFONTW), "\n"); // 284
615  ok(GetObjectW(hFont, sizeof(EXTLOGFONTW), &u.extlogfontw) == sizeof(EXTLOGFONTW), "\n"); // 320
616  ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXW), &u.enumlogfontexw) == sizeof(ENUMLOGFONTEXW), "\n"); // 348
617  ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXW) + 1, &u.enumlogfontexw) == sizeof(ENUMLOGFONTEXW) + 1, "\n"); // 348
618  ok(GetObjectW(hFont, 355, &u.enumlogfontexdvw) == 355, "\n"); // 419
619 
620  ok(GetObjectW(hFont, 356, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); // 419
621  ret = sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD);
622  ret = GetObjectW(hFont, 357, &u.enumlogfontexdvw);
623  ok(ret == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n");
624  ok(GetObjectW(hFont, 357, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); // 419
625  ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXDVW) - 1, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); // 419
626  ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXDVW), &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); // 420
627  ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXDVW)+1, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); // 356!
628  ok(GetLastError() == ERROR_SUCCESS, "got %ld\n", GetLastError());
629 
631 }
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:1059
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define OUT_CHARACTER_PRECIS
Definition: wingdi.h:416
HFONT hFont
Definition: main.c:53
#define CLIP_CHARACTER_PRECIS
Definition: wingdi.h:426
smooth NULL
Definition: ftsmooth.c:416
#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:409
int ret
unsigned char BYTE
Definition: mem.h:68
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 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), sizeof(LOGBRUSH));
161  ok_err(0xbadbad00);
162  DeleteObject(hBrush);
163  SetLastError(0xbadbad00);
164  hpen = CreatePen(PS_SOLID, 1, 123);
165  ok(hpen != NULL, "Failed to create pen\n");
166  ok_long(GetObjectA(hpen, 0, &TestStruct), 0);
167  ok((GetLastError() == 0xbadbad00) || (GetLastError() == ERROR_NOACCESS), "wrong error: %ld\n", GetLastError());
168  SetLastError(0xbadbad00);
169  TestStruct.logbrush.lbStyle = BS_SOLID;
170  TestStruct.logbrush.lbColor = RGB(1,2,3);
171  TestStruct.logbrush.lbHatch = 0;
172  hpen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID, 1, &TestStruct.logbrush, 0, NULL);
173  ok(hpen != NULL, "Failed to create pen\n");
174  ok_long(GetObjectA(hpen, 0, &TestStruct), 0);
175  ok((GetLastError() == 0xbadbad00) || (GetLastError() == ERROR_NOACCESS), "wrong error: %ld\n", GetLastError());
176  SetLastError(0xbadbad00);
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 GDI_OBJECT_TYPE_ENHMETAFILE
Definition: gdi.h:59
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
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:56
_SEH2_TRY
Definition: create.c:4250
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define PS_SOLID
Definition: wingdi.h:585
#define ERROR_NOACCESS
Definition: winerror.h:578
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define SYSTEM_FONT
Definition: wingdi.h:910
void * PVOID
Definition: retypes.h:9
#define RGB(r, g, b)
Definition: wingdi.h:2935
#define SetLastError(x)
Definition: compat.h:409
#define GetObject
Definition: wingdi.h:4463
int ret
#define GDI_OBJECT_TYPE_DC
Definition: gdi.h:46
#define GDI_OBJECT_TYPE_METAFILE
Definition: gdi.h:58
unsigned char BYTE
Definition: mem.h:68
#define ok_err(error)
Definition: atltest.h:124
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
_SEH2_END
Definition: create.c:4424
#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
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 656 of file GetObject.c.

657 {
658  /* Windows does not SetLastError() on a metadc, but it doesn't seem to do anything with it */
659  HDC hMetaDC;
660  BYTE buffer[1000];
661 
662  hMetaDC = CreateMetaFile(NULL);
663  ok(hMetaDC != 0, "CreateMetaFile failed, skipping tests.\n");
664  if(!hMetaDC) return;
665 
667 
669  ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_METADC, 0, NULL) == 0, "\n");
670  ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_METADC, 100, &buffer) == 0, "\n");
671  ok(GetObjectA(hMetaDC, 0, NULL) == 0, "\n");
672  ok(GetObjectA(hMetaDC, 1000, &buffer) == 0, "\n");
673  ok(GetLastError() == ERROR_SUCCESS, "got %ld\n", GetLastError());
674 }
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:1059
GLuint buffer
Definition: glext.h:5915
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:409
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define GDI_OBJECT_TYPE_METADC
Definition: gdi.h:57
unsigned char BYTE
Definition: mem.h:68
#define CreateMetaFile
Definition: wingdi.h:4442
#define ok(value,...)
Definition: atltest.h:57
#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:1059
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
WORD palVersion
Definition: wingdi.h:1828
smooth NULL
Definition: ftsmooth.c:416
#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:409
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define GetObject
Definition: wingdi.h:4463
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
#define ok(value,...)
Definition: atltest.h:57
WORD palNumEntries
Definition: wingdi.h:1829
#define PC_EXPLICIT
Definition: wingdi.h:879

Referenced by START_TEST().

◆ Test_Pen()

void Test_Pen ( void  )

Definition at line 402 of file GetObject.c.

403 {
404  LOGPEN logpen;
405  HPEN hPen;
406 
407  FillMemory(&logpen, sizeof(LOGPEN), 0x77);
408  hPen = CreatePen(PS_SOLID, 3, RGB(4,5,6));
409  ok(hPen != 0, "CreatePen failed, skipping tests.\n");
410  if (!hPen) return;
412  ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_PEN, 0, NULL) == sizeof(LOGPEN), "\n");
413  ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_PEN, 0, NULL) == sizeof(LOGPEN), "\n");
414  ok(GetObject(hPen, sizeof(BITMAP), NULL) == sizeof(LOGPEN), "\n");
415  ok(GetObject(hPen, 0, NULL) == sizeof(LOGPEN), "\n");
416  ok(GetObject(hPen, 5, NULL) == sizeof(LOGPEN), "\n");
417  ok(GetObject(hPen, -5, NULL) == sizeof(LOGPEN), "\n");
418  ok(GetObject(hPen, sizeof(LOGPEN), &logpen) == sizeof(LOGPEN), "\n");
419  ok(GetObject(hPen, sizeof(LOGPEN)-1, &logpen) == 0, "\n");
420  ok(GetObject(hPen, sizeof(LOGPEN)+2, &logpen) == sizeof(LOGPEN), "\n");
421  ok(GetObject(hPen, 0, &logpen) == 0, "\n");
422  ok(GetObject(hPen, -5, &logpen) == sizeof(LOGPEN), "\n");
423  //ok(GetLastError() == ERROR_SUCCESS, "\n"); fails on win7
424 
425  /* test if the fields are filled correctly */
426  ok(logpen.lopnStyle == PS_SOLID, "\n");
427 
428  ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_PEN, sizeof(LOGPEN), &logpen) == 0, "\n");
429  ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
430 
431  DeleteObject(hPen);
432 }
int WINAPI GetObjectA(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define PS_SOLID
Definition: wingdi.h:585
UINT lopnStyle
Definition: wingdi.h:1840
smooth NULL
Definition: ftsmooth.c:416
#define GDI_OBJECT_TYPE_PEN
Definition: gdi.h:54
#define RGB(r, g, b)
Definition: wingdi.h:2935
#define FillMemory(BUF, SIZ, MASK)
Definition: strucsup.c:31
#define SetLastError(x)
Definition: compat.h:409
#define GetObject
Definition: wingdi.h:4463
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

Referenced by START_TEST().

◆ Test_Region()

void Test_Region ( void  )

Definition at line 677 of file GetObject.c.

678 {
679  HRGN hRgn;
680  hRgn = CreateRectRgn(0,0,5,5);
682  ok(GetObjectW(hRgn, 0, NULL) == 0, "\n");
685 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
static HRGN hRgn
Definition: mapping.c:33
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
smooth NULL
Definition: ftsmooth.c:416
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
#define SetLastError(x)
Definition: compat.h:409
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
#define ok(value,...)
Definition: atltest.h:57

Referenced by START_TEST().