refactor(inject): Use new core thread and log modules

Keep this a separate commit because this also removes
inject's own logging engine and replaces it with the
streamlined core API. The core API provides all the
features of inject's own logging engine which also
performed horribly. The entire logging operation
was locked which included expensive operations
that formatted the log messages and required
memory allocations and copying around data.

The core API's implementation at least only
synchronizes the actual IO operations
(though this can be improved further with an
actual async logging sink, TBD)
This commit is contained in:
icex2
2024-02-25 09:30:53 +01:00
parent 5ac858e15d
commit d72996c5d9
5 changed files with 72 additions and 257 deletions
+7 -3
View File
@@ -8,10 +8,11 @@
#include <stdio.h>
#include <stdlib.h>
#include "core/log-bt.h"
#include "core/log.h"
#include "inject/debugger.h"
#include "inject/logger.h"
#include "util/log.h"
#include "util/mem.h"
#include "util/proc.h"
#include "util/signal.h"
@@ -178,6 +179,7 @@ static bool log_debug_str(HANDLE process, const OUTPUT_DEBUG_STRING_INFO *odsi)
log_assert(odsi);
char *debug_str;
size_t debug_str_len;
if (odsi->fUnicode) {
debug_str = read_debug_wstr(process, odsi);
@@ -186,7 +188,9 @@ static bool log_debug_str(HANDLE process, const OUTPUT_DEBUG_STRING_INFO *odsi)
}
if (debug_str) {
logger_log(debug_str);
debug_str_len = strlen(debug_str);
core_log_bt_direct_sink_write(debug_str, debug_str_len);
free(debug_str);
return true;