From f55476359c1be73030c9f52dd18991a590609d6c Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Sat, 27 Dec 2008 20:02:34 +0100 Subject: [PATCH] ntdll: Make the relay debug code more generic to allow supporting 64-bit platforms. --- dlls/ntdll/relay.c | 75 +++++++++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 35 deletions(-) diff --git a/dlls/ntdll/relay.c b/dlls/ntdll/relay.c index a3031f28e3c..a2b3f497ab6 100644 --- a/dlls/ntdll/relay.c +++ b/dlls/ntdll/relay.c @@ -40,14 +40,11 @@ WINE_DEFAULT_DEBUG_CHANNEL(relay); #ifdef __i386__ -WINE_DECLARE_DEBUG_CHANNEL(snoop); -WINE_DECLARE_DEBUG_CHANNEL(seh); - struct relay_descr /* descriptor for a module */ { void *magic; /* signature */ - void *relay_from_32; /* functions to call from relay thunks */ - void *relay_from_32_regs; + void *relay_call; /* functions to call from relay thunks */ + void *relay_call_regs; void *private; /* reserved for the relay code private data */ const char *entry_point_base; /* base address of entry point thunks */ const unsigned int *entry_point_offsets; /* offsets of entry points thunks */ @@ -302,25 +299,25 @@ static BOOL check_from_module( const WCHAR **includelist, const WCHAR **excludel /*********************************************************************** * RELAY_PrintArgs */ -static inline void RELAY_PrintArgs( const int *args, int nb_args, unsigned int typemask ) +static inline void RELAY_PrintArgs( const INT_PTR *args, int nb_args, unsigned int typemask ) { while (nb_args--) { if ((typemask & 3) && HIWORD(*args)) { if (typemask & 2) - DPRINTF( "%08x %s", *args, debugstr_w((LPCWSTR)*args) ); + DPRINTF( "%08lx %s", *args, debugstr_w((LPCWSTR)*args) ); else - DPRINTF( "%08x %s", *args, debugstr_a((LPCSTR)*args) ); + DPRINTF( "%08lx %s", *args, debugstr_a((LPCSTR)*args) ); } - else DPRINTF( "%08x", *args ); + else DPRINTF( "%08lx", *args ); if (nb_args) DPRINTF( "," ); args++; typemask >>= 2; } } -extern LONGLONG call_entry_point( void *func, int nb_args, const int *args ); +extern LONGLONG call_entry_point( void *func, int nb_args, const INT_PTR *args ); __ASM_GLOBAL_FUNC( call_entry_point, "\tpushl %ebp\n" "\tmovl %esp,%ebp\n" @@ -345,11 +342,11 @@ __ASM_GLOBAL_FUNC( call_entry_point, /*********************************************************************** - * relay_call_from_32 + * relay_call * * stack points to the return address, i.e. the first argument is stack[1]. */ -static LONGLONG WINAPI relay_call_from_32( struct relay_descr *descr, unsigned int idx, const int *stack ) +static LONGLONG WINAPI relay_call( struct relay_descr *descr, unsigned int idx, const INT_PTR *stack ) { LONGLONG ret; WORD ordinal = LOWORD(idx); @@ -367,7 +364,7 @@ static LONGLONG WINAPI relay_call_from_32( struct relay_descr *descr, unsigned i else DPRINTF( "%04x:Call %s.%u(", GetCurrentThreadId(), data->dllname, data->base + ordinal ); RELAY_PrintArgs( stack + 1, nb_args, descr->arg_types[ordinal] ); - DPRINTF( ") ret=%08x\n", stack[0] ); + DPRINTF( ") ret=%08lx\n", stack[0] ); ret = call_entry_point( entry_point->orig_func, nb_args, stack + 1 ); @@ -377,21 +374,21 @@ static LONGLONG WINAPI relay_call_from_32( struct relay_descr *descr, unsigned i DPRINTF( "%04x:Ret %s.%u()", GetCurrentThreadId(), data->dllname, data->base + ordinal ); if (flags & 1) /* 64-bit return value */ - DPRINTF( " retval=%08x%08x ret=%08x\n", + DPRINTF( " retval=%08x%08x ret=%08lx\n", (UINT)(ret >> 32), (UINT)ret, stack[0] ); else - DPRINTF( " retval=%08x ret=%08x\n", (UINT)ret, stack[0] ); + DPRINTF( " retval=%08lx ret=%08lx\n", (UINT_PTR)ret, stack[0] ); } return ret; } /*********************************************************************** - * relay_call_from_32_regs + * relay_call_regs */ -void WINAPI __regs_relay_call_from_32_regs( struct relay_descr *descr, unsigned int idx, - unsigned int orig_eax, unsigned int ret_addr, - CONTEXT86 *context ) +void WINAPI __regs_relay_call_regs( struct relay_descr *descr, unsigned int idx, + unsigned int orig_eax, unsigned int ret_addr, + CONTEXT86 *context ) { WORD ordinal = LOWORD(idx); BYTE nb_args = LOBYTE(HIWORD(idx)); @@ -399,8 +396,8 @@ void WINAPI __regs_relay_call_from_32_regs( struct relay_descr *descr, unsigned struct relay_private_data *data = descr->private; struct relay_entry_point *entry_point = data->entry_points + ordinal; BYTE *orig_func = entry_point->orig_func; - int *args = (int *)context->Esp; - int args_copy[32]; + INT_PTR *args = (INT_PTR *)context->Esp; + INT_PTR args_copy[32]; /* restore the context to what it was before the relay thunk */ context->Eax = orig_eax; @@ -452,8 +449,8 @@ void WINAPI __regs_relay_call_from_32_regs( struct relay_descr *descr, unsigned context->SegDs, context->SegEs, context->SegFs, context->SegGs, context->EFlags ); } } -extern void WINAPI relay_call_from_32_regs(void); -DEFINE_REGS_ENTRYPOINT( relay_call_from_32_regs, 16, 16 ) +extern void WINAPI relay_call_regs(void); +DEFINE_REGS_ENTRYPOINT( relay_call_regs, 16, 16 ) /*********************************************************************** @@ -502,8 +499,8 @@ void RELAY_SetupDLL( HMODULE module ) (exports->NumberOfFunctions-1) * sizeof(data->entry_points) ))) return; - descr->relay_from_32 = relay_call_from_32; - descr->relay_from_32_regs = relay_call_from_32_regs; + descr->relay_call = relay_call; + descr->relay_call_regs = relay_call_regs; descr->private = data; data->module = module; @@ -538,12 +535,30 @@ void RELAY_SetupDLL( HMODULE module ) } } +#else /* __i386__ */ + +FARPROC RELAY_GetProcAddress( HMODULE module, const IMAGE_EXPORT_DIRECTORY *exports, + DWORD exp_size, FARPROC proc, DWORD ordinal, const WCHAR *user ) +{ + return proc; +} + +void RELAY_SetupDLL( HMODULE module ) +{ +} + +#endif /* __i386__ */ /***********************************************************************/ /* snoop support */ /***********************************************************************/ +#ifdef __i386__ + +WINE_DECLARE_DEBUG_CHANNEL(seh); +WINE_DECLARE_DEBUG_CHANNEL(snoop); + #include "pshpack1.h" typedef struct @@ -931,22 +946,12 @@ DEFINE_REGS_ENTRYPOINT( SNOOP_Return, 0, 0 ) #else /* __i386__ */ -FARPROC RELAY_GetProcAddress( HMODULE module, const IMAGE_EXPORT_DIRECTORY *exports, - DWORD exp_size, FARPROC proc, DWORD ordinal, const WCHAR *user ) -{ - return proc; -} - FARPROC SNOOP_GetProcAddress( HMODULE hmod, const IMAGE_EXPORT_DIRECTORY *exports, DWORD exp_size, FARPROC origfun, DWORD ordinal, const WCHAR *user ) { return origfun; } -void RELAY_SetupDLL( HMODULE module ) -{ -} - void SNOOP_SetupDLL( HMODULE hmod ) { FIXME("snooping works only on i386 for now.\n"); -- 2.11.4.GIT