From 4be866e69edd5122f3b2fef71ecead859b107ded Mon Sep 17 00:00:00 2001 From: QCDLZCLW3K <1329-33c17f40@users.noreply.dev.s-ul.net> Date: Thu, 12 May 2022 19:45:50 +0900 Subject: [PATCH] Add support for DDR X --- Module.mk | 20 ++ dist/ddr/ddr-11-us.conf | 20 ++ dist/ddr/ddr-11.conf | 20 ++ dist/ddr/gamestart-11-us.bat | 11 + dist/ddr/gamestart-11.bat | 11 + src/main/ddrhook-util/Module.mk | 5 + src/main/{ddrhook => ddrhook-util}/_com4.c | 2 +- src/main/{ddrhook => ddrhook-util}/_com4.h | 0 src/main/{ddrhook => ddrhook-util}/extio.c | 0 src/main/{ddrhook => ddrhook-util}/extio.h | 0 src/main/ddrhook-util/p3io.c | 152 +++++++++++ src/main/ddrhook-util/p3io.h | 23 ++ src/main/{ddrhook => ddrhook-util}/spike.c | 0 src/main/{ddrhook => ddrhook-util}/spike.h | 0 src/main/{ddrhook => ddrhook-util}/usbmem.c | 0 src/main/{ddrhook => ddrhook-util}/usbmem.h | 0 src/main/ddrhook/Module.mk | 5 - src/main/ddrhook/dllmain.c | 10 +- src/main/ddrhook/p3io.c | 85 ------ src/main/ddrhook/p3io.h | 14 - src/main/ddrhookx/Module.mk | 28 ++ src/main/ddrhookx/avs-boot.c | 170 ++++++++++++ src/main/ddrhookx/avs-boot.h | 19 ++ src/main/ddrhookx/config-ddrhookx.c | 54 ++++ src/main/ddrhookx/config-ddrhookx.h | 31 +++ src/main/ddrhookx/config-eamuse.c | 144 ++++++++++ src/main/ddrhookx/config-eamuse.h | 36 +++ src/main/ddrhookx/config-gfx.c | 36 +++ src/main/ddrhookx/config-gfx.h | 30 +++ src/main/ddrhookx/config-security.c | 75 ++++++ src/main/ddrhookx/config-security.h | 34 +++ src/main/ddrhookx/d3d9.c | 281 ++++++++++++++++++++ src/main/ddrhookx/d3d9.h | 18 ++ src/main/ddrhookx/ddrhookx.def | 4 + src/main/ddrhookx/dllmain.c | 197 ++++++++++++++ src/main/ddrhookx/filesystem.c | 115 ++++++++ src/main/ddrhookx/filesystem.h | 8 + src/main/ddrhookx/master.c | 66 +++++ src/main/ddrhookx/master.h | 8 + src/main/hook/d3d9.c | 46 +++- src/main/hook/d3d9.h | 9 + src/main/security/rp-sign-key.c | 3 + src/main/security/rp-sign-key.h | 8 + src/main/unicorntail/dllmain.c | 3 - 44 files changed, 1687 insertions(+), 114 deletions(-) create mode 100644 dist/ddr/ddr-11-us.conf create mode 100644 dist/ddr/ddr-11.conf create mode 100644 dist/ddr/gamestart-11-us.bat create mode 100644 dist/ddr/gamestart-11.bat rename src/main/{ddrhook => ddrhook-util}/_com4.c (99%) rename src/main/{ddrhook => ddrhook-util}/_com4.h (100%) rename src/main/{ddrhook => ddrhook-util}/extio.c (100%) rename src/main/{ddrhook => ddrhook-util}/extio.h (100%) create mode 100644 src/main/ddrhook-util/p3io.c create mode 100644 src/main/ddrhook-util/p3io.h rename src/main/{ddrhook => ddrhook-util}/spike.c (100%) rename src/main/{ddrhook => ddrhook-util}/spike.h (100%) rename src/main/{ddrhook => ddrhook-util}/usbmem.c (100%) rename src/main/{ddrhook => ddrhook-util}/usbmem.h (100%) delete mode 100644 src/main/ddrhook/p3io.c delete mode 100644 src/main/ddrhook/p3io.h create mode 100644 src/main/ddrhookx/Module.mk create mode 100644 src/main/ddrhookx/avs-boot.c create mode 100644 src/main/ddrhookx/avs-boot.h create mode 100644 src/main/ddrhookx/config-ddrhookx.c create mode 100644 src/main/ddrhookx/config-ddrhookx.h create mode 100644 src/main/ddrhookx/config-eamuse.c create mode 100644 src/main/ddrhookx/config-eamuse.h create mode 100644 src/main/ddrhookx/config-gfx.c create mode 100644 src/main/ddrhookx/config-gfx.h create mode 100644 src/main/ddrhookx/config-security.c create mode 100644 src/main/ddrhookx/config-security.h create mode 100644 src/main/ddrhookx/d3d9.c create mode 100644 src/main/ddrhookx/d3d9.h create mode 100644 src/main/ddrhookx/ddrhookx.def create mode 100644 src/main/ddrhookx/dllmain.c create mode 100644 src/main/ddrhookx/filesystem.c create mode 100644 src/main/ddrhookx/filesystem.h create mode 100644 src/main/ddrhookx/master.c create mode 100644 src/main/ddrhookx/master.h diff --git a/Module.mk b/Module.mk index b4a30d1..68b071b 100644 --- a/Module.mk +++ b/Module.mk @@ -94,6 +94,7 @@ include src/main/config/Module.mk include src/main/d3d9exhook/Module.mk include src/main/ddrhook-util/Module.mk include src/main/ddrhook/Module.mk +include src/main/ddrhookx/Module.mk include src/main/ddrio-mm/Module.mk include src/main/ddrio-smx/Module.mk include src/main/ddrio/Module.mk @@ -566,6 +567,25 @@ $(zipdir)/sdvx-hwio-x64.zip: \ $(V)echo ... $@ $(V)zip -j $@ $^ +$(zipdir)/ddr-11.zip: \ + build/bin/indep-32/inject.exe \ + build/bin/avs2_803-32/ddrhookx.dll \ + build/bin/avs2_803-32/unicorntail.dll \ + build/bin/indep-32/config.exe \ + build/bin/indep-32/ddrio.dll \ + build/bin/indep-32/ddrio-mm.dll \ + build/bin/indep-32/ddrio-smx.dll \ + build/bin/indep-32/eamio.dll \ + build/bin/indep-32/geninput.dll \ + dist/ddr/config.bat \ + dist/ddr/gamestart-11.bat \ + dist/ddr/gamestart-11-us.bat \ + dist/ddr/ddr-11.conf \ + dist/ddr/ddr-11-us.conf \ + | $(zipdir)/ + $(V)echo ... $@ + $(V)zip -j $@ $^ + $(zipdir)/ddr-12-to-16.zip: \ build/bin/avs2_1508-32/launcher.exe \ build/bin/avs2_1508-32/ddrhook.dll \ diff --git a/dist/ddr/ddr-11-us.conf b/dist/ddr/ddr-11-us.conf new file mode 100644 index 0000000..7f46bce --- /dev/null +++ b/dist/ddr/ddr-11-us.conf @@ -0,0 +1,20 @@ +# URL (e.g. http://my.eamuse.server:80/whatever) or IPV4 (e.g. 127.0.0.1:80) of the target eamuse server. The port is optional but defaults to 80. +eamuse.server=localhost:80 + +# PCBID +eamuse.pcbid=0101020304050607086F + +# EAMID +eamuse.eamid=0101020304050607086F + +# Mcode of the game to run. +security.mcode=GQHDXUAA + +# Emulate P3IO COM4 and its downstream devices. Uses the Windows COM4 port when disabled. +ddrhookx.use_com4_emu=true + +# SD cabinet mode +ddrhookx.standard_def=false + +# Run the game windowed +gfx.windowed=false diff --git a/dist/ddr/ddr-11.conf b/dist/ddr/ddr-11.conf new file mode 100644 index 0000000..cdb988d --- /dev/null +++ b/dist/ddr/ddr-11.conf @@ -0,0 +1,20 @@ +# URL (e.g. http://my.eamuse.server:80/whatever) or IPV4 (e.g. 127.0.0.1:80) of the target eamuse server. The port is optional but defaults to 80. +eamuse.server=localhost:80 + +# PCBID +eamuse.pcbid=0101020304050607086F + +# EAMID +eamuse.eamid=0101020304050607086F + +# Mcode of the game to run. +security.mcode=GQHDXJAA + +# Emulate P3IO COM4 and its downstream devices. Uses the Windows COM4 port when disabled. +ddrhookx.use_com4_emu=true + +# SD cabinet mode +ddrhookx.standard_def=false + +# Run the game windowed +gfx.windowed=false diff --git a/dist/ddr/gamestart-11-us.bat b/dist/ddr/gamestart-11-us.bat new file mode 100644 index 0000000..f3ce2ce --- /dev/null +++ b/dist/ddr/gamestart-11-us.bat @@ -0,0 +1,11 @@ +@echo off + +cd /d %~dp0 + +if not exist conf mkdir conf +if not exist conf\nvram mkdir conf\nvram +if not exist conf\raw mkdir conf\raw + +regsvr32 /s xactengine2_10.dll + +inject ddrhookx.dll DDR.exe --config ddr-11-us.conf %* diff --git a/dist/ddr/gamestart-11.bat b/dist/ddr/gamestart-11.bat new file mode 100644 index 0000000..328ba52 --- /dev/null +++ b/dist/ddr/gamestart-11.bat @@ -0,0 +1,11 @@ +@echo off + +cd /d %~dp0 + +if not exist conf mkdir conf +if not exist conf\nvram mkdir conf\nvram +if not exist conf\raw mkdir conf\raw + +regsvr32 /s xactengine2_10.dll + +inject ddrhookx.dll DDR.exe --config ddr-11.conf %* diff --git a/src/main/ddrhook-util/Module.mk b/src/main/ddrhook-util/Module.mk index e395d5c..bd7cd9a 100644 --- a/src/main/ddrhook-util/Module.mk +++ b/src/main/ddrhook-util/Module.mk @@ -11,3 +11,8 @@ src_ddrhook-util := \ guid.c \ misc.c \ monitor.c \ + extio.c \ + _com4.c \ + usbmem.c \ + spike.c \ + p3io.c \ diff --git a/src/main/ddrhook/_com4.c b/src/main/ddrhook-util/_com4.c similarity index 99% rename from src/main/ddrhook/_com4.c rename to src/main/ddrhook-util/_com4.c index b100b68..968d97c 100644 --- a/src/main/ddrhook/_com4.c +++ b/src/main/ddrhook-util/_com4.c @@ -19,7 +19,7 @@ #include "bemanitools/ddrio.h" -#include "ddrhook/_com4.h" +#include "ddrhook-util/_com4.h" #include "hook/iohook.h" diff --git a/src/main/ddrhook/_com4.h b/src/main/ddrhook-util/_com4.h similarity index 100% rename from src/main/ddrhook/_com4.h rename to src/main/ddrhook-util/_com4.h diff --git a/src/main/ddrhook/extio.c b/src/main/ddrhook-util/extio.c similarity index 100% rename from src/main/ddrhook/extio.c rename to src/main/ddrhook-util/extio.c diff --git a/src/main/ddrhook/extio.h b/src/main/ddrhook-util/extio.h similarity index 100% rename from src/main/ddrhook/extio.h rename to src/main/ddrhook-util/extio.h diff --git a/src/main/ddrhook-util/p3io.c b/src/main/ddrhook-util/p3io.c new file mode 100644 index 0000000..f55afb0 --- /dev/null +++ b/src/main/ddrhook-util/p3io.c @@ -0,0 +1,152 @@ +#include + +#include +#include + +#include "bemanitools/ddrio.h" + +#include "ddrhook-util/p3io.h" + +#include "p3ioemu/emu.h" +#include "p3ioemu/uart.h" + +#include "util/log.h" + +extern bool _15khz; +extern bool standard_def; + +static HRESULT p3io_ddr_read_jamma(void *ctx, uint32_t *state); +static HRESULT p3io_ddr_set_outputs(void *ctx, uint32_t outputs); +static HRESULT p3io_ddr_get_cab_type(void *ctx, enum p3io_cab_type *type); +static HRESULT p3io_ddr_get_video_freq(void *ctx, enum p3io_video_freq *freq); +static HRESULT p3io_ddr_get_roundplug( + void *ctx, uint8_t plug_id, uint8_t *rom, uint8_t *eeprom); + +static const struct p3io_ops p3io_ddr_ops = { + .read_jamma = p3io_ddr_read_jamma, + .set_outputs = p3io_ddr_set_outputs, + .get_cab_type = p3io_ddr_get_cab_type, + .get_video_freq = p3io_ddr_get_video_freq, +}; + +static const struct p3io_ops p3io_ddr_ops_with_plugs = { + .read_jamma = p3io_ddr_read_jamma, + .set_outputs = p3io_ddr_set_outputs, + .get_cab_type = p3io_ddr_get_cab_type, + .get_video_freq = p3io_ddr_get_video_freq, + .get_roundplug = p3io_ddr_get_roundplug, +}; + +static struct security_mcode p3io_ddr_mcode; +static struct security_id p3io_ddr_pcbid; +static struct security_id p3io_ddr_eamid; +static struct security_rp_sign_key p3io_black_sign_key; +static struct security_rp_sign_key p3io_white_sign_key; + +void p3io_ddr_init(void) +{ + /* COM4 isn't a real COM port, we configure the core P3IO emulator code to + generate IRPs addressed to COM4 and then we possibly intercept them in + _com4.c (or possibly don't, in which case the communications will be + sent to the real COM4 on your system) */ + + p3io_uart_set_path(0, L"COM4"); + p3io_emu_init(&p3io_ddr_ops, NULL); +} + +void p3io_ddr_init_with_plugs( + const struct security_mcode *mcode, + const struct security_id *pcbid, + const struct security_id *eamid, + const struct security_rp_sign_key *black_sign_key, + const struct security_rp_sign_key *white_sign_key) +{ + memcpy(&p3io_ddr_mcode, mcode, sizeof(struct security_mcode)); + memcpy(&p3io_ddr_pcbid, pcbid, sizeof(struct security_id)); + memcpy(&p3io_ddr_eamid, eamid, sizeof(struct security_id)); + memcpy(&p3io_black_sign_key, black_sign_key, sizeof(struct security_rp_sign_key)); + memcpy(&p3io_white_sign_key, white_sign_key, sizeof(struct security_rp_sign_key)); + + /* COM4 isn't a real COM port, we configure the core P3IO emulator code to + generate IRPs addressed to COM4 and then we possibly intercept them in + _com4.c (or possibly don't, in which case the communications will be + sent to the real COM4 on your system) */ + + p3io_uart_set_path(0, L"COM4"); + p3io_emu_init(&p3io_ddr_ops_with_plugs, NULL); +} + +void p3io_ddr_fini(void) +{ + p3io_emu_fini(); +} + +static HRESULT p3io_ddr_read_jamma(void *ctx, uint32_t *state) +{ + log_assert(state != NULL); + + *state = ddr_io_read_pad(); + + return S_OK; +} + +static HRESULT p3io_ddr_set_outputs(void *ctx, uint32_t outputs) +{ + ddr_io_set_lights_p3io(outputs); + + return S_OK; +} + +static HRESULT p3io_ddr_get_cab_type(void *ctx, enum p3io_cab_type *type) +{ + if (standard_def) { + *type = P3IO_CAB_TYPE_SD; + } else { + *type = P3IO_CAB_TYPE_HD; + } + + return S_OK; +} + +static HRESULT p3io_ddr_get_video_freq(void *ctx, enum p3io_video_freq *freq) +{ + if (_15khz) { + *freq = P3IO_VIDEO_FREQ_15KHZ; + } else { + *freq = P3IO_VIDEO_FREQ_31KHZ; + } + + return S_OK; +} + +static HRESULT p3io_ddr_get_roundplug( + void *ctx, uint8_t plug_id, uint8_t *rom, uint8_t *eeprom) +{ + struct security_rp3_eeprom eeprom_out; + + if (plug_id == 0) { + /* black */ + memcpy(rom, p3io_ddr_pcbid.id, sizeof(p3io_ddr_pcbid.id)); + security_rp3_generate_signed_eeprom_data( + SECURITY_RP_UTIL_RP_TYPE_BLACK, + &p3io_black_sign_key, + &p3io_ddr_mcode, + &p3io_ddr_pcbid, + &eeprom_out); + } else { + /* white */ + memcpy(rom, p3io_ddr_eamid.id, sizeof(p3io_ddr_eamid.id)); + security_rp3_generate_signed_eeprom_data( + SECURITY_RP_UTIL_RP_TYPE_WHITE, + &p3io_white_sign_key, + &security_mcode_eamuse, + &p3io_ddr_eamid, + &eeprom_out); + } + + memcpy(eeprom, &eeprom_out, sizeof(struct security_rp3_eeprom)); + + return S_OK; +} + +// TODO coinstock diff --git a/src/main/ddrhook-util/p3io.h b/src/main/ddrhook-util/p3io.h new file mode 100644 index 0000000..68ce7ac --- /dev/null +++ b/src/main/ddrhook-util/p3io.h @@ -0,0 +1,23 @@ +#ifndef DDRHOOK_P3IO_H +#define DDRHOOK_P3IO_H + +#include + +#include "hook/iohook.h" + +#include "security/rp-sign-key.h" +#include "security/rp3.h" + +extern const wchar_t p3io_dev_node_prefix[]; +extern const wchar_t p3io_dev_node[]; + +void p3io_ddr_init(void); +void p3io_ddr_init_with_plugs( + const struct security_mcode *mcode, + const struct security_id *pcbid, + const struct security_id *eamid, + const struct security_rp_sign_key *black_sign_key, + const struct security_rp_sign_key *white_sign_key); +void p3io_ddr_fini(void); + +#endif diff --git a/src/main/ddrhook/spike.c b/src/main/ddrhook-util/spike.c similarity index 100% rename from src/main/ddrhook/spike.c rename to src/main/ddrhook-util/spike.c diff --git a/src/main/ddrhook/spike.h b/src/main/ddrhook-util/spike.h similarity index 100% rename from src/main/ddrhook/spike.h rename to src/main/ddrhook-util/spike.h diff --git a/src/main/ddrhook/usbmem.c b/src/main/ddrhook-util/usbmem.c similarity index 100% rename from src/main/ddrhook/usbmem.c rename to src/main/ddrhook-util/usbmem.c diff --git a/src/main/ddrhook/usbmem.h b/src/main/ddrhook-util/usbmem.h similarity index 100% rename from src/main/ddrhook/usbmem.h rename to src/main/ddrhook-util/usbmem.h diff --git a/src/main/ddrhook/Module.mk b/src/main/ddrhook/Module.mk index b44ae81..6dd0d9b 100644 --- a/src/main/ddrhook/Module.mk +++ b/src/main/ddrhook/Module.mk @@ -15,11 +15,6 @@ libs_ddrhook := \ ddrio \ src_ddrhook := \ - extio.c \ dllmain.c \ - _com4.c \ master.c \ - p3io.c \ - usbmem.c \ - spike.c diff --git a/src/main/ddrhook/dllmain.c b/src/main/ddrhook/dllmain.c index c4dede5..ffb220a 100644 --- a/src/main/ddrhook/dllmain.c +++ b/src/main/ddrhook/dllmain.c @@ -5,14 +5,14 @@ #include "bemanitools/ddrio.h" #include "bemanitools/eamio.h" +#include "ddrhook-util/_com4.h" +#include "ddrhook-util/extio.h" #include "ddrhook-util/gfx.h" +#include "ddrhook-util/p3io.h" +#include "ddrhook-util/spike.h" +#include "ddrhook-util/usbmem.h" -#include "ddrhook/_com4.h" -#include "ddrhook/extio.h" #include "ddrhook/master.h" -#include "ddrhook/p3io.h" -#include "ddrhook/spike.h" -#include "ddrhook/usbmem.h" #include "hook/iohook.h" diff --git a/src/main/ddrhook/p3io.c b/src/main/ddrhook/p3io.c deleted file mode 100644 index 424d9ef..0000000 --- a/src/main/ddrhook/p3io.c +++ /dev/null @@ -1,85 +0,0 @@ -#include - -#include -#include - -#include "bemanitools/ddrio.h" - -#include "ddrhook/p3io.h" - -#include "p3ioemu/emu.h" -#include "p3ioemu/uart.h" - -#include "util/log.h" - -extern bool _15khz; -extern bool standard_def; - -static HRESULT p3io_ddr_read_jamma(void *ctx, uint32_t *state); -static HRESULT p3io_ddr_set_outputs(void *ctx, uint32_t outputs); -static HRESULT p3io_ddr_get_cab_type(void *ctx, enum p3io_cab_type *type); -static HRESULT p3io_ddr_get_video_freq(void *ctx, enum p3io_video_freq *freq); - -static const struct p3io_ops p3io_ddr_ops = { - .read_jamma = p3io_ddr_read_jamma, - .set_outputs = p3io_ddr_set_outputs, - .get_cab_type = p3io_ddr_get_cab_type, - .get_video_freq = p3io_ddr_get_video_freq, -}; - -void p3io_ddr_init(void) -{ - /* COM4 isn't a real COM port, we configure the core P3IO emulator code to - generate IRPs addressed to COM4 and then we possibly intercept them in - _com4.c (or possibly don't, in which case the communications will be - sent to the real COM4 on your system) */ - - p3io_uart_set_path(0, L"COM4"); - p3io_emu_init(&p3io_ddr_ops, NULL); -} - -void p3io_ddr_fini(void) -{ - p3io_emu_fini(); -} - -static HRESULT p3io_ddr_read_jamma(void *ctx, uint32_t *state) -{ - log_assert(state != NULL); - - *state = ddr_io_read_pad(); - - return S_OK; -} - -static HRESULT p3io_ddr_set_outputs(void *ctx, uint32_t outputs) -{ - ddr_io_set_lights_p3io(outputs); - - return S_OK; -} - -static HRESULT p3io_ddr_get_cab_type(void *ctx, enum p3io_cab_type *type) -{ - if (standard_def) { - *type = P3IO_CAB_TYPE_SD; - } else { - *type = P3IO_CAB_TYPE_HD; - } - - return S_OK; -} - -static HRESULT p3io_ddr_get_video_freq(void *ctx, enum p3io_video_freq *freq) -{ - if (_15khz) { - *freq = P3IO_VIDEO_FREQ_15KHZ; - } else { - *freq = P3IO_VIDEO_FREQ_31KHZ; - } - - return S_OK; -} - -// TODO coinstock -// TODO round plug diff --git a/src/main/ddrhook/p3io.h b/src/main/ddrhook/p3io.h deleted file mode 100644 index ae1570d..0000000 --- a/src/main/ddrhook/p3io.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef DDRHOOK_P3IO_H -#define DDRHOOK_P3IO_H - -#include - -#include "hook/iohook.h" - -extern const wchar_t p3io_dev_node_prefix[]; -extern const wchar_t p3io_dev_node[]; - -void p3io_ddr_init(void); -void p3io_ddr_fini(void); - -#endif diff --git a/src/main/ddrhookx/Module.mk b/src/main/ddrhookx/Module.mk new file mode 100644 index 0000000..ea8f853 --- /dev/null +++ b/src/main/ddrhookx/Module.mk @@ -0,0 +1,28 @@ +avsdlls += ddrhookx + +deplibs_ddrhookx := \ + avs \ + +libs_ddrhookx := \ + acioemu \ + cconfig \ + ddrhook-util \ + p3ioemu \ + p3io \ + hook \ + hooklib \ + util \ + eamio \ + ddrio \ + security \ + +src_ddrhookx := \ + avs-boot.c \ + dllmain.c \ + config-ddrhookx.c \ + config-eamuse.c \ + config-gfx.c \ + config-security.c \ + d3d9.c \ + master.c \ + filesystem.c \ diff --git a/src/main/ddrhookx/avs-boot.c b/src/main/ddrhookx/avs-boot.c new file mode 100644 index 0000000..3d0b124 --- /dev/null +++ b/src/main/ddrhookx/avs-boot.c @@ -0,0 +1,170 @@ +#define LOG_MODULE "avs-boot" + +#include +#include +#include +#include + +#include "hook/iohook.h" +#include "hook/table.h" + +#include "imports/avs.h" + +#include "ddrhookx/avs-boot.h" +#include "ddrhookx/filesystem.h" + +#include "util/log.h" +#include "util/str.h" + +static void (*real_avs_boot)( + struct property_node *config, + void *std_heap, + size_t sz_std_heap, + void *avs_heap, + size_t sz_avs_heap, + avs_log_writer_t log_writer, + void *log_context); +static int (*real_ea3_boot)(struct property_node *config); + +static int my_ea3_boot(struct property_node *config); + +static void my_avs_boot( + struct property_node *config, + void *std_heap, + size_t sz_std_heap, + void *avs_heap, + size_t sz_avs_heap, + avs_log_writer_t log_writer, + void *log_context); +static struct net_addr ddrhookx_avs_boot_eamuse_server_addr; + +static const struct hook_symbol ddrxhook_avs_hook_syms[] = { + {.name = "avs_boot", + .patch = my_avs_boot, + .link = (void **) &real_avs_boot}, +}; + +static const struct hook_symbol ddrhookx_avs_ea3_hook_syms[] = { + {.name = "ea3_boot", + .patch = my_ea3_boot, + .link = (void **) &real_ea3_boot}, +}; + +static void avs_boot_replace_property_str( + struct property_node *node, const char *name, const char *val) +{ + struct property_node *tmp; + + tmp = property_search(NULL, node, name); + + if (tmp) { + property_node_remove(tmp); + } + + tmp = property_node_create(NULL, node, PROPERTY_TYPE_STR, name, val); + + if (tmp) { + property_node_datasize(tmp); + } +} + +static void my_avs_boot( + struct property_node *config, + void *std_heap, + size_t sz_std_heap, + void *avs_heap, + size_t sz_avs_heap, + avs_log_writer_t log_writer, + void *log_context) +{ + log_info("Called my_avs_boot"); + + char nvram_path[MAX_PATH] = {0}; + char raw_path[MAX_PATH] = {0}; + + // Using the full path as part of the AVS paths seems to break on long paths. + // So instead, just take the launcher folder relative to the main game directory. + char *launcher_folder; + get_launcher_path_parts(NULL, &launcher_folder); + + if (launcher_folder) { + strcpy(nvram_path, launcher_folder); + strcat(nvram_path, "\\"); + + strcpy(raw_path, launcher_folder); + strcat(raw_path, "\\"); + + free(launcher_folder); + } + + strcat(nvram_path, "conf\\nvram"); + strcat(raw_path, "conf\\raw"); + + log_misc("avs paths: %s %s\n", nvram_path, raw_path); + + avs_boot_replace_property_str( + config, "/fs/nvram/device", nvram_path); + avs_boot_replace_property_str( + config, "/fs/raw/device", raw_path); + + real_avs_boot( + config, + std_heap, + sz_std_heap, + avs_heap, + sz_avs_heap, + log_writer_debug, + NULL); +} + +static int my_ea3_boot(struct property_node *config) +{ + char *server_addr; + + log_info("Called my_ea3_boot"); + + if (ddrhookx_avs_boot_eamuse_server_addr.type != NET_ADDR_TYPE_INVALID) { + log_misc("Injecting network server address"); + + server_addr = net_addr_to_str(&ddrhookx_avs_boot_eamuse_server_addr); + + avs_boot_replace_property_str(config, "network/services", server_addr); + + free(server_addr); + } + + return real_ea3_boot(config); +} + +void ddrhookx_avs_boot_init() +{ + hook_table_apply( + NULL, + "libavs-win32.dll", + ddrxhook_avs_hook_syms, + lengthof(ddrxhook_avs_hook_syms)); + + hook_table_apply( + NULL, + "libavs-win32-ea3.dll", + ddrhookx_avs_ea3_hook_syms, + lengthof(ddrhookx_avs_ea3_hook_syms)); + + memset(&ddrhookx_avs_boot_eamuse_server_addr, 0, sizeof(struct net_addr)); + + log_info("Inserted avs log hooks"); +} + +void ddrhookx_avs_boot_set_eamuse_addr(const struct net_addr *server_addr) +{ + char *str; + + str = net_addr_to_str(server_addr); + log_info("Setting eamuse server: %s", str); + free(str); + + memcpy( + &ddrhookx_avs_boot_eamuse_server_addr, + server_addr, + sizeof(struct net_addr)); +} \ No newline at end of file diff --git a/src/main/ddrhookx/avs-boot.h b/src/main/ddrhookx/avs-boot.h new file mode 100644 index 0000000..140741f --- /dev/null +++ b/src/main/ddrhookx/avs-boot.h @@ -0,0 +1,19 @@ +#ifndef DDRHOOKX_AVS_BOOT_H +#define DDRHOOKX_AVS_BOOT_H + +#include "util/net.h" + +/** + * Initialize hooking of avs_boot and ea3_boot. This re-enables avs logging + * and injects a few important settings. + */ +void ddrhookx_avs_boot_init(); + +/** + * Set the target eamuse server address. + * + * @param server_addr Address to target eamuse server. + */ +void ddrhookx_avs_boot_set_eamuse_addr(const struct net_addr *server_addr); + +#endif diff --git a/src/main/ddrhookx/config-ddrhookx.c b/src/main/ddrhookx/config-ddrhookx.c new file mode 100644 index 0000000..35b0541 --- /dev/null +++ b/src/main/ddrhookx/config-ddrhookx.c @@ -0,0 +1,54 @@ +#include + +#include "cconfig/cconfig-util.h" + +#include "ddrhookx/config-ddrhookx.h" + +#include "util/log.h" + +#define DDRHOOKX_CONFIG_DDRHOOKX_USE_COM4_EMU_KEY "ddrhookx.use_com4_emu" +#define DDRHOOKX_CONFIG_DDRHOOKX_STANDARD_DEF_KEY "ddrhookx.standard_def" + +#define DDRHOOKX_CONFIG_DDRHOOKX_DEFAULT_USE_COM4_EMU_VALUE true +#define DDRHOOKX_CONFIG_DDRHOOKX_DEFAULT_STANDARD_DEF_VALUE false + +void ddrhookx_config_ddrhookx_init(struct cconfig *config) +{ + cconfig_util_set_bool( + config, + DDRHOOKX_CONFIG_DDRHOOKX_USE_COM4_EMU_KEY, + DDRHOOKX_CONFIG_DDRHOOKX_DEFAULT_USE_COM4_EMU_VALUE, + "Don't emulate P3IO COM4 and its downstream devices, use the Windows COM4 port instead"); + cconfig_util_set_bool( + config, + DDRHOOKX_CONFIG_DDRHOOKX_STANDARD_DEF_KEY, + DDRHOOKX_CONFIG_DDRHOOKX_DEFAULT_STANDARD_DEF_VALUE, + "SD cabinet mode"); +} + +void ddrhookx_config_ddrhookx_get( + struct ddrhookx_config_ddrhookx *config_ddrhookx, struct cconfig *config) +{ + if (!cconfig_util_get_bool( + config, + DDRHOOKX_CONFIG_DDRHOOKX_USE_COM4_EMU_KEY, + &config_ddrhookx->use_com4_emu, + DDRHOOKX_CONFIG_DDRHOOKX_DEFAULT_USE_COM4_EMU_VALUE)) { + log_warning( + "Invalid value for key '%s' specified, fallback " + "to default '%d'", + DDRHOOKX_CONFIG_DDRHOOKX_USE_COM4_EMU_KEY, + DDRHOOKX_CONFIG_DDRHOOKX_DEFAULT_USE_COM4_EMU_VALUE); + } + if (!cconfig_util_get_bool( + config, + DDRHOOKX_CONFIG_DDRHOOKX_STANDARD_DEF_KEY, + &config_ddrhookx->standard_def, + DDRHOOKX_CONFIG_DDRHOOKX_DEFAULT_STANDARD_DEF_VALUE)) { + log_warning( + "Invalid value for key '%s' specified, fallback " + "to default '%d'", + DDRHOOKX_CONFIG_DDRHOOKX_STANDARD_DEF_KEY, + DDRHOOKX_CONFIG_DDRHOOKX_DEFAULT_STANDARD_DEF_VALUE); + } +} diff --git a/src/main/ddrhookx/config-ddrhookx.h b/src/main/ddrhookx/config-ddrhookx.h new file mode 100644 index 0000000..1bffa06 --- /dev/null +++ b/src/main/ddrhookx/config-ddrhookx.h @@ -0,0 +1,31 @@ +#ifndef DDRHOOKX_CONFIG_DDRHOOKX_H +#define DDRHOOKX_CONFIG_DDRHOOKX_H + +#include "cconfig/cconfig.h" + +/** + * Struct holding configuration values for game-specific items. + */ +struct ddrhookx_config_ddrhookx { + bool use_com4_emu; + bool standard_def; +}; + +/** + * Initialize a cconfig structure with the basic structure and default values + * of this configuration. + */ +void ddrhookx_config_ddrhookx_init(struct cconfig *config); + +/** + * Read the module specific config struct values from the provided cconfig + * struct. + * + * @param config_ddrhookx Target module specific struct to read configuration + * values to. + * @param config cconfig struct holding the intermediate data to read from. + */ +void ddrhookx_config_ddrhookx_get( + struct ddrhookx_config_ddrhookx *config_ddrhookx, struct cconfig *config); + +#endif diff --git a/src/main/ddrhookx/config-eamuse.c b/src/main/ddrhookx/config-eamuse.c new file mode 100644 index 0000000..a6f9a8d --- /dev/null +++ b/src/main/ddrhookx/config-eamuse.c @@ -0,0 +1,144 @@ +#include + +#include "cconfig/cconfig-util.h" + +#include "ddrhookx/config-eamuse.h" + +#include "util/log.h" +#include "util/net.h" + +#define DDRHOOKX_CONFIG_EAMUSE_SERVER_KEY "eamuse.server" +#define DDRHOOKX_CONFIG_EAMUSE_PCBID_KEY "eamuse.pcbid" +#define DDRHOOKX_CONFIG_EAMUSE_EAMID_KEY "eamuse.eamid" + +#define DDRHOOKX_CONFIG_EAMUSE_DEFAULT_SERVER_VALUE "localhost:80" +#define DDRHOOKX_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE security_id_default +#define DDRHOOKX_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE_LEN \ + sizeof(security_id_default) +#define DDRHOOKX_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE security_id_default +#define DDRHOOKX_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE_LEN \ + sizeof(security_id_default) + +const struct net_addr ddrhookx_eamuse_default_server = { + .type = NET_ADDR_TYPE_HOSTNAME, + .hostname.host = "localhost", + .hostname.port = 80, +}; + +void ddrhookx_config_eamuse_init(struct cconfig *config) +{ + cconfig_util_set_str( + config, + DDRHOOKX_CONFIG_EAMUSE_SERVER_KEY, + DDRHOOKX_CONFIG_EAMUSE_DEFAULT_SERVER_VALUE, + "URL (e.g. http://my.eamuse.server:80/whatever) or IPV4 " + "(e.g. 127.0.0.1:80) of the target eamuse server. The port is " + "optional " + "but defaults to 80."); + + cconfig_util_set_data( + config, + DDRHOOKX_CONFIG_EAMUSE_PCBID_KEY, + (uint8_t *) &DDRHOOKX_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE, + DDRHOOKX_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE_LEN, + "PCBID"); + + cconfig_util_set_data( + config, + DDRHOOKX_CONFIG_EAMUSE_EAMID_KEY, + (uint8_t *) &DDRHOOKX_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE, + DDRHOOKX_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE_LEN, + "EAMID"); +} + +void ddrhookx_config_eamuse_get( + struct ddrhookx_config_eamuse *config_eamuse, struct cconfig *config) +{ + char server_url[1024]; + char *tmp; + char *tmp2; + + memset(config_eamuse, 0, sizeof(struct ddrhookx_config_eamuse)); + + if (!cconfig_util_get_str( + config, + DDRHOOKX_CONFIG_EAMUSE_SERVER_KEY, + server_url, + sizeof(server_url), + DDRHOOKX_CONFIG_EAMUSE_DEFAULT_SERVER_VALUE)) { + log_warning( + "Invalid value for key '%s' specified, fallback " + "to default '%s'", + DDRHOOKX_CONFIG_EAMUSE_SERVER_KEY, + DDRHOOKX_CONFIG_EAMUSE_DEFAULT_SERVER_VALUE); + } + + if (!net_str_parse(server_url, &config_eamuse->server)) { + memcpy( + &config_eamuse->server, + &ddrhookx_eamuse_default_server, + sizeof(config_eamuse->server)); + tmp = net_addr_to_str(&config_eamuse->server); + log_warning( + "Invalid value for key '%s' specified, fallback " + "to default", + tmp); + free(tmp); + } + + if (!cconfig_util_get_data( + config, + DDRHOOKX_CONFIG_EAMUSE_PCBID_KEY, + (uint8_t *) &config_eamuse->pcbid, + DDRHOOKX_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE_LEN, + (uint8_t *) &DDRHOOKX_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE)) { + tmp = security_id_to_str( + &DDRHOOKX_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE, false); + log_warning( + "Invalid value for key '%s' specified, fallback " + "to default", + tmp); + free(tmp); + } + + if (!security_id_verify(&config_eamuse->pcbid)) { + tmp = security_id_to_str( + &DDRHOOKX_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE, false); + tmp2 = security_id_to_str(&config_eamuse->pcbid, false); + log_warning( + "PCBID verification of '%s' failed, fallback to default " + "PCBID '%s'", + tmp2, + tmp); + free(tmp); + free(tmp2); + } + + if (!cconfig_util_get_data( + config, + DDRHOOKX_CONFIG_EAMUSE_EAMID_KEY, + (uint8_t *) &config_eamuse->eamid, + DDRHOOKX_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE_LEN, + (uint8_t *) &DDRHOOKX_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE)) { + tmp = security_id_to_str( + &DDRHOOKX_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE, false); + log_warning( + "Invalid value for key '%s' specified, fallback " + "to default", + tmp); + free(tmp); + } + + if (!security_id_verify(&config_eamuse->eamid)) { + tmp = security_id_to_str( + &DDRHOOKX_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE, false); + tmp2 = security_id_to_str(&config_eamuse->eamid, false); + log_warning( + "EAMID verification of '%s' failed, fallback to default " + "EAMID '%s'", + tmp2, + tmp); + free(tmp); + free(tmp2); + } +} diff --git a/src/main/ddrhookx/config-eamuse.h b/src/main/ddrhookx/config-eamuse.h new file mode 100644 index 0000000..017af7c --- /dev/null +++ b/src/main/ddrhookx/config-eamuse.h @@ -0,0 +1,36 @@ +#ifndef DDRHOOKX_CONFIG_EAMUSE_H +#define DDRHOOKX_CONFIG_EAMUSE_H + +#include "cconfig/cconfig.h" + +#include "security/id.h" + +#include "util/net.h" + +/** + * Struct holding configuration values for eamuse related items. + */ +struct ddrhookx_config_eamuse { + struct net_addr server; + struct security_id pcbid; + struct security_id eamid; +}; + +/** + * Initialize a cconfig structure with the basic structure and default values + * of this configuration. + */ +void ddrhookx_config_eamuse_init(struct cconfig *config); + +/** + * Read the module specific config struct values from the provided cconfig + * struct. + * + * @param config_eamuse Target module specific struct to read configuration + * values to. + * @param config cconfig struct holding the intermediate data to read from. + */ +void ddrhookx_config_eamuse_get( + struct ddrhookx_config_eamuse *config_eamuse, struct cconfig *config); + +#endif \ No newline at end of file diff --git a/src/main/ddrhookx/config-gfx.c b/src/main/ddrhookx/config-gfx.c new file mode 100644 index 0000000..07e1134 --- /dev/null +++ b/src/main/ddrhookx/config-gfx.c @@ -0,0 +1,36 @@ +#include + +#include "cconfig/cconfig-util.h" + +#include "ddrhookx/config-gfx.h" + +#include "util/log.h" + +#define DDRHOOKX_CONFIG_GFX_WINDOWED_KEY "gfx.windowed" + +#define DDRHOOKX_CONFIG_GFX_DEFAULT_WINDOWED_VALUE true + +void ddrhookx_config_gfx_init(struct cconfig *config) +{ + cconfig_util_set_bool( + config, + DDRHOOKX_CONFIG_GFX_WINDOWED_KEY, + DDRHOOKX_CONFIG_GFX_DEFAULT_WINDOWED_VALUE, + "Run the game windowed"); +} + +void ddrhookx_config_gfx_get( + struct ddrhookx_config_gfx *config_gfx, struct cconfig *config) +{ + if (!cconfig_util_get_bool( + config, + DDRHOOKX_CONFIG_GFX_WINDOWED_KEY, + &config_gfx->windowed, + DDRHOOKX_CONFIG_GFX_DEFAULT_WINDOWED_VALUE)) { + log_warning( + "Invalid value for key '%s' specified, fallback " + "to default '%d'", + DDRHOOKX_CONFIG_GFX_WINDOWED_KEY, + DDRHOOKX_CONFIG_GFX_DEFAULT_WINDOWED_VALUE); + } +} diff --git a/src/main/ddrhookx/config-gfx.h b/src/main/ddrhookx/config-gfx.h new file mode 100644 index 0000000..11c247d --- /dev/null +++ b/src/main/ddrhookx/config-gfx.h @@ -0,0 +1,30 @@ +#ifndef DDRHOOKX_CONFIG_GFX_H +#define DDRHOOKX_CONFIG_GFX_H + +#include "cconfig/cconfig.h" + +/** + * Struct holding configuration values for GFX related items. + */ +struct ddrhookx_config_gfx { + bool windowed; +}; + +/** + * Initialize a cconfig structure with the basic structure and default values + * of this configuration. + */ +void ddrhookx_config_gfx_init(struct cconfig *config); + +/** + * Read the module specific config struct values from the provided cconfig + * struct. + * + * @param config_gfx Target module specific struct to read configuration + * values to. + * @param config cconfig struct holding the intermediate data to read from. + */ +void ddrhookx_config_gfx_get( + struct ddrhookx_config_gfx *config_gfx, struct cconfig *config); + +#endif diff --git a/src/main/ddrhookx/config-security.c b/src/main/ddrhookx/config-security.c new file mode 100644 index 0000000..a3401c1 --- /dev/null +++ b/src/main/ddrhookx/config-security.c @@ -0,0 +1,75 @@ +#include + +#include "cconfig/cconfig-util.h" + +#include "ddrhookx/config-security.h" + +#include "security/mcode.h" + +#include "util/log.h" +#include "util/net.h" + +#define DDRHOOKX_CONFIG_SECURITY_MCODE_KEY "security.mcode" + +static const struct security_mcode security_mcode_ddr_x = { + .header = SECURITY_MCODE_HEADER, + .unkn = SECURITY_MCODE_UNKN_Q, + .game = SECURITY_MCODE_GAME_DDR_X, + .region = SECURITY_MCODE_REGION_JAPAN, + .cabinet = SECURITY_MCODE_CABINET_A, + .revision = SECURITY_MCODE_REVISION_A, +}; + +void ddrhookx_config_security_init(struct cconfig *config) +{ + char *tmp; + + tmp = security_mcode_to_str(&security_mcode_ddr_x); + + cconfig_util_set_str( + config, + DDRHOOKX_CONFIG_SECURITY_MCODE_KEY, + tmp, + "Mcode of the game to run."); + + free(tmp); +} + +void ddrhookx_config_security_get( + struct ddrhookx_config_security *config_security, struct cconfig *config) +{ + char *tmp_default; + char mcode[9]; + + tmp_default = + security_mcode_to_str(&security_mcode_ddr_x); + + if (!cconfig_util_get_str( + config, + DDRHOOKX_CONFIG_SECURITY_MCODE_KEY, + mcode, + sizeof(mcode) - 1, + tmp_default)) { + log_warning( + "Invalid value for key '%s' specified, fallback " + "to default '%s'", + DDRHOOKX_CONFIG_SECURITY_MCODE_KEY, + tmp_default); + } + + mcode[8] = '\0'; + + if (!security_mcode_parse(mcode, &config_security->mcode)) { + log_warning( + "Invalid mcode '%s' specified, fallback to default '%s'", + mcode, + tmp_default); + + memcpy( + &config_security->mcode, + &security_mcode_ddr_x, + sizeof(struct security_mcode)); + } + + free(tmp_default); +} diff --git a/src/main/ddrhookx/config-security.h b/src/main/ddrhookx/config-security.h new file mode 100644 index 0000000..5e64dda --- /dev/null +++ b/src/main/ddrhookx/config-security.h @@ -0,0 +1,34 @@ +#ifndef DDRHOOKX_CONFIG_SECURITY_H +#define DDRHOOKX_CONFIG_SECURITY_H + +#include "cconfig/cconfig.h" + +#include "security/mcode.h" + +#include "util/net.h" + +/** + * Struct holding configuration values for security related items. + */ +struct ddrhookx_config_security { + struct security_mcode mcode; +}; + +/** + * Initialize a cconfig structure with the basic structure and default values + * of this configuration. + */ +void ddrhookx_config_security_init(struct cconfig *config); + +/** + * Read the module specific config struct values from the provided cconfig + * struct. + * + * @param config_security Target module specific struct to read configuration + * values to. + * @param config cconfig struct holding the intermediate data to read from. + */ +void ddrhookx_config_security_get( + struct ddrhookx_config_security *config_security, struct cconfig *config); + +#endif \ No newline at end of file diff --git a/src/main/ddrhookx/d3d9.c b/src/main/ddrhookx/d3d9.c new file mode 100644 index 0000000..99fde23 --- /dev/null +++ b/src/main/ddrhookx/d3d9.c @@ -0,0 +1,281 @@ +// TODO: Fix gray arrows on NVIDIA cards (also applies to X3) + +#define LOG_MODULE "d3d9-hook" + +#include +#include +#include + +#include +#include +#include +#include + +#include "hook/com-proxy.h" +#include "hook/table.h" + +#include "ddrhookx/d3d9.h" + +#include "util/defs.h" +#include "util/log.h" +#include "util/str.h" +#include "util/time.h" + +static LONG(STDCALL *real_ChangeDisplaySettingsExA)( + char *dev_name, DEVMODE *dev_mode, HWND hwnd, DWORD flags, void *param); +static LONG(STDCALL *real_SetWindowLongW)( + HWND hWnd, int nIndex, LONG dwNewLong); +static BOOL(STDCALL *real_SetWindowPos)( + HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags); + +static LONG STDCALL my_ChangeDisplaySettingsExA( + char *dev_name, DEVMODE *dev_mode, HWND hwnd, DWORD flags, void *param); +static LONG STDCALL my_SetWindowLongW(HWND hWnd, int nIndex, LONG dwNewLong); +static BOOL STDCALL my_SetWindowPos( + HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags); + +static struct ddrhookx_d3d9_config ddrhookx_d3d9_config; + +static const struct hook_symbol misc_user32_syms[] = { + { + .name = "ChangeDisplaySettingsExA", + .patch = my_ChangeDisplaySettingsExA, + .link = (void **) &real_ChangeDisplaySettingsExA, + }, + { + .name = "SetWindowLongW", + .patch = my_SetWindowLongW, + .link = (void **) &real_SetWindowLongW, + }, + { + .name = "SetWindowPos", + .patch = my_SetWindowPos, + .link = (void **) &real_SetWindowPos, + }, +}; + +/* ------------------------------------------------------------------------- */ + +static void ddrhookx_d3d9_calc_win_size_with_framed( + HWND hwnd, DWORD x, DWORD y, DWORD width, DWORD height, LPWINDOWPOS wp) +{ + /* taken from dxwnd */ + RECT rect; + DWORD style; + int max_x, max_y; + HMENU menu; + + rect.left = x; + rect.top = y; + max_x = width; + max_y = height; + rect.right = x + max_x; + rect.bottom = y + max_y; + + style = GetWindowLong(hwnd, GWL_STYLE); + menu = GetMenu(hwnd); + AdjustWindowRect(&rect, style, (menu != NULL)); + + /* shift down-right so that the border is visible + and also update the iPosX,iPosY upper-left coordinates + of the client area */ + + if (rect.left < 0) { + rect.right -= rect.left; + rect.left = 0; + } + + if (rect.top < 0) { + rect.bottom -= rect.top; + rect.top = 0; + } + + wp->x = rect.left; + wp->y = rect.top; + wp->cx = rect.right - rect.left; + wp->cy = rect.bottom - rect.top; +} + +/* ------------------------------------------------------------------------- */ + +static LONG STDCALL my_SetWindowLongW(HWND hWnd, int nIndex, LONG dwNewLong) +{ + if (ddrhookx_d3d9_config.windowed && nIndex == GWL_STYLE) { + dwNewLong |= WS_OVERLAPPEDWINDOW; + } + + return real_SetWindowLongW(hWnd, nIndex, dwNewLong); +} + +static BOOL STDCALL my_SetWindowPos( + HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags) +{ + if (ddrhookx_d3d9_config.windowed) { + WINDOWPOS wp; + + ddrhookx_d3d9_calc_win_size_with_framed(hWnd, X, Y, cx, cy, &wp); + + return real_SetWindowPos( + hWnd, hWndInsertAfter, wp.x, wp.y, wp.cx, wp.cy, uFlags); + } + + return real_SetWindowPos(hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags); +} + +static LONG STDCALL my_ChangeDisplaySettingsExA( + char *dev_name, DEVMODE *dev_mode, HWND hwnd, DWORD flags, void *param) +{ + if (ddrhookx_d3d9_config.windowed) { + return DISP_CHANGE_SUCCESSFUL; + } + + return real_ChangeDisplaySettingsExA( + dev_name, dev_mode, hwnd, flags, param); +} + +/* ------------------------------------------------------------------------- */ + +static void +ddrhookx_d3d9_log_config(const struct ddrhookx_d3d9_config *config) +{ + log_misc( + "ddrhookx_d3d9_config\n" + "windowed: %d\n", + config->windowed); +} + +void ddrhookx_d3d9_init_config(struct ddrhookx_d3d9_config *config) +{ + config->windowed = false; +} + +void ddrhookx_d3d9_hook_init() +{ + ddrhookx_d3d9_init_config(&ddrhookx_d3d9_config); + + hook_table_apply( + NULL, "user32.dll", misc_user32_syms, lengthof(misc_user32_syms)); + + log_info("Initialized d3d9 hooks"); +} + +/* ------------------------------------------------------------------------- */ + +void ddrhookx_d3d9_configure( + const struct ddrhookx_d3d9_config *config) +{ + log_assert(config); + + ddrhookx_d3d9_log_config(config); + + memcpy( + &ddrhookx_d3d9_config, + config, + sizeof(struct ddrhookx_d3d9_config)); +} + +static void ddrhookx_d3d9_patch_window(struct hook_d3d9_irp *irp) +{ + log_assert(irp); + log_assert(irp->op == HOOK_D3D9_IRP_OP_CREATE_WINDOW_EX); + + if (ddrhookx_d3d9_config.windowed) { + /* use a different style */ + irp->args.create_window_ex.style |= WS_OVERLAPPEDWINDOW; + + /* also show mouse cursor */ + ShowCursor(TRUE); + } +} + +static void +ddrhookx_d3d9_fix_window_size_and_pos(struct hook_d3d9_irp *irp) +{ + log_assert(irp); + log_assert(irp->op == HOOK_D3D9_IRP_OP_CREATE_WINDOW_EX); + + if (ddrhookx_d3d9_config.windowed) { + /* we have to adjust the window size, because the window needs to be a + slightly bigger than the rendering resolution (window caption and + stuff is included in the window size) */ + WINDOWPOS wp; + + ddrhookx_d3d9_calc_win_size_with_framed( + irp->args.create_window_ex.result, + irp->args.create_window_ex.x, + irp->args.create_window_ex.y, + irp->args.create_window_ex.width, + irp->args.create_window_ex.height, + &wp); + + SetWindowPos( + irp->args.create_window_ex.result, 0, wp.x, wp.y, wp.cx, wp.cy, 0); + + irp->args.create_window_ex.x = wp.x; + irp->args.create_window_ex.y = wp.y; + irp->args.create_window_ex.width = wp.cx; + irp->args.create_window_ex.height = wp.cy; + } +} + +static void ddrhookx_d3d9_create_device_apply_window_mode( + struct hook_d3d9_irp *irp) +{ + log_assert(irp); + log_assert(irp->op == HOOK_D3D9_IRP_OP_CTX_CREATE_DEVICE); + D3DPRESENT_PARAMETERS *pp = irp->args.ctx_create_device.pp; + + if (ddrhookx_d3d9_config.windowed) { + pp->Windowed = TRUE; + pp->FullScreen_RefreshRateInHz = 0; + } +} + +static void ddrhookx_d3d9_reset_apply_window_mode( + struct hook_d3d9_irp *irp) +{ + log_assert(irp); + log_assert(irp->op == HOOK_D3D9_IRP_OP_DEV_RESET); + D3DPRESENT_PARAMETERS *pp = irp->args.dev_reset.pp; + + if (ddrhookx_d3d9_config.windowed) { + pp->Windowed = TRUE; + pp->FullScreen_RefreshRateInHz = 0; + } +} + +HRESULT +ddrhookx_d3d9_irp_handler(struct hook_d3d9_irp *irp) +{ + HRESULT hr; + + log_assert(irp); + + switch (irp->op) { + case HOOK_D3D9_IRP_OP_CREATE_WINDOW_EX: + ddrhookx_d3d9_patch_window(irp); + + hr = hook_d3d9_irp_invoke_next(irp); + + if (hr == S_OK) { + ddrhookx_d3d9_fix_window_size_and_pos(irp); + } + + return hr; + + case HOOK_D3D9_IRP_OP_CTX_CREATE_DEVICE: + ddrhookx_d3d9_create_device_apply_window_mode(irp); + hr = hook_d3d9_irp_invoke_next(irp); + return hr; + + case HOOK_D3D9_IRP_OP_DEV_RESET: + ddrhookx_d3d9_reset_apply_window_mode(irp); + hr = hook_d3d9_irp_invoke_next(irp); + return hr; + + default: + return hook_d3d9_irp_invoke_next(irp); + } + + log_fatal("Illegal state"); +} \ No newline at end of file diff --git a/src/main/ddrhookx/d3d9.h b/src/main/ddrhookx/d3d9.h new file mode 100644 index 0000000..b0c41cd --- /dev/null +++ b/src/main/ddrhookx/d3d9.h @@ -0,0 +1,18 @@ +#ifndef DDRHOOKX_D3D9_H +#define DDRHOOKX_D3D9_H + +#include +#include + +#include "hook/d3d9.h" + +struct ddrhookx_d3d9_config { + bool windowed; +}; + +void ddrhookx_d3d9_hook_init(); +void ddrhookx_d3d9_configure( + const struct ddrhookx_d3d9_config *config); +HRESULT ddrhookx_d3d9_irp_handler(struct hook_d3d9_irp *irp); + +#endif diff --git a/src/main/ddrhookx/ddrhookx.def b/src/main/ddrhookx/ddrhookx.def new file mode 100644 index 0000000..51fc64d --- /dev/null +++ b/src/main/ddrhookx/ddrhookx.def @@ -0,0 +1,4 @@ +LIBRARY ddrhookx + +EXPORTS + DllMain@12 @1 NONAME diff --git a/src/main/ddrhookx/dllmain.c b/src/main/ddrhookx/dllmain.c new file mode 100644 index 0000000..efc7c4c --- /dev/null +++ b/src/main/ddrhookx/dllmain.c @@ -0,0 +1,197 @@ +#include + +#include + +#include "bemanitools/ddrio.h" +#include "bemanitools/eamio.h" + +#include "cconfig/cconfig-hook.h" + +#include "ddrhook-util/_com4.h" +#include "ddrhook-util/extio.h" +#include "ddrhook-util/p3io.h" +#include "ddrhook-util/spike.h" +#include "ddrhook-util/usbmem.h" + +#include "ddrhookx/avs-boot.h" +#include "ddrhookx/config-ddrhookx.h" +#include "ddrhookx/config-eamuse.h" +#include "ddrhookx/config-gfx.h" +#include "ddrhookx/config-security.h" +#include "ddrhookx/d3d9.h" +#include "ddrhookx/filesystem.h" +#include "ddrhookx/master.h" + +#include "hook/iohook.h" +#include "hook/table.h" + +#include "hooklib/app.h" +#include "hooklib/rs232.h" + +#include "imports/avs.h" + +#include "p3ioemu/emu.h" + +#include "security/rp-sign-key.h" + +#include "util/cmdline.h" +#include "util/defs.h" +#include "util/log.h" +#include "util/thread.h" + +#define DDRHOOKX_INFO_HEADER \ + "ddrhookx for DDR X" \ + ", build " __DATE__ " " __TIME__ ", gitrev " STRINGIFY(GITREV) +#define DDRHOOKX_CMD_USAGE \ + "Usage: inject.exe ddrhookx.dll [options...]" + +bool standard_def; +bool _15khz; + +static const hook_d3d9_irp_handler_t ddrhookx_d3d9_handlers[] = { + ddrhookx_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 ddrhookx_init_check = false; + +static const struct hook_symbol init_hook_syms[] = { + { + .name = "GetModuleFileNameA", + .patch = my_GetModuleFileNameA, + .link = (void **) &real_GetModuleFileNameA, + }, +}; + +static void ddrhookx_setup_d3d9_hooks( + const struct ddrhookx_config_gfx *config_gfx) +{ + struct ddrhookx_d3d9_config d3d9_config; + + d3d9_config.windowed = config_gfx->windowed; + + ddrhookx_d3d9_configure(&d3d9_config); + + hook_d3d9_init(ddrhookx_d3d9_handlers, lengthof(ddrhookx_d3d9_handlers)); +} + +static DWORD STDCALL +my_GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize) +{ + bool ok; + struct cconfig *config; + + struct ddrhookx_config_ddrhookx config_ddrhookx; + struct ddrhookx_config_eamuse config_eamuse; + struct ddrhookx_config_gfx config_gfx; + struct ddrhookx_config_security config_security; + + if (ddrhookx_init_check) + goto skip; + + log_info("--- Begin ddrhookx GetModuleFileNameA ---"); + + ddrhookx_init_check = true; + + config = cconfig_init(); + + ddrhookx_config_ddrhookx_init(config); + ddrhookx_config_eamuse_init(config); + ddrhookx_config_gfx_init(config); + ddrhookx_config_security_init(config); + + if (!cconfig_hook_config_init( + config, + DDRHOOKX_INFO_HEADER "\n" DDRHOOKX_CMD_USAGE, + CCONFIG_CMD_USAGE_OUT_DBG)) { + cconfig_finit(config); + exit(EXIT_FAILURE); + } + + ddrhookx_config_ddrhookx_get(&config_ddrhookx, config); + ddrhookx_config_eamuse_get(&config_eamuse, config); + ddrhookx_config_gfx_get(&config_gfx, config); + ddrhookx_config_security_get(&config_security, config); + + cconfig_finit(config); + + standard_def = config_ddrhookx.standard_def; + + log_info(DDRHOOKX_INFO_HEADER); + log_info("Initializing ddrhookx..."); + + ddrhookx_avs_boot_init(); + ddrhookx_avs_boot_set_eamuse_addr(&config_eamuse.server); + + iohook_push_handler(p3io_emu_dispatch_irp); + iohook_push_handler(extio_dispatch_irp); + iohook_push_handler(spike_dispatch_irp); + iohook_push_handler(usbmem_dispatch_irp); + + if (config_ddrhookx.use_com4_emu) { + /* See ddrhook/p3io.c for details. */ + iohook_push_handler(com4_dispatch_irp); + } + + ddrhookx_setup_d3d9_hooks(&config_gfx); + + rs232_hook_init(); + + p3io_ddr_init_with_plugs( + &config_security.mcode, + &config_eamuse.pcbid, + &config_eamuse.eamid, + &security_rp_sign_key_black_ddrx, + &security_rp_sign_key_white_eamuse); + extio_init(); + usbmem_init(); + spike_init(); + com4_init(); + + log_info("Initializing DDR IO backend"); + + ok = ddr_io_init(thread_create, thread_join, thread_destroy); + + if (!ok) { + log_fatal("Couldn't initialize DDR IO backend"); + return false; + } + + if (config_ddrhookx.use_com4_emu) { + log_info("Initializing card reader backend"); + + eam_io_set_loggers( + log_body_misc, log_body_info, log_body_warning, log_body_fatal); + + ok = eam_io_init(thread_create, thread_join, thread_destroy); + + if (!ok) { + log_fatal("Couldn't initialize card reader backend"); + return false; + } + } + + log_info("--- End ddrhookx GetModuleFileNameA ---"); + +skip: + return real_GetModuleFileNameA(hModule, lpFilename, nSize); +} + +BOOL WINAPI DllMain(HMODULE self, DWORD reason, void *ctx) +{ + if (reason == DLL_PROCESS_ATTACH) { + log_to_writer(log_writer_debug, NULL); + + hook_table_apply( + NULL, "kernel32.dll", init_hook_syms, lengthof(init_hook_syms)); + + master_insert_hooks(NULL); + filesystem_hook_init(); + + ddrhookx_d3d9_hook_init(); + } + + return TRUE; +} diff --git a/src/main/ddrhookx/filesystem.c b/src/main/ddrhookx/filesystem.c new file mode 100644 index 0000000..99dd23e --- /dev/null +++ b/src/main/ddrhookx/filesystem.c @@ -0,0 +1,115 @@ +#include + +#include +#include +#include +#include + +#include "hook/table.h" + +#include "util/defs.h" +#include "util/log.h" +#include "util/mem.h" + +static BOOL STDCALL my_SetCurrentDirectoryA(LPCTSTR lpPathName); +static BOOL(STDCALL *real_SetCurrentDirectoryA)(LPCTSTR lpPathName); + +static const struct hook_symbol filesystem_hook_syms[] = { + { + .name = "SetCurrentDirectoryA", + .patch = my_SetCurrentDirectoryA, + .link = (void **) &real_SetCurrentDirectoryA, + }, +}; + +void get_launcher_path_parts(char **output_path, char **output_foldername) { + // DDR sets the current directory on boot to "D:/HDX" and then uses + // relative file paths for everything else. + // This function is a helper function to make it easier to turn a path + // into an absolute path relative to the launcher ("D:/HDX/ddr_datecode") + // and not the current working directory ("D:/HDX") so that settings + // can be saved in the same manner as every other game. + char module_path[MAX_PATH]; + char launcher_path[MAX_PATH]; + + memset(launcher_path, 0, MAX_PATH); + + if (output_path != NULL) + *output_path = NULL; + + if (output_foldername != NULL) + *output_foldername = NULL; + + if (GetModuleFileNameA(NULL, module_path, MAX_PATH) == 0) + return; + + char *filename_ptr = NULL; + if (GetFullPathNameA(module_path, MAX_PATH, launcher_path, &filename_ptr) == 0) + return; + + if (filename_ptr != NULL) + launcher_path[strlen(launcher_path) - strlen(filename_ptr) - 1] = 0; + + // Trim tailing slashes + for (int i = strlen(launcher_path) - 1; i > 0; i--) { + if (launcher_path[i] != '\\' && launcher_path[i] != '/') + break; + + launcher_path[i] = 0; + } + + int idx_folder = 0; + for (idx_folder = strlen(launcher_path); idx_folder - 1 > 0; idx_folder--) { + if (launcher_path[idx_folder - 1] == '\\' || launcher_path[idx_folder - 1] == '/') { + break; + } + } + + if (output_foldername != NULL) { + int len = strlen(launcher_path) - idx_folder; + + if (len < 0) + len = 0; + + *output_foldername = (char*)xmalloc(len + 1); + memset(*output_foldername, 0, len + 1); + strncpy(*output_foldername, launcher_path + idx_folder, len); + } + + if (output_path != NULL) { + size_t len = idx_folder - 1 < 0 ? 0 : idx_folder - 1; + + if (len > strlen(launcher_path)) + len = strlen(launcher_path); + + *output_path = (char*)xmalloc(len + 1); + memset(*output_path, 0, len + 1); + strncpy(*output_path, launcher_path, len); + } +} + +static BOOL STDCALL my_SetCurrentDirectoryA(LPCTSTR lpPathName) +{ + if (stricmp(lpPathName, "D:/HDX") == 0 + || stricmp(lpPathName, "D:\\HDX") == 0) { + char *new_path; + get_launcher_path_parts(&new_path, NULL); + + if (new_path != NULL) { + bool r = real_SetCurrentDirectoryA(new_path); + log_misc("Changed directory %s -> %s", lpPathName, new_path); + free(new_path); + return r; + } + } + + return real_SetCurrentDirectoryA(lpPathName); +} + +void filesystem_hook_init() +{ + hook_table_apply( + NULL, "kernel32.dll", filesystem_hook_syms, lengthof(filesystem_hook_syms)); + + log_info("Inserted filesystem hooks"); +} \ No newline at end of file diff --git a/src/main/ddrhookx/filesystem.h b/src/main/ddrhookx/filesystem.h new file mode 100644 index 0000000..ab067a1 --- /dev/null +++ b/src/main/ddrhookx/filesystem.h @@ -0,0 +1,8 @@ +#ifndef DDRHOOKX_FILESYSTEM_H +#define DDRHOOKX_FILESYSTEM_H + +char *get_launcher_path_parts(); + +void filesystem_hook_init(); + +#endif \ No newline at end of file diff --git a/src/main/ddrhookx/master.c b/src/main/ddrhookx/master.c new file mode 100644 index 0000000..729ee91 --- /dev/null +++ b/src/main/ddrhookx/master.c @@ -0,0 +1,66 @@ +#include "ddrhookx/master.h" + +#include "ddrhook-util/dinput.h" +#include "ddrhook-util/monitor.h" + +#include "hook/table.h" + +#include "p3ioemu/devmgr.h" + +#include "util/defs.h" +#include "util/log.h" + +static HMODULE(STDCALL *real_LoadLibraryA)(const char *name); + +static HMODULE STDCALL my_LoadLibraryA(const char *name); + +static const struct hook_symbol master_kernel32_syms[] = { + { + .name = "LoadLibraryA", + .patch = my_LoadLibraryA, + .link = (void **) &real_LoadLibraryA, + }, +}; + +static HMODULE STDCALL my_LoadLibraryA(const char *name) +{ + HMODULE result; + + result = GetModuleHandleA(name); + + if (result != NULL) { + log_misc("LoadLibraryA(%s) -> %p [already loaded]", name, result); + + return result; + } + + result = real_LoadLibraryA(name); + log_misc("LoadLibraryA(%s) -> %p [newly loaded]", name, result); + + if (result == NULL) { + return result; + } + + master_insert_hooks(result); + + return result; +} + +void master_insert_hooks(HMODULE target) +{ + /* Insert all other hooks here */ + + p3io_setupapi_insert_hooks(target); + monitor_setupapi_insert_hooks(target); + dinput_init(target); + + /* Insert dynamic loader hooks so that we can hook late-loaded modules */ + + hook_table_apply( + target, + "kernel32.dll", + master_kernel32_syms, + lengthof(master_kernel32_syms)); + + log_info("Inserted dynamic loader hooks into %p", target); +} diff --git a/src/main/ddrhookx/master.h b/src/main/ddrhookx/master.h new file mode 100644 index 0000000..52f0194 --- /dev/null +++ b/src/main/ddrhookx/master.h @@ -0,0 +1,8 @@ +#ifndef DDRHOOK_MASTER_H +#define DDRHOOK_MASTER_H + +#include + +void master_insert_hooks(HMODULE target); + +#endif diff --git a/src/main/hook/d3d9.c b/src/main/hook/d3d9.c index 953aa79..6da3962 100644 --- a/src/main/hook/d3d9.c +++ b/src/main/hook/d3d9.c @@ -71,6 +71,10 @@ static HRESULT(STDCALL *real_DrawPrimitiveUP)( const void *data, UINT stride); +static HRESULT(STDCALL *real_Reset)( + IDirect3DDevice9 *self, + D3DPRESENT_PARAMETERS *pp); + /* ------------------------------------------------------------------------------------------------------------------ */ @@ -136,6 +140,10 @@ static HRESULT STDCALL my_DrawPrimitiveUP( const void *data, UINT stride); +static HRESULT STDCALL my_Reset( + IDirect3DDevice9 *self, + D3DPRESENT_PARAMETERS *pp); + /* ------------------------------------------------------------------------------------------------------------------ */ @@ -194,6 +202,9 @@ hook_d3d9_irp_handler_real_dev_set_render_state(struct hook_d3d9_irp *irp); static HRESULT hook_d3d9_irp_handler_real_dev_draw_primitive_up(struct hook_d3d9_irp *irp); +static HRESULT +hook_d3d9_irp_handler_real_dev_reset(struct hook_d3d9_irp *irp); + /* ------------------------------------------------------------------------------------------------------------------ */ @@ -218,6 +229,8 @@ static const hook_d3d9_irp_handler_t hook_d3d9_irp_real_handlers[] = { hook_d3d9_irp_handler_real_dev_set_render_state, [HOOK_D3D9_IRP_OP_DEV_DRAW_PRIMITIVE_UP] = hook_d3d9_irp_handler_real_dev_draw_primitive_up, + [HOOK_D3D9_IRP_OP_DEV_RESET] = + hook_d3d9_irp_handler_real_dev_reset, }; static const hook_d3d9_irp_handler_t *hook_d3d9_handlers; @@ -488,6 +501,24 @@ static HRESULT STDCALL my_DrawPrimitiveUP( return hr; } +static HRESULT STDCALL my_Reset( + IDirect3DDevice9 *self, + D3DPRESENT_PARAMETERS *pp) +{ + struct hook_d3d9_irp irp; + HRESULT hr; + + memset(&irp, 0, sizeof(irp)); + + irp.op = HOOK_D3D9_IRP_OP_DEV_RESET; + irp.args.dev_reset.self = self; + irp.args.dev_reset.pp = pp; + + hr = hook_d3d9_irp_invoke_next(&irp); + + return hr; +} + /* ------------------------------------------------------------------------------------------------------------------ */ @@ -528,7 +559,7 @@ static HRESULT hook_d3d9_irp_handler_real_ctx_create(struct hook_d3d9_irp *irp) } res = com_proxy_wrap(&api_proxy, api, sizeof(*api->lpVtbl)); - + if (res != S_OK) { log_fatal("Wrapping com proxy failed: %08lx", res); } @@ -657,6 +688,9 @@ hook_d3d9_irp_handler_real_dev_create_device(struct hook_d3d9_irp *irp) real_DrawPrimitiveUP = api_vtbl->DrawPrimitiveUP; api_vtbl->DrawPrimitiveUP = my_DrawPrimitiveUP; + real_Reset = api_vtbl->Reset; + api_vtbl->Reset = my_Reset; + *irp->args.ctx_create_device.pdev = (IDirect3DDevice9 *) api_proxy; return hr; @@ -731,6 +765,16 @@ hook_d3d9_irp_handler_real_dev_draw_primitive_up(struct hook_d3d9_irp *irp) irp->args.dev_draw_primitive_up.stride); } +static HRESULT +hook_d3d9_irp_handler_real_dev_reset(struct hook_d3d9_irp *irp) +{ + log_assert(irp); + + return real_Reset( + irp->args.dev_reset.self, + irp->args.dev_reset.pp); +} + /* ------------------------------------------------------------------------------------------------------------------ */ diff --git a/src/main/hook/d3d9.h b/src/main/hook/d3d9.h index 6a89fbe..7d5f17d 100644 --- a/src/main/hook/d3d9.h +++ b/src/main/hook/d3d9.h @@ -33,6 +33,7 @@ enum hook_d3d9_irp_op { HOOK_D3D9_IRP_OP_DEV_PRESENT = 9, HOOK_D3D9_IRP_OP_DEV_SET_RENDER_STATE = 10, HOOK_D3D9_IRP_OP_DEV_DRAW_PRIMITIVE_UP = 11, + HOOK_D3D9_IRP_OP_DEV_RESET = 12, }; /** @@ -161,6 +162,14 @@ struct hook_d3d9_irp { const void *data; UINT stride; } dev_draw_primitive_up; + + /** + * Params of IDirect3DDevice9_Reset. + */ + struct { + IDirect3DDevice9 *self; + D3DPRESENT_PARAMETERS *pp; + } dev_reset; } args; size_t next_handler; diff --git a/src/main/security/rp-sign-key.c b/src/main/security/rp-sign-key.c index 68ac9d4..0f4ac79 100644 --- a/src/main/security/rp-sign-key.c +++ b/src/main/security/rp-sign-key.c @@ -15,6 +15,9 @@ const struct security_rp_sign_key security_rp_sign_key_black_gfdmv8 = { const struct security_rp_sign_key security_rp_sign_key_black_ddrx = { .data = "573PROJE"}; +const struct security_rp_sign_key security_rp_sign_key_black_ddrx2 = { + .data = "BMPDDRAC"}; + const struct security_rp_sign_key security_rp_sign_key_black_iidx = { .data = "2DXGLDAC"}; diff --git a/src/main/security/rp-sign-key.h b/src/main/security/rp-sign-key.h index 60c7bf7..db4426d 100644 --- a/src/main/security/rp-sign-key.h +++ b/src/main/security/rp-sign-key.h @@ -46,6 +46,14 @@ extern const struct security_rp_sign_key security_rp_sign_key_black_gfdmv8; */ extern const struct security_rp_sign_key security_rp_sign_key_black_ddrx; +/** + * Signing key used to create eeprom signatures for all black dongles used + * on the following games: + * + * - DDR X2 and beyond + */ +extern const struct security_rp_sign_key security_rp_sign_key_black_ddrx2; + /** * Signing key used to create eeprom signatures for all black dongles used * on the following games: diff --git a/src/main/unicorntail/dllmain.c b/src/main/unicorntail/dllmain.c index 1626bb5..59f862d 100644 --- a/src/main/unicorntail/dllmain.c +++ b/src/main/unicorntail/dllmain.c @@ -2,9 +2,6 @@ #include -#include "ddrhook/p3io.h" -#include "ddrhook/usbmem.h" - #include "hook/iohook.h" #include "hooklib/app.h"