1
0
mirror of https://github.com/djhackersdev/bemanitools.git synced 2024-11-28 08:20:51 +01:00

util/log: Remove log_error, replace occurances with log_warning

log_error was using the log_writer_fatal impl which conflicts with
how this is used on AVS. Therefore, achieve a visible "error"
message in inject by using log_warning + ERROR string in the message
This commit is contained in:
icex2 2020-09-02 21:28:35 +02:00
parent 475d438ec7
commit 917dc88826
4 changed files with 31 additions and 33 deletions

View File

@ -122,8 +122,8 @@ read_debug_str(HANDLE process, const OUTPUT_DEBUG_STRING_INFO *odsi)
} else { } else {
free(str); free(str);
log_error( log_warning(
"ReadProcessMemory for debug string failed: %08x", "ERROR: ReadProcessMemory for debug string failed: %08x",
(unsigned int) GetLastError()); (unsigned int) GetLastError());
str = NULL; str = NULL;
} }
@ -149,12 +149,12 @@ read_debug_wstr(HANDLE process, const OUTPUT_DEBUG_STRING_INFO *odsi)
if (wstr_narrow(wstr, &str)) { if (wstr_narrow(wstr, &str)) {
str[odsi->nDebugStringLength - 1] = '\0'; str[odsi->nDebugStringLength - 1] = '\0';
} else { } else {
log_error("OutputDebugStringW: UTF-16 conversion failed"); log_warning("ERROR: OutputDebugStringW: UTF-16 conversion failed");
str = NULL; str = NULL;
} }
} else { } else {
log_error( log_warning(
"ReadProcessMemory for debug string failed: %08x", "ERROR: ReadProcessMemory for debug string failed: %08x",
(unsigned int) GetLastError()); (unsigned int) GetLastError());
str = NULL; str = NULL;
} }
@ -221,8 +221,8 @@ static bool debugger_create_process(
app_name, cmd_line, NULL, NULL, FALSE, flags, NULL, NULL, &si, &pi); app_name, cmd_line, NULL, NULL, FALSE, flags, NULL, NULL, &si, &pi);
if (!ok) { if (!ok) {
log_error( log_warning(
"Failed to launch hooked EXE: %08x", (unsigned int) GetLastError()); "ERRPR: Failed to launch hooked EXE: %08x", (unsigned int) GetLastError());
free(cmd_line); free(cmd_line);
@ -246,8 +246,8 @@ static bool debugger_loop()
for (;;) { for (;;) {
if (!WaitForDebugEvent(&de, INFINITE)) { if (!WaitForDebugEvent(&de, INFINITE)) {
log_error( log_warning(
"WaitForDebugEvent failed: %08x", "ERROR: WaitForDebugEvent failed: %08x",
(unsigned int) GetLastError()); (unsigned int) GetLastError());
return false; return false;
} }
@ -364,8 +364,8 @@ static bool debugger_loop()
if (!ContinueDebugEvent( if (!ContinueDebugEvent(
de.dwProcessId, de.dwThreadId, continue_status)) { de.dwProcessId, de.dwThreadId, continue_status)) {
log_error( log_warning(
"ContinueDebugEvent failed: %08x", "ERROR: ContinueDebugEvent failed: %08x",
(unsigned int) GetLastError()); (unsigned int) GetLastError());
return false; return false;
} }
@ -410,8 +410,8 @@ bool debugger_init(bool local_debugger, const char *app_name, char *cmd_line)
if (!debugger_ready_event) { if (!debugger_ready_event) {
free(cmd_line); free(cmd_line);
log_error( log_warning(
"Creating event object failed: %08x", "ERROR: Creating event object failed: %08x",
(unsigned int) GetLastError()); (unsigned int) GetLastError());
return false; return false;
} }
@ -430,8 +430,8 @@ bool debugger_init(bool local_debugger, const char *app_name, char *cmd_line)
free(cmd_line); free(cmd_line);
free(thread_params); free(thread_params);
log_error( log_warning(
"Creating debugger thread failed: %08x", "ERROR: Creating debugger thread failed: %08x",
(unsigned int) GetLastError()); (unsigned int) GetLastError());
return false; return false;
} }
@ -453,8 +453,8 @@ bool debugger_wait_for_remote_debugger()
res = FALSE; res = FALSE;
if (!CheckRemoteDebuggerPresent(pi.hProcess, &res)) { if (!CheckRemoteDebuggerPresent(pi.hProcess, &res)) {
log_error( log_warning(
"CheckRemoteDebuggerPresent failed: %08x", "ERROR: CheckRemoteDebuggerPresent failed: %08x",
(unsigned int) GetLastError()); (unsigned int) GetLastError());
return false; return false;
} }
@ -495,7 +495,7 @@ bool debugger_inject_dll(const char *path_dll)
PAGE_READWRITE); PAGE_READWRITE);
if (!remote_addr) { if (!remote_addr) {
log_error("VirtualAllocEx failed: %08x", (unsigned int) GetLastError()); log_warning("ERROR: VirtualAllocEx failed: %08x", (unsigned int) GetLastError());
goto alloc_fail; goto alloc_fail;
} }
@ -504,8 +504,8 @@ bool debugger_inject_dll(const char *path_dll)
pi.hProcess, remote_addr, dll_path, dll_path_length, NULL); pi.hProcess, remote_addr, dll_path, dll_path_length, NULL);
if (!ok) { if (!ok) {
log_error( log_warning(
"WriteProcessMemory failed: %08x", (unsigned int) GetLastError()); "ERROR: WriteProcessMemory failed: %08x", (unsigned int) GetLastError());
goto write_fail; goto write_fail;
} }
@ -520,8 +520,8 @@ bool debugger_inject_dll(const char *path_dll)
NULL); NULL);
if (remote_thread == NULL) { if (remote_thread == NULL) {
log_error( log_warning(
"CreateRemoteThread failed: %08x", (unsigned int) GetLastError()); "ERROR: CreateRemoteThread failed: %08x", (unsigned int) GetLastError());
goto inject_fail; goto inject_fail;
} }
@ -533,7 +533,7 @@ bool debugger_inject_dll(const char *path_dll)
remote_addr = NULL; remote_addr = NULL;
if (!ok) { if (!ok) {
log_error("VirtualFreeEx failed: %08x", (unsigned int) GetLastError()); log_warning("ERROR: VirtualFreeEx failed: %08x", (unsigned int) GetLastError());
} }
return true; return true;
@ -553,8 +553,8 @@ bool debugger_resume_process()
log_info("Resuming remote process..."); log_info("Resuming remote process...");
if (ResumeThread(pi.hThread) == -1) { if (ResumeThread(pi.hThread) == -1) {
log_error( log_warning(
"Error resuming remote process: %08x", "ERROR: Resuming remote process: %08x",
(unsigned int) GetLastError()); (unsigned int) GetLastError());
return false; return false;
} }

