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

View File

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

View File

@ -54,12 +54,12 @@ static bool verify_hook_dll_and_exec_args_and_count_hooks(
}
if (!(*hooks)) {
log_error("No Hook DLL(s) specified before executable");
log_warning("ERROR: No Hook DLL(s) specified before executable");
return false;
}
if (!*exec_arg_pos) {
log_error("No executable specified");
log_warning("ERROR: No executable specified");
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);
if (dll_path_length == 0) {
log_error(
"Hook DLL not found: %08x", (unsigned int) GetLastError());
log_warning(
"ERROR: Hook DLL not found: %08x", (unsigned int) GetLastError());
return false;
}

View File

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