diff --git a/changes.txt b/changes.txt index 56e086e..9acf6c9 100644 --- a/changes.txt +++ b/changes.txt @@ -9,6 +9,9 @@ Version ???: primary flag set. Bugfix: Added missing exports to wsock32.dll and mswsock.dll. + + Update: Log DLL and function names in ipxwrapper.log when call logging + is enabled. Version 0.2.1: Bugfix: Delay stub DLL LoadLibrary calls until first API call as using diff --git a/mkstubs.pl b/mkstubs.pl index 727a0be..7f69236 100644 --- a/mkstubs.pl +++ b/mkstubs.pl @@ -38,6 +38,7 @@ if(@ARGV == 3) { print CODE "\tglobal\t_dllname\n"; print CODE "\tdllname_s:\tdb\t'".$ARGV[2]."'\n"; print CODE "\t_dllname:\tdd\tdllname_s\n"; + print CODE "\tcall_fmt\tdb\t'\%s:\%s'\n"; } foreach my $func(@stubs) { @@ -50,7 +51,7 @@ foreach my $func(@stubs) { print CODE "\nsection .data\n"; if(@ARGV == 3) { - print CODE "\textern\t_call_log\n"; + print CODE "\textern\t_log_calls\n"; } foreach my $func(@stubs) { @@ -61,8 +62,7 @@ print CODE "\nsection .text\n"; print CODE "\textern\t_find_sym\n"; if(@ARGV == 3) { - print CODE "\textern\t_fputs\n"; - print CODE "\textern\t_fputc\n"; + print CODE "\textern\t_log_printf\n"; } foreach my $func(@stubs) { @@ -70,22 +70,16 @@ foreach my $func(@stubs) { print CODE "_$func:\n"; if(@ARGV == 3) { - print CODE "\tcmp\tdword [dword _call_log], 0\n"; + print CODE "\tcmp\tbyte [_log_calls], 0\n"; print CODE "\tje\t$func\_nolog\n"; - # Write symbol name to log with fputs + # Write DLL and symbol name to log # - print CODE "\tpush\tdword [dword _call_log]\n"; print CODE "\tpush\t$func\_sym\n"; - print CODE "\tcall\t_fputs\n"; - print CODE "\tadd esp, 8\n"; - - # Write newline to log with fputc - # - print CODE "\tpush\tdword [dword _call_log]\n"; - print CODE "\tpush\tdword 0x0A\n"; - print CODE "\tcall\t_fputc\n"; - print CODE "\tadd esp, 8\n"; + print CODE "\tpush\tdllname_s\n"; + print CODE "\tpush\tcall_fmt\n"; + print CODE "\tcall\t_log_printf\n"; + print CODE "\tadd esp, 12\n"; print CODE "\t$func\_nolog:\n"; } diff --git a/src/stubdll.c b/src/stubdll.c index 29c8dfd..bbe59e1 100644 --- a/src/stubdll.c +++ b/src/stubdll.c @@ -23,7 +23,7 @@ static HMODULE ipxdll = NULL; static HMODULE sysdll = NULL; extern char const *dllname; -FILE *call_log = NULL; +unsigned char log_calls = 0; void log_open(); void log_close(); @@ -54,13 +54,9 @@ BOOL WINAPI DllMain(HINSTANCE me, DWORD why, LPVOID res) { if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\IPXWrapper", 0, KEY_QUERY_VALUE, &key) == ERROR_SUCCESS) { DWORD size = 1; - unsigned char log_calls; - if(RegQueryValueEx(key, "log_calls", NULL, NULL, (BYTE*)&log_calls, &size) == ERROR_SUCCESS && size == 1) { - if(log_calls && (call_log = fopen("winsock_calls.log", "a"))) { - setbuf(call_log, NULL); - fprintf(call_log, "%s loaded\n", dllname); - } + if(RegQueryValueEx(key, "log_calls", NULL, NULL, (BYTE*)&log_calls, &size) != ERROR_SUCCESS || size != 1) { + log_calls = 0; } RegCloseKey(key); @@ -76,11 +72,6 @@ BOOL WINAPI DllMain(HINSTANCE me, DWORD why, LPVOID res) { ipxdll = NULL; } - if(call_log) { - fclose(call_log); - call_log = NULL; - } - log_close(); }