View File

@ -185,8 +185,8 @@ bool logger_init(const char *log_file_path)
log_info("Log file: %s", log_file_path); log_info("Log file: %s", log_file_path);
if (!log_file) { if (!log_file) {
log_error( log_warning(
"Opening log file %s failed: %s", "ERROR: Opening log file %s failed: %s",
log_file_path, log_file_path,
strerror(errno)); strerror(errno));
return false; return false;

View File

@ -54,12 +54,12 @@ static bool verify_hook_dll_and_exec_args_and_count_hooks(
} }
if (!(*hooks)) { if (!(*hooks)) {
log_error("No Hook DLL(s) specified before executable"); log_warning("ERROR: No Hook DLL(s) specified before executable");
return false; return false;
} }
if (!*exec_arg_pos) { if (!*exec_arg_pos) {
log_error("No executable specified"); log_warning("ERROR: No executable specified");
return false; return false;
} }
@ -83,8 +83,8 @@ verify_hook_dlls_exist(int argc, char **argv, uint32_t hook_dll_count)
SearchPath(NULL, argv[i + 1], NULL, MAX_PATH, dll_path, NULL); SearchPath(NULL, argv[i + 1], NULL, MAX_PATH, dll_path, NULL);
if (dll_path_length == 0) { if (dll_path_length == 0) {
log_error( log_warning(
"Hook DLL not found: %08x", (unsigned int) GetLastError()); "ERROR: Hook DLL not found: %08x", (unsigned int) GetLastError());
return false; return false;
} }

View File

@ -22,7 +22,6 @@
#define log_misc(...) log_impl_misc(LOG_MODULE, __VA_ARGS__) #define log_misc(...) log_impl_misc(LOG_MODULE, __VA_ARGS__)
#define log_info(...) log_impl_info(LOG_MODULE, __VA_ARGS__) #define log_info(...) log_impl_info(LOG_MODULE, __VA_ARGS__)
#define log_warning(...) log_impl_warning(LOG_MODULE, __VA_ARGS__) #define log_warning(...) log_impl_warning(LOG_MODULE, __VA_ARGS__)
#define log_error(...) log_impl_fatal(LOG_MODULE, __VA_ARGS__)
/* This doesn't really belong here, but it's what libavs does so w/e */ /* This doesn't really belong here, but it's what libavs does so w/e */
@ -38,7 +37,6 @@
#define log_misc(...) #define log_misc(...)
#define log_info(...) #define log_info(...)
#define log_warning(...) #define log_warning(...)
#define log_error(...)
#define log_assert(x) \ #define log_assert(x) \
do { \ do { \
if (!(x)) { \ if (!(x)) { \