From 55c9f5a521697201c776a7e89452c706b02c5737 Mon Sep 17 00:00:00 2001 From: icex2 Date: Fri, 21 Aug 2020 16:32:24 +0200 Subject: [PATCH] hooks for inject: Fix log output in DllMain With the new inject tool, the output of OutputDebugString is available on console and file logging. --- src/main/iidxhook1/dllmain.c | 15 +-------------- src/main/iidxhook2/dllmain.c | 15 +-------------- src/main/iidxhook3/dllmain.c | 16 ++-------------- src/main/jbhook1/dllmain.c | 15 +-------------- 4 files changed, 5 insertions(+), 56 deletions(-) diff --git a/src/main/iidxhook1/dllmain.c b/src/main/iidxhook1/dllmain.c index c4bf21d..492b67a 100644 --- a/src/main/iidxhook1/dllmain.c +++ b/src/main/iidxhook1/dllmain.c @@ -244,12 +244,7 @@ skip: BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx) { if (reason == DLL_PROCESS_ATTACH) { -#ifdef DEBUG_HOOKING - FILE *file = fopen("iidxhook.dllmain.log", "w+"); - log_to_writer(log_writer_file, file); -#else - log_to_writer(log_writer_null, NULL); -#endif + log_to_writer(log_writer_debug, NULL); /* Bootstrap hook for further init tasks (see above) */ @@ -262,14 +257,6 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx) adapter_hook_init(); eamuse_hook_init(); settings_hook_init(); - -#ifdef DEBUG_HOOKING - fflush(file); - fclose(file); -#endif - - /* Logging to file and other destinations is handled by inject */ - log_to_writer(log_writer_debug, NULL); } return TRUE; diff --git a/src/main/iidxhook2/dllmain.c b/src/main/iidxhook2/dllmain.c index 9024006..26ccb12 100644 --- a/src/main/iidxhook2/dllmain.c +++ b/src/main/iidxhook2/dllmain.c @@ -243,12 +243,7 @@ skip: BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx) { if (reason == DLL_PROCESS_ATTACH) { -#ifdef DEBUG_HOOKING - FILE *file = fopen("iidxhook.dllmain.log", "w+"); - log_to_writer(log_writer_file, file); -#else - log_to_writer(log_writer_null, NULL); -#endif + log_to_writer(log_writer_debug, NULL); /* Bootstrap hook for further init tasks (see above) */ @@ -261,14 +256,6 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx) adapter_hook_init(); eamuse_hook_init(); settings_hook_init(); - -#ifdef DEBUG_HOOKING - fflush(file); - fclose(file); -#endif - - /* Logging to file and other destinations is handled by inject */ - log_to_writer(log_writer_debug, NULL); } return TRUE; diff --git a/src/main/iidxhook3/dllmain.c b/src/main/iidxhook3/dllmain.c index 656477b..7f7ba13 100644 --- a/src/main/iidxhook3/dllmain.c +++ b/src/main/iidxhook3/dllmain.c @@ -234,12 +234,8 @@ skip: BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx) { if (reason == DLL_PROCESS_ATTACH) { -#ifdef DEBUG_HOOKING - FILE *file = fopen("iidxhook.dllmain.log", "w+"); - log_to_writer(log_writer_file, file); -#else - log_to_writer(log_writer_null, NULL); -#endif + log_to_writer(log_writer_debug, NULL); + /* Bootstrap hook for further init tasks (see above) */ hook_table_apply( @@ -253,14 +249,6 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx) adapter_hook_init(); eamuse_hook_init(); settings_hook_init(); - -#ifdef DEBUG_HOOKING - fflush(file); - fclose(file); -#endif - - /* Logging to file and other destinations is handled by inject */ - log_to_writer(log_writer_debug, NULL); } return TRUE; diff --git a/src/main/jbhook1/dllmain.c b/src/main/jbhook1/dllmain.c index b3d61b2..1c58893 100644 --- a/src/main/jbhook1/dllmain.c +++ b/src/main/jbhook1/dllmain.c @@ -148,12 +148,7 @@ static HWND CDECL my_mwindow_create( BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx) { if (reason == DLL_PROCESS_ATTACH) { -#ifdef DEBUG_HOOKING - FILE *file = fopen("jbhook.dllmain.log", "w+"); - log_to_writer(log_writer_file, file); -#else - log_to_writer(log_writer_null, NULL); -#endif + log_to_writer(log_writer_debug, NULL); /* Bootstrap hook for further init tasks (see above) */ @@ -164,14 +159,6 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx) acp_hook_init(); adapter_hook_init(); - -#ifdef DEBUG_HOOKING - fflush(file); - fclose(file); -#endif - - /* Logging to file and other destinations is handled by inject */ - log_to_writer(log_writer_debug, NULL); } return TRUE;