Commit 2b336340 authored by Alexandre Julliard's avatar Alexandre Julliard

Intercept functions for 16-bit relay debugging by patching the

CALLFROM16 table instead of having the wine_call_from_16 functions call out the relay functions explicitly.
parent 2440dcfe
...@@ -210,6 +210,9 @@ extern void SELECTOR_FreeBlock( WORD sel ); ...@@ -210,6 +210,9 @@ extern void SELECTOR_FreeBlock( WORD sel );
#define IS_SELECTOR_32BIT(sel) \ #define IS_SELECTOR_32BIT(sel) \
(wine_ldt_is_system(sel) || (wine_ldt_copy.flags[LOWORD(sel) >> 3] & WINE_LDT_FLAGS_32BIT)) (wine_ldt_is_system(sel) || (wine_ldt_copy.flags[LOWORD(sel) >> 3] & WINE_LDT_FLAGS_32BIT))
/* relay16.c */
extern int relay_call_from_16( void *entry_point, unsigned char *args16, CONTEXT86 *context );
/* snoop16.c */ /* snoop16.c */
extern void SNOOP16_RegisterDLL(HMODULE16,LPCSTR); extern void SNOOP16_RegisterDLL(HMODULE16,LPCSTR);
extern FARPROC16 SNOOP16_GetProcAddress16(HMODULE16,DWORD,FARPROC16); extern FARPROC16 SNOOP16_GetProcAddress16(HMODULE16,DWORD,FARPROC16);
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(module); WINE_DEFAULT_DEBUG_CHANNEL(module);
WINE_DECLARE_DEBUG_CHANNEL(loaddll); WINE_DECLARE_DEBUG_CHANNEL(loaddll);
WINE_DECLARE_DEBUG_CHANNEL(relay);
#include "pshpack1.h" #include "pshpack1.h"
typedef struct _GPHANDLERDEF typedef struct _GPHANDLERDEF
...@@ -103,21 +104,19 @@ inline static void patch_code_segment( NE_MODULE *pModule ) ...@@ -103,21 +104,19 @@ inline static void patch_code_segment( NE_MODULE *pModule )
{ {
#ifdef __i386__ #ifdef __i386__
int i; int i;
CALLFROM16 *call;
SEGTABLEENTRY *pSeg = NE_SEG_TABLE( pModule ); SEGTABLEENTRY *pSeg = NE_SEG_TABLE( pModule );
for (i = 0; i < pModule->ne_cseg; i++, pSeg++) for (i = 0; i < pModule->ne_cseg; i++, pSeg++)
{ if (!(pSeg->flags & NE_SEGFLAGS_DATA)) break; /* found the code segment */
if (!(pSeg->flags & NE_SEGFLAGS_DATA)) /* found the code segment */
{ call = GlobalLock16( pSeg->hSeg );
CALLFROM16 *call = GlobalLock16( pSeg->hSeg );
if (call->flatcs == wine_get_cs()) return; /* nothing to patch */ if (call->flatcs != wine_get_cs()) /* need to patch cs values */
while (call->pushl == 0x68) for (i = 0; call[i].pushl == 0x68; i++) call[i].flatcs = wine_get_cs();
{
call->flatcs = wine_get_cs(); if (TRACE_ON(relay)) /* patch relay functions to all point to relay_call_from_16 */
call++; for (i = 0; call[i].pushl == 0x68; i++) call[i].relay = relay_call_from_16;
}
}
}
#endif #endif
} }
......
...@@ -293,80 +293,12 @@ static void BuildCallFrom16Core( FILE *outfile, int reg_func, int thunk, int sho ...@@ -293,80 +293,12 @@ static void BuildCallFrom16Core( FILE *outfile, int reg_func, int thunk, int sho
fprintf( outfile, "\tpushl %%esp\n" ); fprintf( outfile, "\tpushl %%esp\n" );
} }
/* Print debug info before call */
if ( debugging )
{
if ( UsePIC )
{
fprintf( outfile, "\tpushl %%ebx\n" );
/* Get Global Offset Table into %ebx (for PLT call) */
fprintf( outfile, "\tcall .L__wine_call_from_16_%s.getgot2\n", name );
fprintf( outfile, ".L__wine_call_from_16_%s.getgot2:\n", name );
fprintf( outfile, "\tpopl %%ebx\n" );
fprintf( outfile, "\taddl $_GLOBAL_OFFSET_TABLE_+[.-.L__wine_call_from_16_%s.getgot2], %%ebx\n", name );
}
fprintf( outfile, "\tpushl %%edx\n" );
if ( reg_func )
fprintf( outfile, "\tleal -%d(%%ebp), %%eax\n\tpushl %%eax\n",
sizeof(CONTEXT) + STRUCTOFFSET(STACK32FRAME, ebp) );
else
fprintf( outfile, "\tpushl $0\n" );
if ( UsePIC )
fprintf( outfile, "\tcall %s\n ", asm_name("RELAY_DebugCallFrom16@PLT"));
else
fprintf( outfile, "\tcall %s\n ", asm_name("RELAY_DebugCallFrom16"));
fprintf( outfile, "\tpopl %%edx\n" );
fprintf( outfile, "\tpopl %%edx\n" );
if ( UsePIC )
fprintf( outfile, "\tpopl %%ebx\n" );
}
/* Call relay routine (which will call the API entry point) */ /* Call relay routine (which will call the API entry point) */
fprintf( outfile, "\tleal %d(%%edx), %%eax\n", sizeof(STACK16FRAME) ); fprintf( outfile, "\tleal %d(%%edx), %%eax\n", sizeof(STACK16FRAME) );
fprintf( outfile, "\tpushl %%eax\n" ); fprintf( outfile, "\tpushl %%eax\n" );
fprintf( outfile, "\tpushl %d(%%edx)\n", STACK16OFFSET(entry_point) ); fprintf( outfile, "\tpushl %d(%%edx)\n", STACK16OFFSET(entry_point) );
fprintf( outfile, "\tcall *%d(%%edx)\n", STACK16OFFSET(relay) ); fprintf( outfile, "\tcall *%d(%%edx)\n", STACK16OFFSET(relay) );
/* Print debug info after call */
if ( debugging )
{
if ( UsePIC )
{
fprintf( outfile, "\tpushl %%ebx\n" );
/* Get Global Offset Table into %ebx (for PLT call) */
fprintf( outfile, "\tcall .L__wine_call_from_16_%s.getgot3\n", name );
fprintf( outfile, ".L__wine_call_from_16_%s.getgot3:\n", name );
fprintf( outfile, "\tpopl %%ebx\n" );
fprintf( outfile, "\taddl $_GLOBAL_OFFSET_TABLE_+[.-.L__wine_call_from_16_%s.getgot3], %%ebx\n", name );
}
fprintf( outfile, "\tpushl %%eax\n" );
if ( reg_func )
fprintf( outfile, "\tleal -%d(%%ebp), %%eax\n\tpushl %%eax\n",
sizeof(CONTEXT) + STRUCTOFFSET(STACK32FRAME, ebp) );
else
fprintf( outfile, "\tpushl $0\n" );
if ( UsePIC )
fprintf( outfile, "\tcall %s\n ", asm_name("RELAY_DebugCallFrom16Ret@PLT"));
else
fprintf( outfile, "\tcall %s\n ", asm_name("RELAY_DebugCallFrom16Ret"));
fprintf( outfile, "\tpopl %%eax\n" );
fprintf( outfile, "\tpopl %%eax\n" );
if ( UsePIC )
fprintf( outfile, "\tpopl %%ebx\n" );
}
if ( reg_func ) if ( reg_func )
{ {
fprintf( outfile, "\tleal -%d(%%ebp), %%ebx\n", fprintf( outfile, "\tleal -%d(%%ebp), %%ebx\n",
......
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