refactor: Entire code base, thread and log usage

Boils down to:
- Include headers
- Reduce boiler plate with helpers
- Swap out explicit usages with core API layer
  and ensure the right API is configured beforehand
This commit is contained in:
icex2
2024-08-14 17:53:51 +02:00
parent 82d1a2df52
commit 93e0a090bc
338 changed files with 1307 additions and 641 deletions
+1
View File
@@ -8,6 +8,7 @@ deplibs_iidxhook3 := \
avs \
libs_iidxhook3 := \
core \
iidxhook-util \
ezusb-emu \
ezusb-iidx-16seg-emu \
+29 -9
View File
@@ -9,6 +9,14 @@
#include "cconfig/cconfig-hook.h"
#include "core/log-bt-ext.h"
#include "core/log-bt.h"
#include "core/log-sink-debug.h"
#include "core/log.h"
#include "core/thread-crt-ext.h"
#include "core/thread-crt.h"
#include "core/thread.h"
#include "ezusb-emu/node-security-plug.h"
#include "ezusb-iidx-emu/node-serial.h"
#include "ezusb-iidx-emu/nodes.h"
@@ -41,9 +49,7 @@
#include "security/rp-sign-key.h"
#include "util/log.h"
#include "util/str.h"
#include "util/thread.h"
#define IIDXHOOK3_INFO_HEADER \
"iidxhook for Gold, DJTroopers, Empress and Sirius" \
@@ -65,6 +71,14 @@ static const struct hook_symbol init_hook_syms[] = {
.link = (void **) &real_OpenProcess},
};
static void _iidxhook3_log_init()
{
core_log_bt_ext_impl_set();
core_log_bt_ext_init_with_debug();
// TODO change log level support
core_log_bt_level_set(CORE_LOG_BT_LOG_LEVEL_MISC);
}
static void
iidxhook3_setup_d3d9_hooks(const struct iidxhook_config_gfx *config_gfx)
{
@@ -199,20 +213,24 @@ my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
/* Start up IIDXIO.DLL */
log_info("Starting IIDX IO backend");
iidx_io_set_loggers(
log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
core_log_impl_assign(iidx_io_set_loggers);
if (!iidx_io_init(thread_create, thread_join, thread_destroy)) {
if (!iidx_io_init(
core_thread_create_impl_get(),
core_thread_join_impl_get(),
core_thread_destroy_impl_get())) {
log_fatal("Initializing IIDX IO backend failed");
}
/* Start up EAMIO.DLL */
log_misc("Initializing card reader backend");
eam_io_set_loggers(
log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
core_log_impl_assign(eam_io_set_loggers);
if (!eam_io_init(thread_create, thread_join, thread_destroy)) {
if (!eam_io_init(
core_thread_create_impl_get(),
core_thread_join_impl_get(),
core_thread_destroy_impl_get())) {
log_fatal("Initializing card reader backend failed");
}
@@ -245,7 +263,9 @@ skip:
BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
{
if (reason == DLL_PROCESS_ATTACH) {
log_to_writer(log_writer_debug, NULL);
core_thread_crt_ext_impl_set();
_iidxhook3_log_init();
/* Bootstrap hook for further init tasks (see above) */