From 6c428e5c07705d556af16745b587d24a68d3dd08 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Fri, 22 Nov 2002 21:58:03 +0000 Subject: [PATCH] Fixed a number of -DSTRICT issues. --- dlls/gdi/printdrv.c | 13 ++++--- objects/clipping.c | 26 ++++++++------ objects/dc.c | 83 ++++++++++++++++++++++++++++++--------------- objects/gdiobj.c | 30 ++++++++++------ objects/metafile.c | 2 +- 5 files changed, 99 insertions(+), 55 deletions(-) diff --git a/dlls/gdi/printdrv.c b/dlls/gdi/printdrv.c index dd79c94b68e..22a7eead03e 100644 --- a/dlls/gdi/printdrv.c +++ b/dlls/gdi/printdrv.c @@ -43,6 +43,7 @@ #include "winspool.h" #include "winerror.h" #include "winreg.h" +#include "wownt32.h" #include "wine/debug.h" #include "gdi.h" #include "heap.h" @@ -153,13 +154,15 @@ INT WINAPI StartPage(HDC hdc) */ INT WINAPI EndPage(HDC hdc) { + ABORTPROC abort_proc; INT ret = 0; DC *dc = DC_GetDCPtr( hdc ); if(!dc) return SP_ERROR; if (dc->funcs->pEndPage) ret = dc->funcs->pEndPage( dc->physDev ); + abort_proc = dc->pAbortProc; GDI_ReleaseObj( hdc ); - if (!QueryAbort16( hdc, 0 )) + if (abort_proc && !abort_proc( hdc, 0 )) { EndDoc( hdc ); ret = 0; @@ -191,9 +194,10 @@ INT WINAPI AbortDoc(HDC hdc) * TRUE if no AbortProc avail or AbortProc wants to continue printing. * FALSE if AbortProc wants to abort printing. */ -BOOL16 WINAPI QueryAbort16(HDC16 hdc, INT16 reserved) +BOOL16 WINAPI QueryAbort16(HDC16 hdc16, INT16 reserved) { BOOL ret = TRUE; + HDC hdc = HDC_32( hdc16 ); DC *dc = DC_GetDCPtr( hdc ); ABORTPROC abproc; @@ -225,7 +229,7 @@ static BOOL CALLBACK call_abort_proc16( HDC hdc, INT code ) if (!dc) return FALSE; proc16 = dc->pAbortProc16; GDI_ReleaseObj( hdc ); - if (proc16) return PRTDRV_CallTo16_word_ww( (FARPROC16)proc16, hdc, code ); + if (proc16) return PRTDRV_CallTo16_word_ww( (FARPROC16)proc16, HDC_16(hdc), code ); return TRUE; } @@ -233,8 +237,9 @@ static BOOL CALLBACK call_abort_proc16( HDC hdc, INT code ) /********************************************************************** * SetAbortProc (GDI.381) */ -INT16 WINAPI SetAbortProc16(HDC16 hdc, ABORTPROC16 abrtprc) +INT16 WINAPI SetAbortProc16(HDC16 hdc16, ABORTPROC16 abrtprc) { + HDC hdc = HDC_32( hdc16 ); DC *dc = DC_GetDCPtr( hdc ); if (!dc) return FALSE; diff --git a/objects/clipping.c b/objects/clipping.c index 499de2e113b..6ec00609840 100644 --- a/objects/clipping.c +++ b/objects/clipping.c @@ -120,9 +120,10 @@ INT WINAPI ExtSelectClipRgn( HDC hdc, HRGN hrgn, INT fnMode ) /*********************************************************************** * SelectVisRgn (GDI.105) */ -INT16 WINAPI SelectVisRgn16( HDC16 hdc, HRGN16 hrgn ) +INT16 WINAPI SelectVisRgn16( HDC16 hdc16, HRGN16 hrgn ) { int retval; + HDC hdc = HDC_32( hdc16 ); DC * dc; if (!hrgn) return ERROR; @@ -164,9 +165,10 @@ INT WINAPI OffsetClipRgn( HDC hdc, INT x, INT y ) /*********************************************************************** * OffsetVisRgn (GDI.102) */ -INT16 WINAPI OffsetVisRgn16( HDC16 hdc, INT16 x, INT16 y ) +INT16 WINAPI OffsetVisRgn16( HDC16 hdc16, INT16 x, INT16 y ) { INT16 retval; + HDC hdc = HDC_32( hdc16 ); DC * dc = DC_GetDCUpdate( hdc ); if (!dc) return ERROR; TRACE("%04x %d,%d\n", hdc, x, y ); @@ -269,12 +271,12 @@ INT WINAPI IntersectClipRect( HDC hdc, INT left, INT top, INT right, INT bottom /*********************************************************************** * ExcludeVisRect (GDI.73) */ -INT16 WINAPI ExcludeVisRect16( HDC16 hdc, INT16 left, INT16 top, - INT16 right, INT16 bottom ) +INT16 WINAPI ExcludeVisRect16( HDC16 hdc16, INT16 left, INT16 top, INT16 right, INT16 bottom ) { HRGN tempRgn; INT16 ret; POINT pt[2]; + HDC hdc = HDC_32( hdc16 ); DC * dc = DC_GetDCUpdate( hdc ); if (!dc) return ERROR; @@ -302,12 +304,12 @@ INT16 WINAPI ExcludeVisRect16( HDC16 hdc, INT16 left, INT16 top, /*********************************************************************** * IntersectVisRect (GDI.98) */ -INT16 WINAPI IntersectVisRect16( HDC16 hdc, INT16 left, INT16 top, - INT16 right, INT16 bottom ) +INT16 WINAPI IntersectVisRect16( HDC16 hdc16, INT16 left, INT16 top, INT16 right, INT16 bottom ) { HRGN tempRgn; INT16 ret; POINT pt[2]; + HDC hdc = HDC_32( hdc16 ); DC * dc = DC_GetDCUpdate( hdc ); if (!dc) return ERROR; @@ -425,10 +427,11 @@ INT WINAPI GetClipRgn( HDC hdc, HRGN hRgn ) /*********************************************************************** * SaveVisRgn (GDI.129) */ -HRGN16 WINAPI SaveVisRgn16( HDC16 hdc ) +HRGN16 WINAPI SaveVisRgn16( HDC16 hdc16 ) { HRGN copy; GDIOBJHDR *obj, *copyObj; + HDC hdc = HDC_32( hdc16 ); DC *dc = DC_GetDCUpdate( hdc ); if (!dc) return 0; @@ -454,21 +457,22 @@ HRGN16 WINAPI SaveVisRgn16( HDC16 hdc ) return 0; } copyObj->hNext = obj->hNext; - obj->hNext = copy; + obj->hNext = HRGN_16(copy); GDI_ReleaseObj( copy ); GDI_ReleaseObj( dc->hVisRgn ); GDI_ReleaseObj( hdc ); - return copy; + return HRGN_16(copy); } /*********************************************************************** * RestoreVisRgn (GDI.130) */ -INT16 WINAPI RestoreVisRgn16( HDC16 hdc ) +INT16 WINAPI RestoreVisRgn16( HDC16 hdc16 ) { HRGN saved; GDIOBJHDR *obj, *savedObj; + HDC hdc = HDC_32( hdc16 ); DC *dc = DC_GetDCPtr( hdc ); INT16 ret = ERROR; @@ -477,7 +481,7 @@ INT16 WINAPI RestoreVisRgn16( HDC16 hdc ) TRACE("%04x\n", hdc ); if (!(obj = GDI_GetObjPtr( dc->hVisRgn, REGION_MAGIC ))) goto done; - saved = obj->hNext; + saved = HRGN_32(obj->hNext); if ((savedObj = GDI_GetObjPtr( saved, REGION_MAGIC ))) { diff --git a/objects/dc.c b/objects/dc.c index 4f19464ef48..de150816916 100644 --- a/objects/dc.c +++ b/objects/dc.c @@ -22,14 +22,15 @@ #include #include -#include "gdi.h" -#include "heap.h" -#include "wine/debug.h" -#include "font.h" -#include "winerror.h" #include "windef.h" #include "wingdi.h" +#include "winerror.h" +#include "wownt32.h" #include "wine/winuser16.h" +#include "gdi.h" +#include "heap.h" +#include "font.h" +#include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(dc); @@ -57,7 +58,7 @@ DC *DC_AllocDC( const DC_FUNCTIONS *funcs ) HDC hdc; DC *dc; - if (!(dc = GDI_AllocObject( sizeof(*dc), DC_MAGIC, &hdc, &dc_funcs ))) return NULL; + if (!(dc = GDI_AllocObject( sizeof(*dc), DC_MAGIC, (HGDIOBJ*)&hdc, &dc_funcs ))) return NULL; dc->hSelf = hdc; dc->funcs = funcs; @@ -163,7 +164,7 @@ DC *DC_GetDCUpdate( HDC hdc ) { DWORD data = dc->dwHookData; GDI_ReleaseObj( hdc ); - proc( hdc, DCHC_INVALIDVISRGN, data, 0 ); + proc( HDC_16(hdc), DCHC_INVALIDVISRGN, data, 0 ); if (!(dc = DC_GetDCPtr( hdc ))) break; /* otherwise restart the loop in case it became dirty again in the meantime */ } @@ -190,7 +191,7 @@ static BOOL DC_DeleteObject( HGDIOBJ handle, void *obj ) */ void DC_InitDC( DC* dc ) { - RealizeDefaultPalette16( dc->hSelf ); + if (dc->funcs->pRealizeDefaultPalette) dc->funcs->pRealizeDefaultPalette( dc->physDev ); SetTextColor( dc->hSelf, dc->textColor ); SetBkColor( dc->hSelf, dc->backgroundColor ); SelectObject( dc->hSelf, dc->hPen ); @@ -267,9 +268,9 @@ void DC_UpdateXforms( DC *dc ) /*********************************************************************** - * GetDCState (GDI.179) + * GetDCState (Not a Windows API) */ -HDC16 WINAPI GetDCState16( HDC16 hdc ) +HDC WINAPI GetDCState( HDC hdc ) { DC * newdc, * dc; HGDIOBJ handle; @@ -356,9 +357,9 @@ HDC16 WINAPI GetDCState16( HDC16 hdc ) /*********************************************************************** - * SetDCState (GDI.180) + * SetDCState (Not a Windows API) */ -void WINAPI SetDCState16( HDC16 hdc, HDC16 hdcs ) +void WINAPI SetDCState( HDC hdc, HDC hdcs ) { DC *dc, *dcs; @@ -439,6 +440,24 @@ void WINAPI SetDCState16( HDC16 hdc, HDC16 hdcs ) } +/*********************************************************************** + * GetDCState (GDI.179) + */ +HDC16 WINAPI GetDCState16( HDC16 hdc ) +{ + return HDC_16( GetDCState( HDC_32(hdc) )); +} + + +/*********************************************************************** + * SetDCState (GDI.180) + */ +void WINAPI SetDCState16( HDC16 hdc, HDC16 hdcs ) +{ + SetDCState( HDC_32(hdc), HDC_32(hdcs) ); +} + + /*********************************************************************** * SaveDC (GDI32.@) */ @@ -458,7 +477,7 @@ INT WINAPI SaveDC( HDC hdc ) return ret; } - if (!(hdcs = GetDCState16( hdc ))) + if (!(hdcs = GetDCState( hdc ))) { GDI_ReleaseObj( hdc ); return 0; @@ -480,7 +499,7 @@ INT WINAPI SaveDC( HDC hdc ) } dcs->header.hNext = dc->header.hNext; - dc->header.hNext = hdcs; + dc->header.hNext = HDC_16(hdcs); TRACE("(%04x): returning %d\n", hdc, dc->saveLevel+1 ); ret = ++dc->saveLevel; GDI_ReleaseObj( hdcs ); @@ -523,7 +542,7 @@ BOOL WINAPI RestoreDC( HDC hdc, INT level ) success=TRUE; while (dc->saveLevel >= level) { - HDC16 hdcs = dc->header.hNext; + HDC hdcs = HDC_32(dc->header.hNext); if (!(dcs = DC_GetDCPtr( hdcs ))) { GDI_ReleaseObj( hdc ); @@ -532,7 +551,7 @@ BOOL WINAPI RestoreDC( HDC hdc, INT level ) dc->header.hNext = dcs->header.hNext; if (--dc->saveLevel < level) { - SetDCState16( hdc, hdcs ); + SetDCState( hdc, hdcs ); if (!PATH_AssignGdiPath( &dc->path, &dcs->path )) /* FIXME: This might not be quite right, since we're * returning FALSE but still destroying the saved DC state */ @@ -728,7 +747,7 @@ BOOL WINAPI DeleteDC( HDC hdc ) { DWORD data = dc->dwHookData; GDI_ReleaseObj( hdc ); - if (!proc( hdc, DCHC_DELETEDC, data, 0 )) return FALSE; + if (!proc( HDC_16(hdc), DCHC_DELETEDC, data, 0 )) return FALSE; if (!(dc = DC_GetDCPtr( hdc ))) return TRUE; /* deleted by the hook */ } } @@ -736,7 +755,7 @@ BOOL WINAPI DeleteDC( HDC hdc ) while (dc->saveLevel) { DC * dcs; - HDC16 hdcs = dc->header.hNext; + HDC hdcs = HDC_32(dc->header.hNext); if (!(dcs = DC_GetDCPtr( hdcs ))) break; dc->header.hNext = dcs->header.hNext; dc->saveLevel--; @@ -900,9 +919,10 @@ BOOL WINAPI GetDCOrgEx( HDC hDC, LPPOINT lpp ) /*********************************************************************** * SetDCOrg (GDI.117) */ -DWORD WINAPI SetDCOrg16( HDC16 hdc, INT16 x, INT16 y ) +DWORD WINAPI SetDCOrg16( HDC16 hdc16, INT16 x, INT16 y ) { DWORD prevOrg = 0; + HDC hdc = HDC_32( hdc16 ); DC *dc = DC_GetDCPtr( hdc ); if (!dc) return 0; if (dc->funcs->pSetDCOrg) prevOrg = dc->funcs->pSetDCOrg( dc->physDev, x, y ); @@ -1126,22 +1146,24 @@ BOOL WINAPI SetDCHook( HDC hdc, DCHOOKPROC hookProc, DWORD dwHookData ) /* relay function to call the 16-bit DC hook proc */ -static BOOL16 WINAPI call_dc_hook16( HDC16 hdc, WORD code, DWORD data, LPARAM lParam ) +static BOOL16 WINAPI call_dc_hook16( HDC16 hdc16, WORD code, DWORD data, LPARAM lParam ) { FARPROC16 proc = NULL; + HDC hdc = HDC_32( hdc16 ); DC *dc = DC_GetDCPtr( hdc ); if (!dc) return FALSE; proc = dc->hookProc; GDI_ReleaseObj( hdc ); if (!proc) return FALSE; - return GDI_CallTo16_word_wwll( proc, hdc, code, data, lParam ); + return GDI_CallTo16_word_wwll( proc, hdc16, code, data, lParam ); } /*********************************************************************** * SetDCHook (GDI.190) */ -BOOL16 WINAPI SetDCHook16( HDC16 hdc, FARPROC16 hookProc, DWORD dwHookData ) +BOOL16 WINAPI SetDCHook16( HDC16 hdc16, FARPROC16 hookProc, DWORD dwHookData ) { + HDC hdc = HDC_32( hdc16 ); DC *dc = DC_GetDCPtr( hdc ); if (!dc) return FALSE; @@ -1154,22 +1176,27 @@ BOOL16 WINAPI SetDCHook16( HDC16 hdc, FARPROC16 hookProc, DWORD dwHookData ) /*********************************************************************** * GetDCHook (GDI.191) */ -DWORD WINAPI GetDCHook16( HDC16 hdc, FARPROC16 *phookProc ) +DWORD WINAPI GetDCHook16( HDC16 hdc16, FARPROC16 *phookProc ) { + HDC hdc = HDC_32( hdc16 ); DC *dc = DC_GetDCPtr( hdc ); + DWORD ret; + if (!dc) return 0; *phookProc = dc->hookProc; + ret = dc->dwHookData; GDI_ReleaseObj( hdc ); - return dc->dwHookData; + return ret; } /*********************************************************************** * SetHookFlags (GDI.192) */ -WORD WINAPI SetHookFlags16(HDC16 hDC, WORD flags) +WORD WINAPI SetHookFlags16(HDC16 hdc16, WORD flags) { - DC *dc = DC_GetDCPtr( hDC ); + HDC hdc = HDC_32( hdc16 ); + DC *dc = DC_GetDCPtr( hdc ); if( dc ) { @@ -1178,13 +1205,13 @@ WORD WINAPI SetHookFlags16(HDC16 hDC, WORD flags) /* "Undocumented Windows" info is slightly confusing. */ - TRACE("hDC %04x, flags %04x\n",hDC,flags); + TRACE("hDC %04x, flags %04x\n",hdc,flags); if( flags & DCHF_INVALIDATEVISRGN ) dc->flags |= DC_DIRTY; else if( flags & DCHF_VALIDATEVISRGN || !flags ) dc->flags &= ~DC_DIRTY; - GDI_ReleaseObj( hDC ); + GDI_ReleaseObj( hdc ); return wRet; } return 0; diff --git a/objects/gdiobj.c b/objects/gdiobj.c index d25f7736e0d..f388158e9d9 100644 --- a/objects/gdiobj.c +++ b/objects/gdiobj.c @@ -38,6 +38,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(gdi); +#define HGDIOBJ_32(h16) ((HGDIOBJ)(ULONG_PTR)(h16)) /*********************************************************************** * GDI stock objects @@ -724,11 +725,12 @@ void *GDI_ReallocObject( WORD size, HGDIOBJ handle, void *object ) if ((UINT_PTR)handle & 2) /* GDI heap handle */ { - LOCAL_Unlock( GDI_HeapSel, handle ); - if ((new_handle = LOCAL_ReAlloc( GDI_HeapSel, handle, size, LMEM_MOVEABLE ))) + HLOCAL16 h = LOWORD(handle); + LOCAL_Unlock( GDI_HeapSel, h ); + if ((new_handle = (HGDIOBJ)(ULONG_PTR)LOCAL_ReAlloc( GDI_HeapSel, h, size, LMEM_MOVEABLE ))) { assert( new_handle == handle ); /* moveable handle cannot change */ - return LOCAL_Lock( GDI_HeapSel, handle ); + return LOCAL_Lock( GDI_HeapSel, h ); } } else @@ -762,8 +764,9 @@ BOOL GDI_FreeObject( HGDIOBJ handle, void *ptr ) object->funcs = NULL; if ((UINT_PTR)handle & 2) /* GDI heap handle */ { - LOCAL_Unlock( GDI_HeapSel, handle ); - LOCAL_Free( GDI_HeapSel, handle ); + HLOCAL16 h = LOWORD(handle); + LOCAL_Unlock( GDI_HeapSel, h ); + LOCAL_Free( GDI_HeapSel, h ); } else /* large heap handle */ { @@ -796,14 +799,15 @@ void *GDI_GetObjPtr( HGDIOBJ handle, WORD magic ) if ((UINT_PTR)handle & 2) /* GDI heap handle */ { - ptr = (GDIOBJHDR *)LOCAL_Lock( GDI_HeapSel, handle ); + HLOCAL16 h = LOWORD(handle); + ptr = (GDIOBJHDR *)LOCAL_Lock( GDI_HeapSel, h ); if (ptr) { if (((magic != MAGIC_DONTCARE) && (GDIMAGIC(ptr->wMagic) != magic)) || (GDIMAGIC(ptr->wMagic) < FIRST_MAGIC) || (GDIMAGIC(ptr->wMagic) > LAST_MAGIC)) { - LOCAL_Unlock( GDI_HeapSel, handle ); + LOCAL_Unlock( GDI_HeapSel, h ); ptr = NULL; } } @@ -836,7 +840,7 @@ void *GDI_GetObjPtr( HGDIOBJ handle, WORD magic ) */ void GDI_ReleaseObj( HGDIOBJ handle ) { - if ((UINT_PTR)handle & 2) LOCAL_Unlock( GDI_HeapSel, handle ); + if ((UINT_PTR)handle & 2) LOCAL_Unlock( GDI_HeapSel, LOWORD(handle) ); TRACE_SEC( handle, "leave" ); _LeaveSysLevel( &GDI_level ); } @@ -907,10 +911,12 @@ HGDIOBJ WINAPI GetStockObject( INT obj ) /*********************************************************************** * GetObject (GDI.82) */ -INT16 WINAPI GetObject16( HANDLE16 handle, INT16 count, LPVOID buffer ) +INT16 WINAPI GetObject16( HANDLE16 handle16, INT16 count, LPVOID buffer ) { GDIOBJHDR * ptr; + HGDIOBJ handle = HGDIOBJ_32( handle16 ); INT16 result = 0; + TRACE("%04x %d %p\n", handle, count, buffer ); if (!count) return 0; @@ -1182,9 +1188,10 @@ INT WINAPI EnumObjects( HDC hdc, INT nObjType, * * returns type of object if valid (W95 system programming secrets p. 264-5) */ -BOOL16 WINAPI IsGDIObject16( HGDIOBJ16 handle ) +BOOL16 WINAPI IsGDIObject16( HGDIOBJ16 handle16 ) { UINT16 magic = 0; + HGDIOBJ handle = HGDIOBJ_32( handle16 ); GDIOBJHDR *object = GDI_GetObjPtr( handle, MAGIC_DONTCARE ); if (object) @@ -1215,8 +1222,9 @@ void WINAPI SetObjectOwner( HGDIOBJ handle, HANDLE owner ) * with 0x2000 (OBJECT_PRIVATE), so we just do it. * But Wine doesn't react on that yet. */ -void WINAPI MakeObjectPrivate16( HGDIOBJ16 handle, BOOL16 private ) +void WINAPI MakeObjectPrivate16( HGDIOBJ16 handle16, BOOL16 private ) { + HGDIOBJ handle = HGDIOBJ_32( handle16 ); GDIOBJHDR *ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE ); if (!ptr) { diff --git a/objects/metafile.c b/objects/metafile.c index 2af7bea1031..0af65bc47c0 100644 --- a/objects/metafile.c +++ b/objects/metafile.c @@ -688,7 +688,7 @@ BOOL16 WINAPI EnumMetaFile16( HDC16 hdc16, HMETAFILE16 hmf, /* free objects in handle table */ for(i = 0; i < mh->mtNoObjects; i++) if(*(ht->objectHandle + i) != 0) - DeleteObject(*(ht->objectHandle + i)); + DeleteObject( (HGDIOBJ)(ULONG_PTR)(*(ht->objectHandle + i) )); /* free handle table */ GlobalFree16(hHT);