Commit 06b97899 authored by Alexandre Julliard's avatar Alexandre Julliard

Win32 register functions can now have arguments.

Simplified relay debugging for register functions.
parent fd456277
......@@ -145,6 +145,7 @@ static BUILTIN32_DLL BuiltinDLLs[] =
};
extern void RELAY_CallFrom32();
extern void RELAY_CallFrom32Regs();
/***********************************************************************
* BUILTIN32_DoLoadImage
......@@ -362,29 +363,25 @@ static HMODULE BUILTIN32_DoLoadImage( BUILTIN32_DLL *dll )
}
switch(args)
{
case 0xfe: /* register func */
debug->call = 0xe8;
debug->callfrom32 = (DWORD)dll->descr->functions[i] -
(DWORD)&debug->ret;
debug->ret = 0x90; /* nop */
debug->args = 0;
*funcs = (LPVOID)((BYTE *)debug - addr);
break;
case 0xfd: /* forward */
case 0xff: /* stub or extern */
break;
default: /* normal function (stdcall or cdecl) */
default: /* normal function (stdcall or cdecl or register) */
if (TRACE_ON(relay)) {
debug->call = 0xe8; /* lcall relative */
debug->callfrom32 = (DWORD)RELAY_CallFrom32 -
(DWORD)&debug->ret;
if (args & 0x40) /* register func */
debug->callfrom32 = (DWORD)RELAY_CallFrom32Regs -
(DWORD)&debug->ret;
else
debug->callfrom32 = (DWORD)RELAY_CallFrom32 -
(DWORD)&debug->ret;
} else {
debug->call = 0xe9; /* ljmp relative */
debug->callfrom32 = (DWORD)dll->descr->functions[i] -
(DWORD)&debug->ret;
}
debug->ret = (args & 0x80) ? 0xc3 : 0xc2; /*ret/ret $n*/
debug->args = (args & 0x7f) * sizeof(int);
debug->args = (args & 0x3f) * sizeof(int);
*funcs = (LPVOID)((BYTE *)debug - addr);
break;
}
......
......@@ -719,7 +719,7 @@ import ntdll.dll
698 stdcall UTRegister(long str str str ptr ptr ptr) UTRegister
699 stdcall UTUnRegister(long) UTUnRegister
700 stdcall UnMapLS(long) UnMapLS
701 register UnMapSLFixArray() UnMapSLFixArray
701 register UnMapSLFixArray(long long) UnMapSLFixArray
702 stdcall UnhandledExceptionFilter(ptr) UnhandledExceptionFilter
703 stdcall UninitializeCriticalSection(ptr) UninitializeCriticalSection
704 stdcall UnlockFile(long long long long long) UnlockFile
......@@ -926,3 +926,8 @@ import ntdll.dll
#1599 wrong ordinal (249 in Win32s's W32SCOMB.DLL) !
1599 stdcall Get16DLLAddress(long str) Get16DLLAddress
# Wine internal functions
1600 register SNOOP_Entry() SNOOP_Entry
1601 register SNOOP_Return() SNOOP_Return
1602 register RELAY_CallFrom32Regs() RELAY_CallFrom32Regs
......@@ -23,6 +23,9 @@ DEFAULT_DEBUG_CHANNEL(snoop)
char **debug_snoop_excludelist = NULL, **debug_snoop_includelist = NULL;
extern void SNOOP_Entry();
extern void SNOOP_Return();
#ifdef __i386__
#ifdef NEED_UNDERSCORE_PREFIX
......@@ -31,27 +34,6 @@ char **debug_snoop_excludelist = NULL, **debug_snoop_includelist = NULL;
# define PREFIX
#endif
/* Well, not exactly extern since they are in the same file (in the lines
* below). But the C Compiler doesn't see them there, so we have to help a bit.
*/
extern void SNOOP_Return();
extern void SNOOP_Entry();
__asm__(".align 4\n\t"
".globl "PREFIX"SNOOP_Entry\n\t"
".type "PREFIX"SNOOP_Entry,@function\n\t"
PREFIX"SNOOP_Entry:\n\t"
"pushl $"PREFIX"__regs_SNOOP_Entry\n\t"
"pushl $"PREFIX"CALL32_Regs\n\t"
"ret\n\t"
".align 4\n\t"
".globl "PREFIX"SNOOP_Return\n\t"
".type "PREFIX"SNOOP_Return,@function\n\t"
PREFIX"SNOOP_Return:\n\t"
"pushl $"PREFIX"__regs_SNOOP_Return\n\t"
"pushl $"PREFIX"CALL32_Regs\n\t"
"ret"
);
#include "pshpack1.h"
typedef struct tagSNOOP_FUN {
......@@ -267,8 +249,9 @@ SNOOP_PrintArg(DWORD x) {
return buf;
}
#define CALLER1REF (*(DWORD*)(ESP_reg(context)+4))
REGS_ENTRYPOINT(SNOOP_Entry) {
#define CALLER1REF (*(DWORD*)ESP_reg(context))
void WINAPI REGS_FUNC(SNOOP_Entry)( CONTEXT *context )
{
DWORD ordinal=0,entry = EIP_reg(context)-5;
SNOOP_DLL *dll = firstdll;
SNOOP_FUN *fun = NULL;
......@@ -336,18 +319,19 @@ REGS_ENTRYPOINT(SNOOP_Entry) {
if (fun->nrofargs>0) {
max = fun->nrofargs; if (max>16) max=16;
for (i=0;i<max;i++)
DPRINTF("%s%s",SNOOP_PrintArg(*(DWORD*)(ESP_reg(context)+8+sizeof(DWORD)*i)),(i<fun->nrofargs-1)?",":"");
DPRINTF("%s%s",SNOOP_PrintArg(*(DWORD*)(ESP_reg(context)+4+sizeof(DWORD)*i)),(i<fun->nrofargs-1)?",":"");
if (max!=fun->nrofargs)
DPRINTF(" ...");
} else if (fun->nrofargs<0) {
DPRINTF("<unknown, check return>");
ret->args = HeapAlloc(SystemHeap,0,16*sizeof(DWORD));
memcpy(ret->args,(LPBYTE)(ESP_reg(context)+8),sizeof(DWORD)*16);
memcpy(ret->args,(LPBYTE)(ESP_reg(context)+4),sizeof(DWORD)*16);
}
DPRINTF(") ret=%08lx fs=%04lx\n",(DWORD)ret->origreturn,FS_reg(context));
}
REGS_ENTRYPOINT(SNOOP_Return) {
void WINAPI REGS_FUNC(SNOOP_Return)( CONTEXT *context )
{
SNOOP_RETURNENTRY *ret = (SNOOP_RETURNENTRY*)(EIP_reg(context)-5);
/* We haven't found out the nrofargs yet. If we called a cdecl
......@@ -388,4 +372,8 @@ void SNOOP_RegisterDLL(HMODULE hmod,LPCSTR name,DWORD nrofordinals) {
FARPROC SNOOP_GetProcAddress(HMODULE hmod,LPCSTR name,DWORD ordinal,FARPROC origfun) {
return origfun;
}
REGS_ENTRYPOINT(SNOOP_Entry) { }
REGS_ENTRYPOINT(SNOOP_Return) { }
#endif /* !__i386__ */
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