Enable/disable relay32 debugging on the fly. Start app with
-debugmsg +relay or warn+relay. Suggested by Juergen Schmied.
This commit is contained in:
parent
a1d6d247d4
commit
3ad2b93f2d
|
@ -28,6 +28,7 @@ extern ENTRYPOINT32 BUILTIN32_GetEntryPoint( char *buffer, void *relay,
|
||||||
extern void BUILTIN32_Unimplemented( const BUILTIN32_DESCRIPTOR *descr,
|
extern void BUILTIN32_Unimplemented( const BUILTIN32_DESCRIPTOR *descr,
|
||||||
int ordinal );
|
int ordinal );
|
||||||
extern void BUILTIN32_PrintDLLs(void);
|
extern void BUILTIN32_PrintDLLs(void);
|
||||||
|
extern void BUILTIN32_SwitchRelayDebug(int onoff);
|
||||||
extern int BUILTIN32_EnableDLL( const char *name, int len, int enable );
|
extern int BUILTIN32_EnableDLL( const char *name, int len, int enable );
|
||||||
|
|
||||||
#endif /* __WINE_BUILTIN32_H */
|
#endif /* __WINE_BUILTIN32_H */
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "process.h"
|
#include "process.h"
|
||||||
#include "shell.h"
|
#include "shell.h"
|
||||||
#include "winbase.h"
|
#include "winbase.h"
|
||||||
|
#include "builtin32.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "debugdefs.h"
|
#include "debugdefs.h"
|
||||||
#include "xmalloc.h"
|
#include "xmalloc.h"
|
||||||
|
@ -234,7 +235,7 @@ BOOL32 MAIN_ParseDebugOptions(char *options)
|
||||||
extern char **debug_snoop_includelist;
|
extern char **debug_snoop_includelist;
|
||||||
extern char **debug_snoop_excludelist;
|
extern char **debug_snoop_excludelist;
|
||||||
|
|
||||||
int l, cls;
|
int l, cls, dotracerelay = TRACE_ON(relay);
|
||||||
|
|
||||||
l = strlen(options);
|
l = strlen(options);
|
||||||
if (l<3)
|
if (l<3)
|
||||||
|
@ -330,6 +331,11 @@ BOOL32 MAIN_ParseDebugOptions(char *options)
|
||||||
options+=l;
|
options+=l;
|
||||||
}
|
}
|
||||||
while((*options==',')&&(*(++options)));
|
while((*options==',')&&(*(++options)));
|
||||||
|
|
||||||
|
/* special handling for relay debugging */
|
||||||
|
if (dotracerelay != TRACE_ON(relay))
|
||||||
|
BUILTIN32_SwitchRelayDebug( TRACE_ON(relay) );
|
||||||
|
|
||||||
if (*options)
|
if (*options)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
else
|
else
|
||||||
|
|
|
@ -110,6 +110,7 @@ static BUILTIN32_DLL BuiltinDLLs[] =
|
||||||
{ NULL, FALSE }
|
{ NULL, FALSE }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern void RELAY_CallFrom32();
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* BUILTIN32_DoLoadImage
|
* BUILTIN32_DoLoadImage
|
||||||
|
@ -118,7 +119,6 @@ static BUILTIN32_DLL BuiltinDLLs[] =
|
||||||
*/
|
*/
|
||||||
static HMODULE32 BUILTIN32_DoLoadImage( BUILTIN32_DLL *dll )
|
static HMODULE32 BUILTIN32_DoLoadImage( BUILTIN32_DLL *dll )
|
||||||
{
|
{
|
||||||
extern void RELAY_CallFrom32();
|
|
||||||
|
|
||||||
IMAGE_DATA_DIRECTORY *dir;
|
IMAGE_DATA_DIRECTORY *dir;
|
||||||
IMAGE_DOS_HEADER *dos;
|
IMAGE_DOS_HEADER *dos;
|
||||||
|
@ -140,7 +140,7 @@ static HMODULE32 BUILTIN32_DoLoadImage( BUILTIN32_DLL *dll )
|
||||||
+ dll->descr->nb_funcs * sizeof(LPVOID)
|
+ dll->descr->nb_funcs * sizeof(LPVOID)
|
||||||
+ dll->descr->nb_names * sizeof(LPSTR));
|
+ dll->descr->nb_names * sizeof(LPSTR));
|
||||||
#ifdef __i386__
|
#ifdef __i386__
|
||||||
if (TRACE_ON(relay))
|
if (WARN_ON(relay) || TRACE_ON(relay))
|
||||||
size += dll->descr->nb_funcs * sizeof(DEBUG_ENTRY_POINT);
|
size += dll->descr->nb_funcs * sizeof(DEBUG_ENTRY_POINT);
|
||||||
#endif
|
#endif
|
||||||
addr = VirtualAlloc( NULL, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE );
|
addr = VirtualAlloc( NULL, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE );
|
||||||
|
@ -206,7 +206,7 @@ static HMODULE32 BUILTIN32_DoLoadImage( BUILTIN32_DLL *dll )
|
||||||
strcpy( sec->Name, ".code" );
|
strcpy( sec->Name, ".code" );
|
||||||
sec->SizeOfRawData = 0;
|
sec->SizeOfRawData = 0;
|
||||||
#ifdef __i386__
|
#ifdef __i386__
|
||||||
if (TRACE_ON(relay))
|
if (WARN_ON(relay) || TRACE_ON(relay))
|
||||||
sec->SizeOfRawData += dll->descr->nb_funcs * sizeof(DEBUG_ENTRY_POINT);
|
sec->SizeOfRawData += dll->descr->nb_funcs * sizeof(DEBUG_ENTRY_POINT);
|
||||||
#endif
|
#endif
|
||||||
sec->Misc.VirtualSize = sec->SizeOfRawData;
|
sec->Misc.VirtualSize = sec->SizeOfRawData;
|
||||||
|
@ -235,7 +235,7 @@ static HMODULE32 BUILTIN32_DoLoadImage( BUILTIN32_DLL *dll )
|
||||||
if (!dll->descr->functions[i]) continue;
|
if (!dll->descr->functions[i]) continue;
|
||||||
*funcs = (LPVOID)((BYTE *)dll->descr->functions[i] - addr);
|
*funcs = (LPVOID)((BYTE *)dll->descr->functions[i] - addr);
|
||||||
#ifdef __i386__
|
#ifdef __i386__
|
||||||
if (!TRACE_ON(relay)) continue;
|
if (!(WARN_ON(relay) || TRACE_ON(relay))) continue;
|
||||||
for (j=0;j<dll->descr->nb_names;j++)
|
for (j=0;j<dll->descr->nb_names;j++)
|
||||||
if (dll->descr->ordinals[j] == i)
|
if (dll->descr->ordinals[j] == i)
|
||||||
break;
|
break;
|
||||||
|
@ -260,9 +260,15 @@ static HMODULE32 BUILTIN32_DoLoadImage( BUILTIN32_DLL *dll )
|
||||||
case 0xff: /* stub or extern */
|
case 0xff: /* stub or extern */
|
||||||
break;
|
break;
|
||||||
default: /* normal function (stdcall or cdecl) */
|
default: /* normal function (stdcall or cdecl) */
|
||||||
debug->call = 0xe8;
|
if (TRACE_ON(relay)) {
|
||||||
|
debug->call = 0xe8; /* lcall relative */
|
||||||
debug->callfrom32 = (DWORD)RELAY_CallFrom32 -
|
debug->callfrom32 = (DWORD)RELAY_CallFrom32 -
|
||||||
(DWORD)&debug->ret;
|
(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->ret = (args & 0x80) ? 0xc3 : 0xc2; /*ret/ret $n*/
|
||||||
debug->args = (args & 0x7f) * sizeof(int);
|
debug->args = (args & 0x7f) * sizeof(int);
|
||||||
*funcs = (LPVOID)((BYTE *)debug - addr);
|
*funcs = (LPVOID)((BYTE *)debug - addr);
|
||||||
|
@ -360,6 +366,43 @@ ENTRYPOINT32 BUILTIN32_GetEntryPoint( char *buffer, void *relay,
|
||||||
return dll->descr->functions[ordinal];
|
return dll->descr->functions[ordinal];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* BUILTIN32_SwitchRelayDebug
|
||||||
|
*
|
||||||
|
* FIXME: enhance to do it module relative.
|
||||||
|
*/
|
||||||
|
void BUILTIN32_SwitchRelayDebug(BOOL32 onoff) {
|
||||||
|
BUILTIN32_DLL *dll;
|
||||||
|
HMODULE32 hModule;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (!(TRACE_ON(relay) || WARN_ON(relay)))
|
||||||
|
return;
|
||||||
|
for (dll = BuiltinDLLs; dll->descr; dll++) {
|
||||||
|
IMAGE_SECTION_HEADER *sec;
|
||||||
|
DEBUG_ENTRY_POINT *debug;
|
||||||
|
if (!dll->used || !(hModule = GetModuleHandle32A(dll->descr->name)))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
sec = PE_SECTIONS(hModule);
|
||||||
|
debug = (DEBUG_ENTRY_POINT *)((DWORD)hModule + sec[1].VirtualAddress);
|
||||||
|
for (i = 0; i < dll->descr->nb_funcs; i++,debug++) {
|
||||||
|
if (!dll->descr->functions[i]) continue;
|
||||||
|
if ((dll->descr->args[i]==0xff) || (dll->descr->args[i]==0xfe))
|
||||||
|
continue;
|
||||||
|
if (onoff) {
|
||||||
|
debug->call = 0xe8; /* lcall relative */
|
||||||
|
debug->callfrom32 = (DWORD)RELAY_CallFrom32 -
|
||||||
|
(DWORD)&debug->ret;
|
||||||
|
} else {
|
||||||
|
debug->call = 0xe9; /* ljmp relative */
|
||||||
|
debug->callfrom32 = (DWORD)dll->descr->functions[i] -
|
||||||
|
(DWORD)&debug->ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* BUILTIN32_Unimplemented
|
* BUILTIN32_Unimplemented
|
||||||
|
|
Loading…
Reference in New Issue