diff --git a/src/main/aciodrv-proc/Module.mk b/src/main/aciodrv-proc/Module.mk index e347f77..9fa6b38 100644 --- a/src/main/aciodrv-proc/Module.mk +++ b/src/main/aciodrv-proc/Module.mk @@ -1,6 +1,7 @@ libs += aciodrv-proc libs_aciodrv-proc := \ + core \ src_aciodrv-proc := \ panb.c \ diff --git a/src/main/aciodrv-proc/panb.c b/src/main/aciodrv-proc/panb.c index c054e21..3f9d5a4 100644 --- a/src/main/aciodrv-proc/panb.c +++ b/src/main/aciodrv-proc/panb.c @@ -5,8 +5,9 @@ #include "aciodrv/device.h" #include "aciodrv/panb.h" -#include "util/log.h" -#include "util/thread.h" +#include "core/thread.h" + +#include "core/log.h" static int auto_poll_proc(void *auto_poll_param); static int auto_poll_threadid; @@ -50,7 +51,7 @@ bool aciodrv_proc_panb_init(struct aciodrv_device_ctx *device) InitializeCriticalSection(&keypair_lock); InitializeCriticalSection(&auto_poll_stop_lock); auto_poll_threadid = - thread_create(auto_poll_proc, (void *) device, 0x4000, 0); + core_thread_create(auto_poll_proc, (void *) device, 0x4000, 0); return true; } @@ -80,8 +81,8 @@ void aciodrv_proc_panb_fini(struct aciodrv_device_ctx *device) auto_poll_stop = true; LeaveCriticalSection(&auto_poll_stop_lock); - thread_join(auto_poll_threadid, NULL); - thread_destroy(auto_poll_threadid); + core_thread_join(auto_poll_threadid, NULL); + core_thread_destroy(auto_poll_threadid); DeleteCriticalSection(&keypair_lock); DeleteCriticalSection(&auto_poll_stop_lock); diff --git a/src/main/aciodrv/device.c b/src/main/aciodrv/device.c index 39bf8af..7584968 100644 --- a/src/main/aciodrv/device.c +++ b/src/main/aciodrv/device.c @@ -7,8 +7,9 @@ #include "aciodrv/port.h" +#include "core/log.h" + #include "util/hex.h" -#include "util/log.h" #include "util/mem.h" /* Enable to dump all data to the logger */ diff --git a/src/main/aciodrv/h44b.c b/src/main/aciodrv/h44b.c index afbab42..19283f6 100644 --- a/src/main/aciodrv/h44b.c +++ b/src/main/aciodrv/h44b.c @@ -7,7 +7,7 @@ #include "aciodrv/device.h" -#include "util/log.h" +#include "core/log.h" bool aciodrv_h44b_init(struct aciodrv_device_ctx *device, uint8_t node_id) { diff --git a/src/main/aciodrv/icca.c b/src/main/aciodrv/icca.c index ac56d0e..7bec0c7 100644 --- a/src/main/aciodrv/icca.c +++ b/src/main/aciodrv/icca.c @@ -5,7 +5,7 @@ #include "aciodrv/device.h" #include "aciodrv/icca.h" -#include "util/log.h" +#include "core/log.h" static bool aciodrv_icca_queue_loop_start( struct aciodrv_device_ctx *device, uint8_t node_id) diff --git a/src/main/aciodrv/kfca.c b/src/main/aciodrv/kfca.c index e21a0b8..88093e4 100644 --- a/src/main/aciodrv/kfca.c +++ b/src/main/aciodrv/kfca.c @@ -5,7 +5,7 @@ #include "aciodrv/device.h" -#include "util/log.h" +#include "core/log.h" static bool aciodrv_kfca_watchdog_start(struct aciodrv_device_ctx *device, uint8_t node_id) diff --git a/src/main/aciodrv/panb.c b/src/main/aciodrv/panb.c index 1412e16..2dbc85e 100644 --- a/src/main/aciodrv/panb.c +++ b/src/main/aciodrv/panb.c @@ -5,8 +5,7 @@ #include "aciodrv/device.h" #include "aciodrv/panb.h" -#include "util/log.h" -#include "util/thread.h" +#include "core/log.h" bool aciodrv_panb_start_auto_input( struct aciodrv_device_ctx *device, uint8_t node_id, uint8_t node_count) diff --git a/src/main/aciodrv/port.c b/src/main/aciodrv/port.c index b38ad2a..c3c9c71 100644 --- a/src/main/aciodrv/port.c +++ b/src/main/aciodrv/port.c @@ -6,7 +6,7 @@ #include -#include "util/log.h" +#include "core/log.h" HANDLE aciodrv_port_open(const char *port_path, int baud) { diff --git a/src/main/aciodrv/rvol.c b/src/main/aciodrv/rvol.c index a9e0c36..ed7c036 100644 --- a/src/main/aciodrv/rvol.c +++ b/src/main/aciodrv/rvol.c @@ -5,7 +5,7 @@ #include "aciodrv/device.h" -#include "util/log.h" +#include "core/log.h" static bool aciodrv_rvol_change_expand_mode( struct aciodrv_device_ctx *device, uint8_t node_id, uint8_t mode) diff --git a/src/main/acioemu/addr.c b/src/main/acioemu/addr.c index 8d85487..3f52fbb 100644 --- a/src/main/acioemu/addr.c +++ b/src/main/acioemu/addr.c @@ -5,7 +5,7 @@ #include "acioemu/addr.h" #include "acioemu/emu.h" -#include "util/log.h" +#include "core/log.h" void ac_io_emu_cmd_assign_addrs( struct ac_io_emu *emu, const struct ac_io_message *req, uint8_t node_count) diff --git a/src/main/acioemu/emu.c b/src/main/acioemu/emu.c index 11cf35a..57f74e0 100644 --- a/src/main/acioemu/emu.c +++ b/src/main/acioemu/emu.c @@ -14,9 +14,10 @@ #include "acioemu/emu.h" #include "acioemu/pipe.h" +#include "core/log.h" + #include "hook/iohook.h" -#include "util/log.h" #include "util/str.h" static HRESULT ac_io_emu_open(struct ac_io_emu *emu, struct irp *irp); diff --git a/src/main/acioemu/hdxs.c b/src/main/acioemu/hdxs.c index 9a38bee..01ec19d 100644 --- a/src/main/acioemu/hdxs.c +++ b/src/main/acioemu/hdxs.c @@ -6,7 +6,7 @@ #include "acioemu/emu.h" #include "acioemu/hdxs.h" -#include "util/log.h" +#include "core/log.h" static void ac_io_emu_hdxs_cmd_send_version( struct ac_io_emu_hdxs *hdxs, const struct ac_io_message *req); diff --git a/src/main/acioemu/pipe.h b/src/main/acioemu/pipe.h index ad442fc..859c3b6 100644 --- a/src/main/acioemu/pipe.h +++ b/src/main/acioemu/pipe.h @@ -7,9 +7,10 @@ #include "acio/acio.h" +#include "core/log.h" + #include "util/iobuf.h" #include "util/list.h" -#include "util/log.h" /* This uses the USB convention where OUT and IN are from the host's (game's) perspective. So an OUT transaction comes in to us and vice versa. diff --git a/src/main/aciomgr/Module.mk b/src/main/aciomgr/Module.mk index 0a17e8c..b87f81b 100644 --- a/src/main/aciomgr/Module.mk +++ b/src/main/aciomgr/Module.mk @@ -1,6 +1,7 @@ dlls += aciomgr libs_aciomgr := \ + core \ aciodrv \ util \ diff --git a/src/main/aciomgr/manager.c b/src/main/aciomgr/manager.c index e73b18e..d7f0378 100644 --- a/src/main/aciomgr/manager.c +++ b/src/main/aciomgr/manager.c @@ -5,14 +5,15 @@ #include #include "aciomgr/manager-init.h" - #include "aciomgr/manager.h" #include "acio/acio.h" #include "aciodrv/device.h" + +#include "core/log.h" + #include "util/array.h" -#include "util/log.h" #define MAX_PORT_PATH_LENGTH 256 @@ -90,7 +91,7 @@ void aciomgr_set_loggers( log_formatter_t warning, log_formatter_t fatal) { - log_to_external(misc, info, warning, fatal); + core_log_impl_set(misc, warning, info, fatal); } struct aciomgr_port_dispatcher *aciomgr_port_init(const char *path, int baud) diff --git a/src/main/aciotest/Module.mk b/src/main/aciotest/Module.mk index af04652..efeb038 100644 --- a/src/main/aciotest/Module.mk +++ b/src/main/aciotest/Module.mk @@ -1,6 +1,7 @@ exes += aciotest libs_aciotest := \ + core \ bio2drv \ aciodrv \ aciodrv-proc \ diff --git a/src/main/aciotest/main.c b/src/main/aciotest/main.c index 4a301c4..fdf6df4 100644 --- a/src/main/aciotest/main.c +++ b/src/main/aciotest/main.c @@ -15,7 +15,14 @@ #include "aciotest/panb.h" #include "aciotest/rvol.h" -#include "util/log.h" +#include "core/log-bt-ext.h" +#include "core/log-bt.h" +#include "core/log.h" +#include "core/thread-crt-ext.h" +#include "core/thread-crt.h" +#include "core/thread.h" + +#include "core/log.h" static uint8_t aciotest_cnt = 0; static uint8_t bi2a_mode = 255; @@ -112,7 +119,10 @@ int main(int argc, char **argv) } } - log_to_writer(log_writer_stdout, NULL); + core_thread_crt_ext_impl_set(); + core_log_bt_ext_impl_set(); + + core_log_bt_ext_init_with_stdout(); struct aciodrv_device_ctx *device = aciodrv_device_open_path(argv[1], atoi(argv[2])); diff --git a/src/main/asio/asio-reghook.c b/src/main/asio/asio-reghook.c index 161b13b..7e05890 100644 --- a/src/main/asio/asio-reghook.c +++ b/src/main/asio/asio-reghook.c @@ -10,13 +10,14 @@ #include +#include "asio/asio-reghook.h" + +#include "core/log.h" + #include "hook/com-proxy.h" #include "hook/table.h" -#include "asio/asio-reghook.h" - #include "util/defs.h" -#include "util/log.h" #include "util/str.h" #include "util/time.h" diff --git a/src/main/asio/config-asio.c b/src/main/asio/config-asio.c index b29f99c..2a8675d 100644 --- a/src/main/asio/config-asio.c +++ b/src/main/asio/config-asio.c @@ -1,8 +1,8 @@ #include "cconfig/cconfig-util.h" -#include "asio/config-asio.h" +#include "core/log.h" -#include "util/log.h" +#include "asio/config-asio.h" #define ASIOHOOK_CONFIG_IO_FORCE_ASIO_KEY "asio.force_asio" #define ASIOHOOK_CONFIG_IO_FORCE_WASAPI_KEY "asio.force_wasapi" diff --git a/src/main/bio2drv/Module.mk b/src/main/bio2drv/Module.mk index f5bdb56..9e5e92b 100644 --- a/src/main/bio2drv/Module.mk +++ b/src/main/bio2drv/Module.mk @@ -1,10 +1,11 @@ libs += bio2drv libs_bio2drv := \ - aciodrv + core \ + aciodrv \ src_bio2drv := \ detect.c \ config-bio2.c \ bi2a-iidx.c \ - bi2a-sdvx.c + bi2a-sdvx.c \ diff --git a/src/main/bio2drv/bi2a-iidx.c b/src/main/bio2drv/bi2a-iidx.c index 1119876..bce8c41 100644 --- a/src/main/bio2drv/bi2a-iidx.c +++ b/src/main/bio2drv/bi2a-iidx.c @@ -7,7 +7,7 @@ #include "aciodrv/device.h" -#include "util/log.h" +#include "core/log.h" // Must be provided on init command. Actual meaning unknown right now. // Not providing this will not initialize the IO correctly resulting diff --git a/src/main/bio2drv/bi2a-sdvx.c b/src/main/bio2drv/bi2a-sdvx.c index 93edf49..14e5239 100644 --- a/src/main/bio2drv/bi2a-sdvx.c +++ b/src/main/bio2drv/bi2a-sdvx.c @@ -7,7 +7,7 @@ #include "aciodrv/device.h" -#include "util/log.h" +#include "core/log.h" static const uint8_t _BIO2DR_BI2A_SDVX_INIT_DATA = 0x3B; diff --git a/src/main/bio2drv/config-bio2.c b/src/main/bio2drv/config-bio2.c index 492cdef..c016fa9 100644 --- a/src/main/bio2drv/config-bio2.c +++ b/src/main/bio2drv/config-bio2.c @@ -1,8 +1,8 @@ #include "cconfig/cconfig-util.h" -#include "bio2drv/config-bio2.h" +#include "core/log.h" -#include "util/log.h" +#include "bio2drv/config-bio2.h" #define BIO2DRV_CONFIG_BIO2_AUTO_KEY "bio2.autodetect" #define BIO2DRV_CONFIG_BIO2_PORT_KEY "bio2.port" diff --git a/src/main/bio2drv/detect.c b/src/main/bio2drv/detect.c index d559175..dfdf501 100644 --- a/src/main/bio2drv/detect.c +++ b/src/main/bio2drv/detect.c @@ -8,11 +8,11 @@ #include "bio2drv/detect.h" +#include "core/log.h" + #include #include -#include "util/log.h" - DEFINE_GUID( GUID_COM_BUS_ENUMERATOR, 0x4D36E978, @@ -142,7 +142,7 @@ void bio2drv_set_loggers( log_formatter_t warning, log_formatter_t fatal) { - log_to_external(misc, info, warning, fatal); + core_log_impl_set(misc, warning, info, fatal); } bool bio2drv_detect( diff --git a/src/main/bio2emu/emu.c b/src/main/bio2emu/emu.c index 9fbcb3d..ea9c7f0 100644 --- a/src/main/bio2emu/emu.c +++ b/src/main/bio2emu/emu.c @@ -14,6 +14,8 @@ #include "acioemu/addr.h" #include "acioemu/emu.h" +#include "core/log.h" + #include "hook/iohook.h" #include "hooklib/rs232.h" @@ -25,7 +27,6 @@ #include "util/array.h" #include "util/defs.h" #include "util/iobuf.h" -#include "util/log.h" #include "util/str.h" static struct array bio2_active_ports; diff --git a/src/main/bio2emu/setupapi.c b/src/main/bio2emu/setupapi.c index 5dbfffc..bb2f32c 100644 --- a/src/main/bio2emu/setupapi.c +++ b/src/main/bio2emu/setupapi.c @@ -6,13 +6,14 @@ #include #include +#include "core/log.h" + #include "hook/table.h" #include "bio2emu/emu.h" #include "bio2emu/setupapi.h" #include "util/defs.h" -#include "util/log.h" #include "util/str.h" #include "util/time.h" diff --git a/src/main/bsthook/Module.mk b/src/main/bsthook/Module.mk index ef61d28..92ab3b1 100644 --- a/src/main/bsthook/Module.mk +++ b/src/main/bsthook/Module.mk @@ -4,6 +4,8 @@ deplibs_bsthook := \ avs \ libs_bsthook := \ + avs-util \ + core \ acioemu \ bstio \ hook \ diff --git a/src/main/bsthook/acio.c b/src/main/bsthook/acio.c index fe5f8cc..500d4c5 100644 --- a/src/main/bsthook/acio.c +++ b/src/main/bsthook/acio.c @@ -19,13 +19,14 @@ #include "bsthook/acio.h" #include "bsthook/kfca.h" +#include "core/log.h" + #include "hook/iohook.h" #include "imports/avs.h" #include "util/defs.h" #include "util/iobuf.h" -#include "util/log.h" #include "util/str.h" static struct ac_io_emu ac_io_emu; diff --git a/src/main/bsthook/dllmain.c b/src/main/bsthook/dllmain.c index 57d38e0..e508057 100644 --- a/src/main/bsthook/dllmain.c +++ b/src/main/bsthook/dllmain.c @@ -2,9 +2,14 @@ #include +#include "avs-util/core-interop.h" + #include "bemanitools/bstio.h" #include "bemanitools/eamio.h" +#include "core/log.h" +#include "core/thread.h" + #include "hook/iohook.h" #include "hooklib/app.h" @@ -18,7 +23,6 @@ #include "util/cmdline.h" #include "util/defs.h" -#include "util/log.h" static bool my_dll_entry_init(char *sidcode, struct property_node *config); static bool my_dll_entry_main(void); @@ -33,19 +37,23 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *config) log_info("Starting up BeatStream IO backend"); - bst_io_set_loggers( - log_body_misc, log_body_info, log_body_warning, log_body_fatal); + core_log_impl_assign(bst_io_set_loggers); - ok = bst_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy); + ok = bst_io_init( + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get()); if (!ok) { goto bst_io_fail; } - eam_io_set_loggers( - log_body_misc, log_body_info, log_body_warning, log_body_fatal); + core_log_impl_assign(eam_io_set_loggers); - ok = eam_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy); + ok = eam_io_init( + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get()); if (!ok) { goto eam_io_fail; @@ -91,8 +99,9 @@ BOOL WINAPI DllMain(HMODULE self, DWORD reason, void *ctx) return TRUE; } - log_to_external( - log_body_misc, log_body_info, log_body_warning, log_body_fatal); + // Use AVS APIs + avs_util_core_interop_thread_avs_impl_set(); + avs_util_core_interop_log_avs_impl_set(); args_recover(&argc, &argv); diff --git a/src/main/bsthook/gfx.c b/src/main/bsthook/gfx.c index 43d88a2..23d37e0 100644 --- a/src/main/bsthook/gfx.c +++ b/src/main/bsthook/gfx.c @@ -3,6 +3,8 @@ #include +#include "core/log.h" + #include "hook/com-proxy.h" #include "hook/pe.h" #include "hook/table.h" @@ -10,7 +12,6 @@ #include "sdvxhook/gfx.h" #include "util/defs.h" -#include "util/log.h" static HRESULT STDCALL my_CreateDevice( IDirect3D9 *self, diff --git a/src/main/bsthook/settings.c b/src/main/bsthook/settings.c index 8f48ea8..c9fb10a 100644 --- a/src/main/bsthook/settings.c +++ b/src/main/bsthook/settings.c @@ -7,10 +7,11 @@ #include #include +#include "core/log.h" + #include "hook/table.h" #include "util/defs.h" -#include "util/log.h" #include "util/str.h" /* ------------------------------------------------------------------------- */ diff --git a/src/main/camhook/cam.c b/src/main/camhook/cam.c index 4ce9260..169fd02 100644 --- a/src/main/camhook/cam.c +++ b/src/main/camhook/cam.c @@ -15,13 +15,14 @@ #include +#include "camhook/cam.h" + +#include "core/log.h" + #include "hook/com-proxy.h" #include "hook/table.h" -#include "camhook/cam.h" - #include "util/defs.h" -#include "util/log.h" #include "util/str.h" #include "util/time.h" diff --git a/src/main/camhook/config-cam.c b/src/main/camhook/config-cam.c index 6a55852..c6dd1af 100644 --- a/src/main/camhook/config-cam.c +++ b/src/main/camhook/config-cam.c @@ -1,8 +1,8 @@ #include "cconfig/cconfig-util.h" -#include "camhook/config-cam.h" +#include "core/log.h" -#include "util/log.h" +#include "camhook/config-cam.h" #define CAMHOOK_CONFIG_CAM_DISABLE_EMU_KEY "cam.disable_emu" #define CAMHOOK_CONFIG_CAM_DEFAULT_DISABLE_EMU_VALUE false diff --git a/src/main/cconfig/cconfig-main.c b/src/main/cconfig/cconfig-main.c index 342a912..342d8df 100644 --- a/src/main/cconfig/cconfig-main.c +++ b/src/main/cconfig/cconfig-main.c @@ -6,8 +6,9 @@ #include "cconfig/cconfig-main.h" +#include "core/log.h" + #include "util/cmdline.h" -#include "util/log.h" bool cconfig_main_config_init( struct cconfig *config, @@ -84,7 +85,7 @@ bool cconfig_main_config_init( } log_misc("Config state after file loading:"); - cconfig_util_log(config, log_impl_misc); + cconfig_util_log(config, core_log_misc_impl_get()); } log_misc("Parsing override config parameters from cmd"); @@ -96,7 +97,7 @@ bool cconfig_main_config_init( } log_misc("Config state after cmd parameter overrides:"); - cconfig_util_log(config, log_impl_misc); + cconfig_util_log(config, core_log_misc_impl_get()); goto success; diff --git a/src/main/cconfig/cconfig-util.c b/src/main/cconfig/cconfig-util.c index f4ce05f..3585357 100644 --- a/src/main/cconfig/cconfig-util.c +++ b/src/main/cconfig/cconfig-util.c @@ -5,8 +5,9 @@ #include "cconfig/cconfig-util.h" +#include "core/log.h" + #include "util/hex.h" -#include "util/log.h" #include "util/mem.h" bool cconfig_util_get_int( @@ -220,10 +221,10 @@ void cconfig_util_set_data( free(str); } -void cconfig_util_log(struct cconfig *config, log_formatter_t log_formatter) +void cconfig_util_log(struct cconfig *config, core_log_message_t log_message) { for (uint32_t i = 0; i < config->nentries; i++) { - log_formatter( + log_message( LOG_MODULE, "%s=%s", config->entries[i].key, diff --git a/src/main/cconfig/cconfig-util.h b/src/main/cconfig/cconfig-util.h index aa9b500..8f6a305 100644 --- a/src/main/cconfig/cconfig-util.h +++ b/src/main/cconfig/cconfig-util.h @@ -7,7 +7,7 @@ #include "cconfig/cconfig.h" -#include "util/log.h" +#include "core/log.h" bool cconfig_util_get_int( struct cconfig *config, @@ -57,6 +57,6 @@ void cconfig_util_set_data( size_t len, const char *desc); -void cconfig_util_log(struct cconfig *config, log_formatter_t log_formatter); +void cconfig_util_log(struct cconfig *config, core_log_message_t log_message); #endif \ No newline at end of file diff --git a/src/main/cconfig/cconfig.c b/src/main/cconfig/cconfig.c index 1cfcbed..6150f66 100644 --- a/src/main/cconfig/cconfig.c +++ b/src/main/cconfig/cconfig.c @@ -2,7 +2,8 @@ #include "cconfig/cconfig.h" -#include "util/log.h" +#include "core/log.h" + #include "util/mem.h" #include "util/str.h" diff --git a/src/main/cconfig/cmd.c b/src/main/cconfig/cmd.c index 3d4f32f..3bb1c24 100644 --- a/src/main/cconfig/cmd.c +++ b/src/main/cconfig/cmd.c @@ -7,8 +7,9 @@ #include "cconfig/cmd.h" +#include "core/log.h" + #include "util/hex.h" -#include "util/log.h" #include "util/str.h" static void diff --git a/src/main/cconfig/conf.c b/src/main/cconfig/conf.c index de21f8b..b23e9d4 100644 --- a/src/main/cconfig/conf.c +++ b/src/main/cconfig/conf.c @@ -6,8 +6,9 @@ #include "cconfig/conf.h" +#include "core/log.h" + #include "util/fs.h" -#include "util/log.h" #include "util/str.h" enum cconfig_conf_error cconfig_conf_load_from_file( diff --git a/src/main/config/Module.mk b/src/main/config/Module.mk index 2f7bac8..fc37a23 100644 --- a/src/main/config/Module.mk +++ b/src/main/config/Module.mk @@ -3,6 +3,7 @@ rc_config := config.rc cppflags_config := -DUNICODE libs_config := \ + core \ eamio \ geninput \ util \ diff --git a/src/main/config/analogs.c b/src/main/config/analogs.c index 5a7bcee..d693667 100644 --- a/src/main/config/analogs.c +++ b/src/main/config/analogs.c @@ -11,13 +11,14 @@ #include "config/schema.h" #include "config/usages.h" +#include "core/log.h" + #include "geninput/hid-mgr.h" #include "geninput/input-config.h" #include "geninput/mapper.h" #include "util/array.h" #include "util/defs.h" -#include "util/log.h" #include "util/mem.h" #include "util/str.h" diff --git a/src/main/config/buttons.c b/src/main/config/buttons.c index f4a498b..e083bf3 100644 --- a/src/main/config/buttons.c +++ b/src/main/config/buttons.c @@ -15,11 +15,12 @@ #include "config/schema.h" #include "config/usages.h" +#include "core/log.h" + #include "geninput/input-config.h" #include "geninput/mapper.h" #include "util/defs.h" -#include "util/log.h" #include "util/mem.h" #include "util/winres.h" diff --git a/src/main/config/eam.c b/src/main/config/eam.c index e9bb76c..1d66518 100644 --- a/src/main/config/eam.c +++ b/src/main/config/eam.c @@ -13,6 +13,8 @@ #include "config/resource.h" #include "config/schema.h" +#include "core/log.h" + #include "eamio/eam-config.h" #include "geninput/hid-mgr.h" @@ -21,7 +23,6 @@ #include "util/array.h" #include "util/defs.h" -#include "util/log.h" #include "util/mem.h" #include "util/str.h" diff --git a/src/main/config/gametype.c b/src/main/config/gametype.c index e7e7353..2ec0ea4 100644 --- a/src/main/config/gametype.c +++ b/src/main/config/gametype.c @@ -6,8 +6,9 @@ #include "config/resource.h" #include "config/schema.h" +#include "core/log.h" + #include "util/defs.h" -#include "util/log.h" static INT_PTR CALLBACK game_type_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); diff --git a/src/main/config/main.c b/src/main/config/main.c index ba51555..8be1370 100644 --- a/src/main/config/main.c +++ b/src/main/config/main.c @@ -14,14 +14,19 @@ #include "config/spinner.h" #include "config/usages.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 "eamio/eam-config.h" #include "geninput/input-config.h" #include "util/defs.h" -#include "util/log.h" #include "util/str.h" -#include "util/thread.h" #include "util/winres.h" HPROPSHEETPAGE @@ -61,11 +66,22 @@ int main(int argc, char **argv) wchar_t text[1024]; int max_light; size_t i; + struct core_log_sink sink; inst = GetModuleHandle(NULL); - log_to_writer(log_writer_debug, NULL); - log_to_external(log_impl_misc, log_impl_info, log_impl_warning, my_fatal); + core_thread_crt_ext_impl_set(); + + core_log_impl_set( + core_log_bt_log_misc, + core_log_bt_log_info, + core_log_bt_log_warning, + my_fatal); + + core_log_sink_debug_open(&sink); + + core_log_bt_init(&sink); + core_log_bt_level_set(CORE_LOG_BT_LOG_LEVEL_MISC); usages_init(inst); @@ -96,13 +112,17 @@ int main(int argc, char **argv) } } - input_set_loggers( - log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal); - input_init(crt_thread_create, crt_thread_join, crt_thread_destroy); + core_log_impl_assign(input_set_loggers); + input_init( + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get()); - eam_io_set_loggers( - log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal); - eam_io_init(crt_thread_create, crt_thread_join, crt_thread_destroy); + core_log_impl_assign(eam_io_set_loggers); + eam_io_init( + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get()); eam_io_config_api = eam_io_get_config_api(); // calculate these and check against the loaded config diff --git a/src/main/config/snap.c b/src/main/config/snap.c index 8981c68..6d8547a 100644 --- a/src/main/config/snap.c +++ b/src/main/config/snap.c @@ -6,10 +6,11 @@ #include "config/snap.h" +#include "core/log.h" + #include "geninput/hid-mgr.h" #include "util/defs.h" -#include "util/log.h" #include "util/mem.h" enum snap_control_heuristic { CONTROL_CENTERING_AXIS, CONTROL_MULTISWITCH }; diff --git a/src/main/config/usages.c b/src/main/config/usages.c index 5e28ad9..771772c 100644 --- a/src/main/config/usages.c +++ b/src/main/config/usages.c @@ -9,8 +9,9 @@ #include "config/resource.h" +#include "core/log.h" + #include "util/array.h" -#include "util/log.h" #include "util/str.h" #include "util/winres.h" diff --git a/src/main/d3d9exhook/config-gfx.c b/src/main/d3d9exhook/config-gfx.c index 6cf57af..b4a5197 100644 --- a/src/main/d3d9exhook/config-gfx.c +++ b/src/main/d3d9exhook/config-gfx.c @@ -4,9 +4,9 @@ #include "cconfig/cconfig-util.h" -#include "d3d9exhook/config-gfx.h" +#include "core/log.h" -#include "util/log.h" +#include "d3d9exhook/config-gfx.h" #define D3D9EXHOOK_CONFIG_GFX_FRAMED_KEY "gfx.framed" #define D3D9EXHOOK_CONFIG_GFX_WINDOWED_KEY "gfx.windowed" diff --git a/src/main/d3d9exhook/d3d9ex.c b/src/main/d3d9exhook/d3d9ex.c index 88d95b0..80d958c 100644 --- a/src/main/d3d9exhook/d3d9ex.c +++ b/src/main/d3d9exhook/d3d9ex.c @@ -9,13 +9,14 @@ #include #include +#include "core/log.h" + #include "hook/com-proxy.h" #include "hook/table.h" #include "d3d9exhook/d3d9ex.h" #include "util/defs.h" -#include "util/log.h" #include "util/str.h" #include "util/time.h" diff --git a/src/main/ddrhook-util/_com4.c b/src/main/ddrhook-util/_com4.c index 44e0178..4ca08c3 100644 --- a/src/main/ddrhook-util/_com4.c +++ b/src/main/ddrhook-util/_com4.c @@ -19,6 +19,8 @@ #include "bemanitools/ddrio.h" +#include "core/log.h" + #include "ddrhook-util/_com4.h" #include "hook/iohook.h" @@ -27,7 +29,6 @@ #include "util/defs.h" #include "util/iobuf.h" -#include "util/log.h" static struct ac_io_emu com4_ac_io_emu; static struct ac_io_emu_hdxs com4_hdxs; diff --git a/src/main/ddrhook-util/dinput.c b/src/main/ddrhook-util/dinput.c index b0fdc66..949fb1e 100644 --- a/src/main/ddrhook-util/dinput.c +++ b/src/main/ddrhook-util/dinput.c @@ -5,12 +5,13 @@ #include +#include "core/log.h" + #include "hook/com-proxy.h" #include "hook/pe.h" #include "hook/table.h" #include "util/defs.h" -#include "util/log.h" static HRESULT STDCALL my_DirectInput8Create( HINSTANCE hinst, diff --git a/src/main/ddrhook-util/extio.c b/src/main/ddrhook-util/extio.c index cd2dc84..661b165 100644 --- a/src/main/ddrhook-util/extio.c +++ b/src/main/ddrhook-util/extio.c @@ -14,10 +14,11 @@ #include "bemanitools/ddrio.h" +#include "core/log.h" + #include "hook/iohook.h" #include "util/iobuf.h" -#include "util/log.h" #include "util/str.h" static HRESULT extio_open(struct irp *irp); diff --git a/src/main/ddrhook-util/gfx.c b/src/main/ddrhook-util/gfx.c index 3f5f773..0bfd0a5 100644 --- a/src/main/ddrhook-util/gfx.c +++ b/src/main/ddrhook-util/gfx.c @@ -11,13 +11,14 @@ #include #include +#include "core/log.h" + #include "hook/com-proxy.h" #include "hook/table.h" #include "ddrhook-util/gfx.h" #include "util/defs.h" -#include "util/log.h" #include "util/str.h" #include "util/time.h" diff --git a/src/main/ddrhook-util/misc.c b/src/main/ddrhook-util/misc.c index b74c8de..e04390d 100644 --- a/src/main/ddrhook-util/misc.c +++ b/src/main/ddrhook-util/misc.c @@ -2,13 +2,14 @@ #include +#include "core/log.h" + #include "ddrhook-util/gfx.h" #include "hook/pe.h" #include "hook/table.h" #include "util/defs.h" -#include "util/log.h" #include "util/str.h" static LRESULT(STDCALL *real_SendMessageW)( diff --git a/src/main/ddrhook-util/monitor.c b/src/main/ddrhook-util/monitor.c index 0dfce07..cba18cc 100644 --- a/src/main/ddrhook-util/monitor.c +++ b/src/main/ddrhook-util/monitor.c @@ -7,12 +7,13 @@ #include #include +#include "core/log.h" + #include "ddrhook-util/monitor.h" #include "hook/table.h" #include "util/defs.h" -#include "util/log.h" #include "util/str.h" /* Link pointers */ diff --git a/src/main/ddrhook-util/p3io.c b/src/main/ddrhook-util/p3io.c index 09b8c6f..af0f1a9 100644 --- a/src/main/ddrhook-util/p3io.c +++ b/src/main/ddrhook-util/p3io.c @@ -7,11 +7,11 @@ #include "ddrhook-util/p3io.h" +#include "core/log.h" + #include "p3ioemu/emu.h" #include "p3ioemu/uart.h" -#include "util/log.h" - extern bool _15khz; extern bool standard_def; diff --git a/src/main/ddrhook-util/spike.c b/src/main/ddrhook-util/spike.c index 0e383d2..37cf888 100644 --- a/src/main/ddrhook-util/spike.c +++ b/src/main/ddrhook-util/spike.c @@ -15,10 +15,11 @@ #include "acioemu/addr.h" #include "acioemu/emu.h" +#include "core/log.h" + #include "hook/iohook.h" #include "util/defs.h" -#include "util/log.h" #include "util/str.h" static struct ac_io_emu spike_ac_io_emu; diff --git a/src/main/ddrhook-util/usbmem.c b/src/main/ddrhook-util/usbmem.c index f85363f..c4e12c4 100644 --- a/src/main/ddrhook-util/usbmem.c +++ b/src/main/ddrhook-util/usbmem.c @@ -12,12 +12,13 @@ #include #include +#include "core/log.h" + #include "hook/iohook.h" #include "util/crc.h" #include "util/fs.h" #include "util/iobuf.h" -#include "util/log.h" #include "util/str.h" #define USBMEM_DEVICE_COUNT 2 diff --git a/src/main/ddrhook1/Module.mk b/src/main/ddrhook1/Module.mk index 83782ae..1e9dc24 100644 --- a/src/main/ddrhook1/Module.mk +++ b/src/main/ddrhook1/Module.mk @@ -7,6 +7,8 @@ deplibs_ddrhook1 := \ avs \ libs_ddrhook1 := \ + avs-util \ + core \ acioemu \ cconfig \ ddrhook-util \ diff --git a/src/main/ddrhook1/avs-boot.c b/src/main/ddrhook1/avs-boot.c index 1b7ad41..db4445b 100644 --- a/src/main/ddrhook1/avs-boot.c +++ b/src/main/ddrhook1/avs-boot.c @@ -5,6 +5,9 @@ #include #include +#include "core/log-bt.h" +#include "core/log.h" + #include "hook/iohook.h" #include "hook/table.h" @@ -13,7 +16,6 @@ #include "ddrhook1/avs-boot.h" #include "ddrhook1/filesystem.h" -#include "util/log.h" #include "util/str.h" static void (*real_avs_boot)( @@ -50,6 +52,11 @@ static const struct hook_symbol ddrhook1_avs_ea3_hook_syms[] = { .link = (void **) &real_ea3_boot}, }; +static AVS_LOG_WRITER(_avs_boot_log_writer, chars, nchars, ctx) +{ + core_log_bt_direct_sink_write(chars, nchars); +} + static void avs_boot_replace_property_str( struct property_node *node, const char *name, const char *val) { @@ -115,7 +122,7 @@ static void my_avs_boot( sz_std_heap, avs_heap, sz_avs_heap, - log_writer_debug, + _avs_boot_log_writer, NULL); } diff --git a/src/main/ddrhook1/config-ddrhook1.c b/src/main/ddrhook1/config-ddrhook1.c index 154f3ae..a5872bf 100644 --- a/src/main/ddrhook1/config-ddrhook1.c +++ b/src/main/ddrhook1/config-ddrhook1.c @@ -2,9 +2,9 @@ #include "cconfig/cconfig-util.h" -#include "ddrhook1/config-ddrhook1.h" +#include "core/log.h" -#include "util/log.h" +#include "ddrhook1/config-ddrhook1.h" #define DDRHOOK1_CONFIG_DDRHOOK1_USE_COM4_EMU_KEY "ddrhook1.use_com4_emu" #define DDRHOOK1_CONFIG_DDRHOOK1_STANDARD_DEF_KEY "ddrhook1.standard_def" diff --git a/src/main/ddrhook1/config-eamuse.c b/src/main/ddrhook1/config-eamuse.c index 260791d..dbe44cd 100644 --- a/src/main/ddrhook1/config-eamuse.c +++ b/src/main/ddrhook1/config-eamuse.c @@ -2,9 +2,10 @@ #include "cconfig/cconfig-util.h" +#include "core/log.h" + #include "ddrhook1/config-eamuse.h" -#include "util/log.h" #include "util/net.h" #define DDRHOOK1_CONFIG_EAMUSE_SERVER_KEY "eamuse.server" diff --git a/src/main/ddrhook1/config-gfx.c b/src/main/ddrhook1/config-gfx.c index 09ccc0c..c71e74d 100644 --- a/src/main/ddrhook1/config-gfx.c +++ b/src/main/ddrhook1/config-gfx.c @@ -2,9 +2,9 @@ #include "cconfig/cconfig-util.h" -#include "ddrhook1/config-gfx.h" +#include "core/log.h" -#include "util/log.h" +#include "ddrhook1/config-gfx.h" #define DDRHOOK1_CONFIG_GFX_WINDOWED_KEY "gfx.windowed" diff --git a/src/main/ddrhook1/config-security.c b/src/main/ddrhook1/config-security.c index 9489b0a..b0b7d2b 100644 --- a/src/main/ddrhook1/config-security.c +++ b/src/main/ddrhook1/config-security.c @@ -2,11 +2,12 @@ #include "cconfig/cconfig-util.h" +#include "core/log.h" + #include "ddrhook1/config-security.h" #include "security/mcode.h" -#include "util/log.h" #include "util/net.h" #define DDRHOOK1_CONFIG_SECURITY_MCODE_KEY "security.mcode" diff --git a/src/main/ddrhook1/dllmain.c b/src/main/ddrhook1/dllmain.c index 3dcc6c9..3cccb3a 100644 --- a/src/main/ddrhook1/dllmain.c +++ b/src/main/ddrhook1/dllmain.c @@ -2,11 +2,20 @@ #include +#include "avs-util/core-interop.h" + #include "bemanitools/ddrio.h" #include "bemanitools/eamio.h" #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.h" +#include "core/thread.h" + #include "ddrhook-util/_com4.h" #include "ddrhook-util/extio.h" #include "ddrhook-util/p3io.h" @@ -37,8 +46,6 @@ #include "util/cmdline.h" #include "util/defs.h" -#include "util/log.h" -#include "util/thread.h" #define DDRHOOK1_INFO_HEADER \ "ddrhook1 for DDR X" \ @@ -68,6 +75,15 @@ static const struct hook_symbol init_hook_syms[] = { }, }; +static void _ddrhook1_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 DWORD STDCALL my_GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize) { @@ -155,7 +171,12 @@ my_GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize) log_info("Initializing DDR IO backend"); - ok = ddr_io_init(thread_create, thread_join, thread_destroy); + core_log_impl_assign(ddr_io_set_loggers); + + ok = ddr_io_init( + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get()); if (!ok) { log_fatal("Couldn't initialize DDR IO backend"); @@ -165,10 +186,12 @@ my_GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize) if (config_ddrhook1.use_com4_emu) { log_info("Initializing card reader backend"); - eam_io_set_loggers( - log_body_misc, log_body_info, log_body_warning, log_body_fatal); + core_log_impl_assign(eam_io_set_loggers); - ok = eam_io_init(thread_create, thread_join, thread_destroy); + ok = eam_io_init( + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get()); if (!ok) { log_fatal("Couldn't initialize card reader backend"); @@ -185,7 +208,12 @@ skip: BOOL WINAPI DllMain(HMODULE self, DWORD reason, void *ctx) { if (reason == DLL_PROCESS_ATTACH) { - log_to_writer(log_writer_debug, NULL); + // Use AVS APIs + avs_util_core_interop_thread_avs_impl_set(); + + // TODO init debug logging but with avs available? why not use avs + // logging? + _ddrhook1_log_init(); hook_table_apply( NULL, "kernel32.dll", init_hook_syms, lengthof(init_hook_syms)); diff --git a/src/main/ddrhook1/filesystem.c b/src/main/ddrhook1/filesystem.c index abec921..9912c4f 100644 --- a/src/main/ddrhook1/filesystem.c +++ b/src/main/ddrhook1/filesystem.c @@ -6,10 +6,11 @@ #include #include +#include "core/log.h" + #include "hook/table.h" #include "util/defs.h" -#include "util/log.h" #include "util/mem.h" #include "util/str.h" diff --git a/src/main/ddrhook1/master.c b/src/main/ddrhook1/master.c index b30836a..480d56f 100644 --- a/src/main/ddrhook1/master.c +++ b/src/main/ddrhook1/master.c @@ -1,3 +1,5 @@ +#include "core/log.h" + #include "ddrhook1/master.h" #include "ddrhook-util/dinput.h" @@ -9,7 +11,6 @@ #include "p3ioemu/devmgr.h" #include "util/defs.h" -#include "util/log.h" static HMODULE(STDCALL *real_LoadLibraryA)(const char *name); static BOOL(STDCALL *real_IsDebuggerPresent)(); diff --git a/src/main/ddrhook2/Module.mk b/src/main/ddrhook2/Module.mk index 0c9fd36..e0416d6 100644 --- a/src/main/ddrhook2/Module.mk +++ b/src/main/ddrhook2/Module.mk @@ -4,6 +4,8 @@ deplibs_ddrhook2 := \ avs \ libs_ddrhook2 := \ + avs-util \ + core \ acioemu \ ddrhook-util \ p3ioemu \ diff --git a/src/main/ddrhook2/dllmain.c b/src/main/ddrhook2/dllmain.c index 9035551..cabbb94 100644 --- a/src/main/ddrhook2/dllmain.c +++ b/src/main/ddrhook2/dllmain.c @@ -2,9 +2,14 @@ #include +#include "avs-util/core-interop.h" + #include "bemanitools/ddrio.h" #include "bemanitools/eamio.h" +#include "core/log.h" +#include "core/thread.h" + #include "ddrhook-util/_com4.h" #include "ddrhook-util/extio.h" #include "ddrhook-util/gfx.h" @@ -25,7 +30,6 @@ #include "util/cmdline.h" #include "util/defs.h" -#include "util/log.h" static bool my_dll_entry_init(char *sidcode, struct property_node *param); static bool my_dll_entry_main(void); @@ -119,10 +123,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param) log_info("Initializing DDR IO backend"); - ddr_io_set_loggers( - log_body_misc, log_body_info, log_body_warning, log_body_fatal); + core_log_impl_assign(ddr_io_set_loggers); - ok = ddr_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy); + ok = ddr_io_init( + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get()); if (!ok) { return false; @@ -131,11 +137,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param) if (com4) { log_info("Initializing card reader backend"); - eam_io_set_loggers( - log_body_misc, log_body_info, log_body_warning, log_body_fatal); + core_log_impl_assign(eam_io_set_loggers); - ok = - eam_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy); + ok = eam_io_init( + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get()); if (!ok) { return false; @@ -174,8 +181,9 @@ BOOL WINAPI DllMain(HMODULE self, DWORD reason, void *ctx) goto end; } - log_to_external( - log_body_misc, log_body_info, log_body_warning, log_body_fatal); + // Use AVS APIs + avs_util_core_interop_thread_avs_impl_set(); + avs_util_core_interop_log_avs_impl_set(); app_hook_init(my_dll_entry_init, my_dll_entry_main); diff --git a/src/main/ddrhook2/master.c b/src/main/ddrhook2/master.c index 89f874f..aba5451 100644 --- a/src/main/ddrhook2/master.c +++ b/src/main/ddrhook2/master.c @@ -1,3 +1,5 @@ +#include "core/log.h" + #include "ddrhook2/master.h" #include "ddrhook-util/dinput.h" @@ -10,7 +12,6 @@ #include "p3ioemu/devmgr.h" #include "util/defs.h" -#include "util/log.h" static HMODULE(STDCALL *real_LoadLibraryA)(const char *name); diff --git a/src/main/ddrio-async/Module.mk b/src/main/ddrio-async/Module.mk index 62006cf..2eb806d 100644 --- a/src/main/ddrio-async/Module.mk +++ b/src/main/ddrio-async/Module.mk @@ -3,6 +3,7 @@ dlls += ddrio-async ldflags_ddrio-async:= \ libs_ddrio-async := \ + core \ util \ src_ddrio-async := \ diff --git a/src/main/ddrio-async/ddrio.c b/src/main/ddrio-async/ddrio.c index fe81f68..998c59a 100644 --- a/src/main/ddrio-async/ddrio.c +++ b/src/main/ddrio-async/ddrio.c @@ -11,8 +11,9 @@ #include "bemanitools/ddrio.h" -#include "util/log.h" -#include "util/thread.h" +#include "core/log.h" +#include "core/thread.h" + #include "util/time.h" typedef void (*ddr_io_set_loggers_t)( @@ -154,7 +155,7 @@ void ddr_io_set_loggers( _log_formatter_warning = warning; _log_formatter_fatal = fatal; - log_to_external(misc, info, warning, fatal); + core_log_impl_set(misc, info, warning, fatal); } bool ddr_io_init( @@ -164,6 +165,8 @@ bool ddr_io_init( { log_info("Loading ddrio-async-child.dll as child ddrio library..."); + core_thread_impl_set(thread_create, thread_join, thread_destroy); + _child_ddr_io_module = LoadLibraryA("ddrio-async-child.dll"); if (_child_ddr_io_module == NULL) { diff --git a/src/main/ddrio-mm/Module.mk b/src/main/ddrio-mm/Module.mk index 9368a62..16e3ca8 100644 --- a/src/main/ddrio-mm/Module.mk +++ b/src/main/ddrio-mm/Module.mk @@ -5,6 +5,7 @@ ldflags_ddrio-mm:= \ -lsetupapi \ libs_ddrio-mm := \ + core \ mm \ util \ diff --git a/src/main/ddrio-mm/ddrio.c b/src/main/ddrio-mm/ddrio.c index 08bd1d2..44bdd35 100644 --- a/src/main/ddrio-mm/ddrio.c +++ b/src/main/ddrio-mm/ddrio.c @@ -7,11 +7,12 @@ #include "bemanitools/ddrio.h" +#include "core/log.h" + #include "mm/mm.h" #include "util/cmdline.h" #include "util/defs.h" -#include "util/log.h" #include "util/mem.h" struct ddr_bittrans { @@ -117,7 +118,7 @@ void ddr_io_set_loggers( log_formatter_t warning, log_formatter_t fatal) { - log_to_external(misc, info, warning, fatal); + core_log_impl_set(misc, info, warning, fatal); } bool ddr_io_init( diff --git a/src/main/ddrio-p3io/Module.mk b/src/main/ddrio-p3io/Module.mk index 43e0fd0..2824bf0 100644 --- a/src/main/ddrio-p3io/Module.mk +++ b/src/main/ddrio-p3io/Module.mk @@ -4,6 +4,7 @@ ldflags_ddrio-p3io:= \ -lsetupapi \ libs_ddrio-p3io := \ + core \ cconfig \ extio \ extiodrv \ diff --git a/src/main/ddrio-p3io/config.c b/src/main/ddrio-p3io/config.c index c45254e..5459157 100644 --- a/src/main/ddrio-p3io/config.c +++ b/src/main/ddrio-p3io/config.c @@ -1,6 +1,6 @@ #include "cconfig/cconfig-util.h" -#include "util/log.h" +#include "core/log.h" #include "config.h" diff --git a/src/main/ddrio-p3io/ddrio.c b/src/main/ddrio-p3io/ddrio.c index a38ce09..6ed7e90 100644 --- a/src/main/ddrio-p3io/ddrio.c +++ b/src/main/ddrio-p3io/ddrio.c @@ -10,15 +10,15 @@ #include "cconfig/cconfig-main.h" +#include "core/log.h" +#include "core/thread.h" + #include "extiodrv/device.h" #include "extiodrv/extio.h" #include "p3iodrv/ddr.h" #include "p3iodrv/device.h" -#include "util/log.h" -#include "util/thread.h" - #include "config.h" static struct ddrio_p3io_config _ddr_io_p3io_config; @@ -255,7 +255,7 @@ void ddr_io_set_loggers( log_formatter_t warning, log_formatter_t fatal) { - log_to_external(misc, info, warning, fatal); + core_log_impl_set(misc, info, warning, fatal); } static void _ddr_io_config_init(struct ddrio_p3io_config *config_ddrio_p3io) diff --git a/src/main/ddrio-smx/Module.mk b/src/main/ddrio-smx/Module.mk index cc0563b..12fd74d 100644 --- a/src/main/ddrio-smx/Module.mk +++ b/src/main/ddrio-smx/Module.mk @@ -5,6 +5,7 @@ deplibs_ddrio-smx := \ SMX \ libs_ddrio-smx := \ + core \ geninput \ util \ diff --git a/src/main/ddrio-smx/ddrio.c b/src/main/ddrio-smx/ddrio.c index a7cda33..334ccac 100644 --- a/src/main/ddrio-smx/ddrio.c +++ b/src/main/ddrio-smx/ddrio.c @@ -6,11 +6,12 @@ #include "bemanitools/ddrio.h" #include "bemanitools/input.h" +#include "core/log.h" + #include "imports/SMX.h" #include "imports/avs.h" #include "util/defs.h" -#include "util/log.h" struct ddr_io_smx_pad_map { int pad_no; @@ -99,7 +100,7 @@ void ddr_io_set_loggers( log_formatter_t warning, log_formatter_t fatal) { - log_to_external(misc, info, warning, fatal); + core_log_impl_set(misc, info, warning, fatal); input_set_loggers(misc, info, warning, fatal); /* We would need a log server thread to accept log messages from SMX, since diff --git a/src/main/ddrio/ddrio.c b/src/main/ddrio/ddrio.c index 167b7c6..5da9934 100644 --- a/src/main/ddrio/ddrio.c +++ b/src/main/ddrio/ddrio.c @@ -4,7 +4,7 @@ #include "bemanitools/input.h" -#include "util/log.h" +#include "core/log.h" void ddr_io_set_loggers( log_formatter_t misc, diff --git a/src/main/ddriotest/Module.mk b/src/main/ddriotest/Module.mk index 569d973..b6cba5c 100644 --- a/src/main/ddriotest/Module.mk +++ b/src/main/ddriotest/Module.mk @@ -1,6 +1,7 @@ exes += ddriotest \ libs_ddriotest := \ + core \ ddrio \ util \ diff --git a/src/main/ddriotest/main.c b/src/main/ddriotest/main.c index e03bc0c..40453ce 100644 --- a/src/main/ddriotest/main.c +++ b/src/main/ddriotest/main.c @@ -7,32 +7,41 @@ #include "bemanitools/ddrio.h" -#include "util/log.h" -#include "util/thread.h" +#include "core/log-bt-ext.h" +#include "core/log-bt.h" +#include "core/log.h" +#include "core/thread-crt-ext.h" +#include "core/thread-crt.h" +#include "core/thread.h" int main(int argc, char **argv) { - enum log_level log_level; + enum core_log_bt_log_level log_level; - log_level = LOG_LEVEL_FATAL; + log_level = CORE_LOG_BT_LOG_LEVEL_FATAL; for (int i = 0; i < argc; i++) { if (!strcmp(argv[i], "-v")) { - log_level = LOG_LEVEL_WARNING; + log_level = CORE_LOG_BT_LOG_LEVEL_WARNING; } else if (!strcmp(argv[i], "-vv")) { - log_level = LOG_LEVEL_INFO; + log_level = CORE_LOG_BT_LOG_LEVEL_INFO; } else if (!strcmp(argv[i], "-vvv")) { - log_level = LOG_LEVEL_MISC; + log_level = CORE_LOG_BT_LOG_LEVEL_MISC; } } - log_to_writer(log_writer_stderr, NULL); - log_set_level(log_level); + core_thread_crt_ext_impl_set(); + core_log_bt_ext_impl_set(); - ddr_io_set_loggers( - log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal); + core_log_bt_ext_init_with_stderr(); + core_log_bt_level_set(log_level); - if (!ddr_io_init(crt_thread_create, crt_thread_join, crt_thread_destroy)) { + core_log_impl_assign(ddr_io_set_loggers); + + if (!ddr_io_init( + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get())) { fprintf(stderr, "Initializing ddrio failed\n"); return -1; } diff --git a/src/main/dinput/dinput.c b/src/main/dinput/dinput.c index 248ead4..e65928f 100644 --- a/src/main/dinput/dinput.c +++ b/src/main/dinput/dinput.c @@ -8,12 +8,13 @@ #include +#include "core/log.h" + #include "hook/com-proxy.h" #include "hook/pe.h" #include "hook/table.h" #include "util/defs.h" -#include "util/log.h" static HRESULT STDCALL my_DirectInput8Create( HINSTANCE hinst, diff --git a/src/main/eamio-icca/Module.mk b/src/main/eamio-icca/Module.mk index 28c388e..bcd4be8 100644 --- a/src/main/eamio-icca/Module.mk +++ b/src/main/eamio-icca/Module.mk @@ -2,6 +2,7 @@ dlls += \ eamio-icca \ libs_eamio-icca := \ + core \ aciodrv \ aciomgr \ cconfig \ diff --git a/src/main/eamio-icca/config-icc.c b/src/main/eamio-icca/config-icc.c index 660c0ee..963f688 100644 --- a/src/main/eamio-icca/config-icc.c +++ b/src/main/eamio-icca/config-icc.c @@ -2,8 +2,6 @@ #include "eamio-icca/config-icc.h" -#include "util/log.h" - #define EAMIO_ICCA_CONFIG_ICC_PORT_KEY "icc.port" #define EAMIO_ICCA_CONFIG_ICC_BAUD_KEY "icc.baud" diff --git a/src/main/eamio-icca/eamio-icca.c b/src/main/eamio-icca/eamio-icca.c index c681610..db0215a 100644 --- a/src/main/eamio-icca/eamio-icca.c +++ b/src/main/eamio-icca/eamio-icca.c @@ -14,11 +14,11 @@ #include "bemanitools/eamio.h" +#include "core/log.h" + #include "cconfig/cconfig-main.h" #include "eamio-icca/config-icc.h" -#include "util/log.h" - #define IDLE_RESPONSES_BETWEEN_FELICA_POLLS 5 #define NUMBER_OF_EMULATED_READERS 2 #define INVALID_NODE_ID -1 @@ -60,7 +60,7 @@ void eam_io_set_loggers( { aciomgr_set_loggers(misc, info, warning, fatal); - log_to_external(misc, info, warning, fatal); + core_log_impl_set(misc, info, warning, fatal); } // all of these are referred to internally as ICCA diff --git a/src/main/eamio/Module.mk b/src/main/eamio/Module.mk index f7a7409..9cf82ed 100644 --- a/src/main/eamio/Module.mk +++ b/src/main/eamio/Module.mk @@ -1,5 +1,5 @@ dlls += eamio -libs_eamio := geninput util +libs_eamio := core geninput util src_eamio := \ eam-api.c \ eam-impl.c \ diff --git a/src/main/eamio/eam-api.c b/src/main/eamio/eam-api.c index 0320317..9d2857d 100644 --- a/src/main/eamio/eam-api.c +++ b/src/main/eamio/eam-api.c @@ -11,14 +11,15 @@ #include "bemanitools/eamio.h" #include "bemanitools/input.h" +#include "core/log.h" +#include "core/thread.h" + #include "eamio/eam-config.h" #include "eamio/eam-impl.h" #include "eamio/eam-s11n.h" #include "util/fs.h" -#include "util/log.h" #include "util/msg-thread.h" -#include "util/thread.h" static void eam_handle_hotplug_msg(WPARAM wparam, const DEV_BROADCAST_HDR *hdr); static FILE *eam_io_config_open(const char *mode); @@ -108,14 +109,14 @@ void eam_io_set_loggers( log_formatter_t warning, log_formatter_t fatal) { - log_to_external(misc, info, warning, fatal); + core_log_impl_set(misc, info, warning, fatal); } bool eam_io_init( thread_create_t create, thread_join_t join, thread_destroy_t destroy) { input_init(create, join, destroy); - thread_api_init(create, join, destroy); + core_thread_impl_set(create, join, destroy); eam_io_config_load(); msg_thread_init(eam_hinst); diff --git a/src/main/eamio/eam-impl.c b/src/main/eamio/eam-impl.c index 0c41709..6aca589 100644 --- a/src/main/eamio/eam-impl.c +++ b/src/main/eamio/eam-impl.c @@ -9,6 +9,8 @@ #include "bemanitools/eamio.h" +#include "core/log.h" + #include "eamio/eam-impl.h" #include "geninput/hid-mgr.h" @@ -16,7 +18,6 @@ #include "util/defs.h" #include "util/fs.h" #include "util/hex.h" -#include "util/log.h" #include "util/mem.h" #include "util/str.h" diff --git a/src/main/eamiotest/Module.mk b/src/main/eamiotest/Module.mk index a54384b..0b9fd4b 100644 --- a/src/main/eamiotest/Module.mk +++ b/src/main/eamiotest/Module.mk @@ -1,6 +1,7 @@ exes += eamiotest libs_eamiotest := \ + core \ eamio \ util \ diff --git a/src/main/eamiotest/main.c b/src/main/eamiotest/main.c index 9880af4..a2f410f 100644 --- a/src/main/eamiotest/main.c +++ b/src/main/eamiotest/main.c @@ -7,20 +7,29 @@ #include "bemanitools/eamio.h" -#include "util/log.h" -#include "util/thread.h" +#include "core/log-bt-ext.h" +#include "core/log-bt.h" +#include "core/log.h" +#include "core/thread-crt-ext.h" +#include "core/thread-crt.h" +#include "core/thread.h" /** * Tool to test your implementations of eamio. */ int main(int argc, char **argv) { - log_to_writer(log_writer_stdout, NULL); + core_thread_crt_ext_impl_set(); + core_log_bt_ext_impl_set(); - eam_io_set_loggers( - log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal); + core_log_bt_ext_init_with_stdout(); - if (!eam_io_init(crt_thread_create, crt_thread_join, crt_thread_destroy)) { + core_log_impl_assign(eam_io_set_loggers); + + if (!eam_io_init( + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get())) { printf("Initializing eamio failed\n"); return -1; } diff --git a/src/main/extiodrv/device.c b/src/main/extiodrv/device.c index ba14fa7..e6bc788 100644 --- a/src/main/extiodrv/device.c +++ b/src/main/extiodrv/device.c @@ -2,7 +2,7 @@ #include "device.h" -#include "util/log.h" +#include "core/log.h" HRESULT extiodrv_device_open(const char *port, HANDLE *handle) { diff --git a/src/main/extiodrv/extio.c b/src/main/extiodrv/extio.c index 8c50de2..5b1ae6a 100644 --- a/src/main/extiodrv/extio.c +++ b/src/main/extiodrv/extio.c @@ -2,7 +2,7 @@ #include "extio.h" -#include "util/log.h" +#include "core/log.h" // static uint8_t _extiodrv_extio_sensor_read_mode_map[5] = { // 1, // all diff --git a/src/main/extiotest/Module.mk b/src/main/extiotest/Module.mk index 73ec1b0..3e05ba0 100644 --- a/src/main/extiotest/Module.mk +++ b/src/main/extiotest/Module.mk @@ -3,6 +3,7 @@ exes += extiotest \ libs_extiotest := \ extiodrv \ extio \ + core \ util \ src_extiotest := \ diff --git a/src/main/extiotest/main.c b/src/main/extiotest/main.c index 3be152b..c9e48ba 100644 --- a/src/main/extiotest/main.c +++ b/src/main/extiotest/main.c @@ -5,12 +5,15 @@ #include -#include "extiodrv/extio.h" +#include "core/log-bt.h" +#include "core/log-sink-std.h" +#include "core/log.h" -#include "util/log.h" +#include "extiodrv/extio.h" int main(int argc, char **argv) { + struct core_log_sink log_sink; HRESULT hr; const char *port; HANDLE handle; @@ -22,8 +25,9 @@ int main(int argc, char **argv) fprintf(stderr, " COM_PORT: For example COM1\n"); } - log_to_writer(log_writer_stderr, NULL); - log_set_level(LOG_LEVEL_MISC); + core_log_sink_std_err_open(true, &log_sink); + core_log_bt_init(&log_sink); + core_log_bt_level_set(CORE_LOG_BT_LOG_LEVEL_MISC); port = argv[1]; diff --git a/src/main/ezusb-emu/device.c b/src/main/ezusb-emu/device.c index 9f1eca8..9cf5c98 100644 --- a/src/main/ezusb-emu/device.c +++ b/src/main/ezusb-emu/device.c @@ -9,6 +9,8 @@ #include +#include "core/log.h" + #include "ezusb/ezusbsys2.h" #include "ezusb/util.h" @@ -25,7 +27,6 @@ #include "util/fs.h" #include "util/hex.h" #include "util/iobuf.h" -#include "util/log.h" #include "util/str.h" // The max buffer size in iidx's ezusb client library is 4096 for the initial diff --git a/src/main/ezusb-emu/node-coin.c b/src/main/ezusb-emu/node-coin.c index 87e7503..6b4aed1 100644 --- a/src/main/ezusb-emu/node-coin.c +++ b/src/main/ezusb-emu/node-coin.c @@ -1,11 +1,11 @@ #define LOG_MODULE "ezusb-emu-node-coin" +#include "core/log.h" + #include "ezusb-emu/node-coin.h" #include "ezusb-iidx/coin-cmd.h" -#include "util/log.h" - static uint8_t ezusb_iidx_emu_node_coin_mode = 0; uint8_t ezusb_iidx_emu_node_coin_process_cmd( diff --git a/src/main/ezusb-emu/node-eeprom.c b/src/main/ezusb-emu/node-eeprom.c index ea6a3fe..f63d866 100644 --- a/src/main/ezusb-emu/node-eeprom.c +++ b/src/main/ezusb-emu/node-eeprom.c @@ -2,12 +2,12 @@ #include +#include "core/log.h" + #include "ezusb-emu/node-eeprom.h" #include "ezusb-iidx/eeprom-cmd.h" -#include "util/log.h" - /* not verified, but we got calls with 3 pages only so far */ #define EEPROM_NPAGES 3 diff --git a/src/main/ezusb-emu/node-security-mem.c b/src/main/ezusb-emu/node-security-mem.c index 92422c8..8d11c5f 100644 --- a/src/main/ezusb-emu/node-security-mem.c +++ b/src/main/ezusb-emu/node-security-mem.c @@ -2,11 +2,11 @@ #include +#include "core/log.h" + #include "ezusb-emu/node-security-mem.h" #include "ezusb-iidx/secmem-cmd.h" -#include "util/log.h" - #define SECURITY2_NPAGES 5 /* Starting GOLD with the new IO2 (C02 is not affected), the game does not diff --git a/src/main/ezusb-emu/node-security-plug.c b/src/main/ezusb-emu/node-security-plug.c index 2b05a03..ed57eed 100644 --- a/src/main/ezusb-emu/node-security-plug.c +++ b/src/main/ezusb-emu/node-security-plug.c @@ -2,6 +2,8 @@ #include +#include "core/log.h" + #include "ezusb-emu/node-eeprom.h" #include "ezusb-emu/node-security-mem.h" #include "ezusb-emu/node-security-plug.h" @@ -11,8 +13,6 @@ #include "security/rp2.h" #include "security/util.h" -#include "util/log.h" - static struct security_mcode ezusb_iidx_emu_node_security_plug_boot_version; static uint32_t ezusb_iidx_emu_node_security_plug_boot_seeds[3]; diff --git a/src/main/ezusb-emu/node-sram.c b/src/main/ezusb-emu/node-sram.c index 200f1ca..dc3846b 100644 --- a/src/main/ezusb-emu/node-sram.c +++ b/src/main/ezusb-emu/node-sram.c @@ -2,12 +2,13 @@ #include +#include "core/log.h" + #include "ezusb-emu/conf.h" #include "ezusb-emu/node-sram.h" #include "ezusb-iidx/sram-cmd.h" #include "util/fs.h" -#include "util/log.h" #define SRAM_NPAGES 12 diff --git a/src/main/ezusb-emu/node-wdt.c b/src/main/ezusb-emu/node-wdt.c index 9185bdd..8c5c541 100644 --- a/src/main/ezusb-emu/node-wdt.c +++ b/src/main/ezusb-emu/node-wdt.c @@ -1,10 +1,10 @@ #define LOG_MODULE "ezusb-emu-node-wdt" +#include "core/log.h" + #include "ezusb-emu/node-wdt.h" #include "ezusb-iidx/wdt-cmd.h" -#include "util/log.h" - uint8_t ezusb_iidx_emu_node_wdt_process_cmd( uint8_t cmd_id, uint8_t cmd_data, uint8_t cmd_data2) { diff --git a/src/main/ezusb-emu/util.c b/src/main/ezusb-emu/util.c index 6e2798a..30edd42 100644 --- a/src/main/ezusb-emu/util.c +++ b/src/main/ezusb-emu/util.c @@ -6,10 +6,11 @@ #include #include +#include "core/log.h" + #include "ezusb-emu/util.h" #include "util/hex.h" -#include "util/log.h" enum ezusb_pipe { /* This is just the NT driver API. Add 1 to get the actual EP number. */ diff --git a/src/main/ezusb-iidx-16seg-emu/node-16seg.c b/src/main/ezusb-iidx-16seg-emu/node-16seg.c index 89bc507..2121235 100644 --- a/src/main/ezusb-iidx-16seg-emu/node-16seg.c +++ b/src/main/ezusb-iidx-16seg-emu/node-16seg.c @@ -6,9 +6,9 @@ #include "bemanitools/iidxio.h" -#include "ezusb-iidx/seg16-cmd.h" +#include "core/log.h" -#include "util/log.h" +#include "ezusb-iidx/seg16-cmd.h" uint8_t ezusb_iidx_emu_node_16seg_process_cmd( uint8_t cmd_id, uint8_t cmd_data, uint8_t cmd_data2) diff --git a/src/main/ezusb-iidx-emu/Module.mk b/src/main/ezusb-iidx-emu/Module.mk index d625363..16f2c1d 100644 --- a/src/main/ezusb-iidx-emu/Module.mk +++ b/src/main/ezusb-iidx-emu/Module.mk @@ -1,6 +1,7 @@ libs += ezusb-iidx-emu libs_ezusb-iidx-emu := \ + core \ ezusb-emu \ ezusb-iidx-16seg-emu \ diff --git a/src/main/ezusb-iidx-emu/card-mag.c b/src/main/ezusb-iidx-emu/card-mag.c index a210fd6..b65414e 100644 --- a/src/main/ezusb-iidx-emu/card-mag.c +++ b/src/main/ezusb-iidx-emu/card-mag.c @@ -2,10 +2,11 @@ #include +#include "core/log.h" + #include "security/mcode.h" #include "util/crc.h" -#include "util/log.h" static const uint16_t ezusb_iidx_emu_card_mag_checksum_table_payload[256] = { 0x0, 0x1189, 0x2312, 0x329B, 0x4624, 0x57AD, 0x6536, 0x74BF, diff --git a/src/main/ezusb-iidx-emu/msg.c b/src/main/ezusb-iidx-emu/msg.c index bcab656..76b9742 100644 --- a/src/main/ezusb-iidx-emu/msg.c +++ b/src/main/ezusb-iidx-emu/msg.c @@ -6,6 +6,8 @@ #include "bemanitools/iidxio.h" +#include "core/log.h" + #include "hook/iohook.h" #include "ezusb-emu/msg.h" @@ -21,7 +23,6 @@ #include "ezusb-iidx-16seg-emu/nodes.h" #include "util/hex.h" -#include "util/log.h" /* ------------------------------------------------------------------------ */ diff --git a/src/main/ezusb-iidx-emu/node-fpga.c b/src/main/ezusb-iidx-emu/node-fpga.c index d66c440..6615b43 100644 --- a/src/main/ezusb-iidx-emu/node-fpga.c +++ b/src/main/ezusb-iidx-emu/node-fpga.c @@ -2,12 +2,13 @@ #include +#include "core/log.h" + #include "ezusb-iidx-emu/conf.h" #include "ezusb-iidx-emu/node-fpga.h" #include "ezusb-iidx/fpga-cmd.h" #include "util/fs.h" -#include "util/log.h" static uint16_t ezusb_iidx_emu_node_fpga_write_ptr; static uint16_t ezusb_iidx_emu_node_fpga_prog_size; diff --git a/src/main/ezusb-iidx-emu/node-serial.c b/src/main/ezusb-iidx-emu/node-serial.c index 378ab02..7dc6519 100644 --- a/src/main/ezusb-iidx-emu/node-serial.c +++ b/src/main/ezusb-iidx-emu/node-serial.c @@ -4,6 +4,9 @@ #include "bemanitools/eamio.h" +#include "core/log.h" +#include "core/thread.h" + #include "ezusb-iidx-emu/card-mag.c" #include "ezusb-iidx-emu/node-serial.h" #include "ezusb-iidx/serial-cmd.h" @@ -11,9 +14,7 @@ #include "security/mcode.h" #include "util/hex.h" -#include "util/log.h" #include "util/mem.h" -#include "util/thread.h" #define CARD_ID_LEN 8 @@ -292,7 +293,7 @@ void ezusb_iidx_emu_node_serial_init(void) &ezusb_iidx_emu_node_serial_emulation_state[i].card_cs); } - ezusb_iidx_emu_node_serial_emu_thread = thread_create( + ezusb_iidx_emu_node_serial_emu_thread = core_thread_create( ezusb_iidx_emu_node_serial_emu_thread_proc, NULL, 0x4000, 0); } diff --git a/src/main/ezusb-iidx-fpga-flash/Module.mk b/src/main/ezusb-iidx-fpga-flash/Module.mk index c250b35..320d6f4 100644 --- a/src/main/ezusb-iidx-fpga-flash/Module.mk +++ b/src/main/ezusb-iidx-fpga-flash/Module.mk @@ -4,6 +4,7 @@ ldflags_ezusb-iidx-fpga-flash := \ -lsetupapi \ libs_ezusb-iidx-fpga-flash := \ + core \ ezusb \ ezusb-iidx \ util \ diff --git a/src/main/ezusb-iidx-fpga-flash/main.c b/src/main/ezusb-iidx-fpga-flash/main.c index a8fb681..f8dacdd 100644 --- a/src/main/ezusb-iidx-fpga-flash/main.c +++ b/src/main/ezusb-iidx-fpga-flash/main.c @@ -3,11 +3,14 @@ #include +#include "core/log-bt-ext.h" +#include "core/log-bt.h" +#include "core/log.h" + #include "ezusb-iidx/fpga.h" #include "ezusb/ezusb.h" #include "util/fs.h" -#include "util/log.h" int main(int argc, char **argv) { @@ -24,7 +27,8 @@ int main(int argc, char **argv) return -1; } - log_to_writer(log_writer_stderr, NULL); + core_log_bt_ext_impl_set(); + core_log_bt_ext_init_with_stderr(); log_info("Opening ezusb '%s'...", EZUSB_DEVICE_PATH); diff --git a/src/main/ezusb-iidx-sram-flash/Module.mk b/src/main/ezusb-iidx-sram-flash/Module.mk index b6e6a73..a369b06 100644 --- a/src/main/ezusb-iidx-sram-flash/Module.mk +++ b/src/main/ezusb-iidx-sram-flash/Module.mk @@ -4,6 +4,7 @@ ldflags_ezusb-iidx-sram-flash := \ -lsetupapi \ libs_ezusb-iidx-sram-flash := \ + core \ ezusb \ ezusb-iidx \ util \ diff --git a/src/main/ezusb-iidx-sram-flash/main.c b/src/main/ezusb-iidx-sram-flash/main.c index d22464e..b4fa94d 100644 --- a/src/main/ezusb-iidx-sram-flash/main.c +++ b/src/main/ezusb-iidx-sram-flash/main.c @@ -3,11 +3,14 @@ #include +#include "core/log-bt-ext.h" +#include "core/log-bt.h" +#include "core/log.h" + #include "ezusb-iidx/sram.h" #include "ezusb/ezusb.h" #include "util/fs.h" -#include "util/log.h" int main(int argc, char **argv) { @@ -24,7 +27,8 @@ int main(int argc, char **argv) return -1; } - log_to_writer(log_writer_stdout, NULL); + core_log_bt_ext_impl_set(); + core_log_bt_ext_init_with_stdout(); log_info("Opening ezusb '%s'...", argv[1]); diff --git a/src/main/ezusb-iidx/ezusb-iidx.c b/src/main/ezusb-iidx/ezusb-iidx.c index e82e214..ae035b7 100644 --- a/src/main/ezusb-iidx/ezusb-iidx.c +++ b/src/main/ezusb-iidx/ezusb-iidx.c @@ -1,11 +1,12 @@ #define LOG_MODULE "ezusb-iidx" +#include "core/log.h" + #include "ezusb-iidx/ezusb-iidx.h" #include "ezusb/ezusbsys2.h" #include "util/hex.h" -#include "util/log.h" #include "util/time.h" #include "msg.h" diff --git a/src/main/ezusb-iidx/fpga.c b/src/main/ezusb-iidx/fpga.c index 23d5fd0..b4d2550 100644 --- a/src/main/ezusb-iidx/fpga.c +++ b/src/main/ezusb-iidx/fpga.c @@ -4,7 +4,7 @@ #include -#include "util/log.h" +#include "core/log.h" #include "ezusb-iidx.h" #include "fpga-cmd.h" diff --git a/src/main/ezusb-iidx/sram.c b/src/main/ezusb-iidx/sram.c index f816b38..fcce384 100644 --- a/src/main/ezusb-iidx/sram.c +++ b/src/main/ezusb-iidx/sram.c @@ -1,8 +1,8 @@ #define LOG_MODULE "ezusb-iidx-sram" -#include "ezusb-iidx/sram.h" +#include "core/log.h" -#include "util/log.h" +#include "ezusb-iidx/sram.h" #include "ezusb-iidx.h" #include "sram-cmd.h" diff --git a/src/main/ezusb-tool/Module.mk b/src/main/ezusb-tool/Module.mk index 349bc08..b5e8158 100644 --- a/src/main/ezusb-tool/Module.mk +++ b/src/main/ezusb-tool/Module.mk @@ -4,6 +4,7 @@ ldflags_ezusb-tool := \ -lsetupapi \ libs_ezusb-tool := \ + core \ ezusb \ util \ diff --git a/src/main/ezusb-tool/main.c b/src/main/ezusb-tool/main.c index 115f79c..ca84781 100644 --- a/src/main/ezusb-tool/main.c +++ b/src/main/ezusb-tool/main.c @@ -3,11 +3,13 @@ #include #include +#include "core/log-bt-ext.h" +#include "core/log-bt.h" +#include "core/log.h" + #include "ezusb/ezusb.h" #include "ezusb/util.h" -#include "util/log.h" - static int info() { HANDLE handle; @@ -103,7 +105,8 @@ int main(int argc, char **argv) arg_pos = 1; - log_to_writer(log_writer_stderr, NULL); + core_log_bt_ext_impl_set(); + core_log_bt_ext_init_with_stderr(); if (!strcmp(argv[arg_pos], "info")) { return info(); diff --git a/src/main/ezusb/ezusb.c b/src/main/ezusb/ezusb.c index ce1b828..7204589 100644 --- a/src/main/ezusb/ezusb.c +++ b/src/main/ezusb/ezusb.c @@ -4,10 +4,11 @@ #include // clang-format on +#include "core/log.h" + #include "ezusb/ezusb.h" #include "ezusb/ezusbsys2.h" -#include "util/log.h" #include "util/str.h" static bool ezusb_reset(HANDLE handle, bool hold) diff --git a/src/main/ezusb/util.c b/src/main/ezusb/util.c index efc2cd1..5bf18a4 100644 --- a/src/main/ezusb/util.c +++ b/src/main/ezusb/util.c @@ -1,11 +1,12 @@ #include #include +#include "core/log.h" + #include "ezusb/util.h" #include "util/crc.h" #include "util/fs.h" -#include "util/log.h" #include "util/mem.h" struct ezusb_firmware *ezusb_firmware_load(const char *file) diff --git a/src/main/ezusb2-dbg-hook/Module.mk b/src/main/ezusb2-dbg-hook/Module.mk index 4290f5c..579e9bf 100644 --- a/src/main/ezusb2-dbg-hook/Module.mk +++ b/src/main/ezusb2-dbg-hook/Module.mk @@ -1,6 +1,7 @@ dlls += ezusb2-dbg-hook libs_ezusb2-dbg-hook := \ + core \ hook \ util \ diff --git a/src/main/ezusb2-dbg-hook/main.c b/src/main/ezusb2-dbg-hook/main.c index e90d3fb..e1c1bdb 100644 --- a/src/main/ezusb2-dbg-hook/main.c +++ b/src/main/ezusb2-dbg-hook/main.c @@ -10,13 +10,17 @@ #include #include +#include "core/log-bt-ext.h" +#include "core/log-bt.h" +#include "core/log-sink-file.h" +#include "core/log.h" + #include "ezusb2/cyioctl.h" #include "hook/table.h" #include "util/cmdline.h" #include "util/hex.h" -#include "util/log.h" #include "util/str.h" static HANDLE STDCALL my_CreateFileW( @@ -367,14 +371,13 @@ static void ezusb2_dbg_hook_terminate_process() BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx) { if (reason == DLL_PROCESS_ATTACH) { - FILE *file; int argc; char **argv; wchar_t *buffer; uint32_t args_success; - file = fopen("ezusb2_dbg.log", "w+"); - log_to_writer(log_writer_file, file); + core_log_bt_ext_impl_set(); + core_log_bt_ext_init_with_file("ezusb2_dbg.log", false, false, 0); hook_table_apply( NULL, diff --git a/src/main/ezusb2-emu/device.c b/src/main/ezusb2-emu/device.c index f465279..ecba816 100644 --- a/src/main/ezusb2-emu/device.c +++ b/src/main/ezusb2-emu/device.c @@ -9,6 +9,8 @@ #include +#include "core/log.h" + #include "ezusb/util.h" #include "ezusb2/cyioctl.h" @@ -27,7 +29,6 @@ #include "util/fs.h" #include "util/hex.h" #include "util/iobuf.h" -#include "util/log.h" #include "util/str.h" // The max buffer size in iidx's ezusb client library is 4096 for the initial diff --git a/src/main/ezusb2-emu/util.c b/src/main/ezusb2-emu/util.c index 2abd513..d5b12b9 100644 --- a/src/main/ezusb2-emu/util.c +++ b/src/main/ezusb2-emu/util.c @@ -6,13 +6,14 @@ #include #include +#include "core/log.h" + #include "ezusb2/cyioctl.h" #include "ezusb2/ezusb2.h" #include "ezusb-emu/util.h" #include "util/hex.h" -#include "util/log.h" void ezusb2_emu_util_log_usb_msg(const char *prefix, const struct irp *irp) { diff --git a/src/main/ezusb2-iidx-emu/msg.c b/src/main/ezusb2-iidx-emu/msg.c index 1279ea9..bfc3dce 100644 --- a/src/main/ezusb2-iidx-emu/msg.c +++ b/src/main/ezusb2-iidx-emu/msg.c @@ -6,6 +6,8 @@ #include "bemanitools/iidxio.h" +#include "core/log.h" + #include "hook/iohook.h" #include "ezusb-emu/msg.h" @@ -15,7 +17,6 @@ #include "ezusb2-iidx/msg.h" #include "util/hex.h" -#include "util/log.h" /* ------------------------------------------------------------------------ */ diff --git a/src/main/ezusb2-popn-emu/msg.c b/src/main/ezusb2-popn-emu/msg.c index 6e83f7a..d696ecc 100644 --- a/src/main/ezusb2-popn-emu/msg.c +++ b/src/main/ezusb2-popn-emu/msg.c @@ -6,6 +6,8 @@ #include "bemanitools/popnio.h" +#include "core/log.h" + #include "hook/iohook.h" #include "ezusb-emu/msg.h" @@ -19,7 +21,6 @@ #include "ezusb2-popn/msg.h" #include "util/hex.h" -#include "util/log.h" /* ------------------------------------------------------------------------ */ diff --git a/src/main/ezusb2-popn-shim/Module.mk b/src/main/ezusb2-popn-shim/Module.mk index aefc2d4..f4536c4 100644 --- a/src/main/ezusb2-popn-shim/Module.mk +++ b/src/main/ezusb2-popn-shim/Module.mk @@ -4,6 +4,7 @@ ldflags_ezusb2-popn-shim := \ -lsetupapi \ libs_ezusb2-popn-shim := \ + core \ ezusb2-emu \ hook \ hooklib \ diff --git a/src/main/ezusb2-popn-shim/dllmain.c b/src/main/ezusb2-popn-shim/dllmain.c index c8e16fc..ec7e18f 100644 --- a/src/main/ezusb2-popn-shim/dllmain.c +++ b/src/main/ezusb2-popn-shim/dllmain.c @@ -4,6 +4,8 @@ #include +#include "core/log.h" + #include "ezusb2-emu/desc.h" #include "ezusb2-emu/device.h" @@ -13,8 +15,6 @@ #include "ezusb2-popn-shim/proxy.h" -#include "util/log.h" - #define EZUSB_REAL_DLL_FILENAME "ezusb.dll" static DWORD(STDCALL *real_entrypoint)(HMODULE self, DWORD reason, void *ctx); diff --git a/src/main/ezusb2-popn-shim/proxy.c b/src/main/ezusb2-popn-shim/proxy.c index fdf4f9f..ec47002 100644 --- a/src/main/ezusb2-popn-shim/proxy.c +++ b/src/main/ezusb2-popn-shim/proxy.c @@ -2,7 +2,7 @@ #include #include -#include "util/log.h" +#include "core/log.h" struct CoinParam; struct EEP_HISTORY; diff --git a/src/main/ezusb2-tool/Module.mk b/src/main/ezusb2-tool/Module.mk index 0611565..87e6dff 100644 --- a/src/main/ezusb2-tool/Module.mk +++ b/src/main/ezusb2-tool/Module.mk @@ -4,6 +4,7 @@ ldflags_ezusb2-tool := \ -lsetupapi \ libs_ezusb2-tool := \ + core \ ezusb2 \ ezusb \ util \ diff --git a/src/main/ezusb2-tool/main.c b/src/main/ezusb2-tool/main.c index cdfd179..0579c07 100644 --- a/src/main/ezusb2-tool/main.c +++ b/src/main/ezusb2-tool/main.c @@ -3,11 +3,13 @@ #include #include +#include "core/log-bt-ext.h" +#include "core/log-bt.h" +#include "core/log.h" + #include "ezusb/util.h" #include "ezusb2/ezusb2.h" -#include "util/log.h" - static int scan() { char *path; @@ -122,7 +124,8 @@ int main(int argc, char **argv) arg_pos = 1; - log_to_writer(log_writer_stderr, NULL); + core_log_bt_ext_impl_set(); + core_log_bt_ext_init_with_stderr(); if (!strcmp(argv[arg_pos], "scan")) { return scan(); diff --git a/src/main/ezusb2/ezusb2.c b/src/main/ezusb2/ezusb2.c index 61fabd7..2c1b7b9 100644 --- a/src/main/ezusb2/ezusb2.c +++ b/src/main/ezusb2/ezusb2.c @@ -4,6 +4,8 @@ #include // clang-format on +#include "core/log.h" + #include "ezusb/ezusb.h" #include "ezusb2/cyioctl.h" @@ -11,7 +13,6 @@ #include "util/crc.h" #include "util/fs.h" -#include "util/log.h" #include "util/str.h" #define REQ_TYPE_HOST_TO_DEV 0x40 diff --git a/src/main/geninput/Module.mk b/src/main/geninput/Module.mk index 1521d80..3115edf 100644 --- a/src/main/geninput/Module.mk +++ b/src/main/geninput/Module.mk @@ -5,6 +5,7 @@ ldflags_geninput := \ -lsetupapi \ libs_geninput := \ + core \ util \ src_geninput := \ diff --git a/src/main/geninput/dev-list.c b/src/main/geninput/dev-list.c index 2bfcb4e..ce6d93a 100644 --- a/src/main/geninput/dev-list.c +++ b/src/main/geninput/dev-list.c @@ -9,9 +9,10 @@ #include #include +#include "core/log.h" + #include "geninput/dev-list.h" -#include "util/log.h" #include "util/mem.h" void dev_list_init(struct dev_list *devs, const GUID *class_guid) diff --git a/src/main/geninput/hid-generic.c b/src/main/geninput/hid-generic.c index 41e7382..46c2924 100644 --- a/src/main/geninput/hid-generic.c +++ b/src/main/geninput/hid-generic.c @@ -12,6 +12,8 @@ #include // clang-format on +#include "core/log.h" + #include "geninput/hid-generic-strings.h" #include "geninput/hid-generic.h" #include "geninput/hid-meta-in.h" @@ -19,7 +21,6 @@ #include "geninput/hid.h" #include "util/defs.h" -#include "util/log.h" #include "util/mem.h" #include "util/str.h" diff --git a/src/main/geninput/hid-meta-in.c b/src/main/geninput/hid-meta-in.c index bbaf44f..3a32494 100644 --- a/src/main/geninput/hid-meta-in.c +++ b/src/main/geninput/hid-meta-in.c @@ -11,10 +11,11 @@ #include #include +#include "core/log.h" + #include "geninput/hid-meta-in.h" #include "geninput/hid-report-in.h" -#include "util/log.h" #include "util/mem.h" static bool diff --git a/src/main/geninput/hid-meta-out.c b/src/main/geninput/hid-meta-out.c index 4f87602..1903785 100644 --- a/src/main/geninput/hid-meta-out.c +++ b/src/main/geninput/hid-meta-out.c @@ -12,10 +12,11 @@ #include #include +#include "core/log.h" + #include "geninput/hid-meta-out.h" #include "geninput/hid-report-out.h" -#include "util/log.h" #include "util/mem.h" static bool diff --git a/src/main/geninput/hid-mgr.c b/src/main/geninput/hid-mgr.c index f22d3a7..2f8a7c1 100644 --- a/src/main/geninput/hid-mgr.c +++ b/src/main/geninput/hid-mgr.c @@ -2,9 +2,10 @@ #include +#include "core/log.h" + #include "geninput/hid-mgr.h" -#include "util/log.h" #include "util/mem.h" #include "util/str.h" diff --git a/src/main/geninput/hid-report-in.c b/src/main/geninput/hid-report-in.c index 721a721..aec213d 100644 --- a/src/main/geninput/hid-report-in.c +++ b/src/main/geninput/hid-report-in.c @@ -10,9 +10,10 @@ #include #include +#include "core/log.h" + #include "geninput/hid-report-in.h" -#include "util/log.h" #include "util/mem.h" void hid_report_in_init( diff --git a/src/main/geninput/hid-report-out.c b/src/main/geninput/hid-report-out.c index 5469e3a..892cd13 100644 --- a/src/main/geninput/hid-report-out.c +++ b/src/main/geninput/hid-report-out.c @@ -11,9 +11,10 @@ #include #include +#include "core/log.h" + #include "geninput/hid-report-out.h" -#include "util/log.h" #include "util/mem.h" bool hid_report_out_init( diff --git a/src/main/geninput/hid.c b/src/main/geninput/hid.c index 57685b0..889ee80 100644 --- a/src/main/geninput/hid.c +++ b/src/main/geninput/hid.c @@ -1,10 +1,11 @@ #include #include +#include "core/log.h" + #include "geninput/dev-list.h" #include "geninput/hid.h" -#include "util/log.h" #include "util/str.h" wchar_t *hid_ri_init_name(const GUID *class_guid, const char *dev_node) diff --git a/src/main/geninput/hotplug.c b/src/main/geninput/hotplug.c index 54dad42..d9954d3 100644 --- a/src/main/geninput/hotplug.c +++ b/src/main/geninput/hotplug.c @@ -6,13 +6,13 @@ #include +#include "core/log.h" + #include "geninput/hid.h" #include "geninput/hotplug.h" #include "geninput/io-thread.h" #include "geninput/ri.h" -#include "util/log.h" - static HDEVNOTIFY hotplug_handle; void hotplug_init(HWND wnd) diff --git a/src/main/geninput/input.c b/src/main/geninput/input.c index 60c94c2..e67df3d 100644 --- a/src/main/geninput/input.c +++ b/src/main/geninput/input.c @@ -7,6 +7,9 @@ #include "bemanitools/glue.h" #include "bemanitools/input.h" +#include "core/log.h" +#include "core/thread.h" + #include "geninput/hid-mgr.h" #include "geninput/hid.h" #include "geninput/io-thread.h" @@ -14,10 +17,8 @@ #include "geninput/mapper.h" #include "util/fs.h" -#include "util/log.h" #include "util/msg-thread.h" #include "util/str.h" -#include "util/thread.h" static HINSTANCE input_hinst; static volatile long input_init_count; @@ -47,7 +48,7 @@ void input_set_loggers( log_formatter_t warning, log_formatter_t fatal) { - log_to_external(misc, info, warning, fatal); + core_log_impl_set(misc, info, warning, fatal); } void input_init( @@ -63,7 +64,7 @@ void input_init( mapper_inst = mapper_impl_create(); - thread_api_init(create, join, destroy); + core_thread_impl_set(create, join, destroy); msg_thread_init(input_hinst); io_thread_init(); } diff --git a/src/main/geninput/io-thread.c b/src/main/geninput/io-thread.c index ca663ff..18f5ccc 100644 --- a/src/main/geninput/io-thread.c +++ b/src/main/geninput/io-thread.c @@ -2,6 +2,9 @@ #include +#include "core/log.h" +#include "core/thread.h" + #include "geninput/dev-list.h" #include "geninput/hid-generic.h" #include "geninput/hid-mgr.h" @@ -10,9 +13,7 @@ #include "geninput/pacdrive.h" #include "util/defs.h" -#include "util/log.h" #include "util/mem.h" -#include "util/thread.h" enum io_thread_cmd { IO_THREAD_CMD_STOP, @@ -172,7 +173,7 @@ void io_thread_init(void) barrier = CreateEvent(NULL, TRUE, FALSE, NULL); - io_thread_id = thread_create(io_thread_proc, barrier, 16384, 0); + io_thread_id = core_thread_create(io_thread_proc, barrier, 16384, 0); WaitForSingleObject(barrier, INFINITE); CloseHandle(barrier); @@ -200,6 +201,6 @@ void io_thread_fini(void) PostQueuedCompletionStatus(io_thread_cp, 0, (uintptr_t) &msg, NULL); - thread_join(io_thread_id, NULL); - thread_destroy(io_thread_id); + core_thread_join(io_thread_id, NULL); + core_thread_destroy(io_thread_id); } diff --git a/src/main/geninput/kbd.c b/src/main/geninput/kbd.c index 9ae8e5e..191890b 100644 --- a/src/main/geninput/kbd.c +++ b/src/main/geninput/kbd.c @@ -11,12 +11,13 @@ #include #include +#include "core/log.h" + #include "geninput/hid.h" #include "geninput/kbd-data.h" #include "geninput/kbd.h" #include "util/defs.h" -#include "util/log.h" #include "util/mem.h" #include "util/str.h" diff --git a/src/main/geninput/mapper.c b/src/main/geninput/mapper.c index c3d0214..3c66c19 100644 --- a/src/main/geninput/mapper.c +++ b/src/main/geninput/mapper.c @@ -1,11 +1,12 @@ #include #include +#include "core/log.h" + #include "geninput/hid-mgr.h" #include "geninput/mapper.h" #include "util/array.h" -#include "util/log.h" #include "util/mem.h" struct action_iter { diff --git a/src/main/geninput/mouse.c b/src/main/geninput/mouse.c index 2b24d1c..f1c54bf 100644 --- a/src/main/geninput/mouse.c +++ b/src/main/geninput/mouse.c @@ -12,11 +12,12 @@ #include #include +#include "core/log.h" + #include "geninput/hid.h" #include "geninput/mouse.h" #include "util/defs.h" -#include "util/log.h" #include "util/mem.h" #include "util/str.h" diff --git a/src/main/geninput/msg-thread.c b/src/main/geninput/msg-thread.c index cc21ae0..7ca47f3 100644 --- a/src/main/geninput/msg-thread.c +++ b/src/main/geninput/msg-thread.c @@ -6,10 +6,11 @@ #include +#include "core/log.h" + #include "geninput/hotplug.h" #include "geninput/ri.h" -#include "util/log.h" #include "util/msg-thread.h" void msg_window_setup(HWND hwnd) diff --git a/src/main/geninput/pacdrive.c b/src/main/geninput/pacdrive.c index 2a5ab36..b388036 100644 --- a/src/main/geninput/pacdrive.c +++ b/src/main/geninput/pacdrive.c @@ -11,12 +11,13 @@ #include #include +#include "core/log.h" + #include "geninput/hid.h" #include "geninput/io-thread.h" #include "geninput/pacdrive.h" #include "util/defs.h" -#include "util/log.h" #include "util/mem.h" /* The PacDrive appears to have a malformed descriptor for its OUT report. diff --git a/src/main/geninput/ri.c b/src/main/geninput/ri.c index b3befee..45b6d65 100644 --- a/src/main/geninput/ri.c +++ b/src/main/geninput/ri.c @@ -1,5 +1,7 @@ #include +#include "core/log.h" + #include "geninput/hid-mgr.h" #include "geninput/hid.h" #include "geninput/kbd.h" @@ -7,7 +9,6 @@ #include "geninput/ri.h" #include "util/defs.h" -#include "util/log.h" #include "util/mem.h" struct ri_handle { diff --git a/src/main/hook/d3d9.c b/src/main/hook/d3d9.c index 45e1fd1..0f09ec6 100644 --- a/src/main/hook/d3d9.c +++ b/src/main/hook/d3d9.c @@ -1,10 +1,10 @@ #define LOG_MODULE "hook-d3d9" -#include "hook/d3d9.h" -#include "hook/com-proxy.h" -#include "hook/table.h" +#include "core/log.h" -#include "util/log.h" +#include "hook/com-proxy.h" +#include "hook/d3d9.h" +#include "hook/table.h" /* ------------------------------------------------------------------------------------------------------------------ */ diff --git a/src/main/hook/table.c b/src/main/hook/table.c index 067ea75..285a43d 100644 --- a/src/main/hook/table.c +++ b/src/main/hook/table.c @@ -174,10 +174,11 @@ static void hook_table_revert_to_iid( sym = &syms[j]; if (hook_table_match_proc(&iate, sym)) { - // Only revert-able if the original pointer was stored previously + // Only revert-able if the original pointer was stored + // previously if (sym->link != NULL && *sym->link != NULL) { pe_patch(iate.ppointer, sym->link, sizeof(*sym->link)); - } + } } } } diff --git a/src/main/hooklib/acp.c b/src/main/hooklib/acp.c index 52675b2..81faa73 100644 --- a/src/main/hooklib/acp.c +++ b/src/main/hooklib/acp.c @@ -6,13 +6,14 @@ #include #include +#include "core/log.h" + #include "hook/table.h" #include "hooklib/acp.h" #include "util/codepage.h" #include "util/defs.h" -#include "util/log.h" static NTSTATUS NTAPI my_RtlMultiByteToUnicodeN( wchar_t *dest, diff --git a/src/main/hooklib/adapter.c b/src/main/hooklib/adapter.c index 0b94c12..8b3b6d9 100644 --- a/src/main/hooklib/adapter.c +++ b/src/main/hooklib/adapter.c @@ -6,13 +6,14 @@ #include #include +#include "core/log.h" + #include "hook/table.h" #include "hooklib/adapter.h" #include "util/codepage.h" #include "util/defs.h" -#include "util/log.h" static DWORD WINAPI my_GetAdaptersInfo(PIP_ADAPTER_INFO adapter_info, PULONG out_buf_len); diff --git a/src/main/hooklib/app.c b/src/main/hooklib/app.c index 7ccd441..11fb824 100644 --- a/src/main/hooklib/app.c +++ b/src/main/hooklib/app.c @@ -1,5 +1,7 @@ #include +#include "core/log.h" + #include "hook/table.h" #include "hooklib/app.h" @@ -7,7 +9,6 @@ #include "imports/avs.h" #include "imports/eapki.h" -#include "util/log.h" #include "util/str.h" static dll_entry_init_t hook_dll_entry_init; diff --git a/src/main/hooklib/config-adapter.c b/src/main/hooklib/config-adapter.c index 49c2450..0ddb680 100644 --- a/src/main/hooklib/config-adapter.c +++ b/src/main/hooklib/config-adapter.c @@ -1,8 +1,8 @@ #include "cconfig/cconfig-util.h" -#include "hooklib/config-adapter.h" +#include "core/log.h" -#include "util/log.h" +#include "hooklib/config-adapter.h" #define HOOKLIB_CONFIG_ADAPTER_OVERRIDE_IP_KEY "adapter.override_ip" diff --git a/src/main/hooklib/memfile.c b/src/main/hooklib/memfile.c index 08dbeba..09c0587 100644 --- a/src/main/hooklib/memfile.c +++ b/src/main/hooklib/memfile.c @@ -3,12 +3,13 @@ #include #include +#include "core/log.h" + #include "hook/hr.h" #include "hook/iohook.h" #include "hook/table.h" #include "util/array.h" -#include "util/log.h" #include "util/str.h" struct file_entry { diff --git a/src/main/hooklib/rs232.c b/src/main/hooklib/rs232.c index 8d6d371..591c98f 100644 --- a/src/main/hooklib/rs232.c +++ b/src/main/hooklib/rs232.c @@ -14,12 +14,13 @@ #include #include +#include "core/log.h" + #include "hook/hr.h" #include "hook/iohook.h" #include "hook/table.h" #include "util/array.h" -#include "util/log.h" /* RS232 API hooks */ diff --git a/src/main/hooklib/setupapi.c b/src/main/hooklib/setupapi.c index 07dc72c..5363c52 100644 --- a/src/main/hooklib/setupapi.c +++ b/src/main/hooklib/setupapi.c @@ -4,12 +4,13 @@ #include #include +#include "core/log.h" + #include "hook/table.h" #include "hooklib/setupapi.h" #include "util/defs.h" -#include "util/log.h" #include "util/str.h" /* my hooks */ diff --git a/src/main/iidx-bio2-exit-hook/Module.mk b/src/main/iidx-bio2-exit-hook/Module.mk index dcf7289..085af3a 100644 --- a/src/main/iidx-bio2-exit-hook/Module.mk +++ b/src/main/iidx-bio2-exit-hook/Module.mk @@ -4,6 +4,7 @@ ldflags_iidx-bio2-exit-hook := \ -lsetupapi \ libs_iidx-bio2-exit-hook := \ + core \ bio2drv \ hook \ util \ diff --git a/src/main/iidx-bio2-exit-hook/main.c b/src/main/iidx-bio2-exit-hook/main.c index 13ac825..2718717 100644 --- a/src/main/iidx-bio2-exit-hook/main.c +++ b/src/main/iidx-bio2-exit-hook/main.c @@ -11,10 +11,13 @@ #include "bio2/bi2a-iidx.h" #include "bio2drv/detect.h" +#include "core/log-bt-ext.h" +#include "core/log-bt.h" +#include "core/log.h" + #include "hook/iobuf.h" #include "hook/iohook.h" -#include "util/log.h" #include "util/mem.h" #include "util/proc.h" #include "util/str.h" @@ -224,7 +227,8 @@ static HRESULT _iohook_handler(struct irp *irp) BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx) { - log_to_writer(log_writer_stdout, NULL); + core_log_bt_ext_impl_set(); + core_log_bt_ext_init_with_stdout(); if (reason != DLL_PROCESS_ATTACH) { return TRUE; diff --git a/src/main/iidx-ezusb-exit-hook/Module.mk b/src/main/iidx-ezusb-exit-hook/Module.mk index 4050ebe..500bd15 100644 --- a/src/main/iidx-ezusb-exit-hook/Module.mk +++ b/src/main/iidx-ezusb-exit-hook/Module.mk @@ -1,6 +1,7 @@ dlls += iidx-ezusb-exit-hook libs_iidx-ezusb-exit-hook := \ + core \ ezusb-iidx \ hook \ util \ diff --git a/src/main/iidx-ezusb2-exit-hook/Module.mk b/src/main/iidx-ezusb2-exit-hook/Module.mk index 7828a97..f449f38 100644 --- a/src/main/iidx-ezusb2-exit-hook/Module.mk +++ b/src/main/iidx-ezusb2-exit-hook/Module.mk @@ -1,6 +1,7 @@ dlls += iidx-ezusb2-exit-hook libs_iidx-ezusb2-exit-hook := \ + core \ hook \ util \ diff --git a/src/main/iidx-irbeat-patch/Module.mk b/src/main/iidx-irbeat-patch/Module.mk index df42cd3..d01645f 100644 --- a/src/main/iidx-irbeat-patch/Module.mk +++ b/src/main/iidx-irbeat-patch/Module.mk @@ -2,6 +2,7 @@ exes += iidx-irbeat-patch libs_iidx-irbeat-patch := \ util \ + core \ src_iidx-irbeat-patch := \ main.c \ diff --git a/src/main/iidxhook-d3d9/bb-scale-hd.c b/src/main/iidxhook-d3d9/bb-scale-hd.c index 60dae6b..84afe7c 100644 --- a/src/main/iidxhook-d3d9/bb-scale-hd.c +++ b/src/main/iidxhook-d3d9/bb-scale-hd.c @@ -2,13 +2,13 @@ #include +#include "core/log.h" + #include "d3d9-util/vertex.h" #include "bb-scale-hd.h" #include "util.h" -#include "util/log.h" - static bool iidxhook_d3d9_bb_scale_initialized; static uint16_t iidxhook_d3d9_bb_scale_hd_width; static uint16_t iidxhook_d3d9_bb_scale_hd_height; diff --git a/src/main/iidxhook-d3d9/util.h b/src/main/iidxhook-d3d9/util.h index 3a77e99..96b489e 100644 --- a/src/main/iidxhook-d3d9/util.h +++ b/src/main/iidxhook-d3d9/util.h @@ -3,9 +3,9 @@ #include -#include "d3d9-util/dxerr9.h" +#include "core/log.h" -#include "util/log.h" +#include "d3d9-util/dxerr9.h" inline void iidxhook_d3d9_util_check_and_handle_failure(HRESULT hr, const char *msg) diff --git a/src/main/iidxhook-util/Module.mk b/src/main/iidxhook-util/Module.mk index 92fe44d..50dd18d 100644 --- a/src/main/iidxhook-util/Module.mk +++ b/src/main/iidxhook-util/Module.mk @@ -1,6 +1,7 @@ libs += iidxhook-util libs_iidxhook-util := \ + core \ util \ src_iidxhook-util := \ diff --git a/src/main/iidxhook-util/acio.c b/src/main/iidxhook-util/acio.c index 6291336..a52fa76 100644 --- a/src/main/iidxhook-util/acio.c +++ b/src/main/iidxhook-util/acio.c @@ -15,6 +15,8 @@ #include "acioemu/emu.h" #include "acioemu/icca.h" +#include "core/log.h" + #include "hook/iohook.h" #include "hooklib/rs232.h" @@ -24,7 +26,6 @@ #include "util/defs.h" #include "util/iobuf.h" -#include "util/log.h" #include "util/str.h" static struct ac_io_emu iidxhook_util_acio_emu; diff --git a/src/main/iidxhook-util/chart-patch.c b/src/main/iidxhook-util/chart-patch.c index 4b2970e..b6cc290 100644 --- a/src/main/iidxhook-util/chart-patch.c +++ b/src/main/iidxhook-util/chart-patch.c @@ -4,12 +4,13 @@ #include #include +#include "core/log.h" + #include "hook/iohook.h" #include "util/crc.h" #include "util/defs.h" #include "util/fs.h" -#include "util/log.h" #include "util/mem.h" #include "util/str.h" diff --git a/src/main/iidxhook-util/clock.c b/src/main/iidxhook-util/clock.c index 8c870ff..dc0e2f2 100644 --- a/src/main/iidxhook-util/clock.c +++ b/src/main/iidxhook-util/clock.c @@ -2,10 +2,11 @@ #include +#include "core/log.h" + #include "hook/table.h" #include "util/defs.h" -#include "util/log.h" static BOOL STDCALL my_SetLocalTime(const SYSTEMTIME *lpSystemTime); static BOOL(STDCALL *real_SetLocalTime)(const SYSTEMTIME *lpSystemTime); diff --git a/src/main/iidxhook-util/config-eamuse.c b/src/main/iidxhook-util/config-eamuse.c index f59b03e..c75bd1a 100644 --- a/src/main/iidxhook-util/config-eamuse.c +++ b/src/main/iidxhook-util/config-eamuse.c @@ -2,12 +2,12 @@ #include "cconfig/cconfig-util.h" +#include "core/log.h" + #include "iidxhook-util/config-eamuse.h" #include "security/mcode.h" -#include "util/log.h" - #define IIDXHOOK_CONFIG_EAMUSE_CARD_TYPE_KEY "eamuse.card_type" #define IIDXHOOK_CONFIG_EAMUSE_SERVER_KEY "eamuse.server" #define IIDXHOOK_CONFIG_EAMUSE_PCBID_KEY "eamuse.pcbid" diff --git a/src/main/iidxhook-util/config-ezusb.c b/src/main/iidxhook-util/config-ezusb.c index e860a1d..14d953d 100644 --- a/src/main/iidxhook-util/config-ezusb.c +++ b/src/main/iidxhook-util/config-ezusb.c @@ -3,9 +3,10 @@ #include "cconfig/cconfig-util.h" +#include "core/log.h" + #include "iidxhook-util/config-ezusb.h" -#include "util/log.h" #include "util/mem.h" #define IIDXHOOK_UTIL_CONFIG_EZUSB_API_CALL_MONITORING_KEY \ diff --git a/src/main/iidxhook-util/config-gfx.c b/src/main/iidxhook-util/config-gfx.c index e591f48..1be281f 100644 --- a/src/main/iidxhook-util/config-gfx.c +++ b/src/main/iidxhook-util/config-gfx.c @@ -2,9 +2,9 @@ #include "cconfig/cconfig-util.h" -#include "iidxhook-util/config-gfx.h" +#include "core/log.h" -#include "util/log.h" +#include "iidxhook-util/config-gfx.h" #define IIDXHOOK_CONFIG_GFX_BGVIDEO_UV_FIX_KEY "gfx.bgvideo_uv_fix" #define IIDXHOOK_CONFIG_GFX_FRAMED_KEY "gfx.framed" diff --git a/src/main/iidxhook-util/config-io.c b/src/main/iidxhook-util/config-io.c index 3055ac6..13c59f3 100644 --- a/src/main/iidxhook-util/config-io.c +++ b/src/main/iidxhook-util/config-io.c @@ -1,8 +1,8 @@ #include "cconfig/cconfig-util.h" -#include "iidxhook-util/config-io.h" +#include "core/log.h" -#include "util/log.h" +#include "iidxhook-util/config-io.h" #define IIDXHOOK_UTIL_CONFIG_IO_DISABLE_CARD_READER_EMU_KEY \ "io.disable_card_reader_emu" diff --git a/src/main/iidxhook-util/config-misc.c b/src/main/iidxhook-util/config-misc.c index 7a18499..fca5ea5 100644 --- a/src/main/iidxhook-util/config-misc.c +++ b/src/main/iidxhook-util/config-misc.c @@ -1,8 +1,8 @@ #include "cconfig/cconfig-util.h" -#include "iidxhook-util/config-misc.h" +#include "core/log.h" -#include "util/log.h" +#include "iidxhook-util/config-misc.h" #define IIDXHOOK_CONFIG_MISC_DISABLE_CLOCK_SET_KEY "misc.disable_clock_set" #define IIDXHOOK_CONFIG_MISC_RTEFFECT_STUB_KEY "misc.rteffect_stub" diff --git a/src/main/iidxhook-util/config-sec.c b/src/main/iidxhook-util/config-sec.c index 54cb0ee..a2e9a57 100644 --- a/src/main/iidxhook-util/config-sec.c +++ b/src/main/iidxhook-util/config-sec.c @@ -3,12 +3,13 @@ #include "cconfig/cconfig-util.h" +#include "core/log.h" + #include "iidxhook-util/config-sec.h" #include "security/mcode.h" #include "security/rp.h" -#include "util/log.h" #include "util/mem.h" #define IIDXHOOK_CONFIG_SEC_BOOT_VERSION_KEY "sec.boot_version" diff --git a/src/main/iidxhook-util/d3d9.c b/src/main/iidxhook-util/d3d9.c index 9c87719..eeb5081 100644 --- a/src/main/iidxhook-util/d3d9.c +++ b/src/main/iidxhook-util/d3d9.c @@ -9,6 +9,8 @@ #include #include +#include "core/log.h" + #include "hook/com-proxy.h" #include "hook/table.h" @@ -16,7 +18,6 @@ #include "iidxhook-util/vertex-shader.h" #include "util/defs.h" -#include "util/log.h" #include "util/str.h" #include "util/time.h" diff --git a/src/main/iidxhook-util/eamuse.c b/src/main/iidxhook-util/eamuse.c index 15d77da..6a127bd 100644 --- a/src/main/iidxhook-util/eamuse.c +++ b/src/main/iidxhook-util/eamuse.c @@ -8,12 +8,13 @@ #include #include +#include "core/log.h" + #include "hook/table.h" #include "iidxhook-util/eamuse.h" #include "util/defs.h" -#include "util/log.h" #include "util/str.h" /* ------------------------------------------------------------------------- */ diff --git a/src/main/iidxhook-util/effector.c b/src/main/iidxhook-util/effector.c index 4f30e27..f313c60 100644 --- a/src/main/iidxhook-util/effector.c +++ b/src/main/iidxhook-util/effector.c @@ -2,12 +2,13 @@ #include +#include "core/log.h" + #include "hook/table.h" #include "iidxhook-util/effector.h" #include "util/defs.h" -#include "util/log.h" static BOOL my_EnableEqualizer(int a1); static BOOL my_GetEqualizerStatus(LPVOID buffer); diff --git a/src/main/iidxhook-util/log-server.c b/src/main/iidxhook-util/log-server.c index 1a7f687..5a2fe3d 100644 --- a/src/main/iidxhook-util/log-server.c +++ b/src/main/iidxhook-util/log-server.c @@ -5,6 +5,9 @@ #include #include +#include "core/log.h" +#include "core/thread.h" + #include "hook/table.h" #include "iidxhook-util/log-server.h" @@ -12,9 +15,7 @@ #include "imports/avs.h" #include "util/defs.h" -#include "util/log.h" #include "util/str.h" -#include "util/thread.h" static int log_thread_proc(void *ctx); static void @@ -39,7 +40,7 @@ void log_server_init(void) log_rv_consumer = CreateSemaphore(NULL, 0, 1, NULL); ready = CreateEvent(NULL, TRUE, FALSE, NULL); - log_to_external( + core_log_impl_set( log_post_misc, log_post_info, log_post_warning, log_post_fatal); log_thread_id = avs_thread_create(log_thread_proc, ready, 16384, 0); diff --git a/src/main/iidxhook-util/settings.c b/src/main/iidxhook-util/settings.c index b4f2ce3..5402f69 100644 --- a/src/main/iidxhook-util/settings.c +++ b/src/main/iidxhook-util/settings.c @@ -7,12 +7,13 @@ #include #include +#include "core/log.h" + #include "hook/iohook.h" #include "hook/table.h" #include "util/defs.h" #include "util/fs.h" -#include "util/log.h" #include "util/mem.h" #include "util/str.h" diff --git a/src/main/iidxhook1/Module.mk b/src/main/iidxhook1/Module.mk index fcfad98..61bb5ff 100644 --- a/src/main/iidxhook1/Module.mk +++ b/src/main/iidxhook1/Module.mk @@ -5,6 +5,7 @@ ldflags_iidxhook1 := \ -liphlpapi \ libs_iidxhook1 := \ + core \ iidxhook-util \ ezusb-emu \ ezusb-iidx-16seg-emu \ diff --git a/src/main/iidxhook1/config-iidxhook1.c b/src/main/iidxhook1/config-iidxhook1.c index 5a02c95..b88d471 100644 --- a/src/main/iidxhook1/config-iidxhook1.c +++ b/src/main/iidxhook1/config-iidxhook1.c @@ -1,8 +1,8 @@ #include "cconfig/cconfig-util.h" -#include "iidxhook1/config-iidxhook1.h" +#include "core/log.h" -#include "util/log.h" +#include "iidxhook1/config-iidxhook1.h" #define IIDXHOOK_CONFIG_MISC_HAPPY_SKY_MS_BG_FIX_KEY "misc.happy_sky_ms_bg_fix" diff --git a/src/main/iidxhook1/dllmain.c b/src/main/iidxhook1/dllmain.c index a3a4a35..60c61a7 100644 --- a/src/main/iidxhook1/dllmain.c +++ b/src/main/iidxhook1/dllmain.c @@ -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/desc.h" #include "ezusb-emu/device.h" #include "ezusb-emu/node-security-plug.h" @@ -42,8 +50,6 @@ #include "iidxhook1/log-ezusb.h" #include "util/defs.h" -#include "util/log.h" -#include "util/thread.h" #define IIDXHOOK1_INFO_HEADER \ "iidxhook for 9th Style, 10th Style, RED and HAPPY SKY" \ @@ -68,6 +74,14 @@ static const struct hook_symbol init_hook_syms[] = { }, }; +static void _iidxhook1_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 iidxhook1_setup_d3d9_hooks( const struct iidxhook_config_gfx *config_gfx, const struct iidxhook_config_iidxhook1 *config_iidxhook1) @@ -215,20 +229,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"); } @@ -261,7 +279,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(); + + _iidxhook1_log_init(); /* Bootstrap hook for further init tasks (see above) */ diff --git a/src/main/iidxhook1/ezusb-mon.c b/src/main/iidxhook1/ezusb-mon.c index b76418a..11f10f9 100644 --- a/src/main/iidxhook1/ezusb-mon.c +++ b/src/main/iidxhook1/ezusb-mon.c @@ -6,12 +6,13 @@ #include #include +#include "core/log.h" + #include "hook/table.h" #include "iidxhook1/ezusb-mon.h" #include "util/defs.h" -#include "util/log.h" #include "util/str.h" /* ------------------------------------------------------------------------- */ diff --git a/src/main/iidxhook1/log-ezusb.c b/src/main/iidxhook1/log-ezusb.c index ac71907..28a9c6a 100644 --- a/src/main/iidxhook1/log-ezusb.c +++ b/src/main/iidxhook1/log-ezusb.c @@ -6,12 +6,13 @@ #include #include +#include "core/log.h" + #include "hook/table.h" #include "iidxhook1/log-ezusb.h" #include "util/defs.h" -#include "util/log.h" #include "util/str.h" /* ------------------------------------------------------------------------- */ diff --git a/src/main/iidxhook2/Module.mk b/src/main/iidxhook2/Module.mk index c9fd438..4612442 100644 --- a/src/main/iidxhook2/Module.mk +++ b/src/main/iidxhook2/Module.mk @@ -5,6 +5,7 @@ ldflags_iidxhook2 := \ -liphlpapi \ libs_iidxhook2 := \ + core \ iidxhook-util \ ezusb-emu \ ezusb-iidx-16seg-emu \ diff --git a/src/main/iidxhook2/config-iidxhook2.c b/src/main/iidxhook2/config-iidxhook2.c index 6e3ac6b..0db10f3 100644 --- a/src/main/iidxhook2/config-iidxhook2.c +++ b/src/main/iidxhook2/config-iidxhook2.c @@ -1,8 +1,8 @@ #include "cconfig/cconfig-util.h" -#include "iidxhook2/config-iidxhook2.h" +#include "core/log.h" -#include "util/log.h" +#include "iidxhook2/config-iidxhook2.h" #define IIDXHOOK_CONFIG_MISC_DISTORTED_MS_BG_FIX_KEY "misc.distorted_ms_bg_fix" diff --git a/src/main/iidxhook2/dllmain.c b/src/main/iidxhook2/dllmain.c index 25a76ed..de8a916 100644 --- a/src/main/iidxhook2/dllmain.c +++ b/src/main/iidxhook2/dllmain.c @@ -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/desc.h" #include "ezusb-emu/device.h" #include "ezusb-emu/node-security-plug.h" @@ -41,9 +49,6 @@ #include "iidxhook2/config-iidxhook2.h" -#include "util/log.h" -#include "util/thread.h" - #define IIDXHOOK2_INFO_HEADER \ "iidxhook for DistorteD" \ ", build " __DATE__ " " __TIME__ ", gitrev " STRINGIFY(GITREV) @@ -65,6 +70,14 @@ static const struct hook_symbol init_hook_syms[] = { .link = (void **) &real_OpenProcess}, }; +static void _iidxhook2_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 iidxhook2_setup_d3d9_hooks( const struct iidxhook_config_gfx *config_gfx, const struct iidxhook_config_iidxhook2 *config_iidxhook2) @@ -207,20 +220,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"); } @@ -254,7 +271,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(); + + _iidxhook2_log_init(); /* Bootstrap hook for further init tasks (see above) */ diff --git a/src/main/iidxhook3/Module.mk b/src/main/iidxhook3/Module.mk index e328bec..6ab9a30 100644 --- a/src/main/iidxhook3/Module.mk +++ b/src/main/iidxhook3/Module.mk @@ -5,6 +5,7 @@ ldflags_iidxhook3 := \ -liphlpapi \ libs_iidxhook3 := \ + core \ iidxhook-util \ ezusb-emu \ ezusb-iidx-16seg-emu \ diff --git a/src/main/iidxhook3/dllmain.c b/src/main/iidxhook3/dllmain.c index b2e0e41..4927fc3 100644 --- a/src/main/iidxhook3/dllmain.c +++ b/src/main/iidxhook3/dllmain.c @@ -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" @@ -40,9 +48,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" \ @@ -64,6 +70,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) { @@ -200,20 +214,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"); } @@ -246,7 +264,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) */ diff --git a/src/main/iidxhook4-cn/Module.mk b/src/main/iidxhook4-cn/Module.mk index 0f7bcee..8cc34cb 100644 --- a/src/main/iidxhook4-cn/Module.mk +++ b/src/main/iidxhook4-cn/Module.mk @@ -8,6 +8,8 @@ deplibs_iidxhook4-cn := \ avs \ libs_iidxhook4-cn := \ + avs-util \ + core \ iidxhook-util \ ezusb-emu \ ezusb-iidx-16seg-emu \ diff --git a/src/main/iidxhook4-cn/avs-boot.c b/src/main/iidxhook4-cn/avs-boot.c index 378d80c..4c498c9 100644 --- a/src/main/iidxhook4-cn/avs-boot.c +++ b/src/main/iidxhook4-cn/avs-boot.c @@ -3,14 +3,15 @@ #include #include +#include "core/log-bt.h" +#include "core/log.h" + #include "hook/table.h" #include "imports/avs.h" #include "iidxhook4-cn/avs-boot.h" -#include "util/log.h" - static void (*real_avs_boot)( struct property_node *config, void *std_heap, @@ -35,6 +36,11 @@ static const struct hook_symbol iidxhook4_cn_log_hook_syms[] = { .link = (void **) &real_avs_boot}, }; +static AVS_LOG_WRITER(_avs_boot_log_writer, chars, nchars, ctx) +{ + core_log_bt_direct_sink_write(chars, nchars); +} + static void avs_boot_replace_property_uint32( struct property_node *node, const char *name, uint32_t val) { @@ -87,7 +93,7 @@ static void my_avs_boot( sz_std_heap, avs_heap, sz_avs_heap, - log_writer_debug, + _avs_boot_log_writer, NULL); } diff --git a/src/main/iidxhook4-cn/dllmain.c b/src/main/iidxhook4-cn/dllmain.c index ea2f42a..9fa61ba 100644 --- a/src/main/iidxhook4-cn/dllmain.c +++ b/src/main/iidxhook4-cn/dllmain.c @@ -5,10 +5,19 @@ #include #include +#include "avs-util/core-interop.h" + #include "bemanitools/iidxio.h" #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.h" +#include "core/thread.h" + #include "ezusb-emu/node-security-plug.h" #include "ezusb2-emu/desc.h" @@ -37,8 +46,6 @@ #include "imports/avs.h" -#include "util/log.h" - #define IIDXHOOK4_CN_INFO_HEADER \ "iidxhook for Resort Anthem CN" \ ", build " __DATE__ " " __TIME__ ", gitrev " STRINGIFY(GITREV) @@ -61,6 +68,14 @@ static const struct hook_symbol init_hook_syms[] = { static struct iidxhook_config_io config_io; +static void _iidxhook4_cn_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 iidxhook4_cn_setup_d3d9_hooks(const struct iidxhook_config_gfx *config_gfx) { @@ -183,11 +198,12 @@ my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId) if (!config_io.disable_io_emu) { 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( - avs_thread_create, avs_thread_join, avs_thread_destroy)) { + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get())) { log_fatal("Initializing IIDX IO backend failed"); } } else { @@ -221,7 +237,11 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx) return TRUE; } - log_to_writer(log_writer_debug, NULL); + // Use AVS APIs + avs_util_core_interop_thread_avs_impl_set(); + + // TODO init debug logging but with avs available? why not use avs logging? + _iidxhook4_cn_log_init(); hook_table_apply( NULL, "kernel32.dll", init_hook_syms, lengthof(init_hook_syms)); diff --git a/src/main/iidxhook4-cn/path.c b/src/main/iidxhook4-cn/path.c index 4ab6c5a..5d4ef1d 100644 --- a/src/main/iidxhook4-cn/path.c +++ b/src/main/iidxhook4-cn/path.c @@ -4,11 +4,12 @@ #include #include +#include "core/log.h" + #include "hook/table.h" #include "iidxhook4-cn/path.h" -#include "util/log.h" #include "util/str.h" #define PATH_A "D:/JDZ-001/contents/" diff --git a/src/main/iidxhook4/Module.mk b/src/main/iidxhook4/Module.mk index 40f40b0..6546ac1 100644 --- a/src/main/iidxhook4/Module.mk +++ b/src/main/iidxhook4/Module.mk @@ -7,6 +7,8 @@ deplibs_iidxhook4 := \ avs \ libs_iidxhook4 := \ + avs-util \ + core \ iidxhook-util \ ezusb-emu \ ezusb-iidx-16seg-emu \ diff --git a/src/main/iidxhook4/dllmain.c b/src/main/iidxhook4/dllmain.c index d7993dd..c52336f 100644 --- a/src/main/iidxhook4/dllmain.c +++ b/src/main/iidxhook4/dllmain.c @@ -5,11 +5,16 @@ #include #include +#include "avs-util/core-interop.h" + #include "bemanitools/eamio.h" #include "bemanitools/iidxio.h" #include "cconfig/cconfig-hook.h" +#include "core/log.h" +#include "core/thread.h" + #include "ezusb-iidx-emu/nodes.h" #include "ezusb2-emu/desc.h" @@ -36,9 +41,7 @@ #include "imports/avs.h" -#include "util/log.h" #include "util/str.h" -#include "util/thread.h" #define IIDXHOOK4_INFO_HEADER \ "iidxhook for Resort Anthem" \ @@ -142,11 +145,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param) if (!config_io.disable_io_emu) { 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( - avs_thread_create, avs_thread_join, avs_thread_destroy)) { + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get())) { log_fatal("Initializing IIDX IO backend failed"); } } else { @@ -156,11 +160,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param) if (!config_io.disable_card_reader_emu) { 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( - avs_thread_create, avs_thread_join, avs_thread_destroy)) { + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get())) { log_fatal("Initializing card reader backend failed"); } } else { @@ -227,8 +232,9 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx) goto end; } - log_to_external( - log_body_misc, log_body_info, log_body_warning, log_body_fatal); + // Use AVS APIs + avs_util_core_interop_thread_avs_impl_set(); + avs_util_core_interop_log_avs_impl_set(); app_hook_init(my_dll_entry_init, my_dll_entry_main); diff --git a/src/main/iidxhook5-cn/Module.mk b/src/main/iidxhook5-cn/Module.mk index feea3d4..5addce9 100644 --- a/src/main/iidxhook5-cn/Module.mk +++ b/src/main/iidxhook5-cn/Module.mk @@ -8,6 +8,8 @@ deplibs_iidxhook5-cn := \ avs \ libs_iidxhook5-cn := \ + avs-util \ + core \ iidxhook-util \ ezusb-emu \ ezusb-iidx-16seg-emu \ diff --git a/src/main/iidxhook5-cn/avs-boot.c b/src/main/iidxhook5-cn/avs-boot.c index 772832a..eaa1f45 100644 --- a/src/main/iidxhook5-cn/avs-boot.c +++ b/src/main/iidxhook5-cn/avs-boot.c @@ -3,14 +3,15 @@ #include #include +#include "core/log-bt.h" +#include "core/log.h" + #include "hook/table.h" #include "imports/avs.h" #include "iidxhook5-cn/avs-boot.h" -#include "util/log.h" - static void (*real_avs_boot)( struct property_node *config, void *std_heap, @@ -35,6 +36,11 @@ static const struct hook_symbol iidxhook5_cn_log_hook_syms[] = { .link = (void **) &real_avs_boot}, }; +static AVS_LOG_WRITER(_avs_boot_log_writer, chars, nchars, ctx) +{ + core_log_bt_direct_sink_write(chars, nchars); +} + static void avs_boot_replace_property_uint32( struct property_node *node, const char *name, uint32_t val) { @@ -87,7 +93,7 @@ static void my_avs_boot( sz_std_heap, avs_heap, sz_avs_heap, - log_writer_debug, + _avs_boot_log_writer, NULL); } diff --git a/src/main/iidxhook5-cn/dllmain.c b/src/main/iidxhook5-cn/dllmain.c index 711c906..1d327dc 100644 --- a/src/main/iidxhook5-cn/dllmain.c +++ b/src/main/iidxhook5-cn/dllmain.c @@ -5,10 +5,18 @@ #include #include +#include "avs-util/core-interop.h" + #include "bemanitools/iidxio.h" #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.h" + #include "ezusb-emu/node-security-plug.h" #include "ezusb2-emu/desc.h" @@ -37,8 +45,6 @@ #include "imports/avs.h" -#include "util/log.h" - #define IIDXHOOK5_CN_INFO_HEADER \ "iidxhook for tricoro CN" \ ", build " __DATE__ " " __TIME__ ", gitrev " STRINGIFY(GITREV) @@ -61,6 +67,14 @@ static const struct hook_symbol init_hook_user32_syms[] = { static struct iidxhook_config_io config_io; +static void _iidxhook5_cn_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 iidxhook5_cn_setup_d3d9_hooks(const struct iidxhook_config_gfx *config_gfx) { @@ -163,11 +177,12 @@ static ATOM WINAPI my_RegisterClassA(const WNDCLASSA *lpWndClass) if (!config_io.disable_io_emu) { 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( - avs_thread_create, avs_thread_join, avs_thread_destroy)) { + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get())) { log_fatal("Initializing IIDX IO backend failed"); } } else { @@ -200,7 +215,11 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx) return TRUE; } - log_to_writer(log_writer_debug, NULL); + // Use AVS APIs + avs_util_core_interop_thread_avs_impl_set(); + + // TODO init debug logging but with avs available? why not use avs logging? + _iidxhook5_cn_log_init(); hook_table_apply( NULL, diff --git a/src/main/iidxhook5-cn/path.c b/src/main/iidxhook5-cn/path.c index d45bf22..bb4f81d 100644 --- a/src/main/iidxhook5-cn/path.c +++ b/src/main/iidxhook5-cn/path.c @@ -4,11 +4,12 @@ #include #include +#include "core/log.h" + #include "hook/table.h" #include "iidxhook5-cn/path.h" -#include "util/log.h" #include "util/str.h" #define PATH_A "D:/JDZ-001/contents/" diff --git a/src/main/iidxhook5/Module.mk b/src/main/iidxhook5/Module.mk index 78ea307..28cb7fe 100644 --- a/src/main/iidxhook5/Module.mk +++ b/src/main/iidxhook5/Module.mk @@ -7,6 +7,8 @@ deplibs_iidxhook5 := \ avs \ libs_iidxhook5 := \ + avs-util \ + core \ iidxhook-util \ ezusb-emu \ ezusb-iidx-16seg-emu \ diff --git a/src/main/iidxhook5/dllmain.c b/src/main/iidxhook5/dllmain.c index 268bf39..0912c38 100644 --- a/src/main/iidxhook5/dllmain.c +++ b/src/main/iidxhook5/dllmain.c @@ -5,11 +5,16 @@ #include #include +#include "avs-util/core-interop.h" + #include "bemanitools/eamio.h" #include "bemanitools/iidxio.h" #include "cconfig/cconfig-hook.h" +#include "core/log.h" +#include "core/thread.h" + #include "ezusb-iidx-emu/nodes.h" #include "ezusb2-emu/desc.h" @@ -36,9 +41,7 @@ #include "imports/avs.h" -#include "util/log.h" #include "util/str.h" -#include "util/thread.h" #include "ifs-snd-redir.h" @@ -144,11 +147,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param) if (!config_io.disable_io_emu) { 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( - avs_thread_create, avs_thread_join, avs_thread_destroy)) { + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get())) { log_fatal("Initializing IIDX IO backend failed"); } } else { @@ -158,11 +162,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param) if (!config_io.disable_card_reader_emu) { 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( - avs_thread_create, avs_thread_join, avs_thread_destroy)) { + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get())) { log_fatal("Initializing card reader backend failed"); } } else { @@ -228,8 +233,9 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx) goto end; } - log_to_external( - log_body_misc, log_body_info, log_body_warning, log_body_fatal); + // Use AVS APIs + avs_util_core_interop_thread_avs_impl_set(); + avs_util_core_interop_log_avs_impl_set(); app_hook_init(my_dll_entry_init, my_dll_entry_main); diff --git a/src/main/iidxhook5/ifs-snd-redir.c b/src/main/iidxhook5/ifs-snd-redir.c index e73dd5c..639d16f 100644 --- a/src/main/iidxhook5/ifs-snd-redir.c +++ b/src/main/iidxhook5/ifs-snd-redir.c @@ -3,13 +3,14 @@ #include #include +#include "core/log.h" + #include "hook/table.h" #include "imports/avs.h" #include "iidxhook5/ifs-snd-redir.h" -#include "util/log.h" #include "util/str.h" static void *(*real_avs_fs_open)(const char *path, int mode, int flags); diff --git a/src/main/iidxhook6/Module.mk b/src/main/iidxhook6/Module.mk index 7fda87b..fe7e955 100644 --- a/src/main/iidxhook6/Module.mk +++ b/src/main/iidxhook6/Module.mk @@ -7,6 +7,8 @@ deplibs_iidxhook6 := \ avs \ libs_iidxhook6 := \ + avs-util \ + core \ iidxhook-d3d9 \ iidxhook-util \ ezusb-emu \ diff --git a/src/main/iidxhook6/dllmain.c b/src/main/iidxhook6/dllmain.c index b4ca65a..4b614a4 100644 --- a/src/main/iidxhook6/dllmain.c +++ b/src/main/iidxhook6/dllmain.c @@ -5,11 +5,16 @@ #include #include +#include "avs-util/core-interop.h" + #include "bemanitools/eamio.h" #include "bemanitools/iidxio.h" #include "cconfig/cconfig-hook.h" +#include "core/log.h" +#include "core/thread.h" + #include "ezusb-iidx-emu/nodes.h" #include "ezusb2-emu/desc.h" @@ -35,9 +40,7 @@ #include "imports/avs.h" -#include "util/log.h" #include "util/str.h" -#include "util/thread.h" #define IIDXHOOK6_INFO_HEADER \ "iidxhook for Tricoro" \ @@ -121,11 +124,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param) if (!config_io.disable_io_emu) { 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( - avs_thread_create, avs_thread_join, avs_thread_destroy)) { + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get())) { log_fatal("Initializing IIDX IO backend failed"); } } else { @@ -135,11 +139,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param) if (!config_io.disable_card_reader_emu) { 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( - avs_thread_create, avs_thread_join, avs_thread_destroy)) { + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get())) { log_fatal("Initializing card reader backend failed"); } } else { @@ -203,8 +208,9 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx) goto end; } - log_to_external( - log_body_misc, log_body_info, log_body_warning, log_body_fatal); + // Use AVS APIs + avs_util_core_interop_thread_avs_impl_set(); + avs_util_core_interop_log_avs_impl_set(); app_hook_init(my_dll_entry_init, my_dll_entry_main); diff --git a/src/main/iidxhook7/Module.mk b/src/main/iidxhook7/Module.mk index a40366a..b1b6d93 100644 --- a/src/main/iidxhook7/Module.mk +++ b/src/main/iidxhook7/Module.mk @@ -8,6 +8,8 @@ deplibs_iidxhook7 := \ avs \ libs_iidxhook7 := \ + avs-util \ + core \ iidxhook-d3d9 \ iidxhook-util \ cconfig \ diff --git a/src/main/iidxhook7/dllmain.c b/src/main/iidxhook7/dllmain.c index af948f6..0823e85 100644 --- a/src/main/iidxhook7/dllmain.c +++ b/src/main/iidxhook7/dllmain.c @@ -5,11 +5,16 @@ #include #include +#include "avs-util/core-interop.h" + #include "bemanitools/eamio.h" #include "bemanitools/iidxio.h" #include "cconfig/cconfig-hook.h" +#include "core/log.h" +#include "core/thread.h" + #include "ezusb-iidx-emu/nodes.h" #include "ezusb2-emu/desc.h" @@ -35,9 +40,7 @@ #include "imports/avs.h" -#include "util/log.h" #include "util/str.h" -#include "util/thread.h" #define IIDXHOOK7_INFO_HEADER \ "iidxhook for SPADA, PENDUAL, copula and SINOBUZ" \ @@ -121,11 +124,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param) if (!config_io.disable_io_emu) { 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( - avs_thread_create, avs_thread_join, avs_thread_destroy)) { + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get())) { log_fatal("Initializing IIDX IO backend failed"); } } else { @@ -135,11 +139,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param) if (!config_io.disable_card_reader_emu) { 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( - avs_thread_create, avs_thread_join, avs_thread_destroy)) { + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get())) { log_fatal("Initializing card reader backend failed"); } } else { @@ -203,8 +208,9 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx) goto end; } - log_to_external( - log_body_misc, log_body_info, log_body_warning, log_body_fatal); + // Use AVS APIs + avs_util_core_interop_thread_avs_impl_set(); + avs_util_core_interop_log_avs_impl_set(); app_hook_init(my_dll_entry_init, my_dll_entry_main); diff --git a/src/main/iidxhook8/Module.mk b/src/main/iidxhook8/Module.mk index e71c8c2..faebbbb 100644 --- a/src/main/iidxhook8/Module.mk +++ b/src/main/iidxhook8/Module.mk @@ -12,6 +12,8 @@ deplibs_iidxhook8 := \ avs \ libs_iidxhook8 := \ + avs-util \ + core \ iidxhook-d3d9 \ iidxhook-util \ acioemu \ diff --git a/src/main/iidxhook8/config-io.c b/src/main/iidxhook8/config-io.c index 8cbb9b2..9f61e13 100644 --- a/src/main/iidxhook8/config-io.c +++ b/src/main/iidxhook8/config-io.c @@ -1,8 +1,8 @@ #include "cconfig/cconfig-util.h" -#include "iidxhook8/config-io.h" +#include "core/log.h" -#include "util/log.h" +#include "iidxhook8/config-io.h" #define IIDXHOOK8_CONFIG_IO_DISABLE_CARD_READER_EMU_KEY \ "io.disable_card_reader_emu" diff --git a/src/main/iidxhook8/dllmain.c b/src/main/iidxhook8/dllmain.c index 13509be..bf1f55d 100644 --- a/src/main/iidxhook8/dllmain.c +++ b/src/main/iidxhook8/dllmain.c @@ -5,11 +5,16 @@ #include #include +#include "avs-util/core-interop.h" + #include "bemanitools/eamio.h" #include "bemanitools/iidxio.h" #include "cconfig/cconfig-hook.h" +#include "core/log.h" +#include "core/thread.h" + #include "hook/d3d9.h" #include "hooklib/acp.h" @@ -34,9 +39,7 @@ #include "imports/avs.h" -#include "util/log.h" #include "util/str.h" -#include "util/thread.h" #define IIDXHOOK8_INFO_HEADER \ "iidxhook for Cannon Ballers/Rootage" \ @@ -131,11 +134,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param) /* Start up IIDXIO.DLL */ if (!iidxhook8_config_io.disable_bio2_emu) { 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( - avs_thread_create, avs_thread_join, avs_thread_destroy)) { + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get())) { log_fatal("Initializing IIDX IO backend failed"); } } @@ -143,11 +147,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param) /* Start up EAMIO.DLL */ if (!iidxhook8_config_io.disable_card_reader_emu) { 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( - avs_thread_create, avs_thread_join, avs_thread_destroy)) { + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get())) { log_fatal("Initializing card reader backend failed"); } } @@ -217,8 +222,9 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx) goto end; } - log_to_external( - log_body_misc, log_body_info, log_body_warning, log_body_fatal); + // Use AVS APIs + avs_util_core_interop_thread_avs_impl_set(); + avs_util_core_interop_log_avs_impl_set(); app_hook_init(my_dll_entry_init, my_dll_entry_main); diff --git a/src/main/iidxhook9/Module.mk b/src/main/iidxhook9/Module.mk index 30384f1..2328fdc 100644 --- a/src/main/iidxhook9/Module.mk +++ b/src/main/iidxhook9/Module.mk @@ -12,6 +12,8 @@ deplibs_iidxhook9 := \ avs \ libs_iidxhook9 := \ + avs-util \ + core \ iidxhook-util \ acioemu \ asio \ diff --git a/src/main/iidxhook9/config-io.c b/src/main/iidxhook9/config-io.c index ba7ff45..34deebf 100644 --- a/src/main/iidxhook9/config-io.c +++ b/src/main/iidxhook9/config-io.c @@ -1,8 +1,8 @@ #include "cconfig/cconfig-util.h" -#include "iidxhook9/config-io.h" +#include "core/log.h" -#include "util/log.h" +#include "iidxhook9/config-io.h" #define IIDXHOOK9_CONFIG_IO_DISABLE_CARD_READER_EMU_KEY \ "io.disable_card_reader_emu" diff --git a/src/main/iidxhook9/dllmain.c b/src/main/iidxhook9/dllmain.c index b7ae85a..ad9572d 100644 --- a/src/main/iidxhook9/dllmain.c +++ b/src/main/iidxhook9/dllmain.c @@ -5,11 +5,18 @@ #include #include +#include "avs-util/core-interop.h" + #include "bemanitools/eamio.h" #include "bemanitools/iidxio.h" #include "cconfig/cconfig-hook.h" +#include "core/log-bt-ext.h" +#include "core/log-bt.h" +#include "core/log.h" +#include "core/thread.h" + #include "hooklib/acp.h" #include "hooklib/adapter.h" #include "hooklib/app.h" @@ -38,9 +45,7 @@ #include "imports/avs.h" #include "util/cmdline.h" -#include "util/log.h" #include "util/str.h" -#include "util/thread.h" #define IIDXHOOK9_INFO_HEADER \ "iidxhook for Heroic Verse" \ @@ -97,6 +102,9 @@ static bool load_configs() static bool my_dll_entry_init(char *sidcode, struct property_node *param) { + // Use AVS APIs + avs_util_core_interop_thread_avs_impl_set(); + // log_server_init is required due to IO occuring in a non avs_thread log_server_init(); @@ -124,11 +132,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param) /* Start up IIDXIO.DLL */ if (!iidxhook9_config_io.disable_bio2_emu) { 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( - avs_thread_create, avs_thread_join, avs_thread_destroy)) { + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get())) { log_fatal("Initializing IIDX IO backend failed"); } } @@ -136,11 +145,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param) /* Start up EAMIO.DLL */ if (!iidxhook9_config_io.disable_card_reader_emu) { 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( - avs_thread_create, avs_thread_join, avs_thread_destroy)) { + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get())) { log_fatal("Initializing card reader backend failed"); } } @@ -271,8 +281,8 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx) // if AVS is loaded, we're likely too late to be a prehook // so we warn the user // and switch the current logging context to AVS so it shows up in logs - log_to_external( - log_body_misc, log_body_info, log_body_warning, log_body_fatal); + avs_util_core_interop_log_avs_impl_set(); + log_warning("iidxhook9 is designed to be used as a prehook"); log_warning("please ensure that it is being loaded with -B"); log_fatal("cya l8r in the prehook :3"); @@ -280,7 +290,7 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx) // we can't log to external in DllMain (AVS) as we're a prehook // later during my_dll_entry_init, log_server_init is called // which sets swaps the main log write to that instead - log_to_writer(log_writer_file, stdout); + core_log_bt_ext_impl_set(); } pre_hook(); diff --git a/src/main/iidxio-bio2/Module.mk b/src/main/iidxio-bio2/Module.mk index 09632c2..e91d76a 100644 --- a/src/main/iidxio-bio2/Module.mk +++ b/src/main/iidxio-bio2/Module.mk @@ -4,6 +4,7 @@ ldflags_iidxio-bio2 := \ -lsetupapi \ libs_iidxio-bio2 := \ + core \ aciodrv \ bio2drv \ cconfig \ diff --git a/src/main/iidxio-ezusb/Module.mk b/src/main/iidxio-ezusb/Module.mk index ce9982c..cc64914 100644 --- a/src/main/iidxio-ezusb/Module.mk +++ b/src/main/iidxio-ezusb/Module.mk @@ -5,6 +5,7 @@ ldflags_iidxio-ezusb := \ -lsetupapi \ libs_iidxio-ezusb := \ + core \ ezusb \ ezusb2 \ ezusb-iidx \ diff --git a/src/main/iidxio-ezusb2/Module.mk b/src/main/iidxio-ezusb2/Module.mk index f1f1963..3371a78 100644 --- a/src/main/iidxio-ezusb2/Module.mk +++ b/src/main/iidxio-ezusb2/Module.mk @@ -5,6 +5,7 @@ ldflags_iidxio-ezusb2 := \ -lsetupapi \ libs_iidxio-ezusb2 := \ + core \ ezusb2 \ ezusb \ ezusb2-iidx \ diff --git a/src/main/iidxiotest/Module.mk b/src/main/iidxiotest/Module.mk index ce0536c..94eca38 100644 --- a/src/main/iidxiotest/Module.mk +++ b/src/main/iidxiotest/Module.mk @@ -1,6 +1,7 @@ exes += iidxiotest \ libs_iidxiotest := \ + core \ iidxio \ util \ diff --git a/src/main/iidxiotest/main.c b/src/main/iidxiotest/main.c index ddd57cf..a9b7daa 100644 --- a/src/main/iidxiotest/main.c +++ b/src/main/iidxiotest/main.c @@ -7,8 +7,12 @@ #include "bemanitools/iidxio.h" -#include "util/log.h" -#include "util/thread.h" +#include "core/log-bt-ext.h" +#include "core/log-bt.h" +#include "core/log.h" +#include "core/thread-crt-ext.h" +#include "core/thread-crt.h" +#include "core/thread.h" static uint8_t _fix_top_lamps_order(uint8_t top_lamps) { @@ -55,12 +59,17 @@ static void _all_lights_off_shutdown() */ int main(int argc, char **argv) { - log_to_writer(log_writer_stdout, NULL); + core_thread_crt_ext_impl_set(); + core_log_bt_ext_impl_set(); - iidx_io_set_loggers( - log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal); + core_log_bt_ext_init_with_stdout(); - if (!iidx_io_init(crt_thread_create, crt_thread_join, crt_thread_destroy)) { + core_log_impl_assign(iidx_io_set_loggers); + + if (!iidx_io_init( + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get())) { printf("Initializing iidxio failed\n"); return -1; } diff --git a/src/main/jbhook-util-p3io/gfx.c b/src/main/jbhook-util-p3io/gfx.c index 63607fd..0574b1f 100644 --- a/src/main/jbhook-util-p3io/gfx.c +++ b/src/main/jbhook-util-p3io/gfx.c @@ -9,6 +9,8 @@ #include #include +#include "core/log.h" + #include "hook/com-proxy.h" #include "hook/table.h" @@ -17,7 +19,6 @@ #include "jbhook-util-p3io/gfx.h" #include "util/defs.h" -#include "util/log.h" #include "util/str.h" #include "util/time.h" diff --git a/src/main/jbhook-util-p3io/mixer.c b/src/main/jbhook-util-p3io/mixer.c index 30dcace..ba52a63 100644 --- a/src/main/jbhook-util-p3io/mixer.c +++ b/src/main/jbhook-util-p3io/mixer.c @@ -6,10 +6,11 @@ #include // clang-format on +#include "core/log.h" + #include "hook/table.h" #include "util/defs.h" -#include "util/log.h" MMRESULT STDCALL hook_mixerGetLineControlsA( HMIXEROBJ hmxobj, LPMIXERLINECONTROLSA pmxlc, DWORD fdwControls); diff --git a/src/main/jbhook-util-p3io/p3io.c b/src/main/jbhook-util-p3io/p3io.c index 25b3364..dd04607 100644 --- a/src/main/jbhook-util-p3io/p3io.c +++ b/src/main/jbhook-util-p3io/p3io.c @@ -5,6 +5,8 @@ #include "bemanitools/jbio.h" +#include "core/log.h" + #include "jbhook-util-p3io/p3io.h" #include "p3ioemu/emu.h" @@ -13,8 +15,6 @@ #include "security/rp-sign-key.h" #include "security/rp3.h" -#include "util/log.h" - static HRESULT jbhook_p3io_read_jamma(void *ctx, uint32_t *state); static HRESULT jbhook_p3io_get_roundplug( void *ctx, uint8_t plug_id, uint8_t *rom, uint8_t *eeprom); diff --git a/src/main/jbhook-util/acio.c b/src/main/jbhook-util/acio.c index a1f5492..8a1ed02 100644 --- a/src/main/jbhook-util/acio.c +++ b/src/main/jbhook-util/acio.c @@ -16,6 +16,8 @@ #include "acioemu/h44b.h" #include "acioemu/icca.h" +#include "core/log.h" + #include "hook/iohook.h" #include "jbhook-util/acio.h" @@ -25,7 +27,6 @@ #include "util/defs.h" #include "util/hex.h" #include "util/iobuf.h" -#include "util/log.h" #include "util/str.h" static struct ac_io_emu ac_io_emu; diff --git a/src/main/jbhook-util/eamuse.c b/src/main/jbhook-util/eamuse.c index 0a79625..c9d1d90 100644 --- a/src/main/jbhook-util/eamuse.c +++ b/src/main/jbhook-util/eamuse.c @@ -9,10 +9,11 @@ #include #include +#include "core/log.h" + #include "hook/table.h" #include "util/defs.h" -#include "util/log.h" #include "util/net.h" #include "util/str.h" diff --git a/src/main/jbhook-util/locale.c b/src/main/jbhook-util/locale.c index 272bbc6..a6b6d17 100644 --- a/src/main/jbhook-util/locale.c +++ b/src/main/jbhook-util/locale.c @@ -2,10 +2,11 @@ #include +#include "core/log.h" + #include "hook/table.h" #include "util/defs.h" -#include "util/log.h" // ANSI/OEM Japanese; Japanese (Shift-JIS) #define CODEPAGE_SHIFT_JIS 932 diff --git a/src/main/jbhook-util/p4io.c b/src/main/jbhook-util/p4io.c index ab77d5d..824ab80 100644 --- a/src/main/jbhook-util/p4io.c +++ b/src/main/jbhook-util/p4io.c @@ -4,14 +4,14 @@ #include "bemanitools/jbio.h" +#include "core/log.h" + #include "imports/avs.h" #include "jbhook-util/p4io.h" #include "p4io/cmd.h" -#include "util/log.h" - static void jbhook_io_jamma2_read(void *resp, uint32_t nbytes); static uint32_t jbhook_command_handle( uint8_t cmd, diff --git a/src/main/jbhook1/Module.mk b/src/main/jbhook1/Module.mk index b5e4777..c434f21 100644 --- a/src/main/jbhook1/Module.mk +++ b/src/main/jbhook1/Module.mk @@ -11,6 +11,7 @@ ldflags_jbhook1 := \ -lopengl32 \ libs_jbhook1 := \ + core \ acioemu \ cconfig \ eamio \ diff --git a/src/main/jbhook1/avs-boot.c b/src/main/jbhook1/avs-boot.c index dccba69..62d6773 100644 --- a/src/main/jbhook1/avs-boot.c +++ b/src/main/jbhook1/avs-boot.c @@ -5,14 +5,15 @@ #include #include +#include "core/log-bt.h" +#include "core/log.h" + #include "hook/table.h" #include "imports/avs.h" #include "jbhook1/avs-boot.h" -#include "util/log.h" - static void (*real_avs_boot)( struct property_node *config, void *std_heap, @@ -52,6 +53,11 @@ static const struct hook_symbol jbhook1_log_gftools_hook_syms2[] = { .link = (void **) &real_ea3_boot}, }; +static AVS_LOG_WRITER(_avs_boot_log_writer, chars, nchars, ctx) +{ + core_log_bt_direct_sink_write(chars, nchars); +} + static void avs_boot_create_property_str( struct property *config, const char *name, const char *val) { @@ -139,7 +145,7 @@ static void my_avs_boot( sz_std_heap, avs_heap, sz_avs_heap, - log_writer_debug, + _avs_boot_log_writer, NULL); } diff --git a/src/main/jbhook1/config-eamuse.c b/src/main/jbhook1/config-eamuse.c index dba512e..77170e2 100644 --- a/src/main/jbhook1/config-eamuse.c +++ b/src/main/jbhook1/config-eamuse.c @@ -2,9 +2,10 @@ #include "cconfig/cconfig-util.h" +#include "core/log.h" + #include "jbhook1/config-eamuse.h" -#include "util/log.h" #include "util/net.h" #define JBHOOK1_CONFIG_EAMUSE_SERVER_KEY "eamuse.server" diff --git a/src/main/jbhook1/config-gfx.c b/src/main/jbhook1/config-gfx.c index 5215659..10102fa 100644 --- a/src/main/jbhook1/config-gfx.c +++ b/src/main/jbhook1/config-gfx.c @@ -2,9 +2,9 @@ #include "cconfig/cconfig-util.h" -#include "jbhook1/config-gfx.h" +#include "core/log.h" -#include "util/log.h" +#include "jbhook1/config-gfx.h" #define JBHOOK1_CONFIG_GFX_WINDOWED_KEY "gfx.windowed" #define JBHOOK1_CONFIG_GFX_VERTICAL_KEY "gfx.vertical" diff --git a/src/main/jbhook1/config-security.c b/src/main/jbhook1/config-security.c index 565081e..d6c56b0 100644 --- a/src/main/jbhook1/config-security.c +++ b/src/main/jbhook1/config-security.c @@ -2,11 +2,12 @@ #include "cconfig/cconfig-util.h" +#include "core/log.h" + #include "jbhook1/config-security.h" #include "security/mcode.h" -#include "util/log.h" #include "util/net.h" #define JBHOOK1_CONFIG_SECURITY_MCODE_KEY "security.mcode" diff --git a/src/main/jbhook1/dllmain.c b/src/main/jbhook1/dllmain.c index 42f8dc9..f058d0f 100644 --- a/src/main/jbhook1/dllmain.c +++ b/src/main/jbhook1/dllmain.c @@ -10,6 +10,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 "hook/table.h" #include "hooklib/acp.h" @@ -33,8 +41,6 @@ #include "p3ioemu/emu.h" #include "util/defs.h" -#include "util/log.h" -#include "util/thread.h" #define JBHOOK1_INFO_HEADER \ "jbhook1 for jubeat" \ @@ -89,6 +95,14 @@ static const struct hook_symbol kernel32_hook_syms[] = { // so our CreateProcessA hook can check static bool vertical; +static void _jbhook1_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); +} + /** * This seems to be a good entry point to intercept before the game calls * anything important (very close to the start of WinMain). @@ -153,19 +167,23 @@ static HWND CDECL my_mwindow_create( log_info("Starting up jubeat IO backend"); - jb_io_set_loggers( - log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal); + core_log_impl_assign(jb_io_set_loggers); - if (!jb_io_init(thread_create, thread_join, thread_destroy)) { + if (!jb_io_init( + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get())) { log_fatal("Initializing jb IO backend failed"); } log_info("Starting up 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"); } @@ -201,7 +219,12 @@ static HWND CDECL my_mwindow_create( BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx) { if (reason == DLL_PROCESS_ATTACH) { - log_to_writer(log_writer_debug, NULL); + // TODO why not use AVS threads? + core_thread_crt_ext_impl_set(); + + // TODO init debug logging but with avs available? why not use avs + // logging? + _jbhook1_log_init(); /* Bootstrap hook for further init tasks (see above) */ diff --git a/src/main/jbhook1/log-gftools.c b/src/main/jbhook1/log-gftools.c index 9772173..f0dbf85 100644 --- a/src/main/jbhook1/log-gftools.c +++ b/src/main/jbhook1/log-gftools.c @@ -5,9 +5,9 @@ #include #include -#include "hook/table.h" +#include "core/log.h" -#include "util/log.h" +#include "hook/table.h" static int CDECL my_GFReportPuts( int level, diff --git a/src/main/jbhook2/Module.mk b/src/main/jbhook2/Module.mk index 2573867..7ecebdb 100644 --- a/src/main/jbhook2/Module.mk +++ b/src/main/jbhook2/Module.mk @@ -10,6 +10,8 @@ ldflags_jbhook2 := \ -lopengl32 \ libs_jbhook2 := \ + avs-util \ + core \ acioemu \ eamio \ jbio \ diff --git a/src/main/jbhook2/dllmain.c b/src/main/jbhook2/dllmain.c index a8523ad..4c06e4d 100644 --- a/src/main/jbhook2/dllmain.c +++ b/src/main/jbhook2/dllmain.c @@ -5,9 +5,14 @@ #include #include +#include "avs-util/core-interop.h" + #include "bemanitools/eamio.h" #include "bemanitools/jbio.h" +#include "core/log.h" +#include "core/thread.h" + #include "hook/iohook.h" #include "hook/table.h" @@ -36,8 +41,6 @@ #include "security/mcode.h" #include "util/defs.h" -#include "util/log.h" -#include "util/thread.h" static struct options options; @@ -80,11 +83,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param) log_info("Starting up jubeat IO backend"); - jb_io_set_loggers( - log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal); + core_log_impl_assign(jb_io_set_loggers); - jb_io_ok = - jb_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy); + jb_io_ok = jb_io_init( + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get()); if (!jb_io_ok) { goto fail; @@ -99,11 +103,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param) log_info("Starting up 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); - eam_io_ok = - eam_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy); + eam_io_ok = eam_io_init( + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get()); if (!eam_io_ok) { goto fail; @@ -224,8 +229,9 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx) return TRUE; } - log_to_external( - log_body_misc, log_body_info, log_body_warning, log_body_fatal); + // Use AVS APIs + avs_util_core_interop_thread_avs_impl_set(); + avs_util_core_interop_log_avs_impl_set(); options_init_from_cmdline(&options); diff --git a/src/main/jbhook2/options.c b/src/main/jbhook2/options.c index 9e1987e..63ee6d4 100644 --- a/src/main/jbhook2/options.c +++ b/src/main/jbhook2/options.c @@ -9,7 +9,7 @@ #include "util/cmdline.h" #include "util/defs.h" #include "util/hex.h" -#include "util/log.h" + #include "util/str.h" void options_init_from_cmdline(struct options *options) diff --git a/src/main/jbhook3/Module.mk b/src/main/jbhook3/Module.mk index a82c4cc..ca36a43 100644 --- a/src/main/jbhook3/Module.mk +++ b/src/main/jbhook3/Module.mk @@ -8,6 +8,8 @@ ldflags_jbhook3 := \ -liphlpapi \ libs_jbhook3 := \ + avs-util \ + core \ acioemu \ eamio \ jbio \ diff --git a/src/main/jbhook3/dllmain.c b/src/main/jbhook3/dllmain.c index b4eada8..30a0eb3 100644 --- a/src/main/jbhook3/dllmain.c +++ b/src/main/jbhook3/dllmain.c @@ -5,9 +5,14 @@ #include #include +#include "avs-util/core-interop.h" + #include "bemanitools/eamio.h" #include "bemanitools/jbio.h" +#include "core/log.h" +#include "core/thread.h" + #include "hook/iohook.h" #include "hook/table.h" @@ -31,8 +36,6 @@ #include "security/id.h" #include "util/defs.h" -#include "util/log.h" -#include "util/thread.h" static struct options options; @@ -62,11 +65,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param) if (!options.disable_p4ioemu) { log_info("Starting up jubeat IO backend"); - jb_io_set_loggers( - log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal); + core_log_impl_assign(jb_io_set_loggers); - jb_io_ok = - jb_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy); + jb_io_ok = jb_io_init( + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get()); if (!jb_io_ok) { goto fail; @@ -79,11 +83,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param) if (!options.disable_cardemu) { log_info("Starting up 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); - eam_io_ok = - eam_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy); + eam_io_ok = eam_io_init( + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get()); if (!eam_io_ok) { goto fail; @@ -143,8 +148,9 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx) return TRUE; } - log_to_external( - log_body_misc, log_body_info, log_body_warning, log_body_fatal); + // Use AVS APIs + avs_util_core_interop_thread_avs_impl_set(); + avs_util_core_interop_log_avs_impl_set(); options_init_from_cmdline(&options); diff --git a/src/main/jbhook3/gfx.c b/src/main/jbhook3/gfx.c index ee3b5ff..827ac55 100644 --- a/src/main/jbhook3/gfx.c +++ b/src/main/jbhook3/gfx.c @@ -5,12 +5,12 @@ #include #include +#include "core/log.h" + #include "hook/table.h" #include "jbhook3/options.h" -#include "util/log.h" - static bool jbhook3_gfx_windowed; static bool jbhook3_gfx_show_cursor; diff --git a/src/main/jbhook3/options.c b/src/main/jbhook3/options.c index 59ffc1e..8bb544b 100644 --- a/src/main/jbhook3/options.c +++ b/src/main/jbhook3/options.c @@ -6,10 +6,11 @@ #include #include +#include "core/log.h" + #include "util/cmdline.h" #include "util/defs.h" #include "util/hex.h" -#include "util/log.h" #include "util/str.h" void options_init_from_cmdline(struct options *options) diff --git a/src/main/jbio-p4io/Module.mk b/src/main/jbio-p4io/Module.mk index b31604d..ca9895e 100644 --- a/src/main/jbio-p4io/Module.mk +++ b/src/main/jbio-p4io/Module.mk @@ -9,6 +9,7 @@ src_jbio-p4io := \ jbio.c \ libs_jbio-p4io := \ + core \ aciodrv \ aciomgr \ cconfig \ diff --git a/src/main/jbio-p4io/config-h44b.c b/src/main/jbio-p4io/config-h44b.c index 91d37cb..98a5f4f 100644 --- a/src/main/jbio-p4io/config-h44b.c +++ b/src/main/jbio-p4io/config-h44b.c @@ -1,8 +1,8 @@ #include "cconfig/cconfig-util.h" -#include "jbio-p4io/config-h44b.h" +#include "core/log.h" -#include "util/log.h" +#include "jbio-p4io/config-h44b.h" #define JBIO_CONFIG_H44B_PORT_KEY "h44b.port" #define JBIO_CONFIG_H44B_BAUD_KEY "h44b.baud" diff --git a/src/main/jbio-p4io/h44b.c b/src/main/jbio-p4io/h44b.c index 1d9b77a..f26aa2a 100644 --- a/src/main/jbio-p4io/h44b.c +++ b/src/main/jbio-p4io/h44b.c @@ -10,7 +10,7 @@ #include "aciomgr/manager.h" -#include "util/log.h" +#include "core/log.h" static int16_t h44b_node_id; diff --git a/src/main/jbio-p4io/jbio.c b/src/main/jbio-p4io/jbio.c index 202187f..58f4db9 100644 --- a/src/main/jbio-p4io/jbio.c +++ b/src/main/jbio-p4io/jbio.c @@ -7,17 +7,17 @@ #include "aciomgr/manager.h" +#include "bemanitools/jbio.h" + #include "cconfig/cconfig-main.h" -#include "bemanitools/jbio.h" +#include "core/log.h" #include "jbio-p4io/config-h44b.h" #include "jbio-p4io/h44b.h" #include "p4iodrv/device.h" -#include "util/log.h" - static struct p4iodrv_ctx *p4io_ctx; static uint16_t jb_io_panels; static uint8_t jb_io_sys_buttons; @@ -36,7 +36,7 @@ void jb_io_set_loggers( { aciomgr_set_loggers(misc, info, warning, fatal); - log_to_external(misc, info, warning, fatal); + core_log_impl_set(misc, info, warning, fatal); } bool jb_io_init( diff --git a/src/main/jbiotest/Module.mk b/src/main/jbiotest/Module.mk index f2cf618..eba9c0b 100644 --- a/src/main/jbiotest/Module.mk +++ b/src/main/jbiotest/Module.mk @@ -1,6 +1,7 @@ exes += jbiotest \ libs_jbiotest := \ + core \ jbio \ util \ diff --git a/src/main/jbiotest/main.c b/src/main/jbiotest/main.c index 416b325..0a6270b 100644 --- a/src/main/jbiotest/main.c +++ b/src/main/jbiotest/main.c @@ -7,8 +7,12 @@ #include "bemanitools/jbio.h" -#include "util/log.h" -#include "util/thread.h" +#include "core/log-bt-ext.h" +#include "core/log-bt.h" +#include "core/log.h" +#include "core/thread-crt-ext.h" +#include "core/thread-crt.h" +#include "core/thread.h" typedef struct { uint8_t r, g, b; @@ -23,12 +27,17 @@ enum jbio_light_mode { LIGHTS_OFF, LIGHTS_ON, LIGHTS_INPUT }; */ int main(int argc, char **argv) { - log_to_writer(log_writer_stdout, NULL); + core_thread_crt_ext_impl_set(); + core_log_bt_ext_impl_set(); - jb_io_set_loggers( - log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal); + core_log_bt_ext_init_with_stdout(); - if (!jb_io_init(crt_thread_create, crt_thread_join, crt_thread_destroy)) { + core_log_impl_assign(jb_io_set_loggers); + + if (!jb_io_init( + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get())) { printf("Initializing jbio failed\n"); return -1; } diff --git a/src/main/mempatch-hook/Module.mk b/src/main/mempatch-hook/Module.mk index 9785efa..1dedd43 100644 --- a/src/main/mempatch-hook/Module.mk +++ b/src/main/mempatch-hook/Module.mk @@ -2,6 +2,7 @@ dlls += mempatch-hook libs_mempatch-hook := \ util \ + core \ src_mempatch-hook := \ main.c \ diff --git a/src/main/mempatch-hook/main.c b/src/main/mempatch-hook/main.c index 43c1dcd..856b962 100644 --- a/src/main/mempatch-hook/main.c +++ b/src/main/mempatch-hook/main.c @@ -4,10 +4,13 @@ #include #include +#include "core/log-bt-ext.h" +#include "core/log-bt.h" +#include "core/log.h" + #include "util/cmdline.h" #include "util/fs.h" #include "util/hex.h" -#include "util/log.h" static bool patch_memory_check_data( uintptr_t base_address, @@ -283,12 +286,12 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx) int argc; char **argv; char *filepath; - FILE *logfile; bool patched; patched = false; - logfile = fopen("mempatch.log", "w+"); - log_to_writer(log_writer_file, logfile); + + core_log_bt_ext_impl_set(); + core_log_bt_ext_init_with_file("mempatch.log", false, false, 0); args_recover(&argc, &argv); @@ -319,8 +322,7 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx) log_info("Patching done"); } - fflush(logfile); - fclose(logfile); + core_log_bt_fini(); } return TRUE; diff --git a/src/main/mm/mm.c b/src/main/mm/mm.c index db543a6..2c89957 100644 --- a/src/main/mm/mm.c +++ b/src/main/mm/mm.c @@ -9,11 +9,12 @@ #include #include +#include "core/log.h" + #include "mm/mm.h" #include "util/cmdline.h" #include "util/defs.h" -#include "util/log.h" #include "util/mem.h" DEFINE_GUID( diff --git a/src/main/p3io-ddr-tool/Module.mk b/src/main/p3io-ddr-tool/Module.mk index 2c76b42..f6e3a16 100644 --- a/src/main/p3io-ddr-tool/Module.mk +++ b/src/main/p3io-ddr-tool/Module.mk @@ -4,6 +4,7 @@ ldflags_p3io-ddr-tool := \ -lsetupapi \ libs_p3io-ddr-tool := \ + core \ extiodrv \ extio \ p3iodrv \ diff --git a/src/main/p3io-ddr-tool/main.c b/src/main/p3io-ddr-tool/main.c index 939e1e7..4a9bac3 100644 --- a/src/main/p3io-ddr-tool/main.c +++ b/src/main/p3io-ddr-tool/main.c @@ -7,15 +7,17 @@ #include #include +#include "core/log-bt-ext.h" +#include "core/log-bt.h" +#include "core/log-sink-std.h" +#include "core/log.h" + #include "extiodrv/extio.h" #include "p3io/ddr.h" #include "p3iodrv/ddr.h" #include "p3iodrv/device.h" -#include "util/log.h" -#include "util/thread.h" - #include "mode-test.h" enum mode { @@ -70,7 +72,7 @@ static mode_proc _mode_procs[MODE_TOTAL_COUNT] = { _mode_sensores, }; -static enum log_level _log_level = LOG_LEVEL_FATAL; +static enum core_log_bt_log_level _log_level = CORE_LOG_BT_LOG_LEVEL_FATAL; static bool _extio_enabled = true; static const char *_p3io_device_path = ""; static const char *_extio_com_port = "COM1"; @@ -196,11 +198,11 @@ static bool _process_cmd_args(int argc, char **argv) for (int i = 0; i < argc; i++) { if (!strcmp(argv[i], "-v")) { - _log_level = LOG_LEVEL_WARNING; + _log_level = CORE_LOG_BT_LOG_LEVEL_WARNING; } else if (!strcmp(argv[i], "-vv")) { - _log_level = LOG_LEVEL_INFO; + _log_level = CORE_LOG_BT_LOG_LEVEL_INFO; } else if (!strcmp(argv[i], "-vvv")) { - _log_level = LOG_LEVEL_MISC; + _log_level = CORE_LOG_BT_LOG_LEVEL_MISC; } else if (!strcmp(argv[i], "-noextio")) { _extio_enabled = false; } else if (!strcmp(argv[i], "-p3io")) { @@ -256,8 +258,9 @@ static bool _process_cmd_args(int argc, char **argv) static void _init_logging() { - log_to_writer(log_writer_stderr, NULL); - log_set_level(_log_level); + core_log_bt_ext_impl_set(); + core_log_bt_ext_init_with_stderr(); + core_log_bt_level_set(_log_level); } static bool _mode_invalid(HANDLE handle) diff --git a/src/main/p3io-ddr-tool/mode-test.c b/src/main/p3io-ddr-tool/mode-test.c index 791e6d2..0c3f5a9 100644 --- a/src/main/p3io-ddr-tool/mode-test.c +++ b/src/main/p3io-ddr-tool/mode-test.c @@ -3,14 +3,14 @@ #include #include +#include "core/log.h" + #include "extiodrv/extio.h" #include "p3io/ddr.h" #include "p3iodrv/ddr.h" #include "p3iodrv/device.h" -#include "util/log.h" - #include "mode-test.h" struct mode_test_output_state { diff --git a/src/main/p3io/cmd.c b/src/main/p3io/cmd.c index 78c8b02..b62958f 100644 --- a/src/main/p3io/cmd.c +++ b/src/main/p3io/cmd.c @@ -1,8 +1,8 @@ #include -#include "p3io/cmd.h" +#include "core/log.h" -#include "util/log.h" +#include "p3io/cmd.h" uint8_t p3io_get_full_req_size(const union p3io_req_any *req) { diff --git a/src/main/p3io/frame.c b/src/main/p3io/frame.c index bc50dd4..1fc6d2c 100644 --- a/src/main/p3io/frame.c +++ b/src/main/p3io/frame.c @@ -3,10 +3,11 @@ #include #include +#include "core/log.h" + #include "p3io/frame.h" #include "util/iobuf.h" -#include "util/log.h" #define P3IO_FRAME_SOF 0xAA #define P3IO_FRAME_ESCAPE 0xFF diff --git a/src/main/p3iodrv/ddr.c b/src/main/p3iodrv/ddr.c index 2cc4526..57ebfab 100644 --- a/src/main/p3iodrv/ddr.c +++ b/src/main/p3iodrv/ddr.c @@ -2,7 +2,7 @@ #include "p3io/cmd.h" -#include "util/log.h" +#include "core/log.h" #include "ddr.h" #include "device.h" diff --git a/src/main/p3iodrv/device.c b/src/main/p3iodrv/device.c index dbbb04a..afa2c51 100644 --- a/src/main/p3iodrv/device.c +++ b/src/main/p3iodrv/device.c @@ -10,13 +10,14 @@ #include // clang-format on +#include "core/log.h" + #include "p3io/cmd.h" #include "p3io/guid.h" #include "p3io/ioctl.h" #include "p3iodrv/device.h" -#include "util/log.h" #include "util/str.h" #define P3IO_DEVICE_FILENMAME "\\p3io" diff --git a/src/main/p3ioemu/devmgr.c b/src/main/p3ioemu/devmgr.c index fc729b3..ac26233 100644 --- a/src/main/p3ioemu/devmgr.c +++ b/src/main/p3ioemu/devmgr.c @@ -7,6 +7,8 @@ #include #include +#include "core/log.h" + #include "hook/table.h" #include "p3io/guid.h" @@ -14,7 +16,6 @@ #include "p3ioemu/devmgr.h" #include "util/defs.h" -#include "util/log.h" #include "util/str.h" /* Link pointers */ diff --git a/src/main/p3ioemu/emu.c b/src/main/p3ioemu/emu.c index 6486d59..7fc2123 100644 --- a/src/main/p3ioemu/emu.c +++ b/src/main/p3ioemu/emu.c @@ -7,6 +7,8 @@ #include #include +#include "core/log.h" + #include "hook/iohook.h" #include "p3io/cmd.h" @@ -18,7 +20,6 @@ #include "p3ioemu/uart.h" #include "util/iobuf.h" -#include "util/log.h" static HANDLE p3io_emu_fd; static uint8_t p3io_emu_resp_bytes[256]; diff --git a/src/main/p3ioemu/uart.c b/src/main/p3ioemu/uart.c index a4a9f73..cbceb5a 100644 --- a/src/main/p3ioemu/uart.c +++ b/src/main/p3ioemu/uart.c @@ -10,6 +10,8 @@ #include +#include "core/log.h" + #include "hook/iohook.h" #include "p3io/cmd.h" @@ -17,7 +19,6 @@ #include "p3ioemu/uart.h" #include "util/iobuf.h" -#include "util/log.h" static HRESULT p3io_uart_open(const wchar_t *path, uint32_t baud_rate, HANDLE *fd); diff --git a/src/main/p4iodrv/device.c b/src/main/p4iodrv/device.c index 67dd56e..da65f7b 100644 --- a/src/main/p4iodrv/device.c +++ b/src/main/p4iodrv/device.c @@ -2,12 +2,13 @@ #include +#include "core/log.h" + #include "p4io/cmd.h" #include "p4iodrv/device.h" #include "p4iodrv/usb.h" -#include "util/log.h" #include "util/mem.h" struct p4iodrv_ctx { diff --git a/src/main/p4iodrv/usb.c b/src/main/p4iodrv/usb.c index 8c99fc4..243adae 100644 --- a/src/main/p4iodrv/usb.c +++ b/src/main/p4iodrv/usb.c @@ -10,13 +10,14 @@ #include // clang-format on +#include "core/log.h" + #include "p4io/cmd.h" #include "p4io/guid.h" #include "p4io/ioctl.h" #include "p4iodrv/usb.h" -#include "util/log.h" #include "util/str.h" HANDLE p4io_usb_open(void) diff --git a/src/main/p4ioemu/device.c b/src/main/p4ioemu/device.c index e18e891..4e7498f 100644 --- a/src/main/p4ioemu/device.c +++ b/src/main/p4ioemu/device.c @@ -6,11 +6,12 @@ #include #include +#include "core/log.h" + #include "hook/iohook.h" #include "p4io/cmd.h" #include "p4io/ioctl.h" #include "util/hex.h" -#include "util/log.h" #include "util/str.h" // #define P4IOEMU_DEBUG_DUMP diff --git a/src/main/pcbidgen/Module.mk b/src/main/pcbidgen/Module.mk index 852a4d0..612510f 100644 --- a/src/main/pcbidgen/Module.mk +++ b/src/main/pcbidgen/Module.mk @@ -3,6 +3,7 @@ exes += pcbidgen libs_pcbidgen := \ security \ util \ + core \ src_pcbidgen := \ main.c \ diff --git a/src/main/popnhook-util/acio.c b/src/main/popnhook-util/acio.c index 60d66b8..465bdcd 100644 --- a/src/main/popnhook-util/acio.c +++ b/src/main/popnhook-util/acio.c @@ -15,6 +15,8 @@ #include "acioemu/emu.h" #include "acioemu/icca.h" +#include "core/log.h" + #include "hook/iohook.h" #include "hooklib/rs232.h" @@ -24,7 +26,6 @@ #include "util/defs.h" #include "util/iobuf.h" -#include "util/log.h" #include "util/str.h" static struct ac_io_emu popnhook_acio_emu; diff --git a/src/main/popnhook-util/mixer.c b/src/main/popnhook-util/mixer.c index 91d3c75..904a008 100644 --- a/src/main/popnhook-util/mixer.c +++ b/src/main/popnhook-util/mixer.c @@ -6,10 +6,11 @@ #include // clang-format on +#include "core/log.h" + #include "hook/table.h" #include "util/defs.h" -#include "util/log.h" MMRESULT STDCALL hook_mixerGetLineControlsA( HMIXEROBJ hmxobj, LPMIXERLINECONTROLSA pmxlc, DWORD fdwControls); diff --git a/src/main/popnhook1/Module.mk b/src/main/popnhook1/Module.mk index c2c1510..f744773 100644 --- a/src/main/popnhook1/Module.mk +++ b/src/main/popnhook1/Module.mk @@ -8,6 +8,7 @@ ldflags_popnhook1 := \ -liphlpapi \ libs_popnhook1 := \ + core \ iidxhook-util \ ezusb-emu \ ezusb2-popn-emu \ diff --git a/src/main/popnhook1/avs-boot.c b/src/main/popnhook1/avs-boot.c index f9833a7..aae4616 100644 --- a/src/main/popnhook1/avs-boot.c +++ b/src/main/popnhook1/avs-boot.c @@ -5,14 +5,14 @@ #include #include +#include "core/log.h" + #include "hook/table.h" #include "imports/avs.h" #include "popnhook1/avs-boot.h" -#include "util/log.h" - static int (*real_ea3_boot_avs)(struct property_node *config); static int (*real_ea3_boot)(struct property_node *config); diff --git a/src/main/popnhook1/config-eamuse.c b/src/main/popnhook1/config-eamuse.c index 98e406b..14864ba 100644 --- a/src/main/popnhook1/config-eamuse.c +++ b/src/main/popnhook1/config-eamuse.c @@ -2,12 +2,12 @@ #include "cconfig/cconfig-util.h" +#include "core/log.h" + #include "popnhook1/config-eamuse.h" #include "security/mcode.h" -#include "util/log.h" - #define POPNHOOK1_CONFIG_EAMUSE_SERVER_KEY "eamuse.server" #define POPNHOOK1_CONFIG_EAMUSE_PCBID_KEY "eamuse.pcbid" #define POPNHOOK1_CONFIG_EAMUSE_EAMID_KEY "eamuse.eamid" diff --git a/src/main/popnhook1/config-gfx.c b/src/main/popnhook1/config-gfx.c index 8e231d1..8bc6b10 100644 --- a/src/main/popnhook1/config-gfx.c +++ b/src/main/popnhook1/config-gfx.c @@ -2,9 +2,9 @@ #include "cconfig/cconfig-util.h" -#include "popnhook1/config-gfx.h" +#include "core/log.h" -#include "util/log.h" +#include "popnhook1/config-gfx.h" #define POPNHOOK1_CONFIG_GFX_WINDOWED_KEY "gfx.windowed" #define POPNHOOK1_CONFIG_GFX_FRAMED_KEY "gfx.framed" diff --git a/src/main/popnhook1/config-sec.c b/src/main/popnhook1/config-sec.c index f155520..99342b2 100644 --- a/src/main/popnhook1/config-sec.c +++ b/src/main/popnhook1/config-sec.c @@ -3,12 +3,13 @@ #include "cconfig/cconfig-util.h" +#include "core/log.h" + #include "popnhook1/config-sec.h" #include "security/mcode.h" #include "security/rp.h" -#include "util/log.h" #include "util/mem.h" #define POPNHOOK1_CONFIG_SEC_BLACK_PLUG_MCODE_KEY "sec.black_plug_mcode" diff --git a/src/main/popnhook1/d3d9.c b/src/main/popnhook1/d3d9.c index 1d67262..44f9e1c 100644 --- a/src/main/popnhook1/d3d9.c +++ b/src/main/popnhook1/d3d9.c @@ -5,6 +5,8 @@ #include +#include "core/log.h" + #include "hook/com-proxy.h" #include "hook/pe.h" #include "hook/table.h" @@ -12,7 +14,6 @@ #include "popnhook1/d3d9.h" #include "util/defs.h" -#include "util/log.h" #include "hook/d3d9.h" diff --git a/src/main/popnhook1/dllmain.c b/src/main/popnhook1/dllmain.c index 5995e22..36c232f 100644 --- a/src/main/popnhook1/dllmain.c +++ b/src/main/popnhook1/dllmain.c @@ -10,6 +10,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 "hook/d3d9.h" @@ -29,8 +37,6 @@ #include "util/cmdline.h" #include "util/defs.h" -#include "util/log.h" -#include "util/thread.h" #include "ezusb2-emu/desc.h" #include "ezusb2-emu/device.h" @@ -62,6 +68,14 @@ static const struct hook_symbol init_hook_syms[] = { }, }; +static void _popnhook1_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 popnhook_setup_d3d9_hooks( const struct popnhook1_config_gfx *config_gfx, const bool texture_usage_fix) { @@ -145,20 +159,24 @@ static DWORD STDCALL my_GetStartupInfoA(LPSTARTUPINFOA lpStartupInfo) /* Start up POPNIO.DLL */ log_info("Starting pop'n IO backend"); - popn_io_set_loggers( - log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal); + core_log_impl_assign(popn_io_set_loggers); - if (!popn_io_init(thread_create, thread_join, thread_destroy)) { + if (!popn_io_init( + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get())) { log_fatal("Initializing pop'n 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"); } @@ -190,7 +208,9 @@ BOOL WINAPI DllMain(HMODULE self, DWORD reason, void *ctx) return TRUE; } - log_to_writer(log_writer_debug, NULL); + core_thread_crt_ext_impl_set(); + + _popnhook1_log_init(); hook_table_apply( NULL, "kernel32.dll", init_hook_syms, lengthof(init_hook_syms)); diff --git a/src/main/popnhook1/filesystem.c b/src/main/popnhook1/filesystem.c index 3d7fd09..d558486 100644 --- a/src/main/popnhook1/filesystem.c +++ b/src/main/popnhook1/filesystem.c @@ -7,10 +7,11 @@ #include #include +#include "core/log.h" + #include "hook/table.h" #include "util/defs.h" -#include "util/log.h" #include "util/mem.h" #include "util/str.h" diff --git a/src/main/sdvxhook/Module.mk b/src/main/sdvxhook/Module.mk index c1a8c5b..cc6d31c 100644 --- a/src/main/sdvxhook/Module.mk +++ b/src/main/sdvxhook/Module.mk @@ -4,6 +4,8 @@ deplibs_sdvxhook := \ avs \ libs_sdvxhook := \ + avs-util \ + core \ acioemu \ hook \ hooklib \ diff --git a/src/main/sdvxhook/acio.c b/src/main/sdvxhook/acio.c index 6596ee4..e8d7dfd 100644 --- a/src/main/sdvxhook/acio.c +++ b/src/main/sdvxhook/acio.c @@ -15,6 +15,8 @@ #include "acioemu/emu.h" #include "acioemu/icca.h" +#include "core/log.h" + #include "hook/iohook.h" #include "imports/avs.h" @@ -24,7 +26,6 @@ #include "util/defs.h" #include "util/iobuf.h" -#include "util/log.h" #include "util/str.h" static struct ac_io_emu ac_io_emu; diff --git a/src/main/sdvxhook/dllmain.c b/src/main/sdvxhook/dllmain.c index 391f4c9..50e2063 100644 --- a/src/main/sdvxhook/dllmain.c +++ b/src/main/sdvxhook/dllmain.c @@ -3,9 +3,14 @@ #include #include +#include "avs-util/core-interop.h" + #include "bemanitools/eamio.h" #include "bemanitools/sdvxio.h" +#include "core/log.h" +#include "core/thread.h" + #include "hook/iohook.h" #include "hooklib/app.h" @@ -17,7 +22,6 @@ #include "util/cmdline.h" #include "util/defs.h" -#include "util/log.h" static bool my_dll_entry_init(char *sidcode, struct property_node *config); static bool my_dll_entry_main(void); @@ -32,10 +36,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *config) log_info("Starting up SDVX IO backend"); - sdvx_io_set_loggers( - log_body_misc, log_body_info, log_body_warning, log_body_fatal); + core_log_impl_assign(sdvx_io_set_loggers); - ok = sdvx_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy); + ok = sdvx_io_init( + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get()); if (!ok) { goto sdvx_io_fail; @@ -43,10 +49,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *config) log_info("Starting up card reader backend"); - eam_io_set_loggers( - log_body_misc, log_body_info, log_body_warning, log_body_fatal); + core_log_impl_assign(eam_io_set_loggers); - ok = eam_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy); + ok = eam_io_init( + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get()); /* Set up IO emulation hooks _after_ IO API setup to allow API implementations with real IO devices */ @@ -100,8 +108,9 @@ BOOL WINAPI DllMain(HMODULE self, DWORD reason, void *ctx) return TRUE; } - log_to_external( - log_body_misc, log_body_info, log_body_warning, log_body_fatal); + // Use AVS APIs + avs_util_core_interop_thread_avs_impl_set(); + avs_util_core_interop_log_avs_impl_set(); args_recover(&argc, &argv); diff --git a/src/main/sdvxhook/gfx.c b/src/main/sdvxhook/gfx.c index 16cf733..2d36759 100644 --- a/src/main/sdvxhook/gfx.c +++ b/src/main/sdvxhook/gfx.c @@ -3,6 +3,8 @@ #include +#include "core/log.h" + #include "hook/com-proxy.h" #include "hook/pe.h" #include "hook/table.h" @@ -10,7 +12,6 @@ #include "sdvxhook/gfx.h" #include "util/defs.h" -#include "util/log.h" static LRESULT CALLBACK my_WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); diff --git a/src/main/sdvxhook/kfca.c b/src/main/sdvxhook/kfca.c index 5c89686..82ac111 100644 --- a/src/main/sdvxhook/kfca.c +++ b/src/main/sdvxhook/kfca.c @@ -9,8 +9,9 @@ #include "bemanitools/sdvxio.h" +#include "core/log.h" + #include "util/defs.h" -#include "util/log.h" #include "util/time.h" static void kfca_send_version(const struct ac_io_message *req); diff --git a/src/main/sdvxhook/lcd.c b/src/main/sdvxhook/lcd.c index 06ea1e6..6d942bb 100644 --- a/src/main/sdvxhook/lcd.c +++ b/src/main/sdvxhook/lcd.c @@ -12,13 +12,14 @@ #include #include +#include "core/log.h" + #include "hook/iohook.h" #include "sdvxhook/lcd.h" #include "util/hex.h" #include "util/iobuf.h" -#include "util/log.h" #include "util/str.h" static HRESULT lcd_open(struct irp *irp); diff --git a/src/main/sdvxhook2-cn/Module.mk b/src/main/sdvxhook2-cn/Module.mk index fd00fc6..2bb715e 100644 --- a/src/main/sdvxhook2-cn/Module.mk +++ b/src/main/sdvxhook2-cn/Module.mk @@ -12,6 +12,8 @@ deplibs_sdvxhook2-cn := \ avs \ libs_sdvxhook2-cn := \ + avs-util \ + core \ acioemu \ camhook \ d3d9exhook \ diff --git a/src/main/sdvxhook2-cn/acio.c b/src/main/sdvxhook2-cn/acio.c index f7116e2..4507333 100644 --- a/src/main/sdvxhook2-cn/acio.c +++ b/src/main/sdvxhook2-cn/acio.c @@ -14,6 +14,8 @@ #include "acioemu/addr.h" #include "acioemu/emu.h" +#include "core/log.h" + #include "hook/iohook.h" #include "hooklib/rs232.h" @@ -24,7 +26,6 @@ #include "util/defs.h" #include "util/iobuf.h" -#include "util/log.h" #include "util/str.h" static struct ac_io_emu ac_io_emu; diff --git a/src/main/sdvxhook2-cn/config-cn.c b/src/main/sdvxhook2-cn/config-cn.c index c492603..650b528 100644 --- a/src/main/sdvxhook2-cn/config-cn.c +++ b/src/main/sdvxhook2-cn/config-cn.c @@ -1,8 +1,8 @@ #include "cconfig/cconfig-util.h" -#include "sdvxhook2-cn/config-cn.h" +#include "core/log.h" -#include "util/log.h" +#include "sdvxhook2-cn/config-cn.h" #define SDVXHOOK2_CN_CONFIG_DISABLE_IO_EMU_KEY "io.disable_io_emu" #define SDVXHOOK2_CN_CONFIG_UNIS_PATH_KEY "cn.unis_path" diff --git a/src/main/sdvxhook2-cn/dllmain.c b/src/main/sdvxhook2-cn/dllmain.c index 3a20217..07d2de0 100644 --- a/src/main/sdvxhook2-cn/dllmain.c +++ b/src/main/sdvxhook2-cn/dllmain.c @@ -5,11 +5,16 @@ #include #include +#include "avs-util/core-interop.h" + #include "bemanitools/eamio.h" #include "bemanitools/sdvxio.h" #include "cconfig/cconfig-hook.h" +#include "core/log.h" +#include "core/thread.h" + #include "hooklib/acp.h" #include "hooklib/adapter.h" #include "hooklib/app.h" @@ -27,9 +32,7 @@ #include "imports/avs.h" -#include "util/log.h" #include "util/str.h" -#include "util/thread.h" #define SDVXHOOK2_CN_INFO_HEADER \ "sdvxhook for VW CN" \ @@ -75,11 +78,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param) /* Start up sdvxio.DLL */ if (!config_cn.disable_io_emu) { log_info("Starting sdvx IO backend"); - sdvx_io_set_loggers( - log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal); + core_log_impl_assign(sdvx_io_set_loggers); if (!sdvx_io_init( - avs_thread_create, avs_thread_join, avs_thread_destroy)) { + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get())) { log_fatal("Initializing sdvx IO backend failed"); } } @@ -134,8 +138,9 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx) goto end; } - log_to_external( - log_body_misc, log_body_info, log_body_warning, log_body_fatal); + // Use AVS APIs + avs_util_core_interop_thread_avs_impl_set(); + avs_util_core_interop_log_avs_impl_set(); app_hook_init(my_dll_entry_init, my_dll_entry_main); diff --git a/src/main/sdvxhook2-cn/kfca.c b/src/main/sdvxhook2-cn/kfca.c index f4d8894..02c7297 100644 --- a/src/main/sdvxhook2-cn/kfca.c +++ b/src/main/sdvxhook2-cn/kfca.c @@ -9,8 +9,9 @@ #include "bemanitools/sdvxio.h" +#include "core/log.h" + #include "util/defs.h" -#include "util/log.h" #include "util/time.h" static void kfca_send_version(const struct ac_io_message *req); diff --git a/src/main/sdvxhook2-cn/unis-version.c b/src/main/sdvxhook2-cn/unis-version.c index d660999..3ed7e38 100644 --- a/src/main/sdvxhook2-cn/unis-version.c +++ b/src/main/sdvxhook2-cn/unis-version.c @@ -8,11 +8,12 @@ #include +#include "core/log.h" + #include "hook/com-proxy.h" #include "hook/table.h" #include "util/defs.h" -#include "util/log.h" #include "util/str.h" #include "util/time.h" diff --git a/src/main/sdvxhook2/Module.mk b/src/main/sdvxhook2/Module.mk index aa38c66..f813557 100644 --- a/src/main/sdvxhook2/Module.mk +++ b/src/main/sdvxhook2/Module.mk @@ -12,6 +12,8 @@ deplibs_sdvxhook2 := \ avs \ libs_sdvxhook2 := \ + avs-util \ + core \ acioemu \ bio2emu \ camhook \ diff --git a/src/main/sdvxhook2/acio.c b/src/main/sdvxhook2/acio.c index 6ac0cdc..8db25df 100644 --- a/src/main/sdvxhook2/acio.c +++ b/src/main/sdvxhook2/acio.c @@ -15,6 +15,8 @@ #include "acioemu/emu.h" #include "acioemu/icca.h" +#include "core/log.h" + #include "hook/iohook.h" #include "hooklib/rs232.h" @@ -24,7 +26,6 @@ #include "util/defs.h" #include "util/iobuf.h" -#include "util/log.h" #include "util/str.h" static struct ac_io_emu ac_io_emu; diff --git a/src/main/sdvxhook2/config-io.c b/src/main/sdvxhook2/config-io.c index 6d87bc0..421f3af 100644 --- a/src/main/sdvxhook2/config-io.c +++ b/src/main/sdvxhook2/config-io.c @@ -1,8 +1,8 @@ #include "cconfig/cconfig-util.h" -#include "sdvxhook2/config-io.h" +#include "core/log.h" -#include "util/log.h" +#include "sdvxhook2/config-io.h" #define SDVXHOOK2_CONFIG_IO_DISABLE_CARD_READER_EMU_KEY \ "io.disable_card_reader_emu" diff --git a/src/main/sdvxhook2/dllmain.c b/src/main/sdvxhook2/dllmain.c index e601e3a..3c74ab4 100644 --- a/src/main/sdvxhook2/dllmain.c +++ b/src/main/sdvxhook2/dllmain.c @@ -5,11 +5,16 @@ #include #include +#include "avs-util/core-interop.h" + #include "bemanitools/eamio.h" #include "bemanitools/sdvxio.h" #include "cconfig/cconfig-hook.h" +#include "core/log.h" +#include "core/thread.h" + #include "hooklib/acp.h" #include "hooklib/adapter.h" #include "hooklib/app.h" @@ -33,9 +38,7 @@ #include "imports/avs.h" -#include "util/log.h" #include "util/str.h" -#include "util/thread.h" #define SDVXHOOK2_INFO_HEADER \ "sdvxhook for VW" \ @@ -105,11 +108,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param) /* Start up sdvxio.DLL */ if (!config_io.disable_bio2_emu) { log_info("Starting sdvx IO backend"); - sdvx_io_set_loggers( - log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal); + core_log_impl_assign(sdvx_io_set_loggers); if (!sdvx_io_init( - avs_thread_create, avs_thread_join, avs_thread_destroy)) { + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get())) { log_fatal("Initializing sdvx IO backend failed"); } } @@ -117,11 +121,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param) /* Start up EAMIO.DLL */ if (!config_io.disable_card_reader_emu) { 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( - avs_thread_create, avs_thread_join, avs_thread_destroy)) { + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get())) { log_fatal("Initializing card reader backend failed"); } } @@ -207,8 +212,9 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx) goto end; } - log_to_external( - log_body_misc, log_body_info, log_body_warning, log_body_fatal); + // Use AVS APIs + avs_util_core_interop_thread_avs_impl_set(); + avs_util_core_interop_log_avs_impl_set(); app_hook_init(my_dll_entry_init, my_dll_entry_main); diff --git a/src/main/sdvxhook2/nvapi.c b/src/main/sdvxhook2/nvapi.c index fbe14d8..e5f244a 100644 --- a/src/main/sdvxhook2/nvapi.c +++ b/src/main/sdvxhook2/nvapi.c @@ -10,13 +10,13 @@ #include +#include "core/log.h" + #include "hook/com-proxy.h" #include "hook/table.h" #include "sdvxhook2/nvapi.h" -#include "util/log.h" - static void *my_GetProcAddress(HMODULE dll, const char *name); static void *(*real_GetProcAddress)(HMODULE dll, const char *name); diff --git a/src/main/sdvxhook2/power.c b/src/main/sdvxhook2/power.c index f860c1b..e6d0d33 100644 --- a/src/main/sdvxhook2/power.c +++ b/src/main/sdvxhook2/power.c @@ -10,13 +10,13 @@ #include +#include "core/log.h" + #include "hook/com-proxy.h" #include "hook/table.h" #include "sdvxhook2/power.h" -#include "util/log.h" - static DWORD my_PowerSetActiveScheme(HKEY UserRootPowerKey, const GUID *SchemeGuid); static DWORD my_PowerWriteACValueIndex( diff --git a/src/main/sdvxio-bio2/Module.mk b/src/main/sdvxio-bio2/Module.mk index bf16a3b..04ea0fd 100644 --- a/src/main/sdvxio-bio2/Module.mk +++ b/src/main/sdvxio-bio2/Module.mk @@ -4,6 +4,7 @@ ldflags_sdvxio-bio2 := \ -lsetupapi \ libs_sdvxio-bio2 := \ + core \ aciodrv \ bio2drv \ cconfig \ diff --git a/src/main/sdvxio-kfca/Module.mk b/src/main/sdvxio-kfca/Module.mk index cb10b22..5127c16 100644 --- a/src/main/sdvxio-kfca/Module.mk +++ b/src/main/sdvxio-kfca/Module.mk @@ -1,6 +1,7 @@ dlls += sdvxio-kfca libs_sdvxio-kfca := \ + core \ geninput \ aciodrv \ aciomgr \ diff --git a/src/main/sdvxio-kfca/config-kfca.c b/src/main/sdvxio-kfca/config-kfca.c index 91814e6..6b95e24 100644 --- a/src/main/sdvxio-kfca/config-kfca.c +++ b/src/main/sdvxio-kfca/config-kfca.c @@ -1,8 +1,8 @@ #include "cconfig/cconfig-util.h" -#include "sdvxio-kfca/config-kfca.h" +#include "core/log.h" -#include "util/log.h" +#include "sdvxio-kfca/config-kfca.h" #define SDVXIO_KFCA_CONFIG_KFCA_PORT_KEY "kfca.port" #define SDVXIO_KFCA_CONFIG_KFCA_BAUD_KEY "kfca.baud" diff --git a/src/main/security/id.c b/src/main/security/id.c index b591fb2..93699aa 100644 --- a/src/main/security/id.c +++ b/src/main/security/id.c @@ -1,9 +1,10 @@ #include +#include "core/log.h" + #include "security/id.h" #include "util/hex.h" -#include "util/log.h" #include "util/mem.h" const struct security_id security_id_default = { diff --git a/src/main/security/mcode.c b/src/main/security/mcode.c index 5bc93fa..8817647 100644 --- a/src/main/security/mcode.c +++ b/src/main/security/mcode.c @@ -1,8 +1,9 @@ #include +#include "core/log.h" + #include "security/mcode.h" -#include "util/log.h" #include "util/mem.h" const struct security_mcode security_mcode_eamuse = { diff --git a/src/main/security/rp-blowfish.c b/src/main/security/rp-blowfish.c index 9aeb696..f45a0a9 100644 --- a/src/main/security/rp-blowfish.c +++ b/src/main/security/rp-blowfish.c @@ -1,10 +1,10 @@ #include +#include "core/log.h" + #include "security/rp-blowfish-table.h" #include "security/rp-blowfish.h" -#include "util/log.h" - static int security_rp_blowfish_enc_sub(int a1) { int result; // eax@1 diff --git a/src/main/security/rp.c b/src/main/security/rp.c index ba82864..5e80670 100644 --- a/src/main/security/rp.c +++ b/src/main/security/rp.c @@ -1,3 +1,5 @@ +#include "core/log.h" + #include "security/rp.h" #include "security/rp-blowfish.h" @@ -5,7 +7,6 @@ #include "security/util.h" #include "util/crypto.h" -#include "util/log.h" static uint32_t security_rp_get_len_mcode(const struct security_mcode *mcode) { diff --git a/src/main/security/rp2.c b/src/main/security/rp2.c index 51480a6..92b3acb 100644 --- a/src/main/security/rp2.c +++ b/src/main/security/rp2.c @@ -1,11 +1,12 @@ #include +#include "core/log.h" + #include "security/rp-util.h" #include "security/rp2.h" #include "security/util.h" #include "util/crypto.h" -#include "util/log.h" static uint8_t security_rp2_signature_scramble_table[16] = { 0x0C, diff --git a/src/main/security/rp3.c b/src/main/security/rp3.c index a6dd5bf..6e83f68 100644 --- a/src/main/security/rp3.c +++ b/src/main/security/rp3.c @@ -1,12 +1,13 @@ #include +#include "core/log.h" + #include "security/rp-util.h" #include "security/rp2.h" #include "security/rp3.h" #include "security/util.h" #include "util/crc.h" -#include "util/log.h" void security_rp3_generate_signed_eeprom_data( enum security_rp_util_rp_type type, diff --git a/src/main/unicorntail/Module.mk b/src/main/unicorntail/Module.mk index bd6d360..d2d96be 100644 --- a/src/main/unicorntail/Module.mk +++ b/src/main/unicorntail/Module.mk @@ -4,6 +4,7 @@ deplibs_unicorntail := \ avs \ libs_unicorntail := \ + core \ p3io \ p3ioemu \ hook \ diff --git a/src/main/unicorntail/dllmain.c b/src/main/unicorntail/dllmain.c index 59f862d..b195edf 100644 --- a/src/main/unicorntail/dllmain.c +++ b/src/main/unicorntail/dllmain.c @@ -2,6 +2,8 @@ #include +#include "core/log.h" + #include "hook/iohook.h" #include "hooklib/app.h" @@ -12,7 +14,6 @@ #include "unicorntail/usbmem.h" #include "util/defs.h" -#include "util/log.h" static bool my_dll_entry_init(char *sidcode, struct property_node *param); static bool my_dll_entry_main(void); @@ -50,7 +51,7 @@ BOOL WINAPI DllMain(HMODULE self, DWORD reason, void *ctx) goto end; } - log_to_external( + core_log_impl_set( log_body_misc, log_body_info, log_body_warning, log_body_fatal); app_hook_init(my_dll_entry_init, my_dll_entry_main); diff --git a/src/main/unicorntail/p3io.c b/src/main/unicorntail/p3io.c index fd0a85c..b4a49b1 100644 --- a/src/main/unicorntail/p3io.c +++ b/src/main/unicorntail/p3io.c @@ -3,6 +3,8 @@ #include #include +#include "core/log.h" + #include "p3io/cmd.h" #include "p3io/frame.h" @@ -11,7 +13,6 @@ #include "unicorntail/p3io.h" #include "util/array.h" -#include "util/log.h" #include "util/str.h" static bool p3io_match_irp_locked(const struct irp *irp); diff --git a/src/main/unicorntail/usbmem.c b/src/main/unicorntail/usbmem.c index 50b496e..ef82069 100644 --- a/src/main/unicorntail/usbmem.c +++ b/src/main/unicorntail/usbmem.c @@ -3,9 +3,10 @@ #include #include +#include "core/log.h" + #include "hook/iohook.h" -#include "util/log.h" #include "util/str.h" static bool usbmem_match_irp(const struct irp *irp); diff --git a/src/main/util/array.c b/src/main/util/array.c index 900fba1..9421fff 100644 --- a/src/main/util/array.c +++ b/src/main/util/array.c @@ -2,8 +2,9 @@ #include #include +#include "core/log.h" + #include "util/array.h" -#include "util/log.h" #include "util/mem.h" void array_init(struct array *array) diff --git a/src/main/util/crc.c b/src/main/util/crc.c index c49af45..7ab06b8 100644 --- a/src/main/util/crc.c +++ b/src/main/util/crc.c @@ -1,7 +1,7 @@ #include #include -#include "util/log.h" +#include "core/log.h" uint8_t crc8(const void *ptr, size_t nbytes, uint8_t in) { diff --git a/src/main/util/crypto.c b/src/main/util/crypto.c index 110dd99..db1702e 100644 --- a/src/main/util/crypto.c +++ b/src/main/util/crypto.c @@ -1,12 +1,13 @@ #define LOG_MODULE "crypto" -#include "util/crypto.h" -#include "util/log.h" -#include "util/mem.h" - #include #include +#include "core/log.h" + +#include "util/crypto.h" +#include "util/mem.h" + static const char vista_prov[] = "Microsoft Enhanced RSA and AES Cryptographic Provider"; static const char winxp_prov[] = diff --git a/src/main/util/fs.c b/src/main/util/fs.c index 731fdf9..8c4c7c6 100644 --- a/src/main/util/fs.c +++ b/src/main/util/fs.c @@ -6,9 +6,10 @@ #include #include +#include "core/log.h" + #include "util/defs.h" #include "util/fs.h" -#include "util/log.h" #include "util/mem.h" #include "util/str.h" diff --git a/src/main/util/hex.c b/src/main/util/hex.c index 1ac6b4d..de08286 100644 --- a/src/main/util/hex.c +++ b/src/main/util/hex.c @@ -2,8 +2,9 @@ #include #include +#include "core/log.h" + #include "util/hex.h" -#include "util/log.h" static bool hex_decode_nibble(char c, uint8_t *nibble) { diff --git a/src/main/util/iobuf.c b/src/main/util/iobuf.c index 45884ea..7638cb5 100644 --- a/src/main/util/iobuf.c +++ b/src/main/util/iobuf.c @@ -1,8 +1,9 @@ #define LOG_MODULE "util-iobuf" -#include "util/iobuf.h" +#include "core/log.h" + #include "util/hex.h" -#include "util/log.h" +#include "util/iobuf.h" #include "util/mem.h" void iobuf_log(struct iobuf *buffer, const char *tag) diff --git a/src/main/util/mem.c b/src/main/util/mem.c index 53e84ff..f03ebaf 100644 --- a/src/main/util/mem.c +++ b/src/main/util/mem.c @@ -7,7 +7,7 @@ #include #include -#include "util/log.h" +#include "core/log.h" void *xcalloc(size_t nbytes) { diff --git a/src/main/util/msg-thread.c b/src/main/util/msg-thread.c index 6b5623d..04d498d 100644 --- a/src/main/util/msg-thread.c +++ b/src/main/util/msg-thread.c @@ -5,9 +5,10 @@ #include #include -#include "util/log.h" +#include "core/log.h" +#include "core/thread.h" + #include "util/msg-thread.h" -#include "util/thread.h" static bool msg_thread_step(HWND hwnd); @@ -102,7 +103,7 @@ void msg_thread_init(HINSTANCE inst) { msg_thread_ready = CreateEvent(NULL, TRUE, FALSE, NULL); msg_thread_stop = CreateEvent(NULL, TRUE, FALSE, NULL); - msg_thread_id = thread_create(msg_thread_proc, inst, 0x4000, 0); + msg_thread_id = core_thread_create(msg_thread_proc, inst, 0x4000, 0); WaitForSingleObject(msg_thread_ready, INFINITE); CloseHandle(msg_thread_ready); @@ -112,8 +113,8 @@ void msg_thread_fini(void) { SetEvent(msg_thread_stop); - thread_join(msg_thread_id, NULL); - thread_destroy(msg_thread_id); + core_thread_join(msg_thread_id, NULL); + core_thread_destroy(msg_thread_id); CloseHandle(msg_thread_stop); } diff --git a/src/main/util/net.c b/src/main/util/net.c index 492e3ef..d2c9d7d 100644 --- a/src/main/util/net.c +++ b/src/main/util/net.c @@ -6,7 +6,8 @@ #include #include -#include "util/log.h" +#include "core/log.h" + #include "util/mem.h" #include "util/net.h" #include "util/str.h" diff --git a/src/main/util/os.c b/src/main/util/os.c index c63de00..e6aad5d 100644 --- a/src/main/util/os.c +++ b/src/main/util/os.c @@ -6,7 +6,8 @@ #include -#include "util/log.h" +#include "core/log.h" + #include "util/os.h" #include "util/str.h" diff --git a/src/main/util/proc.c b/src/main/util/proc.c index 8473113..f1905d3 100644 --- a/src/main/util/proc.c +++ b/src/main/util/proc.c @@ -6,7 +6,7 @@ #include #include -#include "util/log.h" +#include "core/log.h" bool proc_is_running_as_admin_user() { diff --git a/src/main/util/signal.c b/src/main/util/signal.c index 4c15acd..9851c92 100644 --- a/src/main/util/signal.c +++ b/src/main/util/signal.c @@ -1,8 +1,9 @@ #include #include +#include "core/log.h" + #include "util/hex.h" -#include "util/log.h" #include "util/signal.h" static signal_shutdown_handler_t shutdown_handler; diff --git a/src/main/util/time.c b/src/main/util/time.c index 0412b29..feb2904 100644 --- a/src/main/util/time.c +++ b/src/main/util/time.c @@ -1,6 +1,7 @@ #include -#include "util/log.h" +#include "core/log.h" + #include "util/time.h" static uint64_t counter_freq_ns; diff --git a/src/main/vigem-ddrio/Module.mk b/src/main/vigem-ddrio/Module.mk index 8aae8a2..82e0f51 100644 --- a/src/main/vigem-ddrio/Module.mk +++ b/src/main/vigem-ddrio/Module.mk @@ -10,6 +10,7 @@ ldflags_vigem-ddrio := \ -lsetupapi \ libs_vigem-ddrio := \ + core \ cconfig \ ddrio \ util \ diff --git a/src/main/vigem-ddrio/config-vigem-ddrio.c b/src/main/vigem-ddrio/config-vigem-ddrio.c index 59e8251..0ff44f2 100644 --- a/src/main/vigem-ddrio/config-vigem-ddrio.c +++ b/src/main/vigem-ddrio/config-vigem-ddrio.c @@ -1,9 +1,9 @@ #include "cconfig/cconfig-main.h" #include "cconfig/cconfig-util.h" -#include "vigem-ddrio/config-vigem-ddrio.h" +#include "core/log.h" -#include "util/log.h" +#include "vigem-ddrio/config-vigem-ddrio.h" #define VIGEM_DDRIO_CONFIG_ENABLE_REACTIVE_LIGHT_KEY \ "ddrio.enable_reactive_light" diff --git a/src/main/vigem-ddrio/main.c b/src/main/vigem-ddrio/main.c index 62cc7b1..7d7fafa 100644 --- a/src/main/vigem-ddrio/main.c +++ b/src/main/vigem-ddrio/main.c @@ -8,9 +8,17 @@ #include "ViGEm/Client.h" #include "bemanitools/ddrio.h" -#include "util/log.h" + +#include "core/log-bt-ext.h" +#include "core/log-bt.h" +#include "core/log-sink-std.h" +#include "core/log.h" +#include "core/thread-crt-ext.h" +#include "core/thread-crt.h" +#include "core/thread.h" + #include "util/math.h" -#include "util/thread.h" + #include "vigemstub/helper.h" #include "vigem-ddrio/config-vigem-ddrio.h" @@ -112,17 +120,23 @@ void set_reactive_lights(uint32_t input_state) int main(int argc, char **argv) { - log_to_writer(log_writer_stdout, NULL); + core_thread_crt_ext_impl_set(); + core_log_bt_ext_impl_set(); + + core_log_bt_ext_init_with_stdout(); + core_log_bt_level_set(CORE_LOG_BT_LOG_LEVEL_INFO); struct vigem_ddrio_config config; if (!get_vigem_ddrio_config(&config)) { exit(EXIT_FAILURE); } - ddr_io_set_loggers( - log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal); + core_log_impl_assign(ddr_io_set_loggers); - if (!ddr_io_init(crt_thread_create, crt_thread_join, crt_thread_destroy)) { + if (!ddr_io_init( + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get())) { log_warning("Initializing ddrio failed"); return -1; } diff --git a/src/main/vigem-iidxio/Module.mk b/src/main/vigem-iidxio/Module.mk index 887a70f..4fae200 100644 --- a/src/main/vigem-iidxio/Module.mk +++ b/src/main/vigem-iidxio/Module.mk @@ -10,6 +10,7 @@ ldflags_vigem-iidxio := \ -lsetupapi \ libs_vigem-iidxio := \ + core \ cconfig \ iidxio \ util \ diff --git a/src/main/vigem-iidxio/cab-16seg-sequencer.c b/src/main/vigem-iidxio/cab-16seg-sequencer.c index 01ea12b..f7e6e05 100644 --- a/src/main/vigem-iidxio/cab-16seg-sequencer.c +++ b/src/main/vigem-iidxio/cab-16seg-sequencer.c @@ -4,7 +4,8 @@ #include #include -#include "util/log.h" +#include "core/log.h" + #include "util/time.h" static const uint8_t _MAX_LEN_16SEG = 9; diff --git a/src/main/vigem-iidxio/cab-light-sequencer.c b/src/main/vigem-iidxio/cab-light-sequencer.c index 95214f9..6b345b7 100644 --- a/src/main/vigem-iidxio/cab-light-sequencer.c +++ b/src/main/vigem-iidxio/cab-light-sequencer.c @@ -4,9 +4,10 @@ #include #include +#include "core/log.h" + #include "vigem-iidxio/cab-light-sequencer.h" -#include "util/log.h" #include "util/math.h" #include "util/time.h" diff --git a/src/main/vigem-iidxio/config.c b/src/main/vigem-iidxio/config.c index 40eeae5..acf5235 100644 --- a/src/main/vigem-iidxio/config.c +++ b/src/main/vigem-iidxio/config.c @@ -1,9 +1,9 @@ #include "cconfig/cconfig-main.h" #include "cconfig/cconfig-util.h" -#include "vigem-iidxio/config.h" +#include "core/log.h" -#include "util/log.h" +#include "vigem-iidxio/config.h" #define VIGEM_IIDXIO_CONFIG_TT_ANALOG_RELATIVE_KEY \ "vigem.iidxio.tt.anlog.relative" diff --git a/src/main/vigem-iidxio/main.c b/src/main/vigem-iidxio/main.c index 3527545..51b0b14 100644 --- a/src/main/vigem-iidxio/main.c +++ b/src/main/vigem-iidxio/main.c @@ -9,9 +9,14 @@ #include "bemanitools/iidxio.h" -#include "util/log.h" +#include "core/log-bt-ext.h" +#include "core/log-bt.h" +#include "core/log.h" +#include "core/thread-crt-ext.h" +#include "core/thread-crt.h" +#include "core/thread.h" + #include "util/math.h" -#include "util/thread.h" #include "util/time.h" #include "vigem-iidxio/cab-16seg-sequencer.h" @@ -259,7 +264,10 @@ static void _all_lights_off() int main(int argc, char **argv) { - log_to_writer(log_writer_stdout, NULL); + core_thread_crt_ext_impl_set(); + core_log_bt_ext_impl_set(); + + core_log_bt_ext_init_with_stdout(); struct vigem_iidxio_config config; @@ -267,10 +275,12 @@ int main(int argc, char **argv) return -1; } - 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(crt_thread_create, crt_thread_join, crt_thread_destroy)) { + if (!iidx_io_init( + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get())) { log_warning("Initializing iidxio failed"); return -1; } diff --git a/src/main/vigem-sdvxio/Module.mk b/src/main/vigem-sdvxio/Module.mk index 6907fbf..523dd69 100644 --- a/src/main/vigem-sdvxio/Module.mk +++ b/src/main/vigem-sdvxio/Module.mk @@ -10,6 +10,7 @@ ldflags_vigem-sdvxio := \ -lsetupapi \ libs_vigem-sdvxio := \ + core \ cconfig \ sdvxio \ util \ diff --git a/src/main/vigem-sdvxio/config-vigem-sdvxio.c b/src/main/vigem-sdvxio/config-vigem-sdvxio.c index 768a514..faae9e2 100644 --- a/src/main/vigem-sdvxio/config-vigem-sdvxio.c +++ b/src/main/vigem-sdvxio/config-vigem-sdvxio.c @@ -1,9 +1,9 @@ #include "cconfig/cconfig-main.h" #include "cconfig/cconfig-util.h" -#include "vigem-sdvxio/config-vigem-sdvxio.h" +#include "core/log.h" -#include "util/log.h" +#include "vigem-sdvxio/config-vigem-sdvxio.h" #define VIGEM_SDVXIO_CONFIG_ENABLE_KEYLIGHT_KEY "sdvxio.enable_keylight" #define VIGEM_SDVXIO_CONFIG_RELATIVE_ANALOG_KEY "sdvxio.use_relative_analog" diff --git a/src/main/vigem-sdvxio/main.c b/src/main/vigem-sdvxio/main.c index cf4b4e2..c87a436 100644 --- a/src/main/vigem-sdvxio/main.c +++ b/src/main/vigem-sdvxio/main.c @@ -8,9 +8,16 @@ #include "ViGEm/Client.h" #include "bemanitools/sdvxio.h" -#include "util/log.h" + +#include "core/log-bt-ext.h" +#include "core/log-bt.h" +#include "core/log.h" +#include "core/thread-crt-ext.h" +#include "core/thread-crt.h" +#include "core/thread.h" + #include "util/math.h" -#include "util/thread.h" + #include "vigemstub/helper.h" #include "vigem-sdvxio/config-vigem-sdvxio.h" @@ -129,17 +136,21 @@ void set_pwm_brightness(uint8_t wing_pwm, uint8_t controller_pwm) int main(int argc, char **argv) { - log_to_writer(log_writer_stdout, NULL); + core_thread_crt_ext_impl_set(); + core_log_bt_ext_impl_set(); + core_log_bt_ext_init_with_stdout(); struct vigem_sdvxio_config config; if (!get_vigem_sdvxio_config(&config)) { exit(EXIT_FAILURE); } - sdvx_io_set_loggers( - log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal); + core_log_impl_assign(sdvx_io_set_loggers); - if (!sdvx_io_init(crt_thread_create, crt_thread_join, crt_thread_destroy)) { + if (!sdvx_io_init( + core_thread_create_impl_get(), + core_thread_join_impl_get(), + core_thread_destroy_impl_get())) { log_warning("Initializing sdvxio failed"); return -1; } diff --git a/src/main/vigemstub/helper.c b/src/main/vigemstub/helper.c index 4aeb519..a92510b 100644 --- a/src/main/vigemstub/helper.c +++ b/src/main/vigemstub/helper.c @@ -2,9 +2,10 @@ #include #include +#include "core/log.h" + #include "ViGEm/Client.h" -#include "util/log.h" #include "vigemstub/helper.h" PVIGEM_CLIENT vigem_helper_setup(void) diff --git a/src/test/cconfig/Module.mk b/src/test/cconfig/Module.mk index a61e8d9..8143389 100644 --- a/src/test/cconfig/Module.mk +++ b/src/test/cconfig/Module.mk @@ -3,6 +3,7 @@ testexes += cconfig-test srcdir_cconfig-test := src/test/cconfig libs_cconfig-test := \ + core \ cconfig \ test \ util \ @@ -17,6 +18,7 @@ testexes += cconfig-util-test srcdir_cconfig-util-test := src/test/cconfig libs_cconfig-util-test := \ + core \ cconfig \ test \ util \ @@ -31,6 +33,7 @@ testexes += cconfig-cmd-test srcdir_cconfig-cmd-test := src/test/cconfig libs_cconfig-cmd-test := \ + core \ cconfig \ test \ util \ diff --git a/src/test/d3d9hook/Module.mk b/src/test/d3d9hook/Module.mk index 585139c..3ab336b 100644 --- a/src/test/d3d9hook/Module.mk +++ b/src/test/d3d9hook/Module.mk @@ -5,6 +5,7 @@ srcdir_d3d9hook := src/test/d3d9hook ldflags_d3d9hook := \ libs_d3d9hook := \ + core \ hook \ test \ util \ @@ -25,6 +26,7 @@ libs_d3d9hook-test := \ hook \ test \ util \ + core \ src_d3d9hook-test := \ main.c \ diff --git a/src/test/d3d9hook/dllmain.c b/src/test/d3d9hook/dllmain.c index 88060bb..e7052df 100644 --- a/src/test/d3d9hook/dllmain.c +++ b/src/test/d3d9hook/dllmain.c @@ -2,12 +2,14 @@ #include #include +#include "core/log-bt-ext.h" +#include "core/log-bt.h" +#include "core/log.h" + #include "hook/d3d9.h" #include "test/check.h" -#include "util/log.h" - #define debug_print(...) fprintf(stderr, __VA_ARGS__) static HRESULT my_d3d9_handler(struct hook_d3d9_irp *irp); @@ -298,7 +300,9 @@ static HRESULT my_d3d9_handler(struct hook_d3d9_irp *irp) BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx) { if (reason == DLL_PROCESS_ATTACH) { - log_to_writer(log_writer_stderr, NULL); + core_log_bt_ext_init_with_debug(); + core_log_bt_ext_init_with_stderr(); + debug_print("Initializing d3d9 hook module...\n"); hook_d3d9_init(d3d9_handlers, lengthof(d3d9_handlers)); diff --git a/src/test/iidxhook-util/Module.mk b/src/test/iidxhook-util/Module.mk index be4883e..49fdda9 100644 --- a/src/test/iidxhook-util/Module.mk +++ b/src/test/iidxhook-util/Module.mk @@ -6,6 +6,7 @@ ldflags_iidxhook-util-config-eamuse-test := \ -lws2_32 \ libs_iidxhook-util-config-eamuse-test := \ + core \ security \ iidxhook-util \ cconfig \ @@ -22,6 +23,7 @@ testexes += iidxhook-util-config-gfx-test srcdir_iidxhook-util-config-gfx-test := src/test/iidxhook-util libs_iidxhook-util-config-gfx-test := \ + core \ security \ iidxhook-util \ cconfig \ @@ -38,6 +40,7 @@ testexes += iidxhook-util-config-misc-test srcdir_iidxhook-util-config-misc-test := src/test/iidxhook-util libs_iidxhook-util-config-misc-test := \ + core \ security \ iidxhook-util \ cconfig \ @@ -54,6 +57,7 @@ testexes += iidxhook-util-config-sec-test srcdir_iidxhook-util-config-sec-test := src/test/iidxhook-util libs_iidxhook-util-config-sec-test := \ + core \ security \ iidxhook-util \ cconfig \ diff --git a/src/test/iidxhook/Module.mk b/src/test/iidxhook/Module.mk index 8c08642..9172fa5 100644 --- a/src/test/iidxhook/Module.mk +++ b/src/test/iidxhook/Module.mk @@ -3,6 +3,7 @@ testexes += iidxhook-config-iidxhook1-test srcdir_iidxhook-config-iidxhook1-test := src/test/iidxhook libs_iidxhook-config-iidxhook1-test := \ + core \ cconfig \ iidxhook1 \ test \ @@ -18,6 +19,7 @@ testexes += iidxhook-config-iidxhook2-test srcdir_iidxhook-config-iidxhook2-test := src/test/iidxhook libs_iidxhook-config-iidxhook2-test := \ + core \ iidxhook2 \ cconfig \ test \ diff --git a/src/test/iidxhook8/Module.mk b/src/test/iidxhook8/Module.mk index 57731d5..3cccd42 100644 --- a/src/test/iidxhook8/Module.mk +++ b/src/test/iidxhook8/Module.mk @@ -3,6 +3,7 @@ testexes += iidxhook8-config-cam-test srcdir_iidxhook8-config-cam-test := src/test/iidxhook8 libs_iidxhook8-config-cam-test := \ + core \ camhook \ cconfig \ test \ @@ -18,6 +19,7 @@ testexes += iidxhook8-config-io-test srcdir_iidxhook8-config-io-test := src/test/iidxhook8 libs_iidxhook8-config-io-test := \ + core \ cconfig \ test \ util \ diff --git a/src/test/security/Module.mk b/src/test/security/Module.mk index 3bdef67..7ac51d7 100644 --- a/src/test/security/Module.mk +++ b/src/test/security/Module.mk @@ -3,6 +3,7 @@ testexes += security-id-test srcdir_security-id-test := src/test/security libs_security-id-test := \ + core \ security \ test \ util \ @@ -17,6 +18,7 @@ testexes += security-mcode-test srcdir_security-mcode-test := src/test/security libs_security-mcode-test := \ + core \ security \ test \ util \ @@ -31,6 +33,7 @@ testexes += security-util-test srcdir_security-util-test := src/test/security libs_security-util-test := \ + core \ security \ test \ util \ @@ -45,6 +48,7 @@ testexes += security-rp-test srcdir_security-rp-test := src/test/security libs_security-rp-test := \ + core \ security \ test \ util \ @@ -59,6 +63,7 @@ testexes += security-rp2-test srcdir_security-rp2-test := src/test/security libs_security-rp2-test := \ + core \ security \ test \ util \ @@ -73,6 +78,7 @@ testexes += security-rp3-test srcdir_security-rp3-test := src/test/security libs_security-rp3-test := \ + core \ security \ test \ util \ diff --git a/src/test/test/test.h b/src/test/test/test.h index 91fb01b..7d0dda0 100644 --- a/src/test/test/test.h +++ b/src/test/test/test.h @@ -3,12 +3,15 @@ #include -#include "util/log.h" +#include "core/log-bt-ext.h" +#include "core/log-bt.h" +#include "core/log.h" -#define TEST_MODULE_BEGIN(name) \ - int main(int argc, char **argv) \ - { \ - log_to_writer(log_writer_stderr, NULL); \ +#define TEST_MODULE_BEGIN(name) \ + int main(int argc, char **argv) \ + { \ + core_log_bt_ext_impl_set(); \ + core_log_bt_ext_init_with_stderr(); \ fprintf(stderr, "Executing test module '%s'...\n", #name); #define TEST_MODULE_TEST(func) \ @@ -19,6 +22,8 @@ #define TEST_MODULE_END() \ fprintf(stderr, "Finished execution of test module\n"); \ + core_log_bt_fini(); \ + \ return 0; \ } diff --git a/src/test/util/Module.mk b/src/test/util/Module.mk index ca13ecc..90f3424 100644 --- a/src/test/util/Module.mk +++ b/src/test/util/Module.mk @@ -7,6 +7,7 @@ ldflags_util-net-test := \ -liphlpapi \ libs_util-net-test := \ + core \ test \ util \