Jacek Caban : gdi32: Reimplement GetObjectA on top of GetObjectW.
Alexandre Julliard
julliard at winehq.org
Mon Jul 5 16:24:19 CDT 2021
Module: wine
Branch: master
Commit: 3dcb5db47f6f5b35443386cbd64bb614b672eb1a
URL: https://source.winehq.org/git/wine.git/?a=commit;h=3dcb5db47f6f5b35443386cbd64bb614b672eb1a
Author: Jacek Caban <jacek at codeweavers.com>
Date: Mon Jul 5 13:40:00 2021 +0200
gdi32: Reimplement GetObjectA on top of GetObjectW.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/gdi32/bitmap.c | 1 -
dlls/gdi32/brush.c | 1 -
dlls/gdi32/dc.c | 1 -
dlls/gdi32/dib.c | 1 -
dlls/gdi32/font.c | 22 ----------------------
dlls/gdi32/gdi_private.h | 1 -
dlls/gdi32/gdiobj.c | 31 -------------------------------
dlls/gdi32/objects.c | 29 +++++++++++++++++++++++++++++
dlls/gdi32/palette.c | 1 -
dlls/gdi32/pen.c | 1 -
dlls/gdi32/region.c | 1 -
11 files changed, 29 insertions(+), 61 deletions(-)
diff --git a/dlls/gdi32/bitmap.c b/dlls/gdi32/bitmap.c
index d1805beb99c..aaad76dce36 100644
--- a/dlls/gdi32/bitmap.c
+++ b/dlls/gdi32/bitmap.c
@@ -37,7 +37,6 @@ static BOOL BITMAP_DeleteObject( HGDIOBJ handle );
static const struct gdi_obj_funcs bitmap_funcs =
{
- BITMAP_GetObject, /* pGetObjectA */
BITMAP_GetObject, /* pGetObjectW */
NULL, /* pUnrealizeObject */
BITMAP_DeleteObject /* pDeleteObject */
diff --git a/dlls/gdi32/brush.c b/dlls/gdi32/brush.c
index c7b80479594..1d4e45952c9 100644
--- a/dlls/gdi32/brush.c
+++ b/dlls/gdi32/brush.c
@@ -44,7 +44,6 @@ static BOOL BRUSH_DeleteObject( HGDIOBJ handle );
static const struct gdi_obj_funcs brush_funcs =
{
- BRUSH_GetObject, /* pGetObjectA */
BRUSH_GetObject, /* pGetObjectW */
NULL, /* pUnrealizeObject */
BRUSH_DeleteObject /* pDeleteObject */
diff --git a/dlls/gdi32/dc.c b/dlls/gdi32/dc.c
index d96285c6520..861bc97a78e 100644
--- a/dlls/gdi32/dc.c
+++ b/dlls/gdi32/dc.c
@@ -38,7 +38,6 @@ static BOOL DC_DeleteObject( HGDIOBJ handle );
static const struct gdi_obj_funcs dc_funcs =
{
- NULL, /* pGetObjectA */
NULL, /* pGetObjectW */
NULL, /* pUnrealizeObject */
DC_DeleteObject /* pDeleteObject */
diff --git a/dlls/gdi32/dib.c b/dlls/gdi32/dib.c
index 069b9e77a28..e8d99ac415d 100644
--- a/dlls/gdi32/dib.c
+++ b/dlls/gdi32/dib.c
@@ -83,7 +83,6 @@ static BOOL DIB_DeleteObject( HGDIOBJ handle );
static const struct gdi_obj_funcs dib_funcs =
{
- DIB_GetObject, /* pGetObjectA */
DIB_GetObject, /* pGetObjectW */
NULL, /* pUnrealizeObject */
DIB_DeleteObject /* pDeleteObject */
diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c
index 2a51e3f7411..39f2a76255a 100644
--- a/dlls/gdi32/font.c
+++ b/dlls/gdi32/font.c
@@ -180,13 +180,11 @@ static inline WCHAR *strdupW( const WCHAR *p )
return ret;
}
-static INT FONT_GetObjectA( HGDIOBJ handle, INT count, LPVOID buffer );
static INT FONT_GetObjectW( HGDIOBJ handle, INT count, LPVOID buffer );
static BOOL FONT_DeleteObject( HGDIOBJ handle );
static const struct gdi_obj_funcs fontobj_funcs =
{
- FONT_GetObjectA, /* pGetObjectA */
FONT_GetObjectW, /* pGetObjectW */
NULL, /* pUnrealizeObject */
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
*/
diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h
index a4bc141811f..02e4c9d26b0 100644
--- a/dlls/gdi32/gdi_private.h
+++ b/dlls/gdi32/gdi_private.h
@@ -50,7 +50,6 @@ typedef struct {
struct gdi_obj_funcs
{
- INT (*pGetObjectA)( HGDIOBJ handle, INT count, LPVOID buffer );
INT (*pGetObjectW)( HGDIOBJ handle, INT count, LPVOID buffer );
BOOL (*pUnrealizeObject)( HGDIOBJ handle );
BOOL (*pDeleteObject)( HGDIOBJ handle );
diff --git a/dlls/gdi32/gdiobj.c b/dlls/gdi32/gdiobj.c
index 67c2ddc19e6..af74071aa6d 100644
--- a/dlls/gdi32/gdiobj.c
+++ b/dlls/gdi32/gdiobj.c
@@ -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.@)
*/
diff --git a/dlls/gdi32/objects.c b/dlls/gdi32/objects.c
index af1e2a19f06..664dcf4f043 100644
--- a/dlls/gdi32/objects.c
+++ b/dlls/gdi32/objects.c
@@ -23,6 +23,7 @@
#include "windef.h"
#include "winbase.h"
+#include "winnls.h"
#include "ntgdi.h"
#include "winternl.h"
@@ -140,3 +141,31 @@ INT WINAPI GetObjectW( HGDIOBJ handle, INT count, void *buffer )
}
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 );
+}
diff --git a/dlls/gdi32/palette.c b/dlls/gdi32/palette.c
index f9d5851d20e..8584011bda8 100644
--- a/dlls/gdi32/palette.c
+++ b/dlls/gdi32/palette.c
@@ -55,7 +55,6 @@ static BOOL PALETTE_DeleteObject( HGDIOBJ handle );
static const struct gdi_obj_funcs palette_funcs =
{
- PALETTE_GetObject, /* pGetObjectA */
PALETTE_GetObject, /* pGetObjectW */
PALETTE_UnrealizeObject, /* pUnrealizeObject */
PALETTE_DeleteObject /* pDeleteObject */
diff --git a/dlls/gdi32/pen.c b/dlls/gdi32/pen.c
index 0cc242ead5a..8a01125b390 100644
--- a/dlls/gdi32/pen.c
+++ b/dlls/gdi32/pen.c
@@ -45,7 +45,6 @@ static BOOL PEN_DeleteObject( HGDIOBJ handle );
static const struct gdi_obj_funcs pen_funcs =
{
- PEN_GetObject, /* pGetObjectA */
PEN_GetObject, /* pGetObjectW */
NULL, /* pUnrealizeObject */
PEN_DeleteObject /* pDeleteObject */
diff --git a/dlls/gdi32/region.c b/dlls/gdi32/region.c
index 3d0f9cfc211..2e90e82180e 100644
--- a/dlls/gdi32/region.c
+++ b/dlls/gdi32/region.c
@@ -111,7 +111,6 @@ static BOOL REGION_DeleteObject( HGDIOBJ handle );
static const struct gdi_obj_funcs region_funcs =
{
- NULL, /* pGetObjectA */
NULL, /* pGetObjectW */
NULL, /* pUnrealizeObject */
REGION_DeleteObject /* pDeleteObject */
More information about the wine-cvs
mailing list