gdi32: Reimplement GetObjectA on top of GetObjectW.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2021-07-05 13:40:00 +02:00 committed by Alexandre Julliard
parent 14a39fcfe7
commit 3dcb5db47f
11 changed files with 29 additions and 61 deletions

View File

@ -37,7 +37,6 @@ static BOOL BITMAP_DeleteObject( HGDIOBJ handle );
static const struct gdi_obj_funcs bitmap_funcs = static const struct gdi_obj_funcs bitmap_funcs =
{ {
BITMAP_GetObject, /* pGetObjectA */
BITMAP_GetObject, /* pGetObjectW */ BITMAP_GetObject, /* pGetObjectW */
NULL, /* pUnrealizeObject */ NULL, /* pUnrealizeObject */
BITMAP_DeleteObject /* pDeleteObject */ BITMAP_DeleteObject /* pDeleteObject */

View File

@ -44,7 +44,6 @@ static BOOL BRUSH_DeleteObject( HGDIOBJ handle );
static const struct gdi_obj_funcs brush_funcs = static const struct gdi_obj_funcs brush_funcs =
{ {
BRUSH_GetObject, /* pGetObjectA */
BRUSH_GetObject, /* pGetObjectW */ BRUSH_GetObject, /* pGetObjectW */
NULL, /* pUnrealizeObject */ NULL, /* pUnrealizeObject */
BRUSH_DeleteObject /* pDeleteObject */ BRUSH_DeleteObject /* pDeleteObject */

View File

@ -38,7 +38,6 @@ static BOOL DC_DeleteObject( HGDIOBJ handle );
static const struct gdi_obj_funcs dc_funcs = static const struct gdi_obj_funcs dc_funcs =
{ {
NULL, /* pGetObjectA */
NULL, /* pGetObjectW */ NULL, /* pGetObjectW */
NULL, /* pUnrealizeObject */ NULL, /* pUnrealizeObject */
DC_DeleteObject /* pDeleteObject */ DC_DeleteObject /* pDeleteObject */

View File

@ -83,7 +83,6 @@ static BOOL DIB_DeleteObject( HGDIOBJ handle );
static const struct gdi_obj_funcs dib_funcs = static const struct gdi_obj_funcs dib_funcs =
{ {
DIB_GetObject, /* pGetObjectA */
DIB_GetObject, /* pGetObjectW */ DIB_GetObject, /* pGetObjectW */
NULL, /* pUnrealizeObject */ NULL, /* pUnrealizeObject */
DIB_DeleteObject /* pDeleteObject */ DIB_DeleteObject /* pDeleteObject */

View File

@ -180,13 +180,11 @@ static inline WCHAR *strdupW( const WCHAR *p )
return ret; return ret;
} }
static INT FONT_GetObjectA( HGDIOBJ handle, INT count, LPVOID buffer );
static INT FONT_GetObjectW( HGDIOBJ handle, INT count, LPVOID buffer ); static INT FONT_GetObjectW( HGDIOBJ handle, INT count, LPVOID buffer );
static BOOL FONT_DeleteObject( HGDIOBJ handle ); static BOOL FONT_DeleteObject( HGDIOBJ handle );
static const struct gdi_obj_funcs fontobj_funcs = static const struct gdi_obj_funcs fontobj_funcs =
{ {
FONT_GetObjectA, /* pGetObjectA */
FONT_GetObjectW, /* pGetObjectW */ FONT_GetObjectW, /* pGetObjectW */
NULL, /* pUnrealizeObject */ NULL, /* pUnrealizeObject */
FONT_DeleteObject /* pDeleteObject */ FONT_DeleteObject /* pDeleteObject */
@ -4567,26 +4565,6 @@ HGDIOBJ WINAPI NtGdiSelectFont( HDC hdc, HGDIOBJ handle )
} }
/***********************************************************************
* FONT_GetObjectA
*/
static INT FONT_GetObjectA( HGDIOBJ handle, INT count, LPVOID buffer )
{
FONTOBJ *font = GDI_GetObjPtr( handle, OBJ_FONT );
LOGFONTA lfA;
if (!font) return 0;
if (buffer)
{
FONT_LogFontWToA( &font->logfont, &lfA );
if (count > sizeof(lfA)) count = sizeof(lfA);
memcpy( buffer, &lfA, count );
}
else count = sizeof(lfA);
GDI_ReleaseObj( handle );
return count;
}
/*********************************************************************** /***********************************************************************
* FONT_GetObjectW * FONT_GetObjectW
*/ */

View File

@ -50,7 +50,6 @@ typedef struct {
struct gdi_obj_funcs struct gdi_obj_funcs
{ {
INT (*pGetObjectA)( HGDIOBJ handle, INT count, LPVOID buffer );
INT (*pGetObjectW)( HGDIOBJ handle, INT count, LPVOID buffer ); INT (*pGetObjectW)( HGDIOBJ handle, INT count, LPVOID buffer );
BOOL (*pUnrealizeObject)( HGDIOBJ handle ); BOOL (*pUnrealizeObject)( HGDIOBJ handle );
BOOL (*pDeleteObject)( HGDIOBJ handle ); BOOL (*pDeleteObject)( HGDIOBJ handle );

View File

@ -1028,37 +1028,6 @@ HGDIOBJ WINAPI GetStockObject( INT obj )
} }
/***********************************************************************
* GetObjectA (GDI32.@)
*/
INT WINAPI GetObjectA( HGDIOBJ handle, INT count, LPVOID buffer )
{
GDI_HANDLE_ENTRY *entry;
const struct gdi_obj_funcs *funcs = NULL;
INT result = 0;
TRACE("%p %d %p\n", handle, count, buffer );
EnterCriticalSection( &gdi_section );
if ((entry = handle_entry( handle )))
{
funcs = entry_obj( entry )->funcs;
handle = entry_to_handle( entry ); /* make it a full handle */
}
LeaveCriticalSection( &gdi_section );
if (funcs)
{
if (!funcs->pGetObjectA)
SetLastError( ERROR_INVALID_HANDLE );
else if (buffer && ((ULONG_PTR)buffer >> 16) == 0) /* catch apps getting argument order wrong */
SetLastError( ERROR_NOACCESS );
else
result = funcs->pGetObjectA( handle, count, buffer );
}
return result;
}
/*********************************************************************** /***********************************************************************
* NtGdiExtGetObjectW (win32u.@) * NtGdiExtGetObjectW (win32u.@)
*/ */

View File

@ -23,6 +23,7 @@
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "winnls.h"
#include "ntgdi.h" #include "ntgdi.h"
#include "winternl.h" #include "winternl.h"
@ -140,3 +141,31 @@ INT WINAPI GetObjectW( HGDIOBJ handle, INT count, void *buffer )
} }
return result; return result;
} }
/***********************************************************************
* GetObjectA (GDI32.@)
*/
INT WINAPI GetObjectA( HGDIOBJ handle, INT count, void *buffer )
{
TRACE("%p %d %p\n", handle, count, buffer );
if (get_object_type( handle ) == OBJ_FONT)
{
LOGFONTA *lfA = buffer;
LOGFONTW lf;
if (!buffer) return sizeof(*lfA);
if (!GetObjectW( handle, sizeof(lf), &lf )) return 0;
if (count > sizeof(*lfA)) count = sizeof(*lfA);
memcpy( lfA, &lf, min( count, FIELD_OFFSET(LOGFONTA, lfFaceName) ));
if (count > FIELD_OFFSET(LOGFONTA, lfFaceName))
{
WideCharToMultiByte( CP_ACP, 0, lf.lfFaceName, -1, lfA->lfFaceName,
count - FIELD_OFFSET(LOGFONTA, lfFaceName), NULL, NULL );
if (count == sizeof(*lfA)) lfA->lfFaceName[LF_FACESIZE - 1] = 0;
}
return count;
}
return GetObjectW( handle, count, buffer );
}

View File

@ -55,7 +55,6 @@ static BOOL PALETTE_DeleteObject( HGDIOBJ handle );
static const struct gdi_obj_funcs palette_funcs = static const struct gdi_obj_funcs palette_funcs =
{ {
PALETTE_GetObject, /* pGetObjectA */
PALETTE_GetObject, /* pGetObjectW */ PALETTE_GetObject, /* pGetObjectW */
PALETTE_UnrealizeObject, /* pUnrealizeObject */ PALETTE_UnrealizeObject, /* pUnrealizeObject */
PALETTE_DeleteObject /* pDeleteObject */ PALETTE_DeleteObject /* pDeleteObject */

View File

@ -45,7 +45,6 @@ static BOOL PEN_DeleteObject( HGDIOBJ handle );
static const struct gdi_obj_funcs pen_funcs = static const struct gdi_obj_funcs pen_funcs =
{ {
PEN_GetObject, /* pGetObjectA */
PEN_GetObject, /* pGetObjectW */ PEN_GetObject, /* pGetObjectW */
NULL, /* pUnrealizeObject */ NULL, /* pUnrealizeObject */
PEN_DeleteObject /* pDeleteObject */ PEN_DeleteObject /* pDeleteObject */

View File

@ -111,7 +111,6 @@ static BOOL REGION_DeleteObject( HGDIOBJ handle );
static const struct gdi_obj_funcs region_funcs = static const struct gdi_obj_funcs region_funcs =
{ {
NULL, /* pGetObjectA */
NULL, /* pGetObjectW */ NULL, /* pGetObjectW */
NULL, /* pUnrealizeObject */ NULL, /* pUnrealizeObject */
REGION_DeleteObject /* pDeleteObject */ REGION_DeleteObject /* pDeleteObject */