diff --git a/Module.mk b/Module.mk
index 4301af7..f77964c 100644
--- a/Module.mk
+++ b/Module.mk
@@ -650,7 +650,6 @@ $(zipdir)/sdvx-05-to-06.zip: \
build/bin/indep-64/sdvxio.dll \
dist/sdvx5/config.bat \
dist/sdvx5/gamestart.bat \
- dist/sdvx5/sdvxhook2.conf \
dist/sdvx5/launcher.xml \
dist/shared/ea3-ident.xml \
dist/shared/ea3-license.xml \
diff --git a/dist/sdvx5/gamestart.bat b/dist/sdvx5/gamestart.bat
index 2db9289..6f5a362 100644
--- a/dist/sdvx5/gamestart.bat
+++ b/dist/sdvx5/gamestart.bat
@@ -20,6 +20,18 @@ set CONTENT_DIR=%CD%\..
set BEMANITOOLS_DIR=%CONTENT_DIR%\bemanitools
set MODULES_DIR=%CONTENT_DIR%\modules
+if not exist "%BEMANITOOLS_DIR%" (
+ echo The bemanitools directory "%BEMANITOOLS_DIR%" does not exist.
+ pause
+ exit 1
+)
+
+if not exist "%MODULES_DIR%" (
+ echo The game modules directory "%MODULES_DIR%" does not exist.
+ pause
+ exit 1
+)
+
:: Keep that data vanilla, no need to copy these around anymore
:: Just add them to the env PATH so launcher can find the libs and game executable
:: Remark: This also requires admin privileges to propage correctly to launcher
@@ -31,4 +43,6 @@ set PATH=^
:: Current working dir is the game's root folder
cd /d %CONTENT_DIR%
-%BEMANITOOLS_DIR%\launcher %BEMANITOOLS_DIR%\launcher.xml --config %BEMANITOOLS_DIR%\sdvxhook2.conf %*
\ No newline at end of file
+%BEMANITOOLS_DIR%\launcher.exe^
+ %BEMANITOOLS_DIR%\launcher.xml^
+ %*
\ No newline at end of file
diff --git a/dist/sdvx5/launcher.xml b/dist/sdvx5/launcher.xml
index 3ae97c1..736a3a3 100644
--- a/dist/sdvx5/launcher.xml
+++ b/dist/sdvx5/launcher.xml
@@ -58,15 +58,79 @@
bemanitools/ea3-service.xml
-
-
- sdvxhook2.dll
-
-
-
-
-
-
+
+
+ 1
+ sdvxhook2.dll
+
+
+
+
+
+
+
+
+
+ -1
+
+ -1
+
+ -1
+
+
+ -1
+ -1
+
+
+
+
+ 0
+
+ 1
+
+ 0
+
+ 1080
+
+ 1920
+
+ -1
+
+ -1
+
+
+
+
+ 0
+
+
+ 1
+
+
+
+
+
+
+ 0
+
+ 0
+
+ 0
+
+ 0
+
+ 0
+
+ 0
+
+ 0
+
+ 0
+
+
+
+
+
0
0
diff --git a/dist/sdvx5/sdvxhook2.conf b/dist/sdvx5/sdvxhook2.conf
deleted file mode 100644
index 8d2b386..0000000
--- a/dist/sdvx5/sdvxhook2.conf
+++ /dev/null
@@ -1,69 +0,0 @@
-# Disable card reader emulation and enable usage of real card reader hardware on COM2
-io.disable_card_reader_emu=false
-
-# Disable BIO2 emulation and enable usage of real BIO2 hardware
-io.disable_bio2_emu=false
-
-# Disables the poll limiter, warning very high CPU usage may arise
-io.disable_poll_limiter=false
-
-# Forces game to think headphones are attached
-io.force_headphones=false
-
-# Disables the built in file hooks, requiring manual file creation (/dev/raw/j.dest)
-io.disable_file_hooks=false
-
-# Disables the built in power control hooks, allowing game to modify system power settings
-io.disable_power_hooks=false
-
-# Disables the built in NVAPI control hooks, allowing game to modify system monitor settings
-io.disable_nvapi_hooks=false
-
-# Emulates the card reader on COM1 instead of COM2
-io.com1_card_reader=false
-
-# Run the game in a framed window (requires windowed option)
-gfx.framed=true
-
-# Run the game windowed
-gfx.windowed=false
-
-# Confine mouse cursor to window
-gfx.confined=false
-
-# Windowed width, -1 for default size
-gfx.window_width=1080
-
-# Windowed height, -1 for default size
-gfx.window_height=1920
-
-# Windowed X, -1 for default X position
-gfx.window_x=-1
-
-# Windowed Y, -1 for default Y position
-gfx.window_y=-1
-
-# Forced refresh rate, -1 to not force any (try 59 or 60 if monitor check fails to lock on high refresh rate monitors)
-gfx.forced_refresh_rate=-1
-
-# D3D9ex device adapter (monitor), -1 to use default, 0, 1, 2 etc. to use specified adapter
-gfx.device_adapter=-1
-
-# Orientation to force monitor into, -1 to use default, 0, 1, 2, 3 to do 0, 90, 180, 270 degrees
-gfx.force_orientation=-1
-
-# Force a screen resolution (width), -1 to disable. Use this if the game does not auto detect your monitor's resolution properly, e.g. 1368x768 instead of 1280x720.
-gfx.force_screen_res.width=-1
-
-# Force a screen resolution (height), -1 to disable. Use this if the game does not auto detect your monitor's resolution properly, e.g. 1368x768 instead of 1280x720.
-gfx.force_screen_res.height=-1
-
-# Disables the camera emulation
-cam.disable_emu=false
-
-# Override camera device ID detection (copy from device manager, do not escape)
-cam.device_id1=
-
-# IP of adapter to force override with
-adapter.override_ip=
-
diff --git a/src/main/camhook/config-cam.c b/src/main/camhook/config-cam.c
index a56664c..41714d0 100644
--- a/src/main/camhook/config-cam.c
+++ b/src/main/camhook/config-cam.c
@@ -8,7 +8,7 @@
void camhook_config_cam_get(
const bt_core_config_t *config,
- struct camhook_config_cam *config_cam,
+ camhook_config_cam_t *config_cam,
size_t num_cams,
bool use_port_layout)
{
diff --git a/src/main/camhook/config-cam.h b/src/main/camhook/config-cam.h
index 6093bdd..d72b1f8 100644
--- a/src/main/camhook/config-cam.h
+++ b/src/main/camhook/config-cam.h
@@ -7,17 +7,17 @@
#define CAMHOOK_CONFIG_CAM_MAX 2
-struct camhook_config_cam {
+typedef struct camhook_config_cam {
bool disable_emu;
size_t num_devices;
int port_layout;
char device_id[CAMHOOK_CONFIG_CAM_MAX][MAX_PATH];
bool disable_camera[CAMHOOK_CONFIG_CAM_MAX];
-};
+} camhook_config_cam_t;
void camhook_config_cam_get(
const bt_core_config_t *config,
- struct camhook_config_cam *config_cam,
+ camhook_config_cam_t *config_cam,
size_t num_cams,
bool use_port_layout);
diff --git a/src/main/d3d9exhook/config-gfx.c b/src/main/d3d9exhook/config-gfx.c
index 78f9f1d..b051eb5 100644
--- a/src/main/d3d9exhook/config-gfx.c
+++ b/src/main/d3d9exhook/config-gfx.c
@@ -8,7 +8,7 @@
void d3d9exhook_config_gfx_get(
const bt_core_config_t *config,
- struct d3d9exhook_config_gfx *config_gfx)
+ d3d9exhook_config_gfx_t *config_gfx)
{
bt_core_config_s32_get(config, "gfx/device/adapter", &config_gfx->device_adapter);
bt_core_config_s32_get(config, "gfx/device/forced_refresh_rate", &config_gfx->forced_refresh_rate);
diff --git a/src/main/d3d9exhook/config-gfx.h b/src/main/d3d9exhook/config-gfx.h
index e56e3b9..5e06355 100644
--- a/src/main/d3d9exhook/config-gfx.h
+++ b/src/main/d3d9exhook/config-gfx.h
@@ -9,7 +9,7 @@
* Note: forced_refresh_rate sets the monitor's refresh rate
* (it does not limit FPS or anything)
*/
-struct d3d9exhook_config_gfx {
+typedef struct d3d9exhook_config_gfx {
bool framed;
bool windowed;
bool confined;
@@ -25,10 +25,10 @@ struct d3d9exhook_config_gfx {
int32_t width;
int32_t height;
} force_screen_res;
-};
+} d3d9exhook_config_gfx_t;
void d3d9exhook_config_gfx_get(
const bt_core_config_t *config,
- struct d3d9exhook_config_gfx *config_gfx);
+ d3d9exhook_config_gfx_t *config_gfx);
#endif
diff --git a/src/main/hooklib/config-adapter.c b/src/main/hooklib/config-adapter.c
index 0ea1e10..89da7e6 100644
--- a/src/main/hooklib/config-adapter.c
+++ b/src/main/hooklib/config-adapter.c
@@ -1,7 +1,7 @@
#include "hooklib/config-adapter.h"
void hooklib_config_adapter_get(
- const bt_core_config_t *config, struct hooklib_config_adapter *config_adapter)
+ const bt_core_config_t *config, hooklib_config_adapter_t *config_adapter)
{
bt_core_config_str_get(config, "adapter/override_ip", config_adapter->override_ip, sizeof(config_adapter->override_ip));
}
diff --git a/src/main/hooklib/config-adapter.h b/src/main/hooklib/config-adapter.h
index 034b91b..0165d12 100644
--- a/src/main/hooklib/config-adapter.h
+++ b/src/main/hooklib/config-adapter.h
@@ -3,12 +3,12 @@
#include "iface-core/config.h"
-struct hooklib_config_adapter {
+typedef struct hooklib_config_adapter {
// this is larger on purpose, in case ppl enter the wrong stuff here
char override_ip[32];
-};
+} hooklib_config_adapter_t;
void hooklib_config_adapter_get(
- const bt_core_config_t *config, struct hooklib_config_adapter *config_adapter);
+ const bt_core_config_t *config, hooklib_config_adapter_t *config_adapter);
#endif
\ No newline at end of file
diff --git a/src/main/sdvxhook2/Module.mk b/src/main/sdvxhook2/Module.mk
index 3f4e1bb..3e08783 100644
--- a/src/main/sdvxhook2/Module.mk
+++ b/src/main/sdvxhook2/Module.mk
@@ -7,6 +7,7 @@ ldflags_sdvxhook2 := \
-lmf \
-lmfplat \
-lole32 \
+ -lws2_32 \
deplibs_sdvxhook2 := \
avs \
@@ -22,17 +23,18 @@ libs_sdvxhook2 := \
d3d9exhook \
hook \
hooklib \
- cconfig \
util \
iface \
iface-io \
iface-core \
module \
+ security \
src_sdvxhook2 := \
acio.c \
bi2a.c \
- dllmain.c \
config-io.c \
+ dllmain.c \
nvapi.c \
power.c \
+ sdvxhook2.c \
diff --git a/src/main/sdvxhook2/config-io.c b/src/main/sdvxhook2/config-io.c
index ee91cdf..9f3700c 100644
--- a/src/main/sdvxhook2/config-io.c
+++ b/src/main/sdvxhook2/config-io.c
@@ -1,180 +1,16 @@
-#include "cconfig/cconfig-util.h"
-
-#include "iface-core/log.h"
+#include "core/config-ext.h"
#include "sdvxhook2/config-io.h"
-#define SDVXHOOK2_CONFIG_IO_DISABLE_CARD_READER_EMU_KEY \
- "io.disable_card_reader_emu"
-#define SDVXHOOK2_CONFIG_IO_DISABLE_BIO2_EMU_KEY "io.disable_bio2_emu"
-#define SDVXHOOK2_CONFIG_IO_DISABLE_POLL_LIMITER_KEY "io.disable_poll_limiter"
-#define SDVXHOOK2_CONFIG_IO_FORCE_HEADPHONES_KEY "io.force_headphones"
-#define SDVXHOOK2_CONFIG_IO_DISABLE_FILE_HOOKS_KEY "io.disable_file_hooks"
-#define SDVXHOOK2_CONFIG_IO_DISABLE_POWER_HOOKS_KEY "io.disable_power_hooks"
-#define SDVXHOOK2_CONFIG_IO_DISABLE_NVAPI_HOOKS_KEY "io.disable_nvapi_hooks"
-#define SDVXHOOK2_CONFIG_IO_COM1_CARD_READER_KEY "io.com1_card_reader"
-
-#define SDVXHOOK2_CONFIG_IO_DEFAULT_DISABLE_CARD_READER_EMU_VALUE false
-#define SDVXHOOK2_CONFIG_IO_DEFAULT_DISABLE_BIO2_EMU_VALUE false
-#define SDVXHOOK2_CONFIG_IO_DEFAULT_DISABLE_POLL_LIMITER_VALUE false
-#define SDVXHOOK2_CONFIG_IO_DEFAULT_FORCE_HEADPHONES_VALUE false
-#define SDVXHOOK2_CONFIG_IO_DEFAULT_DISABLE_FILE_HOOKS_VALUE false
-#define SDVXHOOK2_CONFIG_IO_DEFAULT_DISABLE_POWER_HOOKS_VALUE false
-#define SDVXHOOK2_CONFIG_IO_DEFAULT_DISABLE_NVAPI_HOOKS_VALUE false
-#define SDVXHOOK2_CONFIG_IO_DEFAULT_DISABLE_NVAPI_HOOKS_VALUE false
-#define SDVXHOOK2_CONFIG_IO_DEFAULT_COM1_CARD_READER_VALUE false
-
-void sdvxhook2_config_io_init(struct cconfig *config)
-{
- cconfig_util_set_bool(
- config,
- SDVXHOOK2_CONFIG_IO_DISABLE_CARD_READER_EMU_KEY,
- SDVXHOOK2_CONFIG_IO_DEFAULT_DISABLE_CARD_READER_EMU_VALUE,
- "Disable card reader emulation and enable usage of real card reader "
- "hardware on COM2");
-
- cconfig_util_set_bool(
- config,
- SDVXHOOK2_CONFIG_IO_DISABLE_BIO2_EMU_KEY,
- SDVXHOOK2_CONFIG_IO_DEFAULT_DISABLE_BIO2_EMU_VALUE,
- "Disable BIO2 emulation and enable usage of real BIO2 hardware");
-
- cconfig_util_set_bool(
- config,
- SDVXHOOK2_CONFIG_IO_DISABLE_POLL_LIMITER_KEY,
- SDVXHOOK2_CONFIG_IO_DEFAULT_DISABLE_POLL_LIMITER_VALUE,
- "Disables the poll limiter, warning very high CPU usage may arise");
-
- cconfig_util_set_bool(
- config,
- SDVXHOOK2_CONFIG_IO_FORCE_HEADPHONES_KEY,
- SDVXHOOK2_CONFIG_IO_DEFAULT_FORCE_HEADPHONES_VALUE,
- "Forces game to think headphones are attached");
-
- cconfig_util_set_bool(
- config,
- SDVXHOOK2_CONFIG_IO_DISABLE_FILE_HOOKS_KEY,
- SDVXHOOK2_CONFIG_IO_DEFAULT_DISABLE_FILE_HOOKS_VALUE,
- "Disables the built in file hooks, requiring manual file creation "
- "(/dev/raw/j.dest)");
-
- cconfig_util_set_bool(
- config,
- SDVXHOOK2_CONFIG_IO_DISABLE_POWER_HOOKS_KEY,
- SDVXHOOK2_CONFIG_IO_DEFAULT_DISABLE_POWER_HOOKS_VALUE,
- "Disables the built in power control hooks, allowing game to modify "
- "system power settings");
-
- cconfig_util_set_bool(
- config,
- SDVXHOOK2_CONFIG_IO_DISABLE_NVAPI_HOOKS_KEY,
- SDVXHOOK2_CONFIG_IO_DEFAULT_DISABLE_NVAPI_HOOKS_VALUE,
- "Disables the built in NVAPI control hooks, allowing game to modify "
- "system monitor settings");
-
- cconfig_util_set_bool(
- config,
- SDVXHOOK2_CONFIG_IO_COM1_CARD_READER_KEY,
- SDVXHOOK2_CONFIG_IO_DEFAULT_COM1_CARD_READER_VALUE,
- "Emulates the card reader on COM1 instead of COM2");
-}
-
void sdvxhook2_config_io_get(
- struct sdvxhook2_config_io *config_io, struct cconfig *config)
+ const bt_core_config_t *config, sdvxhook2_config_io_t *config_out)
{
- if (!cconfig_util_get_bool(
- config,
- SDVXHOOK2_CONFIG_IO_DISABLE_CARD_READER_EMU_KEY,
- &config_io->disable_card_reader_emu,
- SDVXHOOK2_CONFIG_IO_DEFAULT_DISABLE_CARD_READER_EMU_VALUE)) {
- log_warning(
- "Invalid value for key '%s' specified, fallback "
- "to default '%d'",
- SDVXHOOK2_CONFIG_IO_DISABLE_CARD_READER_EMU_KEY,
- SDVXHOOK2_CONFIG_IO_DEFAULT_DISABLE_CARD_READER_EMU_VALUE);
- }
-
- if (!cconfig_util_get_bool(
- config,
- SDVXHOOK2_CONFIG_IO_DISABLE_BIO2_EMU_KEY,
- &config_io->disable_bio2_emu,
- SDVXHOOK2_CONFIG_IO_DEFAULT_DISABLE_BIO2_EMU_VALUE)) {
- log_warning(
- "Invalid value for key '%s' specified, fallback "
- "to default '%d'",
- SDVXHOOK2_CONFIG_IO_DISABLE_BIO2_EMU_KEY,
- SDVXHOOK2_CONFIG_IO_DEFAULT_DISABLE_BIO2_EMU_VALUE);
- }
-
- if (!cconfig_util_get_bool(
- config,
- SDVXHOOK2_CONFIG_IO_DISABLE_POLL_LIMITER_KEY,
- &config_io->disable_poll_limiter,
- SDVXHOOK2_CONFIG_IO_DEFAULT_DISABLE_POLL_LIMITER_VALUE)) {
- log_warning(
- "Invalid value for key '%s' specified, fallback "
- "to default '%d'",
- SDVXHOOK2_CONFIG_IO_DISABLE_POLL_LIMITER_KEY,
- SDVXHOOK2_CONFIG_IO_DEFAULT_DISABLE_POLL_LIMITER_VALUE);
- }
-
- if (!cconfig_util_get_bool(
- config,
- SDVXHOOK2_CONFIG_IO_FORCE_HEADPHONES_KEY,
- &config_io->force_headphones,
- SDVXHOOK2_CONFIG_IO_DEFAULT_FORCE_HEADPHONES_VALUE)) {
- log_warning(
- "Invalid value for key '%s' specified, fallback "
- "to default '%d'",
- SDVXHOOK2_CONFIG_IO_FORCE_HEADPHONES_KEY,
- SDVXHOOK2_CONFIG_IO_DEFAULT_FORCE_HEADPHONES_VALUE);
- }
-
- if (!cconfig_util_get_bool(
- config,
- SDVXHOOK2_CONFIG_IO_DISABLE_FILE_HOOKS_KEY,
- &config_io->disable_file_hooks,
- SDVXHOOK2_CONFIG_IO_DEFAULT_DISABLE_FILE_HOOKS_VALUE)) {
- log_warning(
- "Invalid value for key '%s' specified, fallback "
- "to default '%d'",
- SDVXHOOK2_CONFIG_IO_DISABLE_FILE_HOOKS_KEY,
- SDVXHOOK2_CONFIG_IO_DEFAULT_DISABLE_FILE_HOOKS_VALUE);
- }
-
- if (!cconfig_util_get_bool(
- config,
- SDVXHOOK2_CONFIG_IO_DISABLE_POWER_HOOKS_KEY,
- &config_io->disable_power_hooks,
- SDVXHOOK2_CONFIG_IO_DEFAULT_DISABLE_POWER_HOOKS_VALUE)) {
- log_warning(
- "Invalid value for key '%s' specified, fallback "
- "to default '%d'",
- SDVXHOOK2_CONFIG_IO_DISABLE_POWER_HOOKS_KEY,
- SDVXHOOK2_CONFIG_IO_DEFAULT_DISABLE_POWER_HOOKS_VALUE);
- }
-
- if (!cconfig_util_get_bool(
- config,
- SDVXHOOK2_CONFIG_IO_DISABLE_NVAPI_HOOKS_KEY,
- &config_io->disable_nvapi_hooks,
- SDVXHOOK2_CONFIG_IO_DEFAULT_DISABLE_NVAPI_HOOKS_VALUE)) {
- log_warning(
- "Invalid value for key '%s' specified, fallback "
- "to default '%d'",
- SDVXHOOK2_CONFIG_IO_DISABLE_NVAPI_HOOKS_KEY,
- SDVXHOOK2_CONFIG_IO_DEFAULT_DISABLE_NVAPI_HOOKS_VALUE);
- }
-
- if (!cconfig_util_get_bool(
- config,
- SDVXHOOK2_CONFIG_IO_COM1_CARD_READER_KEY,
- &config_io->com1_card_reader,
- SDVXHOOK2_CONFIG_IO_DEFAULT_COM1_CARD_READER_VALUE)) {
- log_warning(
- "Invalid value for key '%s' specified, fallback "
- "to default '%d'",
- SDVXHOOK2_CONFIG_IO_COM1_CARD_READER_KEY,
- SDVXHOOK2_CONFIG_IO_DEFAULT_COM1_CARD_READER_VALUE);
- }
-}
+ bt_core_config_ext_bool_get(config, "io/disable_card_reader_emu", &config_out->disable_card_reader_emu);
+ bt_core_config_ext_bool_get(config, "io/disable_bio2_emu", &config_out->disable_bio2_emu);
+ bt_core_config_ext_bool_get(config, "io/disable_poll_limiter", &config_out->disable_poll_limiter);
+ bt_core_config_ext_bool_get(config, "io/force_headphones", &config_out->force_headphones);
+ bt_core_config_ext_bool_get(config, "io/disable_file_hooks", &config_out->disable_file_hooks);
+ bt_core_config_ext_bool_get(config, "io/disable_power_hooks", &config_out->disable_power_hooks);
+ bt_core_config_ext_bool_get(config, "io/disable_nvapi_hooks", &config_out->disable_nvapi_hooks);
+ bt_core_config_ext_bool_get(config, "io/com1_card_reader", &config_out->com1_card_reader);
+}
\ No newline at end of file
diff --git a/src/main/sdvxhook2/config-io.h b/src/main/sdvxhook2/config-io.h
index dec90fb..141c730 100644
--- a/src/main/sdvxhook2/config-io.h
+++ b/src/main/sdvxhook2/config-io.h
@@ -1,11 +1,11 @@
#ifndef SDVXHOOK2_CONFIG_IO_H
#define SDVXHOOK2_CONFIG_IO_H
-#include
+#include
-#include "cconfig/cconfig.h"
+#include "api/core/config.h"
-struct sdvxhook2_config_io {
+typedef struct sdvxhook2_config_io {
bool disable_card_reader_emu;
bool disable_bio2_emu;
bool disable_poll_limiter;
@@ -14,11 +14,9 @@ struct sdvxhook2_config_io {
bool disable_power_hooks;
bool disable_nvapi_hooks;
bool com1_card_reader;
-};
-
-void sdvxhook2_config_io_init(struct cconfig *config);
+} sdvxhook2_config_io_t;
void sdvxhook2_config_io_get(
- struct sdvxhook2_config_io *config_io, struct cconfig *config);
+ const bt_core_config_t *config, sdvxhook2_config_io_t *config_out);
#endif
\ No newline at end of file
diff --git a/src/main/sdvxhook2/dllmain.c b/src/main/sdvxhook2/dllmain.c
index 8d72636..f8f6588 100644
--- a/src/main/sdvxhook2/dllmain.c
+++ b/src/main/sdvxhook2/dllmain.c
@@ -1,263 +1,6 @@
#include
-#include
-#include
-#include
-#include
-
-#include "cconfig/cconfig-hook.h"
-
-#include "hooklib/acp.h"
-#include "hooklib/adapter.h"
-#include "hooklib/config-adapter.h"
-#include "hooklib/memfile.h"
-#include "hooklib/rs232.h"
-
-#include "iface-core/log.h"
-#include "iface-core/thread.h"
-
-#include "iface-io/eam.h"
-#include "iface-io/sdvx.h"
-
-#include "module/io-ext.h"
-#include "module/io.h"
-
-#include "bio2emu/emu.h"
-
-#include "sdvxhook2/acio.h"
-#include "sdvxhook2/bi2a.h"
-#include "sdvxhook2/config-io.h"
-#include "sdvxhook2/nvapi.h"
-#include "sdvxhook2/power.h"
-
-#include "camhook/cam.h"
-#include "camhook/config-cam.h"
-
-#include "d3d9exhook/config-gfx.h"
-#include "d3d9exhook/d3d9ex.h"
-
-#include "sdk/module/core/log.h"
-#include "sdk/module/core/thread.h"
-#include "sdk/module/hook.h"
-
-#include "util/str.h"
-
-#define SDVXHOOK2_INFO_HEADER \
- "sdvxhook for VW" \
- ", build " __DATE__ " " __TIME__ ", gitrev " STRINGIFY(GITREV) "\n"
-#define SDVXHOOK2_CMD_USAGE \
- "Usage: launcher.exe -K sdvxhook2.dll [options...]"
-
-struct sdvxhook2_config_io config_io;
-struct camhook_config_cam config_cam;
-struct d3d9exhook_config_gfx config_gfx;
-struct hooklib_config_adapter config_adapter;
-
-static module_io_t *_sdvxhook2_module_io_sdvx;
-static module_io_t *_sdvxhook2_module_io_eam;
-
-static struct bio2emu_port bio2_emu = {
- .port = "COM4",
- .wport = L"\\\\.\\COM4",
- .dispatcher = bio2_emu_bi2a_dispatch_request,
-};
-
-static void attach_dest_fd_intercept(const char *sidcode)
-{
- char region = sidcode[3];
-
- if (region == 'X') {
- region = 'J';
- }
-
- char target_file[8] = "\\x.dest";
- target_file[1] = tolower(region);
-
- // can only capture these by ending path due to /dev/raw being mountable
- memfile_hook_add_fd(target_file, ENDING_MATCH, NULL, 0);
-}
-
-static void _sdvxhook2_io_sdvx_init(module_io_t **module)
-{
- bt_io_sdvx_api_t api;
-
- module_io_ext_load_and_init(
- "sdvxio.dll", "bt_module_io_sdvx_api_get", module);
- module_io_api_get(*module, &api);
- bt_io_sdvx_api_set(&api);
-}
-
-static void _sdvxhook2_io_eam_init(module_io_t **module)
-{
- bt_io_eam_api_t api;
-
- module_io_ext_load_and_init(
- "eamio.dll", "bt_module_io_eam_api_get", module);
- module_io_api_get(*module, &api);
- bt_io_eam_api_set(&api);
-}
-
-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);
- d3d9exhook_config_gfx_init(config);
- camhook_config_cam_init(config, 1, false);
- hooklib_config_adapter_init(config);
-
- if (!cconfig_hook_config_init(
- config,
- SDVXHOOK2_INFO_HEADER "\n" SDVXHOOK2_CMD_USAGE,
- CCONFIG_CMD_USAGE_OUT_STDOUT)) {
- cconfig_finit(config);
- exit(EXIT_FAILURE);
- }
-
- sdvxhook2_config_io_get(&config_io, config);
- camhook_config_cam_get(&config_cam, config, 1, false);
- d3d9exhook_config_gfx_get(&config_gfx, config);
- hooklib_config_adapter_get(&config_adapter, config);
-
- cconfig_finit(config);
-
- 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 */
- if (!config_io.disable_bio2_emu) {
- log_info("Starting sdvx IO backend");
-
- _sdvxhook2_io_sdvx_init(&_sdvxhook2_module_io_sdvx);
-
- if (!bt_io_sdvx_init()) {
- log_fatal("Initializing sdvx IO backend failed");
- }
- }
-
- /* Start up EAMIO.DLL */
- if (!config_io.disable_card_reader_emu) {
- log_misc("Initializing card reader backend");
-
- _sdvxhook2_io_eam_init(&_sdvxhook2_module_io_eam);
-
- if (!bt_io_eam_init()) {
- log_fatal("Initializing card reader backend failed");
- }
- }
-
- /* iohooks are okay, even if emu is diabled since the fake handlers won't be
- * used */
- iohook_push_handler(ac_io_port_dispatch_irp);
- iohook_push_handler(bio2emu_port_dispatch_irp);
-
- if (!config_io.disable_file_hooks) {
- memfile_hook_init();
- iohook_push_handler(memfile_hook_dispatch_irp);
- attach_dest_fd_intercept(sidcode);
- }
-
- rs232_hook_init();
- rs232_hook_limit_hooks();
-
- if (!config_io.disable_bio2_emu) {
- bio2emu_init();
- bio2_emu_bi2a_init(
- &bio2_emu,
- config_io.disable_poll_limiter,
- config_io.force_headphones);
- }
-
- if (!config_io.disable_card_reader_emu) {
- ac_io_port_init(config_io.com1_card_reader);
- }
-
- if (!config_cam.disable_emu) {
- camhook_init(&config_cam);
- }
-
- if (!config_io.disable_power_hooks) {
- powerhook_init();
- }
-
- if (!config_io.disable_nvapi_hooks) {
- nvapihook_init();
- }
-
- adapter_hook_override(config_adapter.override_ip);
-
- log_info("--- End sdvxhook dll_entry_init ---");
-
- return true;
-}
-
-static void _sdvxhook2_main_fini()
-{
- if (!config_cam.disable_emu) {
- camhook_fini();
- }
-
- if (!config_io.disable_card_reader_emu) {
- log_misc("Shutting down card reader backend");
-
- bt_io_eam_fini();
-
- bt_io_eam_api_clear();
- module_io_free(&_sdvxhook2_module_io_eam);
- }
-
- if (!config_io.disable_bio2_emu) {
- log_misc("Shutting down sdvx IO backend");
-
- bt_io_sdvx_fini();
-
- bt_io_sdvx_api_clear();
- module_io_free(&_sdvxhook2_module_io_sdvx);
- }
-
- if (!config_io.disable_file_hooks) {
- memfile_hook_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)
-{
- api->version = 1;
-
- api->v1.main_init = _sdvxhook2_main_init;
- api->v1.main_fini = _sdvxhook2_main_fini;
-}
-
-/**
- * Hook library SDVX5+
- */
BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
{
return TRUE;
-}
+}
\ No newline at end of file
diff --git a/src/main/sdvxhook2/sdvxhook2.c b/src/main/sdvxhook2/sdvxhook2.c
new file mode 100644
index 0000000..40a7f74
--- /dev/null
+++ b/src/main/sdvxhook2/sdvxhook2.c
@@ -0,0 +1,233 @@
+#define LOG_MODULE "sdvxhook2"
+
+#include
+
+#include
+#include
+#include
+#include
+
+#include "hooklib/acp.h"
+#include "hooklib/adapter.h"
+#include "hooklib/config-adapter.h"
+#include "hooklib/memfile.h"
+#include "hooklib/rs232.h"
+
+#include "iface-core/log.h"
+#include "iface-core/thread.h"
+
+#include "iface-io/eam.h"
+#include "iface-io/sdvx.h"
+
+#include "module/io-ext.h"
+#include "module/io.h"
+
+#include "bio2emu/emu.h"
+
+#include "sdvxhook2/acio.h"
+#include "sdvxhook2/bi2a.h"
+#include "sdvxhook2/config-io.h"
+#include "sdvxhook2/nvapi.h"
+#include "sdvxhook2/power.h"
+
+#include "camhook/cam.h"
+#include "camhook/config-cam.h"
+
+#include "d3d9exhook/config-gfx.h"
+#include "d3d9exhook/d3d9ex.h"
+
+#include "sdk/module/core/log.h"
+#include "sdk/module/core/thread.h"
+#include "sdk/module/hook.h"
+
+#include "util/str.h"
+
+static sdvxhook2_config_io_t _sdvxhook2_config_io;
+static camhook_config_cam_t _sdvxhook2_config_cam;
+static d3d9exhook_config_gfx_t _sdvxhook2_config_gfx;
+static hooklib_config_adapter_t _sdvxhook2_config_adapter;
+
+static module_io_t *_sdvxhook2_module_io_sdvx;
+static module_io_t *_sdvxhook2_module_io_eam;
+
+static struct bio2emu_port bio2_emu = {
+ .port = "COM4",
+ .wport = L"\\\\.\\COM4",
+ .dispatcher = bio2_emu_bi2a_dispatch_request,
+};
+
+static void attach_dest_fd_intercept(const char *sidcode)
+{
+ char region = sidcode[3];
+
+ if (region == 'X') {
+ region = 'J';
+ }
+
+ char target_file[8] = "\\x.dest";
+ target_file[1] = tolower(region);
+
+ // can only capture these by ending path due to /dev/raw being mountable
+ memfile_hook_add_fd(target_file, ENDING_MATCH, NULL, 0);
+}
+
+static void _sdvxhook2_io_sdvx_init(module_io_t **module)
+{
+ bt_io_sdvx_api_t api;
+
+ module_io_ext_load_and_init(
+ "sdvxio.dll", "bt_module_io_sdvx_api_get", module);
+ module_io_api_get(*module, &api);
+ bt_io_sdvx_api_set(&api);
+}
+
+static void _sdvxhook2_io_eam_init(module_io_t **module)
+{
+ bt_io_eam_api_t api;
+
+ module_io_ext_load_and_init(
+ "eamio.dll", "bt_module_io_eam_api_get", module);
+ module_io_api_get(*module, &api);
+ bt_io_eam_api_set(&api);
+}
+
+static bool
+_sdvxhook2_main_init(HMODULE game_module, const bt_core_config_t *config)
+{
+ log_info("sdvxhook for Vivid Wave and EXCEED GEAR");
+ log_info("build " __DATE__ " " __TIME__ ", gitrev " STRINGIFY(GITREV));
+
+ // TODO sidcode back-propagation required like jubeat, figure out, crash for now
+ char *sidcode = NULL;
+ log_fatal("DEV TODO: sidcode back-propagation missing");
+ log_assert(sidcode);
+
+ sdvxhook2_config_io_get(config, &_sdvxhook2_config_io);
+ camhook_config_cam_get(config, &_sdvxhook2_config_cam, 1, false);
+ d3d9exhook_config_gfx_get(config, &_sdvxhook2_config_gfx);
+ hooklib_config_adapter_get(config, &_sdvxhook2_config_adapter);
+
+ acp_hook_init();
+ adapter_hook_init();
+ d3d9ex_hook_init();
+
+ d3d9ex_configure(&_sdvxhook2_config_gfx);
+
+ /* Start up sdvxio.DLL */
+ if (!_sdvxhook2_config_io.disable_bio2_emu) {
+ log_info("Starting sdvx IO backend");
+
+ _sdvxhook2_io_sdvx_init(&_sdvxhook2_module_io_sdvx);
+
+ if (!bt_io_sdvx_init()) {
+ log_fatal("Initializing sdvx IO backend failed");
+ }
+ }
+
+ /* Start up EAMIO.DLL */
+ if (!_sdvxhook2_config_io.disable_card_reader_emu) {
+ log_misc("Initializing card reader backend");
+
+ _sdvxhook2_io_eam_init(&_sdvxhook2_module_io_eam);
+
+ if (!bt_io_eam_init()) {
+ log_fatal("Initializing card reader backend failed");
+ }
+ }
+
+ /* iohooks are okay, even if emu is diabled since the fake handlers won't be
+ * used */
+ iohook_push_handler(ac_io_port_dispatch_irp);
+ iohook_push_handler(bio2emu_port_dispatch_irp);
+
+ if (!_sdvxhook2_config_io.disable_file_hooks) {
+ memfile_hook_init();
+ iohook_push_handler(memfile_hook_dispatch_irp);
+ attach_dest_fd_intercept(sidcode);
+ }
+
+ rs232_hook_init();
+ rs232_hook_limit_hooks();
+
+ if (!_sdvxhook2_config_io.disable_bio2_emu) {
+ bio2emu_init();
+ bio2_emu_bi2a_init(
+ &bio2_emu,
+ _sdvxhook2_config_io.disable_poll_limiter,
+ _sdvxhook2_config_io.force_headphones);
+ }
+
+ if (!_sdvxhook2_config_io.disable_card_reader_emu) {
+ ac_io_port_init(_sdvxhook2_config_io.com1_card_reader);
+ }
+
+ if (!_sdvxhook2_config_cam.disable_emu) {
+ camhook_init(&_sdvxhook2_config_cam);
+ }
+
+ if (!_sdvxhook2_config_io.disable_power_hooks) {
+ powerhook_init();
+ }
+
+ if (!_sdvxhook2_config_io.disable_nvapi_hooks) {
+ nvapihook_init();
+ }
+
+ adapter_hook_override(_sdvxhook2_config_adapter.override_ip);
+
+ log_info("--- End sdvxhook dll_entry_init ---");
+
+ return true;
+}
+
+static void _sdvxhook2_main_fini()
+{
+ if (!_sdvxhook2_config_cam.disable_emu) {
+ camhook_fini();
+ }
+
+ if (!_sdvxhook2_config_io.disable_card_reader_emu) {
+ log_misc("Shutting down card reader backend");
+
+ bt_io_eam_fini();
+
+ bt_io_eam_api_clear();
+ module_io_free(&_sdvxhook2_module_io_eam);
+ }
+
+ if (!_sdvxhook2_config_io.disable_bio2_emu) {
+ log_misc("Shutting down sdvx IO backend");
+
+ bt_io_sdvx_fini();
+
+ bt_io_sdvx_api_clear();
+ module_io_free(&_sdvxhook2_module_io_sdvx);
+ }
+
+ if (!_sdvxhook2_config_io.disable_file_hooks) {
+ memfile_hook_fini();
+ }
+}
+
+void bt_module_core_config_api_set(const bt_core_config_api_t *api)
+{
+ bt_core_config_api_set(api);
+}
+
+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;
+}
\ No newline at end of file
diff --git a/src/main/sdvxhook2/sdvxhook2.def b/src/main/sdvxhook2/sdvxhook2.def
index 39341b1..a68079c 100644
--- a/src/main/sdvxhook2/sdvxhook2.def
+++ b/src/main/sdvxhook2/sdvxhook2.def
@@ -4,6 +4,7 @@ EXPORTS
DllMain@12 @1 NONAME
; Bemanitools 6 API
+ bt_module_core_config_api_set
bt_module_core_log_api_set
bt_module_core_thread_api_set
bt_module_hook_api_get
\ No newline at end of file
diff --git a/src/main/sdvxhook2/sdvxhook2.h b/src/main/sdvxhook2/sdvxhook2.h
new file mode 100644
index 0000000..671b926
--- /dev/null
+++ b/src/main/sdvxhook2/sdvxhook2.h
@@ -0,0 +1,9 @@
+#ifndef SDVXHOOK2_H
+#define SDVXHOOK2_H
+
+#include "sdk/module/core/config.h"
+#include "sdk/module/core/log.h"
+#include "sdk/module/core/thread.h"
+#include "sdk/module/hook.h"
+
+#endif
\ No newline at end of file