Change interfaces to THUNK_Alloc/Free slightly and make them non-static.

Remove relays for win16drv from CallBack table, instead use build to
generate them directly in graphics/win16drv/prtdrv.c.
If Printer AbortProc is 16bit then allocate thunk and store that as a
32bit proc in DC.  Setting of abortprocs now done in the correct place
(i.e. not in the driver).
This commit is contained in:
Huw D M Davies 1999-09-13 15:15:45 +00:00 committed by Alexandre Julliard
parent 9e9fc1b9b6
commit 304d9a4737
13 changed files with 196 additions and 177 deletions

View File

@ -22,6 +22,7 @@ INT16 WINAPI Escape16( HDC16 hdc, INT16 nEscape, INT16 cbInput,
{
DC * dc = DC_GetDCPtr( hdc );
if (!dc || !dc->funcs->pEscape) return 0;
if(nEscape == SETABORTPROC) SetAbortProc16(hdc, lpszInData);
return dc->funcs->pEscape( dc, nEscape, cbInput, lpszInData, lpvOutData );
}
@ -33,15 +34,15 @@ INT WINAPI Escape( HDC hdc, INT nEscape, INT cbInput,
{
SEGPTR segin,segout;
INT ret;
DC * dc = DC_GetDCPtr( hdc );
if (!dc || !dc->funcs->pEscape) return 0;
segin = (SEGPTR)lpszInData;
segout = (SEGPTR)lpvOutData;
switch (nEscape) {
/* Escape(hdc,QUERYESCSUPPORT,LPINT,NULL) */
/* Escape(hdc,EXT_DEVICE_CAPS,LPINT,NULL) */
/* Escape(hdc,SETLINECAP,LPINT,NULL) */
case QUERYESCSUPPORT:
case EXT_DEVICE_CAPS:
case SETLINECAP:
case SETLINEJOIN:
{
@ -63,8 +64,20 @@ INT WINAPI Escape( HDC hdc, INT nEscape, INT cbInput,
cbInput = sizeof(POINT16);
break;
/* Escape(hdc,GETTECHNOLOGY,NULL,LPSTR); */
/* Escape(hdc,EXT_DEVICE_CAPS,LPINT,LPDWORD) */
case EXT_DEVICE_CAPS:
{
LPINT16 lpIndex = (LPINT16)SEGPTR_NEW(INT16);
LPDWORD lpCaps = (LPDWORD)SEGPTR_NEW(DWORD);
*lpIndex = *(INT*)lpszInData;
segin = SEGPTR_GET(lpIndex);
segout = SEGPTR_GET(lpCaps);
cbInput = sizeof(INT16);
break;
}
/* Escape(hdc,GETTECHNOLOGY,NULL,LPSTR); */
case GETTECHNOLOGY: {
segout = SEGPTR_GET(SEGPTR_ALLOC(200)); /* enough I hope */
break;
@ -100,12 +113,16 @@ INT WINAPI Escape( HDC hdc, INT nEscape, INT cbInput,
segin = 0;
break;
case SETABORTPROC:
SetAbortProc(hdc, (ABORTPROC)lpszInData);
break;
default:
break;
}
ret = Escape16( hdc, nEscape, cbInput, segin, segout );
ret = dc->funcs->pEscape( dc, nEscape, cbInput, segin, segout );
switch(nEscape) {
case QUERYESCSUPPORT:
@ -113,7 +130,6 @@ INT WINAPI Escape( HDC hdc, INT nEscape, INT cbInput,
TRACE("target DC implements Escape %d\n",nEscape);
SEGPTR_FREE(PTR_SEG_TO_LIN(segin));
break;
case EXT_DEVICE_CAPS:
case SETLINECAP:
case SETLINEJOIN:
SEGPTR_FREE(PTR_SEG_TO_LIN(segin));
@ -126,6 +142,12 @@ INT WINAPI Escape( HDC hdc, INT nEscape, INT cbInput,
SEGPTR_FREE(x);
break;
}
case EXT_DEVICE_CAPS:
*(LPDWORD)lpvOutData = *(LPDWORD)PTR_SEG_TO_LIN(segout);
SEGPTR_FREE(PTR_SEG_TO_LIN(segin));
SEGPTR_FREE(PTR_SEG_TO_LIN(segout));
break;
case GETTECHNOLOGY: {
LPSTR x=PTR_SEG_TO_LIN(segout);
lstrcpyA(lpvOutData,x);

View File

@ -81,7 +81,6 @@ INT PSDRV_Escape( DC *dc, INT nEscape, INT cbInput,
case SETABORTPROC:
TRACE("SETABORTPROC\n");
dc->w.spfnPrint = (FARPROC16)lpInData;
return 1;
case STARTDOC:

View File

@ -1 +1,2 @@
Makefile
prtdrv.glue.c

View File

@ -15,6 +15,8 @@ C_SRCS = \
prtdrv.c \
text.c
GLUE = prtdrv.c
all: $(MODULE).o
@MAKE_RULES@

View File

@ -302,10 +302,9 @@ static INT WIN16DRV_Escape( DC *dc, INT nEscape, INT cbInput,
- Before every metafile record when GDI does banding
*/
/* save the callback address and call Control with hdc as lpInData */
/* Call Control with hdc as lpInData */
HDC16 *seghdc = SEGPTR_NEW(HDC16);
*seghdc = dc->hSelf;
dc->w.spfnPrint = (FARPROC16)lpInData;
nRet = PRTDRV_Control(physDev->segptrPDEVICE, nEscape,
SEGPTR_GET(seghdc), lpOutData);
SEGPTR_FREE(seghdc);
@ -362,3 +361,4 @@ static INT WIN16DRV_Escape( DC *dc, INT nEscape, INT cbInput,
return nRet;
}

View File

@ -21,6 +21,33 @@
DEFAULT_DEBUG_CHANNEL(win16drv)
/* ### start build ### */
extern WORD CALLBACK PRTDRV_CallTo16_word_lwll (FARPROC16,LONG,WORD,LONG,LONG);
extern WORD CALLBACK PRTDRV_CallTo16_word_lwlll (FARPROC16,LONG,WORD,LONG,LONG,
LONG);
extern WORD CALLBACK PRTDRV_CallTo16_word_llll (FARPROC16,LONG,LONG,LONG,LONG);
extern WORD CALLBACK PRTDRV_CallTo16_word_lwwlllll (FARPROC16,LONG,WORD,WORD,
LONG,LONG,LONG,LONG,LONG);
extern LONG CALLBACK PRTDRV_CallTo16_long_lwlll (FARPROC16,LONG,WORD,LONG,LONG,
LONG);
extern WORD CALLBACK PRTDRV_CallTo16_word_lwwwwlwwwwllll (FARPROC16,LONG,WORD,
WORD,WORD,WORD,LONG,
WORD,WORD,WORD,WORD,
LONG,LONG,LONG,LONG);
extern LONG CALLBACK PRTDRV_CallTo16_long_lwwllwlllllw (FARPROC16,LONG,WORD,
WORD,LONG,LONG,WORD,
LONG,LONG,LONG,LONG,
LONG,WORD);
extern WORD CALLBACK PRTDRV_CallTo16_word_llwwlll (FARPROC16,LONG,LONG,WORD,
WORD,LONG,LONG,LONG);
extern WORD CALLBACK PRTDRV_CallTo16_word_wwlllllw (FARPROC16,WORD,WORD,LONG,
LONG,LONG,LONG,LONG,WORD);
extern LONG CALLBACK PRTDRV_CallTo16_long_llwll (FARPROC16,LONG,LONG,WORD,LONG,
LONG);
/* ### stop build ### */
#define MAX_PRINTER_DRIVERS 16
static LOADED_PRINTER_DRIVER *gapLoadedPrinterDrivers[MAX_PRINTER_DRIVERS];
@ -199,7 +226,7 @@ INT16 PRTDRV_Control(LPPDEVICE lpDestDev, WORD wfunction, SEGPTR lpInData, SEGPT
WARN("Not supported by driver\n");
return 0;
}
wRet = Callbacks->CallDrvControlProc( pLPD->fn[FUNC_CONTROL],
wRet = PRTDRV_CallTo16_word_lwll( pLPD->fn[FUNC_CONTROL],
(SEGPTR)lpDestDev, wfunction,
lpInData, lpOutData );
}
@ -246,7 +273,7 @@ WORD PRTDRV_Enable(LPVOID lpDevInfo, WORD wStyle, LPCSTR lpDestDevType,
lP4 = SEGPTR_STRDUP(lpOutputFile);
lP5 = (LONG)lpData;
wRet = Callbacks->CallDrvEnableProc(pLPD->fn[FUNC_ENABLE],
wRet = PRTDRV_CallTo16_word_lwlll(pLPD->fn[FUNC_ENABLE],
(wStyle==INITPDEVICE)?(SEGPTR)lP1:SEGPTR_GET(lP1),
wP2,
SEGPTR_GET(lP3),
@ -294,8 +321,9 @@ WORD PRTDRV_EnumDFonts(LPPDEVICE lpDestDev, LPSTR lpFaceName,
else
lP2 = NULL;
lP4 = (LONG)lpClientData;
wRet = Callbacks->CallDrvEnumDFontsProc( pLPD->fn[FUNC_ENUMDFONTS],
lP1, SEGPTR_GET(lP2), lpCallbackFunc, lP4);
wRet = PRTDRV_CallTo16_word_llll( pLPD->fn[FUNC_ENUMDFONTS],
lP1, SEGPTR_GET(lP2),
(LONG)lpCallbackFunc,lP4);
if(lpFaceName)
SEGPTR_FREE(lP2);
} else
@ -317,8 +345,7 @@ BOOL16 PRTDRV_EnumObj(LPPDEVICE lpDestDev, WORD iStyle,
if ((pLPD = FindPrinterDriverFromPDEVICE(lpDestDev)) != NULL)
{
LONG lP1, lP4;
FARPROC16 lP3;
LONG lP1, lP3, lP4;
WORD wP2;
if (pLPD->fn[FUNC_ENUMOBJ] == NULL)
@ -334,11 +361,11 @@ BOOL16 PRTDRV_EnumObj(LPPDEVICE lpDestDev, WORD iStyle,
/*
* Need to pass addres of function conversion function that will switch back to 32 bit code if necessary
*/
lP3 = (FARPROC16)lpCallbackFunc;
lP3 = (LONG)lpCallbackFunc;
lP4 = (LONG)lpClientData;
wRet = Callbacks->CallDrvEnumObjProc( pLPD->fn[FUNC_ENUMOBJ],
wRet = PRTDRV_CallTo16_word_lwll( pLPD->fn[FUNC_ENUMOBJ],
lP1, wP2, lP3, lP4 );
}
else
@ -403,9 +430,11 @@ WORD PRTDRV_Output(LPPDEVICE lpDestDev,
GetRegionData( hClipRgn, size, clip );
if( clip->rdh.nCount == 0 )
{
wRet = Callbacks->CallDrvOutputProc(pLPD->fn[FUNC_OUTPUT],
lP1, wP2, wP3, SEGPTR_GET(lP4),
lP5, lP6, lP7, (SEGPTR) NULL);
wRet = PRTDRV_CallTo16_word_lwwlllll(pLPD->fn[FUNC_OUTPUT],
lP1, wP2, wP3,
SEGPTR_GET(lP4),
lP5, lP6, lP7,
(SEGPTR) NULL);
}
else
{
@ -419,9 +448,11 @@ WORD PRTDRV_Output(LPPDEVICE lpDestDev,
TRACE("rect = %d,%d - %d,%d\n",
lP8->left, lP8->top, lP8->right, lP8->bottom );
wRet = Callbacks->CallDrvOutputProc(pLPD->fn[FUNC_OUTPUT],
lP1, wP2, wP3, SEGPTR_GET(lP4),
lP5, lP6, lP7, SEGPTR_GET(lP8));
wRet = PRTDRV_CallTo16_word_lwwlllll(pLPD->fn[FUNC_OUTPUT],
lP1, wP2, wP3,
SEGPTR_GET(lP4),
lP5, lP6, lP7,
SEGPTR_GET(lP8));
}
SEGPTR_FREE(lP8);
}
@ -429,8 +460,9 @@ WORD PRTDRV_Output(LPPDEVICE lpDestDev,
}
else
{
wRet = Callbacks->CallDrvOutputProc(pLPD->fn[FUNC_OUTPUT],
lP1, wP2, wP3, SEGPTR_GET(lP4),
wRet = PRTDRV_CallTo16_word_lwwlllll(pLPD->fn[FUNC_OUTPUT],
lP1, wP2, wP3,
SEGPTR_GET(lP4),
lP5, lP6, lP7, (SEGPTR) NULL);
}
SEGPTR_FREE(lP4);
@ -507,7 +539,7 @@ DWORD PRTDRV_RealizeObject(LPPDEVICE lpDestDev, WORD wStyle,
lP5 = lpTextXForm;
TRACE("Calling Realize %08lx %04x %08lx %08lx %08lx\n",
lP1, wP2, lP3, lP4, lP5);
dwRet = Callbacks->CallDrvRealizeProc(pLPD->fn[FUNC_REALIZEOBJECT],
dwRet = PRTDRV_CallTo16_long_lwlll(pLPD->fn[FUNC_REALIZEOBJECT],
lP1, wP2, lP3, lP4, lP5);
if(lpBuf)
SEGPTR_FREE(lpBuf);
@ -568,7 +600,7 @@ DWORD PRTDRV_StretchBlt(LPPDEVICE lpDestDev,
}
else
lP14 = 0L;
wRet = Callbacks->CallDrvStretchBltProc(pLPD->fn[FUNC_STRETCHBLT],
wRet = PRTDRV_CallTo16_word_lwwwwlwwwwllll(pLPD->fn[FUNC_STRETCHBLT],
lP1, wP2, wP3, wP4, wP5,
lP6, wP7, wP8, wP9, wP10,
lP11, lP12, lP13,
@ -652,7 +684,7 @@ DWORD PRTDRV_ExtTextOut(LPPDEVICE lpDestDev, WORD wDestXOrg, WORD wDestYOrg,
nSize,lP5, iP6, lP7, lP8);
TRACE("0x%lx 0x%lx %p 0x%x\n",
lP9, lP10, lP11, wP12);
dwRet = Callbacks->CallDrvExtTextOutProc(pLPD->fn[FUNC_EXTTEXTOUT],
dwRet = PRTDRV_CallTo16_long_lwwllwlllllw(pLPD->fn[FUNC_EXTTEXTOUT],
lP1, wP2, wP3,
SEGPTR_GET(lP4),
SEGPTR_GET(lP5), iP6, lP7,
@ -779,7 +811,7 @@ WORD PRTDRV_GetCharWidth(LPPDEVICE lpDestDev, LPINT lpBuffer,
lP6 = lpDrawMode;
lP7 = lpTextXForm;
wRet = Callbacks->CallDrvGetCharWidthProc(pLPD->fn[FUNC_GETCHARWIDTH],
wRet = PRTDRV_CallTo16_word_llwwlll(pLPD->fn[FUNC_GETCHARWIDTH],
lP1, SEGPTR_GET(lP2), wP3,
wP4, lP5, lP6, lP7 );
@ -819,7 +851,7 @@ INT WIN16DRV_ExtDeviceMode(LPSTR lpszDriver, HWND hwnd, LPDEVMODEA lpdmOutput,
/* We don't know how big this will be so we call the driver's
ExtDeviceMode to find out */
wOutSize = Callbacks->CallDrvExtDeviceModeProc(
wOutSize = PRTDRV_CallTo16_word_wwlllllw(
pLPD->fn[FUNC_EXTDEVICEMODE], hwnd, pLPD->hInst, 0,
SEGPTR_GET(lpSegDevice), SEGPTR_GET(lpSegPort), 0,
SEGPTR_GET(lpSegProfile), 0 );
@ -832,7 +864,7 @@ INT WIN16DRV_ExtDeviceMode(LPSTR lpszDriver, HWND hwnd, LPDEVMODEA lpdmOutput,
memcpy(lpSegIn, lpdmInput, lpdmInput->dmSize +
lpdmInput->dmDriverExtra);
}
wRet = Callbacks->CallDrvExtDeviceModeProc( pLPD->fn[FUNC_EXTDEVICEMODE],
wRet = PRTDRV_CallTo16_word_wwlllllw( pLPD->fn[FUNC_EXTDEVICEMODE],
hwnd, pLPD->hInst,
SEGPTR_GET(lpSegOut),
SEGPTR_GET(lpSegDevice),
@ -890,7 +922,7 @@ DWORD WIN16DRV_DeviceCapabilities(LPSTR lpszDriver, LPCSTR lpszDevice,
lpDevMode->dmDriverExtra);
}
dwRet = Callbacks->CallDrvDeviceCapabilitiesProc(
dwRet = PRTDRV_CallTo16_long_llwll(
pLPD->fn[FUNC_DEVICECAPABILITIES],
SEGPTR_GET(lpSegDevice), SEGPTR_GET(lpSegPort),
fwCapability, 0, SEGPTR_GET(lpSegdm) );
@ -963,7 +995,7 @@ DWORD WIN16DRV_DeviceCapabilities(LPSTR lpszDriver, LPCSTR lpszDevice,
if(OutputSize && lpszOutput) {
lpSegOut = SEGPTR_ALLOC(OutputSize);
dwRet = Callbacks->CallDrvDeviceCapabilitiesProc(
dwRet = PRTDRV_CallTo16_long_llwll(
pLPD->fn[FUNC_DEVICECAPABILITIES],
SEGPTR_GET(lpSegDevice),
SEGPTR_GET(lpSegPort),

View File

@ -45,38 +45,19 @@ extern WORD CALLBACK THUNK_CallTo16_word_wwl (FARPROC16,WORD,WORD,LONG);
extern WORD CALLBACK THUNK_CallTo16_word_wlw (FARPROC16,WORD,LONG,WORD);
extern LONG CALLBACK THUNK_CallTo16_long_wwl (FARPROC16,WORD,WORD,LONG);
extern WORD CALLBACK THUNK_CallTo16_word_llwl (FARPROC16,LONG,LONG,WORD,LONG);
extern WORD CALLBACK THUNK_CallTo16_word_lwll (FARPROC16,LONG,WORD,LONG,LONG);
extern WORD CALLBACK THUNK_CallTo16_word_lwww (FARPROC16,LONG,WORD,WORD,WORD);
extern WORD CALLBACK THUNK_CallTo16_word_wlww (FARPROC16,WORD,LONG,WORD,WORD);
extern WORD CALLBACK THUNK_CallTo16_word_wwll (FARPROC16,WORD,WORD,LONG,LONG);
extern WORD CALLBACK THUNK_CallTo16_word_wwwl (FARPROC16,WORD,WORD,WORD,LONG);
extern LONG CALLBACK THUNK_CallTo16_long_wwwl (FARPROC16,WORD,WORD,WORD,LONG);
extern WORD CALLBACK THUNK_CallTo16_word_llll (FARPROC16,LONG,LONG,LONG,LONG);
extern WORD CALLBACK THUNK_CallTo16_word_wllwl(FARPROC16,WORD,LONG,LONG,WORD,LONG);
extern WORD CALLBACK THUNK_CallTo16_word_lwwww(FARPROC16,LONG,WORD,WORD,WORD,WORD);
extern LONG CALLBACK THUNK_CallTo16_long_lwwll(FARPROC16,LONG,WORD,WORD,LONG,LONG);
extern WORD CALLBACK THUNK_CallTo16_word_wwlll(FARPROC16,WORD,WORD,LONG,LONG,LONG);
extern WORD CALLBACK THUNK_CallTo16_word_wwwww(FARPROC16,WORD,WORD,WORD,WORD,WORD);
extern WORD CALLBACK THUNK_CallTo16_word_lwlll(FARPROC16,LONG,WORD,LONG,LONG,LONG);
extern LONG CALLBACK THUNK_CallTo16_long_lwlll(FARPROC16,LONG,WORD,LONG,LONG,LONG);
extern WORD CALLBACK THUNK_CallTo16_word_llwwlll(FARPROC16,LONG,LONG,WORD,WORD,LONG,LONG,LONG);
extern LONG CALLBACK THUNK_CallTo16_word_lwwlllll(FARPROC16,LONG,WORD,WORD,LONG,LONG,
LONG,LONG,LONG);
extern LONG CALLBACK THUNK_CallTo16_long_lwwllwlllllw(FARPROC16,LONG,WORD,WORD,LONG,
LONG,WORD,LONG,LONG,LONG,LONG,
LONG,WORD);
extern LONG CALLBACK THUNK_CallTo16_word_lwwwwlwwwwllll(FARPROC16,LONG,WORD,WORD,
WORD,WORD,LONG,WORD,WORD,
WORD,WORD,LONG,LONG,LONG,
LONG);
extern WORD CALLBACK THUNK_CallTo16_word_wwlllllw(FARPROC16,WORD,WORD,LONG,
LONG,LONG,LONG,LONG,WORD);
extern LONG CALLBACK THUNK_CallTo16_long_llwll(FARPROC16,LONG,LONG,WORD,LONG,
LONG);
/* ### stop build ### */
typedef void (*RELAY)();
#include "pshpack1.h"
@ -84,13 +65,16 @@ typedef struct tagTHUNK
{
BYTE popl_eax; /* 0x58 popl %eax (return address)*/
BYTE pushl_func; /* 0x68 pushl $proc */
FARPROC proc WINE_PACKED;
FARPROC16 proc WINE_PACKED;
BYTE pushl_eax; /* 0x50 pushl %eax */
BYTE jmp; /* 0xe9 jmp relay (relative jump)*/
RELAY relay WINE_PACKED;
struct tagTHUNK *next WINE_PACKED;
DWORD magic;
} THUNK;
#define CALLTO16_THUNK_MAGIC 0x54484e4b /* "THNK" */
#include "poppack.h"
#define DECL_THUNK(aname,aproc,arelay) \
@ -101,7 +85,8 @@ typedef struct tagTHUNK
aname.pushl_eax = 0x50; \
aname.jmp = 0xe9; \
aname.relay = (RELAY)((char *)(arelay) - (char *)(&(aname).next)); \
aname.next = NULL;
aname.next = NULL; \
aname.magic = CALLTO16_THUNK_MAGIC;
static THUNK *firstThunk = NULL;
@ -122,20 +107,7 @@ static const CALLBACKS_TABLE CALLBACK_EmulatorTable =
(void *)THUNK_CallTo16_word_www, /* CallLocalNotifyFunc */
(void *)THUNK_CallTo16_word_www, /* CallResourceHandlerProc */
(void *)THUNK_CallTo16_long_ll, /* CallUTProc */
(void *)THUNK_CallTo16_long_l, /* CallASPIPostProc */
(void *)THUNK_CallTo16_word_lwll, /* CallDrvControlProc */
(void *)THUNK_CallTo16_word_lwlll, /* CallDrvEnableProc */
(void *)THUNK_CallTo16_word_llll, /* CallDrvEnumDFontsProc */
(void *)THUNK_CallTo16_word_lwll, /* CallDrvEnumObjProc */
(void *)THUNK_CallTo16_word_lwwlllll, /* CallDrvOutputProc */
(void *)THUNK_CallTo16_long_lwlll, /* CallDrvRealizeProc */
(void *)THUNK_CallTo16_word_lwwwwlwwwwllll, /* CallDrvStretchBltProc */
(void *)THUNK_CallTo16_long_lwwllwlllllw, /* CallDrvExtTextOutProc */
(void *)THUNK_CallTo16_word_llwwlll, /* CallDrvGetCharWidth */
(void *)THUNK_CallTo16_word_ww, /* CallDrvAbortProc */
(void *)THUNK_CallTo16_word_wwlllllw, /* CallDrvExtDeviceModeProc */
(void *)THUNK_CallTo16_long_llwll /* CallDrvDeviceCapabilitesProc */
(void *)THUNK_CallTo16_long_l /* CallASPIPostProc */
};
const CALLBACKS_TABLE *Callbacks = &CALLBACK_EmulatorTable;
@ -155,7 +127,7 @@ BOOL THUNK_Init(void)
/***********************************************************************
* THUNK_Alloc
*/
static THUNK *THUNK_Alloc( FARPROC func, RELAY relay )
FARPROC THUNK_Alloc( FARPROC16 func, RELAY relay )
{
THUNK *thunk = HeapAlloc( GetProcessHeap(), 0, sizeof(*thunk) );
if (thunk)
@ -166,44 +138,59 @@ static THUNK *THUNK_Alloc( FARPROC func, RELAY relay )
thunk->pushl_eax = 0x50;
thunk->jmp = 0xe9;
thunk->relay = (RELAY)((char *)relay - (char *)(&thunk->next));
thunk->magic = CALLTO16_THUNK_MAGIC;
thunk->next = firstThunk;
firstThunk = thunk;
}
return thunk;
return (FARPROC)thunk;
}
/***********************************************************************
* THUNK_Find
*/
static THUNK *THUNK_Find( FARPROC func )
FARPROC THUNK_Find( FARPROC16 func )
{
THUNK *thunk = firstThunk;
while (thunk && (thunk->proc != func)) thunk = thunk->next;
return thunk;
return (FARPROC)thunk;
}
/***********************************************************************
* THUNK_Free
*/
static void THUNK_Free( THUNK *thunk )
void THUNK_Free( FARPROC thunk )
{
if (HEAP_IsInsideHeap( GetProcessHeap(), 0, thunk ))
THUNK *t = (THUNK*)thunk;
if(IsBadReadPtr(&(t->magic), sizeof(t->magic)) ||
t->magic != CALLTO16_THUNK_MAGIC)
return;
if (HEAP_IsInsideHeap( GetProcessHeap(), 0, t ))
{
THUNK **prev = &firstThunk;
while (*prev && (*prev != thunk)) prev = &(*prev)->next;
while (*prev && (*prev != t)) prev = &(*prev)->next;
if (*prev)
{
*prev = thunk->next;
HeapFree( GetProcessHeap(), 0, thunk );
*prev = t->next;
HeapFree( GetProcessHeap(), 0, t );
return;
}
}
ERR_(thunk)("invalid thunk addr %p\n", thunk );
return;
}
/***********************************************************************
* THUNK_GetProc
*/
FARPROC16 THUNK_GetProc( FARPROC thunk )
{
return ((THUNK *)thunk)->proc;
}
/***********************************************************************
* THUNK_EnumObjects16 (GDI.71)
*/
@ -337,7 +324,7 @@ FARPROC16 WINAPI THUNK_SetWindowsHook16( INT16 id, HOOKPROC16 proc )
{
HINSTANCE16 hInst = FarGetOwner16( HIWORD(proc) );
HTASK16 hTask = (id == WH_MSGFILTER) ? GetCurrentTask() : 0;
THUNK *thunk = THUNK_Alloc( (FARPROC16)proc, (RELAY)THUNK_CallTo16_long_wwl );
FARPROC thunk = THUNK_Alloc( (FARPROC16)proc, (RELAY)THUNK_CallTo16_long_wwl );
if (!thunk) return 0;
return (FARPROC16)SetWindowsHookEx16( id, (HOOKPROC16)thunk, hInst, hTask);
}
@ -349,7 +336,7 @@ FARPROC16 WINAPI THUNK_SetWindowsHook16( INT16 id, HOOKPROC16 proc )
BOOL16 WINAPI THUNK_UnhookWindowsHook16( INT16 id, HOOKPROC16 proc )
{
BOOL16 ret;
THUNK *thunk = THUNK_Find( (FARPROC16)proc );
FARPROC thunk = THUNK_Find( (FARPROC16)proc );
if (!thunk) return FALSE;
ret = UnhookWindowsHook16( id, (HOOKPROC16)thunk );
THUNK_Free( thunk );
@ -363,7 +350,7 @@ BOOL16 WINAPI THUNK_UnhookWindowsHook16( INT16 id, HOOKPROC16 proc )
HHOOK WINAPI THUNK_SetWindowsHookEx16( INT16 id, HOOKPROC16 proc,
HINSTANCE16 hInst, HTASK16 hTask )
{
THUNK *thunk = THUNK_Alloc( (FARPROC16)proc, (RELAY)THUNK_CallTo16_long_wwl );
FARPROC thunk = THUNK_Alloc( (FARPROC16)proc, (RELAY)THUNK_CallTo16_long_wwl );
if (!thunk) return 0;
return SetWindowsHookEx16( id, (HOOKPROC16)thunk, hInst, hTask );
}
@ -374,7 +361,7 @@ HHOOK WINAPI THUNK_SetWindowsHookEx16( INT16 id, HOOKPROC16 proc,
*/
BOOL16 WINAPI THUNK_UnhookWindowsHookEx16( HHOOK hhook )
{
THUNK *thunk = (THUNK *)HOOK_GetProc16( hhook );
FARPROC thunk = (FARPROC)HOOK_GetProc16( hhook );
BOOL16 ret = UnhookWindowsHookEx16( hhook );
if (thunk) THUNK_Free( thunk );
return ret;
@ -389,7 +376,7 @@ static FARPROC16 defDCHookProc = NULL;
*/
BOOL16 WINAPI THUNK_SetDCHook( HDC16 hdc, FARPROC16 proc, DWORD dwHookData )
{
THUNK *thunk, *oldThunk;
FARPROC thunk, oldThunk;
if (!defDCHookProc) /* Get DCHook Win16 entry point */
{
@ -409,13 +396,13 @@ BOOL16 WINAPI THUNK_SetDCHook( HDC16 hdc, FARPROC16 proc, DWORD dwHookData )
thunk = THUNK_Alloc( proc, (RELAY)THUNK_CallTo16_word_wwll );
if (!thunk) return FALSE;
}
else thunk = (THUNK *)DCHook16;
else thunk = (FARPROC)DCHook16;
/* Free the previous thunk */
GetDCHook( hdc, (FARPROC16 *)&oldThunk );
if (oldThunk && (oldThunk != (THUNK *)DCHook16)) THUNK_Free( oldThunk );
if (oldThunk && (oldThunk != (FARPROC)DCHook16)) THUNK_Free( oldThunk );
return SetDCHook( hdc, (FARPROC16)thunk, dwHookData );
return SetDCHook( hdc, thunk, dwHookData );
}
@ -424,11 +411,11 @@ BOOL16 WINAPI THUNK_SetDCHook( HDC16 hdc, FARPROC16 proc, DWORD dwHookData )
*/
DWORD WINAPI THUNK_GetDCHook( HDC16 hdc, FARPROC16 *phookProc )
{
THUNK *thunk = NULL;
DWORD ret = GetDCHook( hdc, (FARPROC16 *)&thunk );
FARPROC thunk = NULL;
DWORD ret = GetDCHook( hdc, &thunk );
if (thunk)
{
if (thunk == (THUNK *)DCHook16)
if (thunk == (FARPROC)DCHook16)
{
/* Note: we can only get here when running built-in USER */
@ -437,7 +424,7 @@ DWORD WINAPI THUNK_GetDCHook( HDC16 hdc, FARPROC16 *phookProc )
*phookProc = defDCHookProc;
}
else *phookProc = thunk->proc;
else *phookProc = THUNK_GetProc(thunk);
}
return ret;
}
@ -448,13 +435,13 @@ DWORD WINAPI THUNK_GetDCHook( HDC16 hdc, FARPROC16 *phookProc )
*/
FARPROC16 WINAPI THUNK_SetTaskSignalProc( HTASK16 hTask, FARPROC16 proc )
{
THUNK *thunk = THUNK_Alloc( proc, (RELAY)THUNK_CallTo16_word_wwwww );
FARPROC thunk = THUNK_Alloc( proc, (RELAY)THUNK_CallTo16_word_wwwww );
if ( !thunk ) return NULL;
thunk = (THUNK*)SetTaskSignalProc( hTask, (FARPROC16)thunk );
thunk = (FARPROC)SetTaskSignalProc( hTask, (FARPROC16)thunk );
if ( !thunk ) return NULL;
proc = thunk->proc;
proc = THUNK_GetProc(thunk);
THUNK_Free( thunk );
return proc;
}
@ -505,7 +492,7 @@ static VOID WINAPI THUNK_CallMouseEventProc( FARPROC16 proc,
}
VOID WINAPI THUNK_MOUSE_Enable( FARPROC16 proc )
{
static THUNK *lastThunk = NULL;
static FARPROC lastThunk = NULL;
static FARPROC16 lastProc = NULL;
if ( lastProc != proc )
@ -567,7 +554,7 @@ static VOID WINAPI THUNK_CallKeybdEventProc( FARPROC16 proc,
}
VOID WINAPI THUNK_KEYBOARD_Enable( FARPROC16 proc, LPBYTE lpKeyState )
{
static THUNK *lastThunk = NULL;
static FARPROC lastThunk = NULL;
static FARPROC16 lastProc = NULL;
if ( lastProc != proc )
@ -631,7 +618,7 @@ static void THUNK_CallSystemTimerProc( FARPROC16 proc, WORD timer )
}
WORD WINAPI WIN16_CreateSystemTimer( WORD rate, FARPROC16 proc )
{
THUNK *thunk = THUNK_Alloc( proc, (RELAY)THUNK_CallSystemTimerProc );
FARPROC thunk = THUNK_Alloc( proc, (RELAY)THUNK_CallSystemTimerProc );
WORD timer = CreateSystemTimer( rate, (SYSTEMTIMERPROC)thunk );
if (!timer) THUNK_Free( thunk );
return timer;

View File

@ -18,6 +18,12 @@ extern int (*IF1632_CallLargeStack)( int (*func)(void), void *arg );
IF1632_CallLargeStack( (int(*)())(func), (void *)(arg) ) : \
((int(*)())(func))((void *)arg))
typedef void (*RELAY)();
extern FARPROC THUNK_Alloc( FARPROC16 func, RELAY relay );
extern void THUNK_Free( FARPROC thunk );
extern FARPROC16 THUNK_GetProc( FARPROC thunk );
extern FARPROC THUNK_Find( FARPROC16 func );
typedef struct
{
LONG (CALLBACK *CallRegisterShortProc)( CONTEXT86 *, INT );
@ -37,35 +43,6 @@ typedef struct
HGLOBAL16 (CALLBACK *CallResourceHandlerProc)( FARPROC16, HGLOBAL16, HMODULE16, HRSRC16 );
DWORD (CALLBACK *CallUTProc)( FARPROC16, DWORD, DWORD );
LRESULT (CALLBACK *CallASPIPostProc)( FARPROC16, SEGPTR );
/* Following are the graphics driver callbacks */
WORD (CALLBACK *CallDrvControlProc)( FARPROC16, SEGPTR, WORD,
SEGPTR, SEGPTR );
WORD (CALLBACK *CallDrvEnableProc)( FARPROC16, SEGPTR, WORD, SEGPTR,
SEGPTR, SEGPTR );
WORD (CALLBACK *CallDrvEnumDFontsProc)( FARPROC16, SEGPTR, SEGPTR,
FARPROC16, SEGPTR );
WORD (CALLBACK *CallDrvEnumObjProc)( FARPROC16, SEGPTR, WORD, FARPROC16,
SEGPTR );
WORD (CALLBACK *CallDrvOutputProc)( FARPROC16, SEGPTR, WORD, WORD, SEGPTR,
SEGPTR, SEGPTR, SEGPTR, SEGPTR );
DWORD (CALLBACK *CallDrvRealizeProc)( FARPROC16, SEGPTR, WORD, SEGPTR,
SEGPTR, SEGPTR );
WORD (CALLBACK *CallDrvStretchBltProc)( FARPROC16, SEGPTR, WORD, WORD,
WORD, WORD, SEGPTR, WORD, WORD,
WORD, WORD, DWORD, SEGPTR, SEGPTR,
SEGPTR );
DWORD (CALLBACK *CallDrvExtTextOutProc)( FARPROC16, SEGPTR, WORD, WORD,
SEGPTR, SEGPTR, INT16, SEGPTR,
SEGPTR, SEGPTR, SEGPTR, SEGPTR,
WORD );
WORD (CALLBACK *CallDrvGetCharWidthProc)( FARPROC16, SEGPTR, SEGPTR, WORD,
WORD, SEGPTR, SEGPTR, SEGPTR );
BOOL16 (CALLBACK *CallDrvAbortProc)( FARPROC16, HDC16, INT16 );
WORD (CALLBACK *CallDrvExtDeviceModeProc)( FARPROC16, WORD, WORD, SEGPTR,
SEGPTR, SEGPTR, SEGPTR, SEGPTR,
WORD );
DWORD (CALLBACK *CallDrvDeviceCapabilitiesProc)( FARPROC16, SEGPTR, SEGPTR,
WORD, SEGPTR, SEGPTR );
} CALLBACKS_TABLE;
extern const CALLBACKS_TABLE *Callbacks;

View File

@ -127,8 +127,7 @@ typedef struct
INT GraphicsMode; /* Graphics mode */
INT DCOrgX; /* DC origin */
INT DCOrgY;
FARPROC16 spfnPrint; /* 16bit AbortProc for Printing */
ABORTPROC lpfnPrint; /* 32bit AbortProc for Printing */
ABORTPROC pAbortProc; /* AbortProc for Printing */
INT CursPosX; /* Current position */
INT CursPosY;
INT ArcDirection;

View File

@ -1 +1,2 @@
Makefile
printdrv.glue.c

View File

@ -30,6 +30,8 @@ C_SRCS = \
wsprintf.c \
xmalloc.c
GLUE = printdrv.c
all: $(MODULE).o
@MAKE_RULES@

View File

@ -208,36 +208,30 @@ INT WINAPI AbortDoc(HDC hdc)
BOOL16 WINAPI QueryAbort16(HDC16 hdc, INT16 reserved)
{
DC *dc = DC_GetDCPtr( hdc );
BOOL16 ret;
if(!dc) {
ERR("Invalid hdc %04x\n", hdc);
return FALSE;
}
if(!dc->w.lpfnPrint && !dc->w.spfnPrint)
if(!dc->w.pAbortProc)
return TRUE;
if(dc->w.lpfnPrint && dc->w.spfnPrint)
FIXME("16 and 32 bit AbortProcs set?\n");
if(dc->w.spfnPrint) {
TRACE("Calling 16bit AbortProc\n");
ret = Callbacks->CallDrvAbortProc(dc->w.spfnPrint, hdc, 0);
} else {
TRACE("Calling 32bit AbortProc\n");
ret = dc->w.lpfnPrint(hdc,0);
}
return ret;
return dc->w.pAbortProc(hdc, 0);
}
/* ### start build ### */
extern WORD CALLBACK PRTDRV_CallTo16_word_ww(FARPROC16,WORD,WORD);
/* ### stop build ### */
/**********************************************************************
* SetAbortProc16 (GDI.381)
*
*/
INT16 WINAPI SetAbortProc16(HDC16 hdc, SEGPTR abrtprc)
{
return Escape16(hdc, SETABORTPROC, 0, abrtprc, (SEGPTR)0);
ABORTPROC proc32 = (ABORTPROC)THUNK_Alloc((FARPROC16)abrtprc,
(RELAY)PRTDRV_CallTo16_word_ww);
return SetAbortProc(hdc, proc32);
}
/**********************************************************************
@ -248,7 +242,8 @@ INT WINAPI SetAbortProc(HDC hdc, ABORTPROC abrtprc)
{
DC *dc = DC_GetDCPtr( hdc );
dc->w.lpfnPrint = abrtprc;
if(dc->w.pAbortProc) THUNK_Free((FARPROC)dc->w.pAbortProc);
dc->w.pAbortProc = abrtprc;
return TRUE;
}

View File

@ -19,6 +19,7 @@
#include "heap.h"
#include "debugtools.h"
#include "font.h"
#include "callback.h"
#include "winerror.h"
#include "wine/winuser16.h"
@ -63,8 +64,7 @@ static void DC_Init_DC_INFO( WIN_DC_INFO *win_dc_info )
win_dc_info->GraphicsMode = GM_COMPATIBLE;
win_dc_info->DCOrgX = 0;
win_dc_info->DCOrgY = 0;
win_dc_info->spfnPrint = 0;
win_dc_info->lpfnPrint = NULL;
win_dc_info->pAbortProc = NULL;
win_dc_info->CursPosX = 0;
win_dc_info->CursPosY = 0;
win_dc_info->ArcDirection = AD_COUNTERCLOCKWISE;
@ -285,6 +285,8 @@ HDC16 WINAPI GetDCState16( HDC16 hdc )
PATH_InitGdiPath( &newdc->w.path );
newdc->w.pAbortProc = NULL;
/* Get/SetDCState() don't change hVisRgn field ("Undoc. Windows" p.559). */
newdc->w.hGCClipRgn = newdc->w.hVisRgn = 0;
@ -525,7 +527,7 @@ HDC16 WINAPI CreateDC16( LPCSTR driver, LPCSTR device, LPCSTR output,
debugstr_a(driver), debugstr_a(device), debugstr_a(output), dc->hSelf );
if (dc->funcs->pCreateDC &&
!dc->funcs->pCreateDC( dc, driver, device, output, initData ))
!dc->funcs->pCreateDC( dc, buf, device, output, initData ))
{
WARN("creation aborted by device\n" );
GDI_HEAP_FREE( dc->hSelf );
@ -707,7 +709,7 @@ BOOL WINAPI DeleteDC( HDC hdc )
if (dc->w.hClipRgn) DeleteObject( dc->w.hClipRgn );
if (dc->w.hVisRgn) DeleteObject( dc->w.hVisRgn );
if (dc->w.hGCClipRgn) DeleteObject( dc->w.hGCClipRgn );
if (dc->w.pAbortProc) THUNK_Free( (FARPROC)dc->w.pAbortProc );
PATH_DestroyGdiPath(&dc->w.path);
return GDI_FreeObject( hdc );