mirror of
https://github.com/solemnwarning/ipxwrapper
synced 2024-12-30 16:45:37 +01:00
Terminate stub symbol names correctly and optionally log calls
This commit is contained in:
parent
8ebce5612d
commit
cbbc7f13b1
@ -45,12 +45,13 @@ for($n = 0; $n < @stubs; $n++) {
|
||||
my $func = $stubs[$n];
|
||||
$func =~ s/^r_//;
|
||||
|
||||
print CODE "\tname$n:\tdb\t'$func'\n";
|
||||
print CODE "\tname$n:\tdb\t'$func', 0\n";
|
||||
print CODE "\taddr$n:\tdd\t0\n";
|
||||
}
|
||||
|
||||
print CODE "\nsection .text\n";
|
||||
print CODE "\textern\t_find_sym\n";
|
||||
#print CODE "\textern\t_log_call\n";
|
||||
|
||||
for($n = 0; $n < @stubs; $n++) {
|
||||
my $func = $stubs[$n];
|
||||
@ -61,9 +62,10 @@ for($n = 0; $n < @stubs; $n++) {
|
||||
my $func = $stubs[$n];
|
||||
|
||||
print CODE "\n_$func:\n";
|
||||
#print CODE "\tpush\tname$n\n";
|
||||
#print CODE "\tcall\t_log_call\n";
|
||||
print CODE "\tcmp\tdword [addr$n], 0\n";
|
||||
print CODE "\tjne\tjmp$n\n\n";
|
||||
|
||||
print CODE "\tjne\tjmp$n\n";
|
||||
print CODE "\tpush\tname$n\n";
|
||||
print CODE "\tcall\t_find_sym\n";
|
||||
print CODE "\tmov\t[addr$n], eax\n";
|
||||
|
@ -23,6 +23,10 @@ static HMODULE ipxdll = NULL;
|
||||
static HMODULE sysdll = NULL;
|
||||
extern char const *dllname;
|
||||
|
||||
#ifdef LOG_CALLS
|
||||
static FILE *call_log = NULL;
|
||||
#endif
|
||||
|
||||
void __stdcall *find_sym(char const *symbol);
|
||||
void debug(char const *fmt, ...);
|
||||
|
||||
@ -44,6 +48,12 @@ static void load_dlls() {
|
||||
}
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE me, DWORD why, LPVOID res) {
|
||||
if(why == DLL_PROCESS_ATTACH) {
|
||||
#ifdef LOG_CALLS
|
||||
call_log = fopen("calls.log", "a");
|
||||
#endif
|
||||
}
|
||||
|
||||
if(why == DLL_PROCESS_DETACH) {
|
||||
if(sysdll) {
|
||||
FreeLibrary(sysdll);
|
||||
@ -54,6 +64,11 @@ BOOL WINAPI DllMain(HINSTANCE me, DWORD why, LPVOID res) {
|
||||
FreeLibrary(ipxdll);
|
||||
ipxdll = NULL;
|
||||
}
|
||||
|
||||
#ifdef LOG_CALLS
|
||||
fclose(call_log);
|
||||
call_log = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@ -94,3 +109,10 @@ void debug(char const *fmt, ...) {
|
||||
real_debug("%s", msgbuf);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef LOG_CALLS
|
||||
void __stdcall log_call(const char *sym) {
|
||||
fprintf(call_log, "%s\n", sym);
|
||||
fflush(call_log);
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user