Commit 7d155d67 authored by Alexandre Julliard's avatar Alexandre Julliard

Changed DC hook and abort proc handling to avoid having to allocate

thunks dynamically.
parent f12e130f
...@@ -421,3 +421,4 @@ debug_channels (bitblt bitmap clipping dc ddraw driver enhmetafile font gdi ...@@ -421,3 +421,4 @@ debug_channels (bitblt bitmap clipping dc ddraw driver enhmetafile font gdi
# #
@ stdcall CreateMetaFile16(str) CreateMetaFile16 @ stdcall CreateMetaFile16(str) CreateMetaFile16
@ stdcall CloseMetaFile16(long) CloseMetaFile16 @ stdcall CloseMetaFile16(long) CloseMetaFile16
@ stdcall SetDCHook(long ptr long) SetDCHook
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include "winbase.h" #include "winbase.h"
#include "winuser.h"
#include "wine/winbase16.h" #include "wine/winbase16.h"
#include "wine/wingdi16.h" #include "wine/wingdi16.h"
#include "winspool.h" #include "winspool.h"
...@@ -24,7 +25,6 @@ ...@@ -24,7 +25,6 @@
#include "winreg.h" #include "winreg.h"
#include "debugtools.h" #include "debugtools.h"
#include "gdi.h" #include "gdi.h"
#include "callback.h"
#include "heap.h" #include "heap.h"
#include "file.h" #include "file.h"
...@@ -250,14 +250,32 @@ extern WORD CALLBACK PRTDRV_CallTo16_word_ww(FARPROC16,WORD,WORD); ...@@ -250,14 +250,32 @@ extern WORD CALLBACK PRTDRV_CallTo16_word_ww(FARPROC16,WORD,WORD);
/* ### stop build ### */ /* ### stop build ### */
/********************************************************************** /**********************************************************************
* call_abort_proc16
*/
static BOOL CALLBACK call_abort_proc16( HDC hdc, INT code )
{
ABORTPROC16 proc16;
DC *dc = DC_GetDCPtr( hdc );
if (!dc) return FALSE;
proc16 = dc->pAbortProc16;
GDI_ReleaseObj( hdc );
if (proc16) return PRTDRV_CallTo16_word_ww( (FARPROC16)proc16, hdc, code );
return TRUE;
}
/**********************************************************************
* SetAbortProc (GDI.381) * SetAbortProc (GDI.381)
*
*/ */
INT16 WINAPI SetAbortProc16(HDC16 hdc, SEGPTR abrtprc) INT16 WINAPI SetAbortProc16(HDC16 hdc, ABORTPROC16 abrtprc)
{ {
ABORTPROC proc32 = (ABORTPROC)THUNK_Alloc((FARPROC16)abrtprc, DC *dc = DC_GetDCPtr( hdc );
(RELAY)PRTDRV_CallTo16_word_ww);
return SetAbortProc(hdc, proc32); if (!dc) return FALSE;
dc->pAbortProc16 = abrtprc;
GDI_ReleaseObj( hdc );
return SetAbortProc( hdc, call_abort_proc16 );
} }
/********************************************************************** /**********************************************************************
...@@ -268,7 +286,7 @@ INT WINAPI SetAbortProc(HDC hdc, ABORTPROC abrtprc) ...@@ -268,7 +286,7 @@ INT WINAPI SetAbortProc(HDC hdc, ABORTPROC abrtprc)
{ {
DC *dc = DC_GetDCPtr( hdc ); DC *dc = DC_GetDCPtr( hdc );
if(dc->pAbortProc) THUNK_Free((FARPROC)dc->pAbortProc); if (!dc) return FALSE;
dc->pAbortProc = abrtprc; dc->pAbortProc = abrtprc;
GDI_ReleaseObj( hdc ); GDI_ReleaseObj( hdc );
return TRUE; return TRUE;
......
...@@ -103,7 +103,7 @@ INT16 WINAPI Escape16( HDC16 hdc, INT16 escape, INT16 in_count, ...@@ -103,7 +103,7 @@ INT16 WINAPI Escape16( HDC16 hdc, INT16 escape, INT16 in_count,
/* Escape(hdc,SETABORTPROC,ABORTPROC,NULL); */ /* Escape(hdc,SETABORTPROC,ABORTPROC,NULL); */
case SETABORTPROC: case SETABORTPROC:
return SetAbortProc16( hdc, in_data ); return SetAbortProc16( hdc, (ABORTPROC16)in_data );
/* Escape(hdc,STARTDOC,LPSTR,LPDOCINFO16); /* Escape(hdc,STARTDOC,LPSTR,LPDOCINFO16);
* lpvOutData is actually a pointer to the DocInfo structure and used as * lpvOutData is actually a pointer to the DocInfo structure and used as
......
...@@ -46,8 +46,6 @@ typedef struct tagGDIOBJHDR ...@@ -46,8 +46,6 @@ typedef struct tagGDIOBJHDR
} GDIOBJHDR; } GDIOBJHDR;
typedef BOOL16 CALLBACK (*DCHOOKPROC)(HDC16,WORD,DWORD,LPARAM);
typedef struct tagGdiFont *GdiFont; typedef struct tagGdiFont *GdiFont;
typedef struct tagDC typedef struct tagDC
...@@ -109,6 +107,7 @@ typedef struct tagDC ...@@ -109,6 +107,7 @@ typedef struct tagDC
INT DCOrgX; /* DC origin */ INT DCOrgX; /* DC origin */
INT DCOrgY; INT DCOrgY;
ABORTPROC pAbortProc; /* AbortProc for Printing */ ABORTPROC pAbortProc; /* AbortProc for Printing */
ABORTPROC16 pAbortProc16;
INT CursPosX; /* Current position */ INT CursPosX; /* Current position */
INT CursPosY; INT CursPosY;
INT ArcDirection; INT ArcDirection;
......
...@@ -216,11 +216,13 @@ typedef struct ...@@ -216,11 +216,13 @@ typedef struct
FONTSIGNATURE ntmFontSig; FONTSIGNATURE ntmFontSig;
} NEWTEXTMETRICEX16,*LPNEWTEXTMETRICEX16; } NEWTEXTMETRICEX16,*LPNEWTEXTMETRICEX16;
typedef BOOL16 CALLBACK (*DCHOOKPROC)(HDC16,WORD,DWORD,LPARAM);
typedef INT16 CALLBACK (*FONTENUMPROC16)(SEGPTR,SEGPTR,UINT16,LPARAM); typedef INT16 CALLBACK (*FONTENUMPROC16)(SEGPTR,SEGPTR,UINT16,LPARAM);
typedef INT16 CALLBACK (*FONTENUMPROCEX16)(SEGPTR,SEGPTR,UINT16,LPARAM); typedef INT16 CALLBACK (*FONTENUMPROCEX16)(SEGPTR,SEGPTR,UINT16,LPARAM);
typedef VOID CALLBACK (*LINEDDAPROC16)(INT16,INT16,LPARAM); typedef VOID CALLBACK (*LINEDDAPROC16)(INT16,INT16,LPARAM);
typedef INT16 CALLBACK (*GOBJENUMPROC16)(SEGPTR,LPARAM); typedef INT16 CALLBACK (*GOBJENUMPROC16)(SEGPTR,LPARAM);
typedef struct typedef struct
{ {
UINT16 gmBlackBoxX; UINT16 gmBlackBoxX;
...@@ -505,7 +507,7 @@ BOOL16 WINAPI SelectClipPath16(HDC16,INT16); ...@@ -505,7 +507,7 @@ BOOL16 WINAPI SelectClipPath16(HDC16,INT16);
INT16 WINAPI SelectClipRgn16(HDC16,HRGN16); INT16 WINAPI SelectClipRgn16(HDC16,HRGN16);
HGDIOBJ16 WINAPI SelectObject16(HDC16,HGDIOBJ16); HGDIOBJ16 WINAPI SelectObject16(HDC16,HGDIOBJ16);
INT16 WINAPI SelectVisRgn16(HDC16,HRGN16); INT16 WINAPI SelectVisRgn16(HDC16,HRGN16);
INT16 WINAPI SetAbortProc16(HDC16,SEGPTR); INT16 WINAPI SetAbortProc16(HDC16,ABORTPROC16);
INT16 WINAPI SetArcDirection16(HDC16,INT16); INT16 WINAPI SetArcDirection16(HDC16,INT16);
LONG WINAPI SetBitmapBits16(HBITMAP16,LONG,LPCVOID); LONG WINAPI SetBitmapBits16(HBITMAP16,LONG,LPCVOID);
DWORD WINAPI SetBitmapDimension16(HBITMAP16,INT16,INT16); DWORD WINAPI SetBitmapDimension16(HBITMAP16,INT16,INT16);
...@@ -514,7 +516,8 @@ COLORREF WINAPI SetBkColor16(HDC16,COLORREF); ...@@ -514,7 +516,8 @@ COLORREF WINAPI SetBkColor16(HDC16,COLORREF);
INT16 WINAPI SetBkMode16(HDC16,INT16); INT16 WINAPI SetBkMode16(HDC16,INT16);
UINT16 WINAPI SetBoundsRect16(HDC16,const RECT16*,UINT16); UINT16 WINAPI SetBoundsRect16(HDC16,const RECT16*,UINT16);
DWORD WINAPI SetBrushOrg16(HDC16,INT16,INT16); DWORD WINAPI SetBrushOrg16(HDC16,INT16,INT16);
BOOL16 WINAPI SetDCHook(HDC16,FARPROC16,DWORD); BOOL WINAPI SetDCHook(HDC,DCHOOKPROC,DWORD);
BOOL16 WINAPI SetDCHook16(HDC16,FARPROC16,DWORD);
DWORD WINAPI SetDCOrg16(HDC16,INT16,INT16); DWORD WINAPI SetDCOrg16(HDC16,INT16,INT16);
VOID WINAPI SetDCState16(HDC16,HDC16); VOID WINAPI SetDCState16(HDC16,HDC16);
UINT16 WINAPI SetDIBColorTable16(HDC16,UINT16,UINT16,RGBQUAD*); UINT16 WINAPI SetDIBColorTable16(HDC16,UINT16,UINT16,RGBQUAD*);
......
Makefile Makefile
dc.glue.c dc.glue.c
font.glue.c
gdiobj.glue.c
linedda.glue.c
metafile.glue.c
...@@ -23,7 +23,12 @@ C_SRCS = \ ...@@ -23,7 +23,12 @@ C_SRCS = \
region.c \ region.c \
text.c text.c
GLUE = dc.c GLUE = \
dc.c \
font.c \
gdiobj.c \
linedda.c \
metafile.c
all: $(MODULE).o all: $(MODULE).o
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "heap.h" #include "heap.h"
#include "debugtools.h" #include "debugtools.h"
#include "font.h" #include "font.h"
#include "callback.h"
#include "winerror.h" #include "winerror.h"
#include "windef.h" #include "windef.h"
#include "wingdi.h" #include "wingdi.h"
...@@ -21,6 +20,9 @@ ...@@ -21,6 +20,9 @@
DEFAULT_DEBUG_CHANNEL(dc); DEFAULT_DEBUG_CHANNEL(dc);
/* ### start build ### */
extern WORD CALLBACK GDI_CallTo16_word_wwll(FARPROC16,WORD,WORD,LONG,LONG);
/* ### stop build ### */
/*********************************************************************** /***********************************************************************
* DC_AllocDC * DC_AllocDC
...@@ -773,8 +775,6 @@ BOOL WINAPI DeleteDC( HDC hdc ) ...@@ -773,8 +775,6 @@ BOOL WINAPI DeleteDC( HDC hdc )
if (dc->hClipRgn) DeleteObject( dc->hClipRgn ); if (dc->hClipRgn) DeleteObject( dc->hClipRgn );
if (dc->hVisRgn) DeleteObject( dc->hVisRgn ); if (dc->hVisRgn) DeleteObject( dc->hVisRgn );
if (dc->hGCClipRgn) DeleteObject( dc->hGCClipRgn ); if (dc->hGCClipRgn) DeleteObject( dc->hGCClipRgn );
if (dc->pAbortProc) THUNK_Free( (FARPROC)dc->pAbortProc );
if (dc->hookThunk) THUNK_Free( (FARPROC)dc->hookThunk );
if (dc->gdiFont) WineEngDecRefFont( dc->gdiFont ); if (dc->gdiFont) WineEngDecRefFont( dc->gdiFont );
PATH_DestroyGdiPath(&dc->path); PATH_DestroyGdiPath(&dc->path);
...@@ -1181,43 +1181,45 @@ BOOL WINAPI CombineTransform( LPXFORM xformResult, const XFORM *xform1, ...@@ -1181,43 +1181,45 @@ BOOL WINAPI CombineTransform( LPXFORM xformResult, const XFORM *xform1,
/*********************************************************************** /***********************************************************************
* SetDCHook (GDI.190) * SetDCHook (GDI32.@)
*
* Note: this doesn't exist in Win32, we add it here because user32 needs it.
*/ */
BOOL WINAPI SetDCHook( HDC hdc, DCHOOKPROC hookProc, DWORD dwHookData )
{
DC *dc = DC_GetDCPtr( hdc );
/* ### start build ### */ if (!dc) return FALSE;
extern WORD CALLBACK GDI_CallTo16_word_wwll(FARPROC16,WORD,WORD,LONG,LONG); dc->dwHookData = dwHookData;
/* ### stop build ### */ dc->hookThunk = hookProc;
GDI_ReleaseObj( hdc );
return TRUE;
}
/**********************************************************************/
BOOL16 WINAPI SetDCHook( HDC16 hdc, FARPROC16 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 )
{ {
FARPROC16 proc = NULL;
DC *dc = DC_GetDCPtr( hdc ); DC *dc = DC_GetDCPtr( hdc );
if (!dc) return FALSE; if (!dc) return FALSE;
proc = dc->hookProc;
GDI_ReleaseObj( hdc );
if (!proc) return FALSE;
return GDI_CallTo16_word_wwll( proc, hdc, code, data, lParam );
}
/* /***********************************************************************
* Note: We store the original SEGPTR 'hookProc' as we need to be * SetDCHook (GDI.190)
* able to return it verbatim in GetDCHook, */
* BOOL16 WINAPI SetDCHook16( HDC16 hdc, FARPROC16 hookProc, DWORD dwHookData )
* On the other hand, we still call THUNK_Alloc and store the {
* 32-bit thunk into another DC member, because THUNK_Alloc DC *dc = DC_GetDCPtr( hdc );
* recognizes the (typical) case that the 'hookProc' is indeed if (!dc) return FALSE;
* the 16-bit API entry point of a built-in routine (e.g. DCHook16)
*
* We could perform that test every time the hook is about to
* be called (or else we could live with the 32->16->32 detour),
* but this way is the most efficient ...
*/
dc->hookProc = hookProc; dc->hookProc = hookProc;
dc->dwHookData = dwHookData;
THUNK_Free( (FARPROC)dc->hookThunk );
dc->hookThunk = (DCHOOKPROC)
THUNK_Alloc( hookProc, (RELAY)GDI_CallTo16_word_wwll );
GDI_ReleaseObj( hdc ); GDI_ReleaseObj( hdc );
return TRUE; return SetDCHook( hdc, call_dc_hook16, dwHookData );
} }
......
...@@ -68,7 +68,6 @@ static void DCE_DumpCache(void) ...@@ -68,7 +68,6 @@ static void DCE_DumpCache(void)
*/ */
DCE *DCE_AllocDCE( HWND hWnd, DCE_TYPE type ) DCE *DCE_AllocDCE( HWND hWnd, DCE_TYPE type )
{ {
FARPROC16 hookProc;
DCE * dce; DCE * dce;
if (!(dce = HeapAlloc( GetProcessHeap(), 0, sizeof(DCE) ))) return NULL; if (!(dce = HeapAlloc( GetProcessHeap(), 0, sizeof(DCE) ))) return NULL;
...@@ -81,8 +80,7 @@ DCE *DCE_AllocDCE( HWND hWnd, DCE_TYPE type ) ...@@ -81,8 +80,7 @@ DCE *DCE_AllocDCE( HWND hWnd, DCE_TYPE type )
/* store DCE handle in DC hook data field */ /* store DCE handle in DC hook data field */
hookProc = GetProcAddress16( GetModuleHandle16("USER"), (LPCSTR)362 ); SetDCHook( dce->hDC, DCHook16, (DWORD)dce );
SetDCHook( dce->hDC, hookProc, (DWORD)dce );
dce->hwndCurrent = WIN_GetFullHandle( hWnd ); dce->hwndCurrent = WIN_GetFullHandle( hWnd );
dce->hClipRgn = 0; dce->hClipRgn = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment