mirror of
https://github.com/djhackersdev/bemanitools.git
synced 2026-09-15 03:45:09 -05:00
refactor: Move all hook and IO libraries to use btools log and thread api
Remove usages of AVS threads and logging functions from the bemanitools backend. Use the bemanitools 6 API instead which propagates interfaces to call thread and log APIs. Prior design decisions for using these were: - have a single log stream through the AVS logging system for “neatness”, log output redirection options in launcher, and theoretically logging to an xrpc endpoint - IIDX 19 to IIDX 24 crash the AVS logging engine in libavs due to IO hook code running in a non AVS thread (threads in ezusb library) causing a stackoverflow when trying to acquire a mutex (see dev journal 2018-02-10-logging-breakdown-avs.md for details) With a flexible log sink architecture in the core of bemanitools, and a separate writer function that is hooked up as a log writer to AVS, log streams are still unified on a sink level. This takes care of having all log messaged sinked to the same targets no matter how many logging engines are using them. This avoids going through the AVS logging engine with the IO related hooking code in iidx, which just uses the bemanitools logging engine instead. Furthermore, this removes any needs to having to switch thread and logging implementations once AVS is booted which significantly simplifies the runtime orchestration during bootstrapping. The log-server, which was specifically implemented for iidx to solve the threading issue, can also be removed now. Unfortunately, this also caused performance issues such as stuttering due to it’s rather simplistic implementation.
This commit is contained in:
@@ -9,12 +9,6 @@
|
||||
|
||||
#include "api/core/config.h"
|
||||
|
||||
typedef enum bt_io_bst_gpio_sys_bit {
|
||||
BT_IO_BST_GPIO_SYS_COIN = 2,
|
||||
BT_IO_BST_GPIO_SYS_TEST = 4,
|
||||
BT_IO_BST_GPIO_SYS_SERVICE = 5,
|
||||
} bt_io_bst_gpio_sys_bit_t;
|
||||
|
||||
typedef void (*bt_hook_iat_dll_name_get_t)(char *buffer, size_t size);
|
||||
typedef bool (*bt_hook_pre_avs_init_t)(const bt_core_config_t *config);
|
||||
// game module reference, either the exe or dll. allow for further targeted hooking/patching
|
||||
|
||||
@@ -6,8 +6,6 @@ libs_avs-ext := \
|
||||
src_avs-ext := \
|
||||
fs.c \
|
||||
error.c \
|
||||
log.c \
|
||||
property-ext.c \
|
||||
property-node.c \
|
||||
property.c \
|
||||
thread.c \
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
#include "api/core/log.h"
|
||||
|
||||
#include "avs-ext/log.h"
|
||||
|
||||
#include "iface-core/log.h"
|
||||
|
||||
#include "imports/avs.h"
|
||||
|
||||
static void _avs_ext_log_core_api_get(bt_core_log_api_t *api)
|
||||
{
|
||||
log_assert(api);
|
||||
|
||||
api->version = 1;
|
||||
|
||||
api->v1.misc = log_body_misc;
|
||||
api->v1.info = log_body_info;
|
||||
api->v1.warning = log_body_warning;
|
||||
api->v1.fatal = log_body_fatal;
|
||||
}
|
||||
|
||||
void avs_ext_log_core_api_set()
|
||||
{
|
||||
bt_core_log_api_t api;
|
||||
|
||||
_avs_ext_log_core_api_get(&api);
|
||||
bt_core_log_api_set(&api);
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
#ifndef AVS_EXT_LOG_H
|
||||
#define AVS_EXT_LOG_H
|
||||
|
||||
#include "api/core/log.h"
|
||||
|
||||
void avs_ext_log_core_api_set();
|
||||
|
||||
#endif
|
||||
@@ -1,56 +0,0 @@
|
||||
#include "api/core/thread.h"
|
||||
#include "api/core/log.h"
|
||||
|
||||
#include "avs-ext/thread.h"
|
||||
|
||||
#include "iface-core/log.h"
|
||||
#include "iface-core/thread.h"
|
||||
|
||||
#include "imports/avs.h"
|
||||
|
||||
static bt_core_thread_result_t _avs_ext_thread_create(
|
||||
int (*proc)(void *),
|
||||
void *ctx,
|
||||
uint32_t stack_sz,
|
||||
unsigned int priority,
|
||||
bt_core_thread_id_t *thread_id)
|
||||
{
|
||||
*thread_id = avs_thread_create(proc, ctx, stack_sz, priority);
|
||||
|
||||
return BT_CORE_THREAD_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
static bt_core_thread_result_t
|
||||
_avs_ext_thread_join(bt_core_thread_id_t thread_id, int *result)
|
||||
{
|
||||
avs_thread_join(thread_id, result);
|
||||
|
||||
return BT_CORE_THREAD_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
static bt_core_thread_result_t
|
||||
_avs_ext_thread_destroy(bt_core_thread_id_t thread_id)
|
||||
{
|
||||
avs_thread_destroy(thread_id);
|
||||
|
||||
return BT_CORE_THREAD_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
static void _avs_ext_thread_core_api_get(bt_core_thread_api_t *api)
|
||||
{
|
||||
log_assert(api);
|
||||
|
||||
api->version = 1;
|
||||
|
||||
api->v1.create = _avs_ext_thread_create;
|
||||
api->v1.join = _avs_ext_thread_join;
|
||||
api->v1.destroy = _avs_ext_thread_destroy;
|
||||
}
|
||||
|
||||
void avs_ext_thread_core_api_set()
|
||||
{
|
||||
bt_core_thread_api_t api;
|
||||
|
||||
_avs_ext_thread_core_api_get(&api);
|
||||
bt_core_thread_api_set(&api);
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
#ifndef AVS_EXT_THREAD_H
|
||||
#define AVS_EXT_THREAD_H
|
||||
|
||||
#include "api/core/thread.h"
|
||||
|
||||
void avs_ext_thread_core_api_set();
|
||||
|
||||
#endif
|
||||
@@ -2,3 +2,8 @@ LIBRARY bsthook
|
||||
|
||||
EXPORTS
|
||||
DllMain@12 @1 NONAME
|
||||
|
||||
; Bemanitools 6 API
|
||||
bt_module_core_log_api_set
|
||||
bt_module_core_thread_api_set
|
||||
bt_module_hook_api_get
|
||||
@@ -2,37 +2,32 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "avs-ext/log.h"
|
||||
#include "avs-ext/thread.h"
|
||||
|
||||
#include "bsthook/acio.h"
|
||||
#include "bsthook/gfx.h"
|
||||
#include "bsthook/settings.h"
|
||||
|
||||
#include "iface-core/config.h"
|
||||
#include "iface-core/log.h"
|
||||
#include "iface-core/thread.h"
|
||||
|
||||
#include "iface-io/bst.h"
|
||||
#include "iface-io/eam.h"
|
||||
|
||||
#include "hook/iohook.h"
|
||||
|
||||
#include "hooklib/app.h"
|
||||
#include "hooklib/rs232.h"
|
||||
|
||||
#include "imports/avs.h"
|
||||
|
||||
#include "module/io-ext.h"
|
||||
|
||||
#include "sdk/module/core/log.h"
|
||||
#include "sdk/module/core/thread.h"
|
||||
#include "sdk/module/hook.h"
|
||||
|
||||
#include "util/cmdline.h"
|
||||
#include "util/defs.h"
|
||||
|
||||
static module_io_t *_bsthook_module_io_bst;
|
||||
static module_io_t *_bsthook_module_io_eam;
|
||||
|
||||
static bool my_dll_entry_init(char *sidcode, struct property_node *config);
|
||||
static bool my_dll_entry_main(void);
|
||||
|
||||
static void _bsthook_io_bst_init(module_io_t **module)
|
||||
{
|
||||
bt_io_bst_api_t api;
|
||||
@@ -53,10 +48,37 @@ static void _bsthook_io_eam_init(module_io_t **module)
|
||||
bt_io_eam_api_set(&api);
|
||||
}
|
||||
|
||||
static bool my_dll_entry_init(char *sidcode, struct property_node *config)
|
||||
static bool
|
||||
_bsthook_main_init(HMODULE game_module, const bt_core_config_t *config_)
|
||||
{
|
||||
int i;
|
||||
int argc;
|
||||
char **argv;
|
||||
bool ok;
|
||||
|
||||
args_recover(&argc, &argv);
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (argv[i][0] != '-') {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (argv[i][1]) {
|
||||
case 'w':
|
||||
gfx_set_windowed();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
args_free(argc, argv);
|
||||
|
||||
iohook_push_handler(ac_io_bus_dispatch_irp);
|
||||
rs232_hook_init();
|
||||
|
||||
gfx_init();
|
||||
settings_hook_init();
|
||||
|
||||
log_info("--- Begin bsthook dll_entry_init ---");
|
||||
|
||||
log_info("Starting up BeatStream IO backend");
|
||||
@@ -81,7 +103,7 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *config)
|
||||
|
||||
log_info("--- End bsthook dll_entry_init ---");
|
||||
|
||||
return app_hook_invoke_init(sidcode, config);
|
||||
return true;
|
||||
|
||||
eam_io_fail:
|
||||
bt_io_bst_fini();
|
||||
@@ -94,12 +116,8 @@ bst_io_fail:
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool my_dll_entry_main(void)
|
||||
static void _bsthook_main_fini()
|
||||
{
|
||||
bool result;
|
||||
|
||||
result = app_hook_invoke_main();
|
||||
|
||||
log_info("Shutting down card reader backend");
|
||||
bt_io_eam_fini();
|
||||
|
||||
@@ -113,47 +131,27 @@ static bool my_dll_entry_main(void)
|
||||
module_io_free(&_bsthook_module_io_bst);
|
||||
|
||||
ac_io_bus_fini();
|
||||
}
|
||||
|
||||
return result;
|
||||
void bt_module_core_log_api_set(const bt_core_log_api_t *api)
|
||||
{
|
||||
bt_core_log_api_set(api);
|
||||
}
|
||||
|
||||
void bt_module_core_thread_api_set(const bt_core_thread_api_t *api)
|
||||
{
|
||||
bt_core_thread_api_set(api);
|
||||
}
|
||||
|
||||
void bt_module_hook_api_get(bt_hook_api_t *api)
|
||||
{
|
||||
api->version = 1;
|
||||
|
||||
api->v1.main_init = _bsthook_main_init;
|
||||
api->v1.main_fini = _bsthook_main_fini;
|
||||
}
|
||||
|
||||
BOOL WINAPI DllMain(HMODULE self, DWORD reason, void *ctx)
|
||||
{
|
||||
int i;
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
if (reason != DLL_PROCESS_ATTACH) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Use AVS APIs
|
||||
avs_ext_log_core_api_set();
|
||||
avs_ext_thread_core_api_set();
|
||||
|
||||
args_recover(&argc, &argv);
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (argv[i][0] != '-') {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (argv[i][1]) {
|
||||
case 'w':
|
||||
gfx_set_windowed();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
args_free(argc, argv);
|
||||
|
||||
app_hook_init(my_dll_entry_init, my_dll_entry_main);
|
||||
iohook_push_handler(ac_io_bus_dispatch_irp);
|
||||
rs232_hook_init();
|
||||
|
||||
gfx_init();
|
||||
settings_hook_init();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -2,3 +2,8 @@ LIBRARY ddrhook1
|
||||
|
||||
EXPORTS
|
||||
DllMain@12 @1 NONAME
|
||||
|
||||
; Bemanitools 6 API
|
||||
bt_module_core_log_api_set
|
||||
bt_module_core_thread_api_set
|
||||
bt_module_hook_api_get
|
||||
@@ -2,9 +2,6 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "avs-ext/log.h"
|
||||
#include "avs-ext/thread.h"
|
||||
|
||||
#include "cconfig/cconfig-hook.h"
|
||||
|
||||
#include "core/log-bt-ext.h"
|
||||
@@ -31,7 +28,6 @@
|
||||
#include "hook/iohook.h"
|
||||
#include "hook/table.h"
|
||||
|
||||
#include "hooklib/app.h"
|
||||
#include "hooklib/rs232.h"
|
||||
|
||||
#include "iface-core/log.h"
|
||||
@@ -40,13 +36,15 @@
|
||||
#include "iface-io/ddr.h"
|
||||
#include "iface-io/eam.h"
|
||||
|
||||
#include "imports/avs.h"
|
||||
|
||||
#include "module/io-ext.h"
|
||||
#include "module/io.h"
|
||||
|
||||
#include "p3ioemu/emu.h"
|
||||
|
||||
#include "sdk/module/core/log.h"
|
||||
#include "sdk/module/core/thread.h"
|
||||
#include "sdk/module/hook.h"
|
||||
|
||||
#include "security/rp-sign-key.h"
|
||||
|
||||
#include "util/cmdline.h"
|
||||
@@ -65,24 +63,9 @@ static const hook_d3d9_irp_handler_t ddrhook1_d3d9_handlers[] = {
|
||||
gfx_d3d9_irp_handler,
|
||||
};
|
||||
|
||||
static DWORD STDCALL
|
||||
my_GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize);
|
||||
static DWORD(STDCALL *real_GetModuleFileNameA)(
|
||||
HMODULE hModule, LPSTR lpFilename, DWORD nSize);
|
||||
|
||||
static bool ddrhook1_init_check = false;
|
||||
|
||||
static module_io_t *_ddrhook1_module_io_ddr;
|
||||
static module_io_t *_ddrhook1_module_io_eam;
|
||||
|
||||
static const struct hook_symbol init_hook_syms[] = {
|
||||
{
|
||||
.name = "GetModuleFileNameA",
|
||||
.patch = my_GetModuleFileNameA,
|
||||
.link = (void **) &real_GetModuleFileNameA,
|
||||
},
|
||||
};
|
||||
|
||||
static void _ddrhook1_io_ddr_init(module_io_t **module)
|
||||
{
|
||||
bt_io_ddr_api_t api;
|
||||
@@ -103,8 +86,8 @@ static void _ddrhook1_io_eam_init(module_io_t **module)
|
||||
bt_io_eam_api_set(&api);
|
||||
}
|
||||
|
||||
static DWORD STDCALL
|
||||
my_GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize)
|
||||
static bool
|
||||
_ddrhook1_main_init(HMODULE game_module, const bt_core_config_t *config_)
|
||||
{
|
||||
bool ok;
|
||||
struct cconfig *config;
|
||||
@@ -114,13 +97,14 @@ my_GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize)
|
||||
struct ddrhook1_config_gfx config_gfx;
|
||||
struct ddrhook1_config_security config_security;
|
||||
|
||||
if (ddrhook1_init_check)
|
||||
goto skip;
|
||||
ddrhook1_master_insert_hooks(NULL);
|
||||
ddrhook1_filesystem_hook_init();
|
||||
|
||||
hook_d3d9_init(
|
||||
ddrhook1_d3d9_handlers, lengthof(ddrhook1_d3d9_handlers));
|
||||
|
||||
log_info("--- Begin ddrhook1 main ---");
|
||||
|
||||
ddrhook1_init_check = true;
|
||||
|
||||
config = cconfig_init();
|
||||
|
||||
ddrhook1_config_ddrhook1_init(config);
|
||||
@@ -214,26 +198,33 @@ my_GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize)
|
||||
|
||||
log_info("--- End ddrhook1 main ---");
|
||||
|
||||
skip:
|
||||
return real_GetModuleFileNameA(hModule, lpFilename, nSize);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void _ddrhook1_main_fini()
|
||||
{
|
||||
// TODO cleanup
|
||||
}
|
||||
|
||||
void bt_module_core_log_api_set(const bt_core_log_api_t *api)
|
||||
{
|
||||
bt_core_log_api_set(api);
|
||||
}
|
||||
|
||||
void bt_module_core_thread_api_set(const bt_core_thread_api_t *api)
|
||||
{
|
||||
bt_core_thread_api_set(api);
|
||||
}
|
||||
|
||||
void bt_module_hook_api_get(bt_hook_api_t *api)
|
||||
{
|
||||
api->version = 1;
|
||||
|
||||
api->v1.main_init = _ddrhook1_main_init;
|
||||
api->v1.main_fini = _ddrhook1_main_fini;
|
||||
}
|
||||
|
||||
BOOL WINAPI DllMain(HMODULE self, DWORD reason, void *ctx)
|
||||
{
|
||||
if (reason == DLL_PROCESS_ATTACH) {
|
||||
// Use AVS APIs
|
||||
avs_ext_log_core_api_set();
|
||||
avs_ext_thread_core_api_set();
|
||||
|
||||
hook_table_apply(
|
||||
NULL, "kernel32.dll", init_hook_syms, lengthof(init_hook_syms));
|
||||
|
||||
ddrhook1_master_insert_hooks(NULL);
|
||||
ddrhook1_filesystem_hook_init();
|
||||
|
||||
hook_d3d9_init(
|
||||
ddrhook1_d3d9_handlers, lengthof(ddrhook1_d3d9_handlers));
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -2,3 +2,8 @@ LIBRARY ddrhook2
|
||||
|
||||
EXPORTS
|
||||
DllMain@12 @1 NONAME
|
||||
|
||||
; Bemanitools 6 API
|
||||
bt_module_core_log_api_set
|
||||
bt_module_core_thread_api_set
|
||||
bt_module_hook_api_get
|
||||
@@ -2,9 +2,6 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "avs-ext/log.h"
|
||||
#include "avs-ext/thread.h"
|
||||
|
||||
#include "ddrhook-util/_com4.h"
|
||||
#include "ddrhook-util/extio.h"
|
||||
#include "ddrhook-util/gfx.h"
|
||||
@@ -16,7 +13,6 @@
|
||||
|
||||
#include "hook/iohook.h"
|
||||
|
||||
#include "hooklib/app.h"
|
||||
#include "hooklib/rs232.h"
|
||||
|
||||
#include "iface-core/log.h"
|
||||
@@ -25,19 +21,18 @@
|
||||
#include "iface-io/ddr.h"
|
||||
#include "iface-io/eam.h"
|
||||
|
||||
#include "imports/avs.h"
|
||||
|
||||
#include "module/io-ext.h"
|
||||
#include "module/io.h"
|
||||
|
||||
#include "p3ioemu/emu.h"
|
||||
|
||||
#include "sdk/module/core/log.h"
|
||||
#include "sdk/module/core/thread.h"
|
||||
#include "sdk/module/hook.h"
|
||||
|
||||
#include "util/cmdline.h"
|
||||
#include "util/defs.h"
|
||||
|
||||
static bool my_dll_entry_init(char *sidcode, struct property_node *param);
|
||||
static bool my_dll_entry_main(void);
|
||||
|
||||
bool standard_def;
|
||||
bool _15khz;
|
||||
|
||||
@@ -64,7 +59,8 @@ static void _ddrhook2_io_eam_init(module_io_t **module)
|
||||
bt_io_eam_api_set(&api);
|
||||
}
|
||||
|
||||
static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
static bool
|
||||
_ddrhook2_main_init(HMODULE game_module, const bt_core_config_t *config_)
|
||||
{
|
||||
int argc;
|
||||
char **argv;
|
||||
@@ -172,15 +168,11 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
|
||||
log_info("--- End ddrhook dll_entry_init ---");
|
||||
|
||||
return app_hook_invoke_init(sidcode, param);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool my_dll_entry_main(void)
|
||||
static void _ddrhook2_main_fini()
|
||||
{
|
||||
bool result;
|
||||
|
||||
result = app_hook_invoke_main();
|
||||
|
||||
log_misc("Shutting down card reader backend");
|
||||
bt_io_eam_fini();
|
||||
bt_io_eam_api_clear();
|
||||
@@ -196,22 +188,27 @@ static bool my_dll_entry_main(void)
|
||||
usbmem_fini();
|
||||
extio_fini();
|
||||
p3io_emu_fini();
|
||||
}
|
||||
|
||||
return result;
|
||||
void bt_module_core_log_api_set(const bt_core_log_api_t *api)
|
||||
{
|
||||
bt_core_log_api_set(api);
|
||||
}
|
||||
|
||||
void bt_module_core_thread_api_set(const bt_core_thread_api_t *api)
|
||||
{
|
||||
bt_core_thread_api_set(api);
|
||||
}
|
||||
|
||||
void bt_module_hook_api_get(bt_hook_api_t *api)
|
||||
{
|
||||
api->version = 1;
|
||||
|
||||
api->v1.main_init = _ddrhook2_main_init;
|
||||
api->v1.main_fini = _ddrhook2_main_fini;
|
||||
}
|
||||
|
||||
BOOL WINAPI DllMain(HMODULE self, DWORD reason, void *ctx)
|
||||
{
|
||||
if (reason != DLL_PROCESS_ATTACH) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
// Use AVS APIs
|
||||
avs_ext_log_core_api_set();
|
||||
avs_ext_thread_core_api_set();
|
||||
|
||||
app_hook_init(my_dll_entry_init, my_dll_entry_main);
|
||||
|
||||
end:
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -17,5 +17,4 @@ src_iidxhook-util := \
|
||||
d3d9.c \
|
||||
eamuse.c \
|
||||
effector.c \
|
||||
log-server.c \
|
||||
settings.c \
|
||||
|
||||
@@ -1,170 +0,0 @@
|
||||
#include <windows.h>
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "hook/table.h"
|
||||
|
||||
#include "iface-core/log.h"
|
||||
#include "iface-core/thread.h"
|
||||
|
||||
#include "iidxhook-util/log-server.h"
|
||||
|
||||
#include "imports/avs.h"
|
||||
|
||||
#include "util/defs.h"
|
||||
#include "util/str.h"
|
||||
|
||||
static int log_thread_proc(void *ctx);
|
||||
static void
|
||||
log_post(char level, const char *module, const char *fmt, va_list ap);
|
||||
static void log_post_misc(const char *module, const char *fmt, ...);
|
||||
static void log_post_info(const char *module, const char *fmt, ...);
|
||||
static void log_post_warning(const char *module, const char *fmt, ...);
|
||||
static void log_post_fatal(const char *module, const char *fmt, ...);
|
||||
|
||||
static int log_thread_id;
|
||||
static HANDLE log_rv_producer;
|
||||
static HANDLE log_rv_consumer;
|
||||
static char log_rv_level;
|
||||
static const char *log_rv_module;
|
||||
static char log_rv_buffer[8192];
|
||||
|
||||
void log_server_init(void)
|
||||
{
|
||||
HANDLE ready;
|
||||
bt_core_log_api_t api;
|
||||
|
||||
log_rv_producer = CreateSemaphore(NULL, 1, 1, NULL);
|
||||
log_rv_consumer = CreateSemaphore(NULL, 0, 1, NULL);
|
||||
ready = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
|
||||
api.version = 1;
|
||||
api.v1.fatal = log_post_fatal;
|
||||
api.v1.warning = log_post_warning;
|
||||
api.v1.info = log_post_info;
|
||||
api.v1.misc = log_post_misc;
|
||||
|
||||
bt_core_log_api_set(&api);
|
||||
|
||||
log_thread_id = avs_thread_create(log_thread_proc, ready, 16384, 0);
|
||||
|
||||
if (WaitForSingleObject(ready, INFINITE)) {
|
||||
// can't do any logging here, yet.
|
||||
fprintf(
|
||||
stderr,
|
||||
"ERROR log_server_init: WaitForSingleObject failed: %08x",
|
||||
(unsigned int) GetLastError());
|
||||
return;
|
||||
}
|
||||
|
||||
CloseHandle(ready);
|
||||
|
||||
log_misc("Started log server thread");
|
||||
}
|
||||
|
||||
static int log_thread_proc(void *ctx)
|
||||
{
|
||||
bool run;
|
||||
|
||||
SetEvent((HANDLE) ctx);
|
||||
|
||||
run = true;
|
||||
|
||||
log_body_misc(LOG_MODULE, "Log server thread is running");
|
||||
|
||||
while (run) {
|
||||
if (WaitForSingleObject(log_rv_consumer, INFINITE)) {
|
||||
log_fatal(
|
||||
"WaitForSingleObject failed: %08x",
|
||||
(unsigned int) GetLastError());
|
||||
}
|
||||
|
||||
switch (log_rv_level) {
|
||||
case '\0':
|
||||
run = false;
|
||||
|
||||
break;
|
||||
|
||||
case 'M':
|
||||
log_body_misc(log_rv_module, "%s", log_rv_buffer);
|
||||
|
||||
break;
|
||||
|
||||
case 'I':
|
||||
log_body_info(log_rv_module, "%s", log_rv_buffer);
|
||||
|
||||
break;
|
||||
|
||||
case 'W':
|
||||
log_body_warning(log_rv_module, "%s", log_rv_buffer);
|
||||
|
||||
break;
|
||||
|
||||
case 'F':
|
||||
log_body_fatal(log_rv_module, "%s", log_rv_buffer);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (!ReleaseSemaphore(log_rv_producer, 1, NULL)) {
|
||||
log_fatal(
|
||||
"ReleaseSemaphore failed: %08x", (unsigned int) GetLastError());
|
||||
}
|
||||
}
|
||||
|
||||
log_body_misc(LOG_MODULE, "Log server thread is exiting");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
log_post(char level, const char *module, const char *fmt, va_list ap)
|
||||
{
|
||||
if (WaitForSingleObject(log_rv_producer, INFINITE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
log_rv_level = level;
|
||||
log_rv_module = module;
|
||||
str_vformat(log_rv_buffer, sizeof(log_rv_buffer), fmt, ap);
|
||||
|
||||
ReleaseSemaphore(log_rv_consumer, 1, NULL);
|
||||
}
|
||||
|
||||
#define LOG_POST_IMPL(name, level) \
|
||||
static void name(const char *module, const char *fmt, ...) \
|
||||
{ \
|
||||
va_list ap; \
|
||||
\
|
||||
va_start(ap, fmt); \
|
||||
log_post(level, module, fmt, ap); \
|
||||
va_end(ap); \
|
||||
}
|
||||
|
||||
LOG_POST_IMPL(log_post_misc, 'M')
|
||||
LOG_POST_IMPL(log_post_info, 'I')
|
||||
LOG_POST_IMPL(log_post_warning, 'W')
|
||||
LOG_POST_IMPL(log_post_fatal, 'F')
|
||||
|
||||
void log_server_fini(void)
|
||||
{
|
||||
int thread_result;
|
||||
|
||||
log_misc("Stopping log server thread");
|
||||
|
||||
WaitForSingleObject(log_rv_producer, INFINITE);
|
||||
log_rv_level = '\0';
|
||||
ReleaseSemaphore(log_rv_consumer, 1, NULL);
|
||||
|
||||
avs_thread_join(log_thread_id, &thread_result);
|
||||
avs_thread_destroy(log_thread_id);
|
||||
|
||||
CloseHandle(log_rv_producer);
|
||||
CloseHandle(log_rv_consumer);
|
||||
|
||||
log_rv_producer = NULL;
|
||||
log_rv_consumer = NULL;
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
#ifndef IIDXHOOK_LOG_SERVER_H
|
||||
#define IIDXHOOK_LOG_SERVER_H
|
||||
|
||||
/**
|
||||
* Initialize the log server which creates a dedicated thread and a log message
|
||||
* queue.
|
||||
*
|
||||
* Log messages are posted to the queue by the application and the background
|
||||
* thread writes them to the target output. Required for newer iidx and pop'n
|
||||
* games using the avs log api (e.g. iidxhook4 to 7) due to a quirk of the ezusb
|
||||
* driver. For a full breakdown about the logging on avs (and non avs) based
|
||||
* konami games, see doc/logging-breadkdown-avs.md.
|
||||
*/
|
||||
void log_server_init(void);
|
||||
|
||||
/**
|
||||
* Shut down the log server.
|
||||
*/
|
||||
void log_server_fini(void);
|
||||
|
||||
#endif
|
||||
@@ -5,11 +5,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "avs-ext/thread.h"
|
||||
|
||||
#include "cconfig/cconfig-hook.h"
|
||||
|
||||
#include "core/boot.h"
|
||||
#include "core/log-bt-ext.h"
|
||||
#include "core/log-bt.h"
|
||||
#include "core/log-sink-debug.h"
|
||||
@@ -43,11 +40,13 @@
|
||||
#include "iidxhook-util/d3d9.h"
|
||||
#include "iidxhook-util/settings.h"
|
||||
|
||||
#include "imports/avs.h"
|
||||
|
||||
#include "module/io-ext.h"
|
||||
#include "module/io.h"
|
||||
|
||||
#include "sdk/module/core/log.h"
|
||||
#include "sdk/module/core/thread.h"
|
||||
#include "sdk/module/hook.h"
|
||||
|
||||
#include "security/rp-sign-key.h"
|
||||
|
||||
#define IIDXHOOK4_CN_INFO_HEADER \
|
||||
@@ -56,30 +55,13 @@
|
||||
#define IIDXHOOK4_CN_CMD_USAGE \
|
||||
"Usage: inject.exe iidxhook4-cn.dll <bm2dx.exe> [options...]"
|
||||
|
||||
static HANDLE STDCALL my_OpenProcess(DWORD, BOOL, DWORD);
|
||||
static HANDLE(STDCALL *real_OpenProcess)(DWORD, BOOL, DWORD);
|
||||
static bool iidxhook_init_check;
|
||||
|
||||
static const hook_d3d9_irp_handler_t iidxhook_d3d9_handlers[] = {
|
||||
iidxhook_util_d3d9_irp_handler,
|
||||
};
|
||||
|
||||
static const struct hook_symbol init_hook_syms[] = {
|
||||
{.name = "OpenProcess",
|
||||
.patch = my_OpenProcess,
|
||||
.link = (void **) &real_OpenProcess},
|
||||
};
|
||||
|
||||
static struct iidxhook_config_io config_io;
|
||||
static module_io_t *iidxhook_module_io_iidx;
|
||||
|
||||
static void _iidxhook4_cn_log_init()
|
||||
{
|
||||
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_io_iidx_init(module_io_t **module)
|
||||
{
|
||||
bt_io_iidx_api_t api;
|
||||
@@ -137,12 +119,8 @@ iidxhook4_cn_setup_d3d9_hooks(const struct iidxhook_config_gfx *config_gfx)
|
||||
hook_d3d9_init(iidxhook_d3d9_handlers, lengthof(iidxhook_d3d9_handlers));
|
||||
}
|
||||
|
||||
/**
|
||||
* This seems to be a good entry point to intercept
|
||||
* before the game calls anything important
|
||||
*/
|
||||
static HANDLE STDCALL
|
||||
my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
|
||||
static bool
|
||||
_iidxhook4_cn_main_init(HMODULE game_module, const bt_core_config_t *config_)
|
||||
{
|
||||
struct cconfig *config;
|
||||
|
||||
@@ -151,12 +129,6 @@ my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
|
||||
struct iidxhook_config_sec config_sec;
|
||||
struct iidxhook_config_misc config_misc;
|
||||
|
||||
if (iidxhook_init_check) {
|
||||
return real_OpenProcess(dwDesiredAccess, bInheritHandle, dwProcessId);
|
||||
}
|
||||
|
||||
iidxhook_init_check = true;
|
||||
|
||||
log_info("-------------------------------------------------------------");
|
||||
log_info("--------------- Begin iidxhook my_OpenProcess ---------------");
|
||||
log_info("-------------------------------------------------------------");
|
||||
@@ -188,6 +160,11 @@ my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
|
||||
log_info(IIDXHOOK4_CN_INFO_HEADER);
|
||||
log_info("Initializing iidxhook...");
|
||||
|
||||
iidxhook4_cn_path_init();
|
||||
iidxhook4_cn_avs_boot_init();
|
||||
acp_hook_init();
|
||||
settings_hook_init();
|
||||
|
||||
/**
|
||||
* This game is using a black round plug for game license management instead
|
||||
* of a black usb dongle. No white dongle hooks applies since the game does
|
||||
@@ -236,7 +213,30 @@ my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
|
||||
log_info("---------------- End iidxhook my_OpenProcess ----------------");
|
||||
log_info("-------------------------------------------------------------");
|
||||
|
||||
return real_OpenProcess(dwDesiredAccess, bInheritHandle, dwProcessId);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void _iidxhook4_cn_main_fini()
|
||||
{
|
||||
// TODO cleanup initialized stuff
|
||||
}
|
||||
|
||||
void bt_module_core_log_api_set(const bt_core_log_api_t *api)
|
||||
{
|
||||
bt_core_log_api_set(api);
|
||||
}
|
||||
|
||||
void bt_module_core_thread_api_set(const bt_core_thread_api_t *api)
|
||||
{
|
||||
bt_core_thread_api_set(api);
|
||||
}
|
||||
|
||||
void bt_module_hook_api_get(bt_hook_api_t *api)
|
||||
{
|
||||
api->version = 1;
|
||||
|
||||
api->v1.main_init = _iidxhook4_cn_main_init;
|
||||
api->v1.main_fini = _iidxhook4_cn_main_fini;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -244,28 +244,5 @@ my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
|
||||
*/
|
||||
BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
|
||||
{
|
||||
if (reason != DLL_PROCESS_ATTACH) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
core_boot_dll("iidxhook4-cn");
|
||||
|
||||
// Use bemanitools core APIs
|
||||
core_log_bt_core_api_set();
|
||||
|
||||
// Use AVS APIs
|
||||
avs_ext_thread_core_api_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));
|
||||
|
||||
iidxhook4_cn_path_init();
|
||||
iidxhook4_cn_avs_boot_init();
|
||||
acp_hook_init();
|
||||
settings_hook_init();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -2,3 +2,8 @@ LIBRARY iidxhook4-cn
|
||||
|
||||
EXPORTS
|
||||
DllMain@12 @1 NONAME
|
||||
|
||||
; Bemanitools 6 API
|
||||
bt_module_core_log_api_set
|
||||
bt_module_core_thread_api_set
|
||||
bt_module_hook_api_get
|
||||
@@ -5,13 +5,8 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "avs-ext/log.h"
|
||||
#include "avs-ext/thread.h"
|
||||
|
||||
#include "cconfig/cconfig-hook.h"
|
||||
|
||||
#include "core/boot.h"
|
||||
|
||||
#include "ezusb-iidx-emu/nodes.h"
|
||||
|
||||
#include "ezusb2-emu/desc.h"
|
||||
@@ -23,7 +18,6 @@
|
||||
|
||||
#include "hooklib/acp.h"
|
||||
#include "hooklib/adapter.h"
|
||||
#include "hooklib/app.h"
|
||||
#include "hooklib/rs232.h"
|
||||
#include "hooklib/setupapi.h"
|
||||
|
||||
@@ -39,14 +33,15 @@
|
||||
#include "iidxhook-util/config-io.h"
|
||||
#include "iidxhook-util/config-misc.h"
|
||||
#include "iidxhook-util/d3d9.h"
|
||||
#include "iidxhook-util/log-server.h"
|
||||
#include "iidxhook-util/settings.h"
|
||||
|
||||
#include "imports/avs.h"
|
||||
|
||||
#include "module/io-ext.h"
|
||||
#include "module/io.h"
|
||||
|
||||
#include "sdk/module/core/log.h"
|
||||
#include "sdk/module/core/thread.h"
|
||||
#include "sdk/module/hook.h"
|
||||
|
||||
#include "util/str.h"
|
||||
|
||||
#define IIDXHOOK4_INFO_HEADER \
|
||||
@@ -128,14 +123,14 @@ iidxhook4_setup_d3d9_hooks(const struct iidxhook_config_gfx *config_gfx)
|
||||
hook_d3d9_init(iidxhook_d3d9_handlers, lengthof(iidxhook_d3d9_handlers));
|
||||
}
|
||||
|
||||
static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
static bool
|
||||
_iidxhook4_main_init(HMODULE game_module, const bt_core_config_t *config_)
|
||||
{
|
||||
struct cconfig *config;
|
||||
|
||||
struct iidxhook_config_gfx config_gfx;
|
||||
struct iidxhook_config_misc config_misc;
|
||||
|
||||
log_server_init();
|
||||
log_info("-------------------------------------------------------------");
|
||||
log_info("--------------- Begin iidxhook dll_entry_init ---------------");
|
||||
log_info("-------------------------------------------------------------");
|
||||
@@ -151,7 +146,7 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
IIDXHOOK4_INFO_HEADER "\n" IIDXHOOK4_CMD_USAGE,
|
||||
CCONFIG_CMD_USAGE_OUT_DBG)) {
|
||||
cconfig_finit(config);
|
||||
log_server_fini();
|
||||
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -164,6 +159,10 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
log_info(IIDXHOOK4_INFO_HEADER);
|
||||
log_info("Initializing iidxhook...");
|
||||
|
||||
acp_hook_init();
|
||||
adapter_hook_init();
|
||||
settings_hook_init();
|
||||
|
||||
iidxhook4_setup_d3d9_hooks(&config_gfx);
|
||||
|
||||
if (strlen(config_misc.settings_path) > 0) {
|
||||
@@ -219,15 +218,11 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
log_info("---------------- End iidxhook dll_entry_init ----------------");
|
||||
log_info("-------------------------------------------------------------");
|
||||
|
||||
return app_hook_invoke_init(sidcode, param);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool my_dll_entry_main(void)
|
||||
static void _iidxhook4_main_fini()
|
||||
{
|
||||
bool result;
|
||||
|
||||
result = app_hook_invoke_main();
|
||||
|
||||
iidxhook_util_chart_patch_fini();
|
||||
|
||||
if (!config_io.disable_card_reader_emu) {
|
||||
@@ -245,10 +240,24 @@ static bool my_dll_entry_main(void)
|
||||
bt_io_iidx_api_clear();
|
||||
module_io_free(&iidxhook_module_io_iidx);
|
||||
}
|
||||
}
|
||||
|
||||
log_server_fini();
|
||||
void bt_module_core_log_api_set(const bt_core_log_api_t *api)
|
||||
{
|
||||
bt_core_log_api_set(api);
|
||||
}
|
||||
|
||||
return result;
|
||||
void bt_module_core_thread_api_set(const bt_core_thread_api_t *api)
|
||||
{
|
||||
bt_core_thread_api_set(api);
|
||||
}
|
||||
|
||||
void bt_module_hook_api_get(bt_hook_api_t *api)
|
||||
{
|
||||
api->version = 1;
|
||||
|
||||
api->v1.main_init = _iidxhook4_main_init;
|
||||
api->v1.main_fini = _iidxhook4_main_fini;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,22 +265,5 @@ static bool my_dll_entry_main(void)
|
||||
*/
|
||||
BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
|
||||
{
|
||||
if (reason != DLL_PROCESS_ATTACH) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
core_boot("iidxhook4");
|
||||
|
||||
// Use AVS APIs
|
||||
avs_ext_log_core_api_set();
|
||||
avs_ext_thread_core_api_set();
|
||||
|
||||
app_hook_init(my_dll_entry_init, my_dll_entry_main);
|
||||
|
||||
acp_hook_init();
|
||||
adapter_hook_init();
|
||||
settings_hook_init();
|
||||
|
||||
end:
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -2,4 +2,8 @@ LIBRARY iidxhook4
|
||||
|
||||
EXPORTS
|
||||
DllMain@12 @1 NONAME
|
||||
|
||||
|
||||
; Bemanitools 6 API
|
||||
bt_module_core_log_api_set
|
||||
bt_module_core_thread_api_set
|
||||
bt_module_hook_api_get
|
||||
@@ -5,15 +5,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "avs-ext/thread.h"
|
||||
|
||||
#include "cconfig/cconfig-hook.h"
|
||||
|
||||
#include "core/boot.h"
|
||||
#include "core/log-bt-ext.h"
|
||||
#include "core/log-bt.h"
|
||||
#include "core/log-sink-debug.h"
|
||||
|
||||
#include "ezusb-emu/node-security-plug.h"
|
||||
|
||||
#include "ezusb2-emu/desc.h"
|
||||
@@ -43,11 +36,13 @@
|
||||
#include "iidxhook-util/d3d9.h"
|
||||
#include "iidxhook-util/settings.h"
|
||||
|
||||
#include "imports/avs.h"
|
||||
|
||||
#include "module/io-ext.h"
|
||||
#include "module/io.h"
|
||||
|
||||
#include "sdk/module/core/log.h"
|
||||
#include "sdk/module/core/thread.h"
|
||||
#include "sdk/module/hook.h"
|
||||
|
||||
#include "security/rp-sign-key.h"
|
||||
|
||||
#define IIDXHOOK5_CN_INFO_HEADER \
|
||||
@@ -56,30 +51,13 @@
|
||||
#define IIDXHOOK5_CN_CMD_USAGE \
|
||||
"Usage: inject.exe iidxhook5-cn.dll <bm2dx.exe> [options...]"
|
||||
|
||||
static ATOM WINAPI my_RegisterClassA(const WNDCLASSA *lpWndClass);
|
||||
static ATOM(WINAPI *real_RegisterClassA)(const WNDCLASSA *lpWndClass);
|
||||
static bool iidxhook_init_check;
|
||||
|
||||
static const hook_d3d9_irp_handler_t iidxhook_d3d9_handlers[] = {
|
||||
iidxhook_util_d3d9_irp_handler,
|
||||
};
|
||||
|
||||
static const struct hook_symbol init_hook_user32_syms[] = {
|
||||
{.name = "RegisterClassA",
|
||||
.patch = my_RegisterClassA,
|
||||
.link = (void **) &real_RegisterClassA},
|
||||
};
|
||||
|
||||
static struct iidxhook_config_io config_io;
|
||||
static module_io_t *iidxhook_module_io_iidx;
|
||||
|
||||
static void _iidxhook5_cn_log_init()
|
||||
{
|
||||
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_io_iidx_init(module_io_t **module)
|
||||
{
|
||||
bt_io_iidx_api_t api;
|
||||
@@ -118,11 +96,8 @@ iidxhook5_cn_setup_d3d9_hooks(const struct iidxhook_config_gfx *config_gfx)
|
||||
hook_d3d9_init(iidxhook_d3d9_handlers, lengthof(iidxhook_d3d9_handlers));
|
||||
}
|
||||
|
||||
/**
|
||||
* OpenProcess is basically used for hooks in exe games,
|
||||
* but since it does not exist in this game, RegisterClassA is used instead.
|
||||
*/
|
||||
static ATOM WINAPI my_RegisterClassA(const WNDCLASSA *lpWndClass)
|
||||
static bool
|
||||
_iidxhook5_cn_main_init(HMODULE game_module, const bt_core_config_t *config_)
|
||||
{
|
||||
struct cconfig *config;
|
||||
|
||||
@@ -131,12 +106,6 @@ static ATOM WINAPI my_RegisterClassA(const WNDCLASSA *lpWndClass)
|
||||
struct iidxhook_config_sec config_sec;
|
||||
struct iidxhook_config_misc config_misc;
|
||||
|
||||
if (iidxhook_init_check) {
|
||||
return real_RegisterClassA(lpWndClass);
|
||||
}
|
||||
|
||||
iidxhook_init_check = true;
|
||||
|
||||
log_info("-------------------------------------------------------------");
|
||||
log_info("------------- Begin iidxhook my_RegisterClassA --------------");
|
||||
log_info("-------------------------------------------------------------");
|
||||
@@ -168,6 +137,11 @@ static ATOM WINAPI my_RegisterClassA(const WNDCLASSA *lpWndClass)
|
||||
log_info(IIDXHOOK5_CN_INFO_HEADER);
|
||||
log_info("Initializing iidxhook...");
|
||||
|
||||
iidxhook5_cn_path_init();
|
||||
iidxhook5_cn_avs_boot_init();
|
||||
acp_hook_init();
|
||||
settings_hook_init();
|
||||
|
||||
/**
|
||||
* This game is using a black round plug for game license management instead
|
||||
* of a black usb dongle. No white dongle hooks applies since the game does
|
||||
@@ -215,7 +189,30 @@ static ATOM WINAPI my_RegisterClassA(const WNDCLASSA *lpWndClass)
|
||||
log_info("-------------- End iidxhook my_RegisterClassA ---------------");
|
||||
log_info("-------------------------------------------------------------");
|
||||
|
||||
return real_RegisterClassA(lpWndClass);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void _iidxhook5_cn_main_fini()
|
||||
{
|
||||
// TODO cleanup
|
||||
}
|
||||
|
||||
void bt_module_core_log_api_set(const bt_core_log_api_t *api)
|
||||
{
|
||||
bt_core_log_api_set(api);
|
||||
}
|
||||
|
||||
void bt_module_core_thread_api_set(const bt_core_thread_api_t *api)
|
||||
{
|
||||
bt_core_thread_api_set(api);
|
||||
}
|
||||
|
||||
void bt_module_hook_api_get(bt_hook_api_t *api)
|
||||
{
|
||||
api->version = 1;
|
||||
|
||||
api->v1.main_init = _iidxhook5_cn_main_init;
|
||||
api->v1.main_fini = _iidxhook5_cn_main_fini;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -223,31 +220,5 @@ static ATOM WINAPI my_RegisterClassA(const WNDCLASSA *lpWndClass)
|
||||
*/
|
||||
BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
|
||||
{
|
||||
if (reason != DLL_PROCESS_ATTACH) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
core_boot_dll("iidxhook5-cn");
|
||||
|
||||
// Use bemanitools core APIs
|
||||
core_log_bt_core_api_set();
|
||||
|
||||
// Use AVS APIs
|
||||
avs_ext_thread_core_api_set();
|
||||
|
||||
// TODO init debug logging but with avs available? why not use avs logging?
|
||||
_iidxhook5_cn_log_init();
|
||||
|
||||
hook_table_apply(
|
||||
NULL,
|
||||
"user32.dll",
|
||||
init_hook_user32_syms,
|
||||
lengthof(init_hook_user32_syms));
|
||||
|
||||
iidxhook5_cn_path_init();
|
||||
iidxhook5_cn_avs_boot_init();
|
||||
acp_hook_init();
|
||||
settings_hook_init();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -2,3 +2,8 @@ LIBRARY iidxhook5-cn
|
||||
|
||||
EXPORTS
|
||||
DllMain@12 @1 NONAME
|
||||
|
||||
; Bemanitools 6 API
|
||||
bt_module_core_log_api_set
|
||||
bt_module_core_thread_api_set
|
||||
bt_module_hook_api_get
|
||||
@@ -5,13 +5,8 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "avs-ext/log.h"
|
||||
#include "avs-ext/thread.h"
|
||||
|
||||
#include "cconfig/cconfig-hook.h"
|
||||
|
||||
#include "core/boot.h"
|
||||
|
||||
#include "ezusb-iidx-emu/nodes.h"
|
||||
|
||||
#include "ezusb2-emu/desc.h"
|
||||
@@ -23,7 +18,6 @@
|
||||
|
||||
#include "hooklib/acp.h"
|
||||
#include "hooklib/adapter.h"
|
||||
#include "hooklib/app.h"
|
||||
#include "hooklib/rs232.h"
|
||||
#include "hooklib/setupapi.h"
|
||||
|
||||
@@ -39,14 +33,15 @@
|
||||
#include "iidxhook-util/config-io.h"
|
||||
#include "iidxhook-util/config-misc.h"
|
||||
#include "iidxhook-util/d3d9.h"
|
||||
#include "iidxhook-util/log-server.h"
|
||||
#include "iidxhook-util/settings.h"
|
||||
|
||||
#include "imports/avs.h"
|
||||
|
||||
#include "module/io-ext.h"
|
||||
#include "module/io.h"
|
||||
|
||||
#include "sdk/module/core/log.h"
|
||||
#include "sdk/module/core/thread.h"
|
||||
#include "sdk/module/hook.h"
|
||||
|
||||
#include "util/str.h"
|
||||
|
||||
#include "ifs-snd-redir.h"
|
||||
@@ -130,14 +125,14 @@ iidxhook5_setup_d3d9_hooks(const struct iidxhook_config_gfx *config_gfx)
|
||||
hook_d3d9_init(iidxhook_d3d9_handlers, lengthof(iidxhook_d3d9_handlers));
|
||||
}
|
||||
|
||||
static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
static bool
|
||||
_iidxhook5_main_init(HMODULE game_module, const bt_core_config_t *config_)
|
||||
{
|
||||
struct cconfig *config;
|
||||
|
||||
struct iidxhook_config_gfx config_gfx;
|
||||
struct iidxhook_config_misc config_misc;
|
||||
|
||||
log_server_init();
|
||||
log_info("-------------------------------------------------------------");
|
||||
log_info("--------------- Begin iidxhook dll_entry_init ---------------");
|
||||
log_info("-------------------------------------------------------------");
|
||||
@@ -153,7 +148,7 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
IIDXHOOK5_INFO_HEADER "\n" IIDXHOOK5_CMD_USAGE,
|
||||
CCONFIG_CMD_USAGE_OUT_DBG)) {
|
||||
cconfig_finit(config);
|
||||
log_server_fini();
|
||||
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -166,6 +161,10 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
log_info(IIDXHOOK5_INFO_HEADER);
|
||||
log_info("Initializing iidxhook...");
|
||||
|
||||
acp_hook_init();
|
||||
adapter_hook_init();
|
||||
settings_hook_init();
|
||||
|
||||
iidxhook5_setup_d3d9_hooks(&config_gfx);
|
||||
|
||||
if (strlen(config_misc.settings_path) > 0) {
|
||||
@@ -222,15 +221,11 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
log_info("---------------- End iidxhook dll_entry_init ----------------");
|
||||
log_info("-------------------------------------------------------------");
|
||||
|
||||
return app_hook_invoke_init(sidcode, param);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool my_dll_entry_main(void)
|
||||
static void _iidxhook5_main_fini()
|
||||
{
|
||||
bool result;
|
||||
|
||||
result = app_hook_invoke_main();
|
||||
|
||||
if (!config_io.disable_card_reader_emu) {
|
||||
log_misc("Shutting down card reader backend");
|
||||
bt_io_eam_fini();
|
||||
@@ -246,10 +241,24 @@ static bool my_dll_entry_main(void)
|
||||
bt_io_iidx_api_clear();
|
||||
module_io_free(&iidxhook_module_io_iidx);
|
||||
}
|
||||
}
|
||||
|
||||
log_server_fini();
|
||||
void bt_module_core_log_api_set(const bt_core_log_api_t *api)
|
||||
{
|
||||
bt_core_log_api_set(api);
|
||||
}
|
||||
|
||||
return result;
|
||||
void bt_module_core_thread_api_set(const bt_core_thread_api_t *api)
|
||||
{
|
||||
bt_core_thread_api_set(api);
|
||||
}
|
||||
|
||||
void bt_module_hook_api_get(bt_hook_api_t *api)
|
||||
{
|
||||
api->version = 1;
|
||||
|
||||
api->v1.main_init = _iidxhook5_main_init;
|
||||
api->v1.main_fini = _iidxhook5_main_fini;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -257,22 +266,5 @@ static bool my_dll_entry_main(void)
|
||||
*/
|
||||
BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
|
||||
{
|
||||
if (reason != DLL_PROCESS_ATTACH) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
core_boot("iidxhook5");
|
||||
|
||||
// Use AVS APIs
|
||||
avs_ext_log_core_api_set();
|
||||
avs_ext_thread_core_api_set();
|
||||
|
||||
app_hook_init(my_dll_entry_init, my_dll_entry_main);
|
||||
|
||||
acp_hook_init();
|
||||
adapter_hook_init();
|
||||
settings_hook_init();
|
||||
|
||||
end:
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -2,4 +2,8 @@ LIBRARY iidxhook5
|
||||
|
||||
EXPORTS
|
||||
DllMain@12 @1 NONAME
|
||||
|
||||
|
||||
; Bemanitools 6 API
|
||||
bt_module_core_log_api_set
|
||||
bt_module_core_thread_api_set
|
||||
bt_module_hook_api_get
|
||||
@@ -5,13 +5,8 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "avs-ext/log.h"
|
||||
#include "avs-ext/thread.h"
|
||||
|
||||
#include "cconfig/cconfig-hook.h"
|
||||
|
||||
#include "core/boot.h"
|
||||
|
||||
#include "ezusb-iidx-emu/nodes.h"
|
||||
|
||||
#include "ezusb2-emu/desc.h"
|
||||
@@ -38,11 +33,12 @@
|
||||
#include "iidxhook-util/config-gfx.h"
|
||||
#include "iidxhook-util/config-io.h"
|
||||
#include "iidxhook-util/d3d9.h"
|
||||
#include "iidxhook-util/log-server.h"
|
||||
|
||||
#include "module/io-ext.h"
|
||||
#include "module/io.h"
|
||||
|
||||
#include "sdk/module/core/log.h"
|
||||
#include "sdk/module/core/thread.h"
|
||||
#include "sdk/module/hook.h"
|
||||
|
||||
#include "util/str.h"
|
||||
@@ -116,10 +112,6 @@ iidxhook6_setup_d3d9_hooks(const struct iidxhook_config_gfx *config_gfx)
|
||||
static bool
|
||||
_iidxhook6_main_init(HMODULE game_module, const bt_core_config_t *config_)
|
||||
{
|
||||
// Use AVS APIs
|
||||
avs_ext_log_core_api_set();
|
||||
avs_ext_thread_core_api_set();
|
||||
|
||||
struct cconfig *config;
|
||||
|
||||
struct iidxhook_config_gfx config_gfx;
|
||||
@@ -146,8 +138,6 @@ _iidxhook6_main_init(HMODULE game_module, const bt_core_config_t *config_)
|
||||
|
||||
log_info(IIDXHOOK6_INFO_HEADER);
|
||||
|
||||
log_server_init();
|
||||
|
||||
acp_hook_init();
|
||||
adapter_hook_init();
|
||||
|
||||
@@ -217,8 +207,16 @@ static void _iidxhook6_main_fini()
|
||||
bt_io_iidx_api_clear();
|
||||
module_io_free(&iidxhook_module_io_iidx);
|
||||
}
|
||||
}
|
||||
|
||||
log_server_fini();
|
||||
void bt_module_core_log_api_set(const bt_core_log_api_t *api)
|
||||
{
|
||||
bt_core_log_api_set(api);
|
||||
}
|
||||
|
||||
void bt_module_core_thread_api_set(const bt_core_thread_api_t *api)
|
||||
{
|
||||
bt_core_thread_api_set(api);
|
||||
}
|
||||
|
||||
void bt_module_hook_api_get(bt_hook_api_t *api)
|
||||
|
||||
@@ -4,4 +4,6 @@ EXPORTS
|
||||
DllMain@12 @1 NONAME
|
||||
|
||||
; Bemanitools 6 API
|
||||
bt_module_core_log_api_set
|
||||
bt_module_core_thread_api_set
|
||||
bt_module_hook_api_get
|
||||
@@ -5,13 +5,8 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "avs-ext/log.h"
|
||||
#include "avs-ext/thread.h"
|
||||
|
||||
#include "cconfig/cconfig-hook.h"
|
||||
|
||||
#include "core/boot.h"
|
||||
|
||||
#include "ezusb-iidx-emu/nodes.h"
|
||||
|
||||
#include "ezusb2-emu/desc.h"
|
||||
@@ -23,7 +18,6 @@
|
||||
|
||||
#include "hooklib/acp.h"
|
||||
#include "hooklib/adapter.h"
|
||||
#include "hooklib/app.h"
|
||||
#include "hooklib/rs232.h"
|
||||
#include "hooklib/setupapi.h"
|
||||
|
||||
@@ -39,13 +33,14 @@
|
||||
#include "iidxhook-util/config-gfx.h"
|
||||
#include "iidxhook-util/config-io.h"
|
||||
#include "iidxhook-util/d3d9.h"
|
||||
#include "iidxhook-util/log-server.h"
|
||||
|
||||
#include "imports/avs.h"
|
||||
|
||||
#include "module/io-ext.h"
|
||||
#include "module/io.h"
|
||||
|
||||
#include "sdk/module/core/log.h"
|
||||
#include "sdk/module/core/thread.h"
|
||||
#include "sdk/module/hook.h"
|
||||
|
||||
#include "util/str.h"
|
||||
|
||||
#define IIDXHOOK7_INFO_HEADER \
|
||||
@@ -114,13 +109,13 @@ iidxhook7_setup_d3d9_hooks(const struct iidxhook_config_gfx *config_gfx)
|
||||
hook_d3d9_init(iidxhook_d3d9_handlers, lengthof(iidxhook_d3d9_handlers));
|
||||
}
|
||||
|
||||
static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
static bool
|
||||
_iidxhook7_main_init(HMODULE game_module, const bt_core_config_t *config_)
|
||||
{
|
||||
struct cconfig *config;
|
||||
|
||||
struct iidxhook_config_gfx config_gfx;
|
||||
|
||||
log_server_init();
|
||||
log_info("-------------------------------------------------------------");
|
||||
log_info("--------------- Begin iidxhook dll_entry_init ---------------");
|
||||
log_info("-------------------------------------------------------------");
|
||||
@@ -135,7 +130,7 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
IIDXHOOK7_INFO_HEADER "\n" IIDXHOOK7_CMD_USAGE,
|
||||
CCONFIG_CMD_USAGE_OUT_DBG)) {
|
||||
cconfig_finit(config);
|
||||
log_server_fini();
|
||||
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -147,6 +142,9 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
log_info(IIDXHOOK7_INFO_HEADER);
|
||||
log_info("Initializing iidxhook...");
|
||||
|
||||
acp_hook_init();
|
||||
adapter_hook_init();
|
||||
|
||||
iidxhook7_setup_d3d9_hooks(&config_gfx);
|
||||
|
||||
if (!config_io.disable_io_emu) {
|
||||
@@ -197,15 +195,11 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
log_info("---------------- End iidxhook dll_entry_init ----------------");
|
||||
log_info("-------------------------------------------------------------");
|
||||
|
||||
return app_hook_invoke_init(sidcode, param);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool my_dll_entry_main(void)
|
||||
static void _iidxhook7_main_fini()
|
||||
{
|
||||
bool result;
|
||||
|
||||
result = app_hook_invoke_main();
|
||||
|
||||
if (!config_io.disable_card_reader_emu) {
|
||||
log_misc("Shutting down card reader backend");
|
||||
bt_io_eam_fini();
|
||||
@@ -221,10 +215,24 @@ static bool my_dll_entry_main(void)
|
||||
bt_io_iidx_api_clear();
|
||||
module_io_free(&iidxhook_module_io_iidx);
|
||||
}
|
||||
}
|
||||
|
||||
log_server_fini();
|
||||
void bt_module_core_log_api_set(const bt_core_log_api_t *api)
|
||||
{
|
||||
bt_core_log_api_set(api);
|
||||
}
|
||||
|
||||
return result;
|
||||
void bt_module_core_thread_api_set(const bt_core_thread_api_t *api)
|
||||
{
|
||||
bt_core_thread_api_set(api);
|
||||
}
|
||||
|
||||
void bt_module_hook_api_get(bt_hook_api_t *api)
|
||||
{
|
||||
api->version = 1;
|
||||
|
||||
api->v1.main_init = _iidxhook7_main_init;
|
||||
api->v1.main_fini = _iidxhook7_main_fini;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -232,21 +240,5 @@ static bool my_dll_entry_main(void)
|
||||
*/
|
||||
BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
|
||||
{
|
||||
if (reason != DLL_PROCESS_ATTACH) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
core_boot("iidxhook7");
|
||||
|
||||
// Use AVS APIs
|
||||
avs_ext_log_core_api_set();
|
||||
avs_ext_thread_core_api_set();
|
||||
|
||||
app_hook_init(my_dll_entry_init, my_dll_entry_main);
|
||||
|
||||
acp_hook_init();
|
||||
adapter_hook_init();
|
||||
|
||||
end:
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -2,3 +2,8 @@ LIBRARY iidxhook7
|
||||
|
||||
EXPORTS
|
||||
DllMain@12 @1 NONAME
|
||||
|
||||
; Bemanitools 6 API
|
||||
bt_module_core_log_api_set
|
||||
bt_module_core_thread_api_set
|
||||
bt_module_hook_api_get
|
||||
@@ -5,18 +5,12 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "avs-ext/log.h"
|
||||
#include "avs-ext/thread.h"
|
||||
|
||||
#include "cconfig/cconfig-hook.h"
|
||||
|
||||
#include "core/boot.h"
|
||||
|
||||
#include "hook/d3d9.h"
|
||||
|
||||
#include "hooklib/acp.h"
|
||||
#include "hooklib/adapter.h"
|
||||
#include "hooklib/app.h"
|
||||
#include "hooklib/rs232.h"
|
||||
#include "hooklib/setupapi.h"
|
||||
|
||||
@@ -31,7 +25,6 @@
|
||||
#include "iidxhook-util/acio.h"
|
||||
#include "iidxhook-util/config-gfx.h"
|
||||
#include "iidxhook-util/d3d9.h"
|
||||
#include "iidxhook-util/log-server.h"
|
||||
|
||||
#include "bio2emu-iidx/bi2a.h"
|
||||
#include "bio2emu/emu.h"
|
||||
@@ -40,11 +33,13 @@
|
||||
#include "camhook/config-cam.h"
|
||||
#include "iidxhook8/config-io.h"
|
||||
|
||||
#include "imports/avs.h"
|
||||
|
||||
#include "module/io-ext.h"
|
||||
#include "module/io.h"
|
||||
|
||||
#include "sdk/module/core/log.h"
|
||||
#include "sdk/module/core/thread.h"
|
||||
#include "sdk/module/hook.h"
|
||||
|
||||
#include "util/str.h"
|
||||
|
||||
#define IIDXHOOK8_INFO_HEADER \
|
||||
@@ -121,15 +116,13 @@ static struct bio2emu_port bio2_emu = {
|
||||
.dispatcher = bio2_emu_bi2a_dispatch_request,
|
||||
};
|
||||
|
||||
static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
static bool
|
||||
_iidxhook8_main_init(HMODULE game_module, const bt_core_config_t *config_)
|
||||
{
|
||||
struct cconfig *config;
|
||||
|
||||
struct iidxhook_config_gfx config_gfx;
|
||||
|
||||
// log_server_init is required due to IO occuring in a non avs_thread
|
||||
log_server_init();
|
||||
|
||||
log_info("-------------------------------------------------------------");
|
||||
log_info("--------------- Begin iidxhook dll_entry_init ---------------");
|
||||
log_info("-------------------------------------------------------------");
|
||||
@@ -145,7 +138,7 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
IIDXHOOK8_INFO_HEADER "\n" IIDXHOOK8_CMD_USAGE,
|
||||
CCONFIG_CMD_USAGE_OUT_DBG)) {
|
||||
cconfig_finit(config);
|
||||
log_server_fini();
|
||||
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -158,6 +151,9 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
log_info(IIDXHOOK8_INFO_HEADER);
|
||||
log_info("Initializing iidxhook...");
|
||||
|
||||
acp_hook_init();
|
||||
adapter_hook_init();
|
||||
|
||||
iidxhook8_setup_d3d9_hooks(&config_gfx);
|
||||
|
||||
/* Start up IIDXIO.DLL */
|
||||
@@ -210,15 +206,11 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
log_info("---------------- End iidxhook dll_entry_init ----------------");
|
||||
log_info("-------------------------------------------------------------");
|
||||
|
||||
return app_hook_invoke_init(sidcode, param);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool my_dll_entry_main(void)
|
||||
static void _iidxhook8_main_fini()
|
||||
{
|
||||
bool result;
|
||||
|
||||
result = app_hook_invoke_main();
|
||||
|
||||
if (!config_cam.disable_emu) {
|
||||
camhook_fini();
|
||||
}
|
||||
@@ -238,10 +230,24 @@ static bool my_dll_entry_main(void)
|
||||
bt_io_iidx_api_clear();
|
||||
module_io_free(&iidxhook_module_io_iidx);
|
||||
}
|
||||
}
|
||||
|
||||
log_server_fini();
|
||||
void bt_module_core_log_api_set(const bt_core_log_api_t *api)
|
||||
{
|
||||
bt_core_log_api_set(api);
|
||||
}
|
||||
|
||||
return result;
|
||||
void bt_module_core_thread_api_set(const bt_core_thread_api_t *api)
|
||||
{
|
||||
bt_core_thread_api_set(api);
|
||||
}
|
||||
|
||||
void bt_module_hook_api_get(bt_hook_api_t *api)
|
||||
{
|
||||
api->version = 1;
|
||||
|
||||
api->v1.main_init = _iidxhook8_main_init;
|
||||
api->v1.main_fini = _iidxhook8_main_fini;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -249,21 +255,5 @@ static bool my_dll_entry_main(void)
|
||||
*/
|
||||
BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
|
||||
{
|
||||
if (reason != DLL_PROCESS_ATTACH) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
core_boot("iidxhook8");
|
||||
|
||||
// Use AVS APIs
|
||||
avs_ext_log_core_api_set();
|
||||
avs_ext_thread_core_api_set();
|
||||
|
||||
app_hook_init(my_dll_entry_init, my_dll_entry_main);
|
||||
|
||||
acp_hook_init();
|
||||
adapter_hook_init();
|
||||
|
||||
end:
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -2,3 +2,8 @@ LIBRARY iidxhook8
|
||||
|
||||
EXPORTS
|
||||
DllMain@12 @1 NONAME
|
||||
|
||||
; Bemanitools 6 API
|
||||
bt_module_core_log_api_set
|
||||
bt_module_core_thread_api_set
|
||||
bt_module_hook_api_get
|
||||
@@ -5,19 +5,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "avs-ext/log.h"
|
||||
#include "avs-ext/thread.h"
|
||||
|
||||
#include "cconfig/cconfig-hook.h"
|
||||
|
||||
#include "core/boot.h"
|
||||
|
||||
#include "core/log-bt-ext.h"
|
||||
#include "core/log-bt.h"
|
||||
|
||||
#include "hooklib/acp.h"
|
||||
#include "hooklib/adapter.h"
|
||||
#include "hooklib/app.h"
|
||||
#include "hooklib/config-adapter.h"
|
||||
#include "hooklib/memfile.h"
|
||||
#include "hooklib/rs232.h"
|
||||
@@ -30,7 +21,6 @@
|
||||
#include "iface-io/iidx.h"
|
||||
|
||||
#include "iidxhook-util/acio.h"
|
||||
#include "iidxhook-util/log-server.h"
|
||||
|
||||
#include "bio2emu/emu.h"
|
||||
|
||||
@@ -47,11 +37,13 @@
|
||||
#include "d3d9exhook/d3d9ex.h"
|
||||
#include "dinput/dinput.h"
|
||||
|
||||
#include "imports/avs.h"
|
||||
|
||||
#include "module/io-ext.h"
|
||||
#include "module/io.h"
|
||||
|
||||
#include "sdk/module/core/log.h"
|
||||
#include "sdk/module/core/thread.h"
|
||||
#include "sdk/module/hook.h"
|
||||
|
||||
#include "util/cmdline.h"
|
||||
#include "util/str.h"
|
||||
|
||||
@@ -131,15 +123,39 @@ static bool load_configs()
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
static bool _iidxhook9_pre_avs_init(const bt_core_config_t *config)
|
||||
{
|
||||
// Use AVS APIs
|
||||
avs_ext_log_core_api_set();
|
||||
avs_ext_thread_core_api_set();
|
||||
log_info("-------------------------------------------------------------");
|
||||
log_info("------------------ Begin iidxhook pre_hook ------------------");
|
||||
log_info("-------------------------------------------------------------");
|
||||
|
||||
// log_server_init is required due to IO occurring in a non avs_thread
|
||||
log_server_init();
|
||||
if (!load_configs()) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// asio hooks
|
||||
if (config_asio.force_asio) {
|
||||
SetEnvironmentVariable("SOUND_OUTPUT_DEVICE", "asio");
|
||||
} else if (config_asio.force_wasapi) {
|
||||
SetEnvironmentVariable("SOUND_OUTPUT_DEVICE", "wasapi");
|
||||
}
|
||||
|
||||
if (iidxhook9_config_io.disable_cams) {
|
||||
// this disables the entire camera subsystem
|
||||
// useful for skipping the camera error entierly
|
||||
SetEnvironmentVariable("CONNECT_CAMERA", "0");
|
||||
}
|
||||
|
||||
log_info("-------------------------------------------------------------");
|
||||
log_info("------------------- End iidxhook pre_hook -------------------");
|
||||
log_info("-------------------------------------------------------------");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
_iidxhook9_main_init(HMODULE game_module, const bt_core_config_t *config_)
|
||||
{
|
||||
log_info("-------------------------------------------------------------");
|
||||
log_info("--------------- Begin iidxhook dll_entry_init ---------------");
|
||||
log_info("-------------------------------------------------------------");
|
||||
@@ -150,7 +166,6 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
// reload configs again so they get logged through avs as well
|
||||
// (so we get a copy of them in the -Y logfile)
|
||||
if (!load_configs()) {
|
||||
log_server_fini();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -240,15 +255,11 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
log_info("---------------- End iidxhook dll_entry_init ----------------");
|
||||
log_info("-------------------------------------------------------------");
|
||||
|
||||
return app_hook_invoke_init(sidcode, param);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool my_dll_entry_main(void)
|
||||
static void _iidxhook9_main_fini()
|
||||
{
|
||||
bool result;
|
||||
|
||||
result = app_hook_invoke_main();
|
||||
|
||||
if (!config_cam.disable_emu) {
|
||||
camhook_fini();
|
||||
}
|
||||
@@ -272,38 +283,25 @@ static bool my_dll_entry_main(void)
|
||||
if (!iidxhook9_config_io.disable_file_hooks) {
|
||||
memfile_hook_fini();
|
||||
}
|
||||
|
||||
log_server_fini();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void pre_hook()
|
||||
void bt_module_core_log_api_set(const bt_core_log_api_t *api)
|
||||
{
|
||||
log_info("-------------------------------------------------------------");
|
||||
log_info("------------------ Begin iidxhook pre_hook ------------------");
|
||||
log_info("-------------------------------------------------------------");
|
||||
bt_core_log_api_set(api);
|
||||
}
|
||||
|
||||
if (!load_configs()) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
void bt_module_core_thread_api_set(const bt_core_thread_api_t *api)
|
||||
{
|
||||
bt_core_thread_api_set(api);
|
||||
}
|
||||
|
||||
// asio hooks
|
||||
if (config_asio.force_asio) {
|
||||
SetEnvironmentVariable("SOUND_OUTPUT_DEVICE", "asio");
|
||||
} else if (config_asio.force_wasapi) {
|
||||
SetEnvironmentVariable("SOUND_OUTPUT_DEVICE", "wasapi");
|
||||
}
|
||||
void bt_module_hook_api_get(bt_hook_api_t *api)
|
||||
{
|
||||
api->version = 1;
|
||||
|
||||
if (iidxhook9_config_io.disable_cams) {
|
||||
// this disables the entire camera subsystem
|
||||
// useful for skipping the camera error entierly
|
||||
SetEnvironmentVariable("CONNECT_CAMERA", "0");
|
||||
}
|
||||
|
||||
log_info("-------------------------------------------------------------");
|
||||
log_info("------------------- End iidxhook pre_hook -------------------");
|
||||
log_info("-------------------------------------------------------------");
|
||||
api->v1.pre_avs_init = _iidxhook9_pre_avs_init;
|
||||
api->v1.main_init = _iidxhook9_main_init;
|
||||
api->v1.main_fini = _iidxhook9_main_fini;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -311,32 +309,5 @@ static void pre_hook()
|
||||
*/
|
||||
BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
|
||||
{
|
||||
if (reason != DLL_PROCESS_ATTACH) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
core_boot("iidxhook9");
|
||||
|
||||
if (avs_is_active()) {
|
||||
// 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
|
||||
avs_ext_log_core_api_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");
|
||||
} else {
|
||||
// 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
|
||||
core_log_bt_ext_init_with_stderr();
|
||||
}
|
||||
|
||||
pre_hook();
|
||||
|
||||
app_hook_init(my_dll_entry_init, my_dll_entry_main);
|
||||
|
||||
end:
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -2,3 +2,8 @@ LIBRARY iidxhook9
|
||||
|
||||
EXPORTS
|
||||
DllMain@12 @1 NONAME
|
||||
|
||||
; Bemanitools 6 API
|
||||
bt_module_core_log_api_set
|
||||
bt_module_core_thread_api_set
|
||||
bt_module_hook_api_get
|
||||
@@ -5,14 +5,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "avs-ext/log.h"
|
||||
#include "avs-ext/thread.h"
|
||||
|
||||
#include "hook/iohook.h"
|
||||
#include "hook/table.h"
|
||||
|
||||
#include "hooklib/adapter.h"
|
||||
#include "hooklib/app.h"
|
||||
#include "hooklib/rs232.h"
|
||||
#include "hooklib/setupapi.h"
|
||||
|
||||
@@ -22,8 +18,6 @@
|
||||
#include "iface-io/eam.h"
|
||||
#include "iface-io/jb.h"
|
||||
|
||||
#include "imports/avs.h"
|
||||
|
||||
#include "jbhook2/options.h"
|
||||
|
||||
#include "jbhook-util/acio.h"
|
||||
@@ -44,12 +38,62 @@
|
||||
#include "security/id.h"
|
||||
#include "security/mcode.h"
|
||||
|
||||
#include "sdk/module/core/log.h"
|
||||
#include "sdk/module/core/thread.h"
|
||||
#include "sdk/module/hook.h"
|
||||
|
||||
#include "util/defs.h"
|
||||
|
||||
static struct options options;
|
||||
static module_io_t *jbhook_module_io_jb;
|
||||
static module_io_t *jbhook_module_io_eam;
|
||||
|
||||
static HWND CDECL
|
||||
my_mwindow_create(HINSTANCE, void *, const char *, DWORD, DWORD, BOOL);
|
||||
static HWND(CDECL *real_mwindow_create)(
|
||||
HINSTANCE, void *, const char *, DWORD, DWORD, BOOL);
|
||||
|
||||
static const struct hook_symbol init_hook_syms[] = {
|
||||
{
|
||||
.name = "mwindow_create",
|
||||
.patch = my_mwindow_create,
|
||||
.link = (void **) &real_mwindow_create,
|
||||
},
|
||||
};
|
||||
|
||||
static HWND CDECL my_mwindow_create(
|
||||
HINSTANCE hinstance,
|
||||
void *callback,
|
||||
const char *window_title,
|
||||
DWORD window_width,
|
||||
DWORD window_height,
|
||||
BOOL fullscreen)
|
||||
{
|
||||
log_info("-------------------------------------------------------------");
|
||||
log_info("---------------- Begin jbhook mwindow_create ----------------");
|
||||
log_info("-------------------------------------------------------------");
|
||||
|
||||
if (options.vertical) {
|
||||
DWORD tmp = window_width;
|
||||
window_width = window_height;
|
||||
window_height = tmp;
|
||||
}
|
||||
|
||||
if (options.show_cursor) {
|
||||
ShowCursor(TRUE);
|
||||
}
|
||||
|
||||
fullscreen = !options.windowed;
|
||||
|
||||
return real_mwindow_create(
|
||||
hinstance,
|
||||
callback,
|
||||
window_title,
|
||||
window_width,
|
||||
window_height,
|
||||
fullscreen);
|
||||
}
|
||||
|
||||
static void _jbhook2_io_jb_init(module_io_t **module)
|
||||
{
|
||||
bt_io_jb_api_t api;
|
||||
@@ -69,7 +113,8 @@ static void _jbhook2_io_eam_init(module_io_t **module)
|
||||
bt_io_eam_api_set(&api);
|
||||
}
|
||||
|
||||
static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
static bool
|
||||
_jbhook2_main_init(HMODULE game_module, const bt_core_config_t *config_)
|
||||
{
|
||||
bool eam_io_ok;
|
||||
bool jb_io_ok;
|
||||
@@ -79,8 +124,21 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
|
||||
log_info("--- Begin jbhook dll_entry_init ---");
|
||||
|
||||
char *sidcode = NULL; // TODO this isn't propagated with the new api anymore, what to do?
|
||||
|
||||
log_assert(sidcode != NULL);
|
||||
|
||||
options_init_from_cmdline(&options);
|
||||
|
||||
hook_table_apply(
|
||||
NULL, "mwindow.dll", init_hook_syms, lengthof(init_hook_syms));
|
||||
|
||||
if (!options.disable_adapteremu) {
|
||||
adapter_hook_init();
|
||||
}
|
||||
|
||||
jbhook_util_eamuse_hook_init();
|
||||
|
||||
if (options.vertical) {
|
||||
jbhook_util_gfx_install_vertical_hooks();
|
||||
}
|
||||
@@ -138,7 +196,8 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
|
||||
char *sidcode_in_ea3_config = strdup(sidcode);
|
||||
|
||||
bool ret = app_hook_invoke_init(sidcode, param);
|
||||
// TODO the following needs the sidcode back-propagation, figure something out
|
||||
// bool ret = app_hook_invoke_init(sidcode, param);
|
||||
|
||||
// If the game is append, the mcode `cabinet` is forced to C. This is bad if
|
||||
// p3io was configured to respond as A! Help the user help themsevles...
|
||||
@@ -157,7 +216,7 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
|
||||
free(sidcode_in_ea3_config);
|
||||
|
||||
return ret;
|
||||
return true;
|
||||
|
||||
fail:
|
||||
if (eam_io_ok) {
|
||||
@@ -177,12 +236,8 @@ fail:
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool my_dll_entry_main(void)
|
||||
static void _jbhook2_main_fini()
|
||||
{
|
||||
bool result;
|
||||
|
||||
result = app_hook_invoke_main();
|
||||
|
||||
if (!options.disable_cardemu) {
|
||||
log_info("Shutting down card reader backend");
|
||||
|
||||
@@ -205,78 +260,27 @@ static bool my_dll_entry_main(void)
|
||||
}
|
||||
|
||||
options_fini(&options);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static HWND CDECL
|
||||
my_mwindow_create(HINSTANCE, void *, const char *, DWORD, DWORD, BOOL);
|
||||
static HWND(CDECL *real_mwindow_create)(
|
||||
HINSTANCE, void *, const char *, DWORD, DWORD, BOOL);
|
||||
|
||||
static const struct hook_symbol init_hook_syms[] = {
|
||||
{
|
||||
.name = "mwindow_create",
|
||||
.patch = my_mwindow_create,
|
||||
.link = (void **) &real_mwindow_create,
|
||||
},
|
||||
};
|
||||
|
||||
static HWND CDECL my_mwindow_create(
|
||||
HINSTANCE hinstance,
|
||||
void *callback,
|
||||
const char *window_title,
|
||||
DWORD window_width,
|
||||
DWORD window_height,
|
||||
BOOL fullscreen)
|
||||
void bt_module_core_log_api_set(const bt_core_log_api_t *api)
|
||||
{
|
||||
log_info("-------------------------------------------------------------");
|
||||
log_info("---------------- Begin jbhook mwindow_create ----------------");
|
||||
log_info("-------------------------------------------------------------");
|
||||
bt_core_log_api_set(api);
|
||||
}
|
||||
|
||||
if (options.vertical) {
|
||||
DWORD tmp = window_width;
|
||||
window_width = window_height;
|
||||
window_height = tmp;
|
||||
}
|
||||
void bt_module_core_thread_api_set(const bt_core_thread_api_t *api)
|
||||
{
|
||||
bt_core_thread_api_set(api);
|
||||
}
|
||||
|
||||
if (options.show_cursor) {
|
||||
ShowCursor(TRUE);
|
||||
}
|
||||
void bt_module_hook_api_get(bt_hook_api_t *api)
|
||||
{
|
||||
api->version = 1;
|
||||
|
||||
fullscreen = !options.windowed;
|
||||
|
||||
return real_mwindow_create(
|
||||
hinstance,
|
||||
callback,
|
||||
window_title,
|
||||
window_width,
|
||||
window_height,
|
||||
fullscreen);
|
||||
api->v1.main_init = _jbhook2_main_init;
|
||||
api->v1.main_fini = _jbhook2_main_fini;
|
||||
}
|
||||
|
||||
BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
|
||||
{
|
||||
if (reason != DLL_PROCESS_ATTACH) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Use AVS APIs
|
||||
avs_ext_log_core_api_set();
|
||||
avs_ext_thread_core_api_set();
|
||||
|
||||
options_init_from_cmdline(&options);
|
||||
|
||||
hook_table_apply(
|
||||
NULL, "mwindow.dll", init_hook_syms, lengthof(init_hook_syms));
|
||||
|
||||
app_hook_init(my_dll_entry_init, my_dll_entry_main);
|
||||
|
||||
if (!options.disable_adapteremu) {
|
||||
adapter_hook_init();
|
||||
}
|
||||
|
||||
jbhook_util_eamuse_hook_init();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -2,3 +2,8 @@ LIBRARY jbhook2
|
||||
|
||||
EXPORTS
|
||||
DllMain@12 @1 NONAME
|
||||
|
||||
; Bemanitools 6 API
|
||||
bt_module_core_log_api_set
|
||||
bt_module_core_thread_api_set
|
||||
bt_module_hook_api_get
|
||||
@@ -5,14 +5,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "avs-ext/log.h"
|
||||
#include "avs-ext/thread.h"
|
||||
|
||||
#include "hook/iohook.h"
|
||||
#include "hook/table.h"
|
||||
|
||||
#include "hooklib/adapter.h"
|
||||
#include "hooklib/app.h"
|
||||
#include "hooklib/rs232.h"
|
||||
#include "hooklib/setupapi.h"
|
||||
|
||||
@@ -22,8 +18,6 @@
|
||||
#include "iface-io/eam.h"
|
||||
#include "iface-io/jb.h"
|
||||
|
||||
#include "imports/avs.h"
|
||||
|
||||
#include "jbhook3/gfx.h"
|
||||
#include "jbhook3/options.h"
|
||||
|
||||
@@ -37,6 +31,10 @@
|
||||
#include "p4ioemu/device.h"
|
||||
#include "p4ioemu/setupapi.h"
|
||||
|
||||
#include "sdk/module/core/log.h"
|
||||
#include "sdk/module/core/thread.h"
|
||||
#include "sdk/module/hook.h"
|
||||
|
||||
#include "security/id.h"
|
||||
|
||||
#include "util/defs.h"
|
||||
@@ -64,7 +62,8 @@ static void _jbhook3_io_eam_init(module_io_t **module)
|
||||
bt_io_eam_api_set(&api);
|
||||
}
|
||||
|
||||
static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
static bool
|
||||
_jbhook3_main_init(HMODULE game_module, const bt_core_config_t *config_)
|
||||
{
|
||||
bool eam_io_ok;
|
||||
bool jb_io_ok;
|
||||
@@ -74,6 +73,14 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
|
||||
log_info("--- Begin jbhook dll_entry_init ---");
|
||||
|
||||
options_init_from_cmdline(&options);
|
||||
|
||||
if (!options.disable_adapteremu) {
|
||||
adapter_hook_init();
|
||||
}
|
||||
|
||||
jbhook_util_eamuse_hook_init();
|
||||
|
||||
iohook_push_handler(p4ioemu_dispatch_irp);
|
||||
iohook_push_handler(jbhook_util_ac_io_port_dispatch_irp);
|
||||
|
||||
@@ -120,9 +127,7 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
|
||||
log_info("--- End jbhook dll_entry_init ---");
|
||||
|
||||
bool ret = app_hook_invoke_init(sidcode, param);
|
||||
|
||||
return ret;
|
||||
return true;
|
||||
|
||||
fail:
|
||||
if (eam_io_ok) {
|
||||
@@ -142,12 +147,8 @@ fail:
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool my_dll_entry_main(void)
|
||||
static void _jbhook3_main_fini()
|
||||
{
|
||||
bool result;
|
||||
|
||||
result = app_hook_invoke_main();
|
||||
|
||||
if (!options.disable_cardemu) {
|
||||
log_info("Shutting down card reader backend");
|
||||
|
||||
@@ -170,29 +171,27 @@ static bool my_dll_entry_main(void)
|
||||
}
|
||||
|
||||
options_fini(&options);
|
||||
}
|
||||
|
||||
return result;
|
||||
void bt_module_core_log_api_set(const bt_core_log_api_t *api)
|
||||
{
|
||||
bt_core_log_api_set(api);
|
||||
}
|
||||
|
||||
void bt_module_core_thread_api_set(const bt_core_thread_api_t *api)
|
||||
{
|
||||
bt_core_thread_api_set(api);
|
||||
}
|
||||
|
||||
void bt_module_hook_api_get(bt_hook_api_t *api)
|
||||
{
|
||||
api->version = 1;
|
||||
|
||||
api->v1.main_init = _jbhook3_main_init;
|
||||
api->v1.main_fini = _jbhook3_main_fini;
|
||||
}
|
||||
|
||||
BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
|
||||
{
|
||||
if (reason != DLL_PROCESS_ATTACH) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Use AVS APIs
|
||||
avs_ext_log_core_api_set();
|
||||
avs_ext_thread_core_api_set();
|
||||
|
||||
options_init_from_cmdline(&options);
|
||||
|
||||
app_hook_init(my_dll_entry_init, my_dll_entry_main);
|
||||
|
||||
if (!options.disable_adapteremu) {
|
||||
adapter_hook_init();
|
||||
}
|
||||
|
||||
jbhook_util_eamuse_hook_init();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -2,3 +2,8 @@ LIBRARY jbhook3
|
||||
|
||||
EXPORTS
|
||||
DllMain@12 @1 NONAME
|
||||
|
||||
; Bemanitools 6 API
|
||||
bt_module_core_log_api_set
|
||||
bt_module_core_thread_api_set
|
||||
bt_module_hook_api_get
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "avs-ext/error.h"
|
||||
#include "avs-ext/log.h"
|
||||
#include "avs-ext/property-node.h"
|
||||
|
||||
#include "core/log-bt.h"
|
||||
@@ -98,16 +97,6 @@ static AVS_LOG_WRITER(_avs_context_log_writer, chars, nchars, ctx)
|
||||
free(utf16);
|
||||
}
|
||||
|
||||
static void _avs_switch_log_engine()
|
||||
{
|
||||
// Switch the logging backend now that AVS is booted to use a single logging
|
||||
// engine which avoids concurrency issues as AVS runs it's own async logger
|
||||
// thread
|
||||
avs_ext_log_core_api_set();
|
||||
|
||||
log_misc("Switched logging engine to AVS");
|
||||
}
|
||||
|
||||
void avs_fs_assert_root_device_exists(const core_property_node_t *node)
|
||||
{
|
||||
char root_device_path[PATH_MAX];
|
||||
@@ -213,8 +202,6 @@ void avs_init(
|
||||
avs_node, avs_heap, avs_heap_size, NULL, _avs_context_log_writer, NULL);
|
||||
#endif
|
||||
|
||||
_avs_switch_log_engine();
|
||||
|
||||
log_misc("init done");
|
||||
}
|
||||
|
||||
|
||||
@@ -498,11 +498,6 @@ void _launcher_init(
|
||||
&bootstrap_config->startup.log,
|
||||
launcher_config->avs.property);
|
||||
|
||||
// Set APIs again because these have changed with AVS being initialized
|
||||
hooks_core_log_api_set();
|
||||
hooks_core_thread_api_set();
|
||||
hooks_core_config_api_set();
|
||||
|
||||
bootstrap_default_files_create(&bootstrap_config->startup.default_file);
|
||||
|
||||
_launcher_ea3_ident_config_load(
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "avs-ext/log.h"
|
||||
#include "avs-ext/thread.h"
|
||||
|
||||
#include "hook/iohook.h"
|
||||
|
||||
#include "hooklib/app.h"
|
||||
@@ -20,6 +17,10 @@
|
||||
#include "module/io-ext.h"
|
||||
#include "module/io.h"
|
||||
|
||||
#include "sdk/module/core/log.h"
|
||||
#include "sdk/module/core/thread.h"
|
||||
#include "sdk/module/hook.h"
|
||||
|
||||
#include "sdvxhook/acio.h"
|
||||
#include "sdvxhook/gfx.h"
|
||||
#include "sdvxhook/lcd.h"
|
||||
@@ -27,9 +28,6 @@
|
||||
#include "util/cmdline.h"
|
||||
#include "util/defs.h"
|
||||
|
||||
static bool my_dll_entry_init(char *sidcode, struct property_node *config);
|
||||
static bool my_dll_entry_main(void);
|
||||
|
||||
static module_io_t *_sdvxhook_module_io_sdvx;
|
||||
static module_io_t *_sdvxhook_module_io_eam;
|
||||
|
||||
@@ -53,12 +51,39 @@ static void _sdvxhook_io_eam_init(module_io_t **module)
|
||||
bt_io_eam_api_set(&api);
|
||||
}
|
||||
|
||||
static bool my_dll_entry_init(char *sidcode, struct property_node *config)
|
||||
static bool
|
||||
_sdvxhook_main_init(HMODULE game_module, const bt_core_config_t *config_)
|
||||
{
|
||||
bool ok;
|
||||
int i;
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
args_recover(&argc, &argv);
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (argv[i][0] != '-') {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (argv[i][1]) {
|
||||
case 'c':
|
||||
gfx_set_confined();
|
||||
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
gfx_set_windowed();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
args_free(argc, argv);
|
||||
|
||||
log_info("--- Begin sdvxhook dll_entry_init ---");
|
||||
|
||||
gfx_init();
|
||||
ac_io_bus_init();
|
||||
|
||||
log_info("Starting up SDVX IO backend");
|
||||
@@ -91,7 +116,7 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *config)
|
||||
|
||||
log_info("--- End sdvxhook dll_entry_init ---");
|
||||
|
||||
return app_hook_invoke_init(sidcode, config);
|
||||
return true;
|
||||
|
||||
eam_io_fail:
|
||||
bt_io_sdvx_fini();
|
||||
@@ -105,12 +130,8 @@ sdvx_io_fail:
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool my_dll_entry_main(void)
|
||||
static void _sdvxhook_main_fini()
|
||||
{
|
||||
bool result;
|
||||
|
||||
result = app_hook_invoke_main();
|
||||
|
||||
log_info("Shutting down card reader backend");
|
||||
bt_io_eam_fini();
|
||||
|
||||
@@ -124,49 +145,27 @@ static bool my_dll_entry_main(void)
|
||||
module_io_free(&_sdvxhook_module_io_sdvx);
|
||||
|
||||
ac_io_bus_fini();
|
||||
}
|
||||
|
||||
return result;
|
||||
void bt_module_core_log_api_set(const bt_core_log_api_t *api)
|
||||
{
|
||||
bt_core_log_api_set(api);
|
||||
}
|
||||
|
||||
void bt_module_core_thread_api_set(const bt_core_thread_api_t *api)
|
||||
{
|
||||
bt_core_thread_api_set(api);
|
||||
}
|
||||
|
||||
void bt_module_hook_api_get(bt_hook_api_t *api)
|
||||
{
|
||||
api->version = 1;
|
||||
|
||||
api->v1.main_init = _sdvxhook_main_init;
|
||||
api->v1.main_fini = _sdvxhook_main_fini;
|
||||
}
|
||||
|
||||
BOOL WINAPI DllMain(HMODULE self, DWORD reason, void *ctx)
|
||||
{
|
||||
int i;
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
if (reason != DLL_PROCESS_ATTACH) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Use AVS APIs
|
||||
avs_ext_log_core_api_set();
|
||||
avs_ext_thread_core_api_set();
|
||||
|
||||
args_recover(&argc, &argv);
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (argv[i][0] != '-') {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (argv[i][1]) {
|
||||
case 'c':
|
||||
gfx_set_confined();
|
||||
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
gfx_set_windowed();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
args_free(argc, argv);
|
||||
|
||||
app_hook_init(my_dll_entry_init, my_dll_entry_main);
|
||||
|
||||
gfx_init();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -2,3 +2,8 @@ LIBRARY sdvxhook
|
||||
|
||||
EXPORTS
|
||||
DllMain@12 @1 NONAME
|
||||
|
||||
; Bemanitools 6 API
|
||||
bt_module_core_log_api_set
|
||||
bt_module_core_thread_api_set
|
||||
bt_module_hook_api_get
|
||||
@@ -5,14 +5,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "avs-ext/log.h"
|
||||
#include "avs-ext/thread.h"
|
||||
|
||||
#include "cconfig/cconfig-hook.h"
|
||||
|
||||
#include "hooklib/acp.h"
|
||||
#include "hooklib/adapter.h"
|
||||
#include "hooklib/app.h"
|
||||
#include "hooklib/rs232.h"
|
||||
|
||||
#include "iface-core/log.h"
|
||||
@@ -33,7 +29,9 @@
|
||||
#include "d3d9exhook/config-gfx.h"
|
||||
#include "d3d9exhook/d3d9ex.h"
|
||||
|
||||
#include "imports/avs.h"
|
||||
#include "sdk/module/core/log.h"
|
||||
#include "sdk/module/core/thread.h"
|
||||
#include "sdk/module/hook.h"
|
||||
|
||||
#include "util/str.h"
|
||||
|
||||
@@ -59,7 +57,8 @@ static void _sdvxhook2_cn_io_sdvx_init(module_io_t **module)
|
||||
bt_io_sdvx_api_set(&api);
|
||||
}
|
||||
|
||||
static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
static bool
|
||||
_sdvxhook2_cn_main_init(HMODULE game_module, const bt_core_config_t *config_)
|
||||
{
|
||||
struct cconfig *config;
|
||||
|
||||
@@ -88,6 +87,10 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
log_info(SDVXHOOK2_CN_INFO_HEADER);
|
||||
log_info("Initializing sdvxhook2-cn...");
|
||||
|
||||
acp_hook_init();
|
||||
adapter_hook_init();
|
||||
d3d9ex_hook_init();
|
||||
|
||||
d3d9ex_configure(&config_gfx);
|
||||
|
||||
/* Start up sdvxio.DLL */
|
||||
@@ -121,15 +124,11 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
|
||||
log_info("--- End sdvxhook dll_entry_init ---");
|
||||
|
||||
return app_hook_invoke_init(sidcode, param);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool my_dll_entry_main(void)
|
||||
static void _sdvxhook2_cn_main_fini()
|
||||
{
|
||||
bool result;
|
||||
|
||||
result = app_hook_invoke_main();
|
||||
|
||||
if (!config_cam.disable_emu) {
|
||||
camhook_fini();
|
||||
}
|
||||
@@ -142,8 +141,24 @@ static bool my_dll_entry_main(void)
|
||||
bt_io_sdvx_api_clear();
|
||||
module_io_free(&_sdvxhook2_cn_module_io_sdvx);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
void bt_module_core_log_api_set(const bt_core_log_api_t *api)
|
||||
{
|
||||
bt_core_log_api_set(api);
|
||||
}
|
||||
|
||||
void bt_module_core_thread_api_set(const bt_core_thread_api_t *api)
|
||||
{
|
||||
bt_core_thread_api_set(api);
|
||||
}
|
||||
|
||||
void bt_module_hook_api_get(bt_hook_api_t *api)
|
||||
{
|
||||
api->version = 1;
|
||||
|
||||
api->v1.main_init = _sdvxhook2_cn_main_init;
|
||||
api->v1.main_fini = _sdvxhook2_cn_main_fini;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,20 +166,5 @@ static bool my_dll_entry_main(void)
|
||||
*/
|
||||
BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
|
||||
{
|
||||
if (reason != DLL_PROCESS_ATTACH) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
// Use AVS APIs
|
||||
avs_ext_log_core_api_set();
|
||||
avs_ext_thread_core_api_set();
|
||||
|
||||
app_hook_init(my_dll_entry_init, my_dll_entry_main);
|
||||
|
||||
acp_hook_init();
|
||||
adapter_hook_init();
|
||||
d3d9ex_hook_init();
|
||||
|
||||
end:
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -5,14 +5,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "avs-ext/log.h"
|
||||
#include "avs-ext/thread.h"
|
||||
|
||||
#include "cconfig/cconfig-hook.h"
|
||||
|
||||
#include "hooklib/acp.h"
|
||||
#include "hooklib/adapter.h"
|
||||
#include "hooklib/app.h"
|
||||
#include "hooklib/config-adapter.h"
|
||||
#include "hooklib/memfile.h"
|
||||
#include "hooklib/rs232.h"
|
||||
@@ -40,7 +36,9 @@
|
||||
#include "d3d9exhook/config-gfx.h"
|
||||
#include "d3d9exhook/d3d9ex.h"
|
||||
|
||||
#include "imports/avs.h"
|
||||
#include "sdk/module/core/log.h"
|
||||
#include "sdk/module/core/thread.h"
|
||||
#include "sdk/module/hook.h"
|
||||
|
||||
#include "util/str.h"
|
||||
|
||||
@@ -99,12 +97,18 @@ static void _sdvxhook2_io_eam_init(module_io_t **module)
|
||||
bt_io_eam_api_set(&api);
|
||||
}
|
||||
|
||||
static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
static bool
|
||||
_sdvxhook2_main_init(HMODULE game_module, const bt_core_config_t *config_)
|
||||
{
|
||||
struct cconfig *config;
|
||||
|
||||
log_info("--- Begin sdvxhook dll_entry_init ---");
|
||||
|
||||
// TODO sidcode back-propagation required like jubeat, figure out
|
||||
char *sidcode = NULL;
|
||||
|
||||
log_assert(sidcode);
|
||||
|
||||
config = cconfig_init();
|
||||
|
||||
sdvxhook2_config_io_init(config);
|
||||
@@ -130,6 +134,10 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
log_info(SDVXHOOK2_INFO_HEADER);
|
||||
log_info("Initializing sdvxhook2...");
|
||||
|
||||
acp_hook_init();
|
||||
adapter_hook_init();
|
||||
d3d9ex_hook_init();
|
||||
|
||||
d3d9ex_configure(&config_gfx);
|
||||
|
||||
/* Start up sdvxio.DLL */
|
||||
@@ -196,15 +204,11 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
|
||||
log_info("--- End sdvxhook dll_entry_init ---");
|
||||
|
||||
return app_hook_invoke_init(sidcode, param);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool my_dll_entry_main(void)
|
||||
static void _sdvxhook2_main_fini()
|
||||
{
|
||||
bool result;
|
||||
|
||||
result = app_hook_invoke_main();
|
||||
|
||||
if (!config_cam.disable_emu) {
|
||||
camhook_fini();
|
||||
}
|
||||
@@ -230,8 +234,24 @@ static bool my_dll_entry_main(void)
|
||||
if (!config_io.disable_file_hooks) {
|
||||
memfile_hook_fini();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
void bt_module_core_log_api_set(const bt_core_log_api_t *api)
|
||||
{
|
||||
bt_core_log_api_set(api);
|
||||
}
|
||||
|
||||
void bt_module_core_thread_api_set(const bt_core_thread_api_t *api)
|
||||
{
|
||||
bt_core_thread_api_set(api);
|
||||
}
|
||||
|
||||
void bt_module_hook_api_get(bt_hook_api_t *api)
|
||||
{
|
||||
api->version = 1;
|
||||
|
||||
api->v1.main_init = _sdvxhook2_main_init;
|
||||
api->v1.main_fini = _sdvxhook2_main_fini;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -239,20 +259,5 @@ static bool my_dll_entry_main(void)
|
||||
*/
|
||||
BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
|
||||
{
|
||||
if (reason != DLL_PROCESS_ATTACH) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
// Use AVS APIs
|
||||
avs_ext_log_core_api_set();
|
||||
avs_ext_thread_core_api_set();
|
||||
|
||||
app_hook_init(my_dll_entry_init, my_dll_entry_main);
|
||||
|
||||
acp_hook_init();
|
||||
adapter_hook_init();
|
||||
d3d9ex_hook_init();
|
||||
|
||||
end:
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -2,3 +2,8 @@ LIBRARY sdvxhook2
|
||||
|
||||
EXPORTS
|
||||
DllMain@12 @1 NONAME
|
||||
|
||||
; Bemanitools 6 API
|
||||
bt_module_core_log_api_set
|
||||
bt_module_core_thread_api_set
|
||||
bt_module_hook_api_get
|
||||
@@ -2,26 +2,22 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "avs-ext/log.h"
|
||||
#include "avs-ext/thread.h"
|
||||
|
||||
#include "hook/iohook.h"
|
||||
|
||||
#include "hooklib/app.h"
|
||||
|
||||
#include "iface-core/log.h"
|
||||
#include "iface-core/thread.h"
|
||||
|
||||
#include "imports/avs.h"
|
||||
#include "sdk/module/core/log.h"
|
||||
#include "sdk/module/core/thread.h"
|
||||
#include "sdk/module/hook.h"
|
||||
|
||||
#include "unicorntail/p3io.h"
|
||||
#include "unicorntail/usbmem.h"
|
||||
|
||||
#include "util/defs.h"
|
||||
|
||||
static bool my_dll_entry_init(char *sidcode, struct property_node *param);
|
||||
static bool my_dll_entry_main(void);
|
||||
|
||||
static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
static bool
|
||||
_unicorntail_main_init(HMODULE game_module, const bt_core_config_t *config_)
|
||||
{
|
||||
log_info("--- Begin unicorntail dll_entry_init ---");
|
||||
|
||||
@@ -33,32 +29,34 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
|
||||
log_info("--- End unicorntail dll_entry_init ---");
|
||||
|
||||
return app_hook_invoke_init(sidcode, param);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool my_dll_entry_main(void)
|
||||
static void _unicorntail_main_fini()
|
||||
{
|
||||
bool result;
|
||||
|
||||
result = app_hook_invoke_main();
|
||||
|
||||
usbmem_fini();
|
||||
p3io_filter_fini();
|
||||
}
|
||||
|
||||
return result;
|
||||
void bt_module_core_log_api_set(const bt_core_log_api_t *api)
|
||||
{
|
||||
bt_core_log_api_set(api);
|
||||
}
|
||||
|
||||
void bt_module_core_thread_api_set(const bt_core_thread_api_t *api)
|
||||
{
|
||||
bt_core_thread_api_set(api);
|
||||
}
|
||||
|
||||
void bt_module_hook_api_get(bt_hook_api_t *api)
|
||||
{
|
||||
api->version = 1;
|
||||
|
||||
api->v1.main_init = _unicorntail_main_init;
|
||||
api->v1.main_fini = _unicorntail_main_fini;
|
||||
}
|
||||
|
||||
BOOL WINAPI DllMain(HMODULE self, DWORD reason, void *ctx)
|
||||
{
|
||||
if (reason != DLL_PROCESS_ATTACH) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
avs_ext_log_core_api_set();
|
||||
avs_ext_thread_core_api_set();
|
||||
|
||||
app_hook_init(my_dll_entry_init, my_dll_entry_main);
|
||||
|
||||
end:
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -2,3 +2,8 @@ LIBRARY unicorntail
|
||||
|
||||
EXPORTS
|
||||
DllMain@12 @1 NONAME
|
||||
|
||||
; Bemanitools 6 API
|
||||
bt_module_core_log_api_set
|
||||
bt_module_core_thread_api_set
|
||||
bt_module_hook_api_get
|
||||
@@ -4,7 +4,8 @@ ldflags_vefxio := \
|
||||
-lwinmm
|
||||
|
||||
libs_vefxio := \
|
||||
geninput
|
||||
iface-core \
|
||||
geninput \
|
||||
|
||||
src_vefxio := \
|
||||
vefxio.c \
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "iface-core/log.h"
|
||||
#include "iface-io/vefx.h"
|
||||
|
||||
#include "sdk/module/io/vefx.h"
|
||||
@@ -148,6 +149,11 @@ bool bt_io_vefx_16seg_send(const char *text)
|
||||
return true;
|
||||
}
|
||||
|
||||
void bt_module_core_log_api_set(const bt_core_log_api_t *api)
|
||||
{
|
||||
bt_core_log_api_set(api);
|
||||
}
|
||||
|
||||
void bt_module_io_vefx_api_get(bt_io_vefx_api_t *api)
|
||||
{
|
||||
api->version = 1;
|
||||
|
||||
@@ -2,6 +2,7 @@ LIBRARY vefxio
|
||||
|
||||
EXPORTS
|
||||
; Bemanitools 6 API
|
||||
bt_module_core_log_api_set
|
||||
bt_module_io_vefx_api_get
|
||||
|
||||
; Direct API
|
||||
|
||||
2
todo.md
2
todo.md
@@ -9,8 +9,6 @@ goal: fix inefficient logging causing stuttering and unify across launcher/injec
|
||||
|
||||
new plan:
|
||||
* bt-log as its own async logging engine with ring buffer
|
||||
* don't use AVS loggers anymore, don't need to use AVS threads either then
|
||||
* gets rid of log-server in iidx since all logging in btools goes through bt-log engine
|
||||
* log sink needs to be setup with a mutex to ensure log messages aren't split
|
||||
* since AVS and btools log engines are async then, this is fine
|
||||
* can also simplify the whole logging API stuff since there is only one API impl
|
||||
|
||||
Reference in New Issue
Block a user