Add option to use original usio functions
This commit is contained in:
parent
f07574ac3f
commit
cd6261bc3d
33
README.md
33
README.md
@ -31,12 +31,6 @@ country_code = "JPN"
|
||||
# JPN39: JPN 39.06
|
||||
# CHN00: CHN 00.32 (based on JPN 32.09)
|
||||
version = "auto"
|
||||
# window resolution
|
||||
res = { x = 1920, y = 1080 }
|
||||
# window mode
|
||||
windowed = false
|
||||
# vertical sync
|
||||
vsync = false
|
||||
# unlock all songs
|
||||
unlock_songs = true
|
||||
|
||||
@ -50,24 +44,35 @@ unlock_songs = true
|
||||
# enable ai soshina mode
|
||||
mode_collabo026 = false
|
||||
|
||||
[emulation]
|
||||
# If usio emulation is disabled, card_reader emulation, qr emulation and plugins will also stop working
|
||||
# Also, you need to place bnusio_original.dll (unmodified bnusio.dll) in the executable folder
|
||||
usio = true
|
||||
card_reader = true
|
||||
qr = true
|
||||
|
||||
[graphics]
|
||||
# window resolution
|
||||
res = { x = 1920, y = 1080 }
|
||||
# window mode
|
||||
windowed = false
|
||||
# vertical sync
|
||||
vsync = false
|
||||
# fps limit
|
||||
fpslimit = 120
|
||||
|
||||
[audio]
|
||||
# wasapi shared mode
|
||||
# allows you to have multiple audio sources at once at a cost of having higher latency
|
||||
wasapi_shared = true
|
||||
# use asio
|
||||
# use asio audio mode
|
||||
asio = false
|
||||
# asio driver name
|
||||
# to find it, open up regedit then navigate to HKEY_LOCAL_MACHINE\SOFTWARE\ASIO
|
||||
# the name is case sensitive !
|
||||
asio_driver = ""
|
||||
|
||||
[card_reader]
|
||||
# enable card reader emulation
|
||||
enabled = true
|
||||
|
||||
[qr]
|
||||
# enable qr emulation
|
||||
enabled = true
|
||||
# qr image path
|
||||
image_path = ""
|
||||
|
||||
@ -99,7 +104,7 @@ jp_layout = false
|
||||
[layeredfs]
|
||||
# replace assets from the game using a layered file system.
|
||||
# For example if you want to edit the wordlist, add your edited version like so :
|
||||
# DumpFolder\Data_mods\x64\datatable\wordlist.bin
|
||||
# .\Data_mods\x64\datatable\wordlist.bin
|
||||
enabled = false
|
||||
# AES encryption keys needed to dynamically encrypt datatable files and fumens
|
||||
# keys need to be provided in an hexlified form. A missing or incorrect key will crash the game !
|
||||
|
9
dist/config.toml
vendored
9
dist/config.toml
vendored
@ -16,6 +16,11 @@ unlock_songs = true
|
||||
mode_collabo025 = false
|
||||
mode_collabo026 = false
|
||||
|
||||
[emulation]
|
||||
usio = true
|
||||
card_reader = true
|
||||
qr = true
|
||||
|
||||
[graphics]
|
||||
res = { x = 1920, y = 1080 }
|
||||
windowed = false
|
||||
@ -27,11 +32,7 @@ wasapi_shared = true
|
||||
asio = false
|
||||
asio_driver = ""
|
||||
|
||||
[card_reader]
|
||||
enabled = true
|
||||
|
||||
[qr]
|
||||
enabled = true
|
||||
image_path = ""
|
||||
|
||||
[qr.data]
|
||||
|
158
src/bnusio.cpp
158
src/bnusio.cpp
@ -12,6 +12,8 @@ extern char accessCode2[21];
|
||||
extern char chipId1[33];
|
||||
extern char chipId2[33];
|
||||
extern bool autoIME;
|
||||
extern bool emulateUSIO;
|
||||
extern bool emulateCardReader;
|
||||
|
||||
typedef i32 (*callbackAttach) (i32, i32, i32 *);
|
||||
typedef void (*callbackTouch) (i32, i32, u8[168], u64);
|
||||
@ -274,6 +276,52 @@ bnusio_Close () {
|
||||
}
|
||||
}
|
||||
|
||||
FUNCTION_PTR (i64, bnusio_ClearSram_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_ClearSram"));
|
||||
FUNCTION_PTR (u64, bnusio_Communication_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_Communication"), i32 a1);
|
||||
FUNCTION_PTR (u64, bnusio_DecService_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_DecService"), i32 a1, u16 a2);
|
||||
FUNCTION_PTR (void *, bnusio_GetBuffer_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_GetBuffer"), u16 a1, i64 a2, i16 a3);
|
||||
FUNCTION_PTR (i64, bnusio_GetCDOut_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_GetCDOut"), u8 a1);
|
||||
FUNCTION_PTR (void *, bnusio_GetCoinError_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_GetCoinError"), i32 a1);
|
||||
FUNCTION_PTR (i64, bnusio_GetCoinLock_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_GetCoinLock"), u8 a1);
|
||||
FUNCTION_PTR (u64, bnusio_GetEncoder_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_GetEncoder"));
|
||||
FUNCTION_PTR (void *, bnusio_GetExpansionMode_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_GetExpansionMode"));
|
||||
FUNCTION_PTR (u8, bnusio_GetGout_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_GetGout"), u8 a1);
|
||||
FUNCTION_PTR (i64, bnusio_GetHopOut_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_GetHopOut"), u8 a1);
|
||||
FUNCTION_PTR (char *, bnusio_GetIoBoardName_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_GetIoBoardName"));
|
||||
FUNCTION_PTR (u16, bnusio_GetRegisterU16_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_GetRegisterU16"), i16 a1);
|
||||
FUNCTION_PTR (u8, bnusio_GetRegisterU8_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_GetRegisterU8"), i16 a1);
|
||||
FUNCTION_PTR (void *, bnusio_GetService_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_GetService"), i32 a1);
|
||||
FUNCTION_PTR (void *, bnusio_GetServiceError_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_GetServiceError"), i32 a1);
|
||||
FUNCTION_PTR (u16, bnusio_GetStatusU16_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_GetStatusU16"), u16 a1);
|
||||
FUNCTION_PTR (u8, bnusio_GetStatusU8_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_GetStatusU8"), u16 a1);
|
||||
FUNCTION_PTR (u64, bnusio_GetSwIn64_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_GetSwIn64"));
|
||||
FUNCTION_PTR (void *, bnusio_GetSystemError_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_GetSystemError"));
|
||||
FUNCTION_PTR (u8, bnusio_IsConnected_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_IsConnected"));
|
||||
FUNCTION_PTR (u8, bnusio_IsWideUsio_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_IsWideUsio"));
|
||||
FUNCTION_PTR (i64, bnusio_Open_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_Open"));
|
||||
FUNCTION_PTR (i32, bnusio_ResetIoBoard_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_ResetIoBoard"));
|
||||
FUNCTION_PTR (i64, bnusio_SetBuffer_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_SetBuffer"), u16 a1, i32 a2, i16 a3);
|
||||
FUNCTION_PTR (i64, bnusio_SetCDOut_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_SetCDOut"), u8 a1, u8 a2);
|
||||
FUNCTION_PTR (i64, bnusio_SetCoinLock_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_SetCoinLock"), u8 a1, u8 a2);
|
||||
FUNCTION_PTR (i64, bnusio_SetExpansionMode_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_SetExpansionMode"), i16 a1);
|
||||
FUNCTION_PTR (i64, bnusio_SetGout_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_SetGout"), u8 a1, u8 a2);
|
||||
FUNCTION_PTR (i64, bnusio_SetHopOut_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_SetHopOut"), u8 a1, u8 a2);
|
||||
FUNCTION_PTR (i64, bnusio_SetHopperLimit_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_SetHopperLimit"), u16 a1, i16 a2);
|
||||
FUNCTION_PTR (i64, bnusio_SetHopperRequest_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_SetHopperRequest"), u16 a1, i16 a2);
|
||||
FUNCTION_PTR (void *, bnusio_SetPLCounter_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_SetPLCounter"), i16 a1);
|
||||
FUNCTION_PTR (i64, bnusio_SetRegisterU16_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_SetRegisterU16"), u16 a1, u16 a2);
|
||||
FUNCTION_PTR (i64, bnusio_SetRegisterU8_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_SetRegisterU8"), u16 a1, u8 a2);
|
||||
FUNCTION_PTR (i64, bnusio_SetSystemError_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_SetSystemError"), i16 a1);
|
||||
FUNCTION_PTR (i64, bnusio_SramRead_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_SramRead"), i32 a1, u8 a2, i32 a3, u16 a4);
|
||||
FUNCTION_PTR (i64, bnusio_SramWrite_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_SramWrite"), i32 a1, u8 a2, i32 a3, u16 a4);
|
||||
FUNCTION_PTR (i64, bnusio_ResetCoin_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_ResetCoin"));
|
||||
FUNCTION_PTR (i64, bnusio_DecCoin_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_DecCoin"), i32 a1, u16 a2);
|
||||
FUNCTION_PTR (size_t, bnusio_GetFirmwareVersion_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_GetFirmwareVersion"));
|
||||
FUNCTION_PTR (u16, bnusio_GetAnalogIn_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_GetAnalogIn"), u8 a1);
|
||||
FUNCTION_PTR (u16, bnusio_GetCoin_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_GetCoin"), i32 a1);
|
||||
FUNCTION_PTR (u32, bnusio_GetSwIn_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_GetSwIn"));
|
||||
FUNCTION_PTR (i64, bnusio_Close_Original, PROC_ADDRESS ("bnusio_original.dll", "bnusio_Close"));
|
||||
|
||||
HOOK (u64, bngrw_DevReset, PROC_ADDRESS ("bngrw.dll", "BngRwDevReset")) { return 1; }
|
||||
HOOK (u64, bngrw_ReadMifare, PROC_ADDRESS ("bngrw.dll", "BngRwExReadMifareAllBlock")) { return 0xFFFFFF9C; }
|
||||
HOOK (void, bngrw_fin, PROC_ADDRESS ("bngrw.dll", "BngRwFin")) { return; }
|
||||
@ -326,35 +374,6 @@ Init () {
|
||||
analogInput = readConfigBool (controller, "analog_input", analogInput);
|
||||
if (analogInput) printf ("Using analog input mode. All the keyboard drum inputs have been disabled.\n");
|
||||
}
|
||||
auto card = openConfigSection (config, "card_reader");
|
||||
if (card) {
|
||||
bool cardEnabled = readConfigBool (card, "enabled", true);
|
||||
if (cardEnabled) {
|
||||
INSTALL_HOOK (bngrw_DevReset);
|
||||
INSTALL_HOOK (bngrw_ReadMifare);
|
||||
INSTALL_HOOK (bngrw_fin);
|
||||
INSTALL_HOOK (bngrw_GetFwVersion);
|
||||
INSTALL_HOOK (bngrw_GetStationID);
|
||||
INSTALL_HOOK (bngrw_GetRetryCount);
|
||||
INSTALL_HOOK (bngrw_IsCmdExec);
|
||||
INSTALL_HOOK (bngrw_ReqAction);
|
||||
INSTALL_HOOK (bngrw_ReqAiccAuth);
|
||||
INSTALL_HOOK (bngrw_ReqBeep);
|
||||
INSTALL_HOOK (bngrw_ReqFwCleanup);
|
||||
INSTALL_HOOK (bngrw_ReqFwVersionUp);
|
||||
INSTALL_HOOK (bngrw_ReqLatchID);
|
||||
INSTALL_HOOK (bngrw_ReqLed);
|
||||
INSTALL_HOOK (bngrw_ReqSendMail);
|
||||
INSTALL_HOOK (bngrw_ReqSendUrl);
|
||||
INSTALL_HOOK (bngrw_ReqSetLedPower);
|
||||
INSTALL_HOOK (bngrw_reqCancel);
|
||||
INSTALL_HOOK (bngrw_Init)
|
||||
INSTALL_HOOK (bngrw_attach);
|
||||
INSTALL_HOOK (bngrw_reqWaitTouch);
|
||||
} else {
|
||||
std::cout << "[Init] Card reader emulation disabled" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto keyconfigPath = std::filesystem::current_path () / "keyconfig.toml";
|
||||
@ -384,5 +403,86 @@ Init () {
|
||||
SetConfigValue (keyconfig, "P2_RIGHT_RED", &P2_RIGHT_RED);
|
||||
SetConfigValue (keyconfig, "P2_RIGHT_BLUE", &P2_RIGHT_BLUE);
|
||||
}
|
||||
|
||||
if (!emulateUSIO && !std::filesystem::exists (std::filesystem::current_path () / "bnusio_original.dll")) {
|
||||
emulateUSIO = true;
|
||||
std::cerr << "[Init] bnusio_original.dll not found! usio emulation enabled" << std::endl;
|
||||
}
|
||||
|
||||
if (!emulateUSIO) {
|
||||
INSTALL_HOOK_DIRECT (bnusio_ClearSram, bnusio_ClearSram_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_Communication, bnusio_Communication_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_DecService, bnusio_DecService_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_GetBuffer, bnusio_GetBuffer_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_GetCDOut, bnusio_GetCDOut_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_GetCoinError, bnusio_GetCoinError_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_GetCoinLock, bnusio_GetCoinLock_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_GetEncoder, bnusio_GetEncoder_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_GetExpansionMode, bnusio_GetExpansionMode_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_GetGout, bnusio_GetGout_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_GetHopOut, bnusio_GetHopOut_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_GetIoBoardName, bnusio_GetIoBoardName_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_GetRegisterU16, bnusio_GetRegisterU16_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_GetRegisterU8, bnusio_GetRegisterU8_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_GetService, bnusio_GetService_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_GetServiceError, bnusio_GetServiceError_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_GetStatusU16, bnusio_GetStatusU16_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_GetStatusU8, bnusio_GetStatusU8_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_GetSwIn64, bnusio_GetSwIn64_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_GetSystemError, bnusio_GetSystemError_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_IsConnected, bnusio_IsConnected_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_IsWideUsio, bnusio_IsWideUsio_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_Open, bnusio_Open_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_ResetIoBoard, bnusio_ResetIoBoard_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_SetBuffer, bnusio_SetBuffer_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_SetCDOut, bnusio_SetCDOut_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_SetCoinLock, bnusio_SetCoinLock_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_SetExpansionMode, bnusio_SetExpansionMode_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_SetGout, bnusio_SetGout_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_SetHopOut, bnusio_SetHopOut_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_SetHopperLimit, bnusio_SetHopperLimit_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_SetHopperRequest, bnusio_SetHopperRequest_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_SetPLCounter, bnusio_SetPLCounter_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_SetRegisterU16, bnusio_SetRegisterU16_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_SetRegisterU8, bnusio_SetRegisterU8_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_SetSystemError, bnusio_SetSystemError_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_SramRead, bnusio_SramRead_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_SramWrite, bnusio_SramWrite_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_ResetCoin, bnusio_ResetCoin_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_DecCoin, bnusio_DecCoin_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_GetFirmwareVersion, bnusio_GetFirmwareVersion_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_GetAnalogIn, bnusio_GetAnalogIn_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_GetCoin, bnusio_GetCoin_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_GetSwIn, bnusio_GetSwIn_Original);
|
||||
INSTALL_HOOK_DIRECT (bnusio_Close, bnusio_Close_Original);
|
||||
|
||||
std::cout << "[Init] USIO emulation disabled" << std::endl;
|
||||
}
|
||||
|
||||
if (emulateCardReader) {
|
||||
INSTALL_HOOK (bngrw_DevReset);
|
||||
INSTALL_HOOK (bngrw_ReadMifare);
|
||||
INSTALL_HOOK (bngrw_fin);
|
||||
INSTALL_HOOK (bngrw_GetFwVersion);
|
||||
INSTALL_HOOK (bngrw_GetStationID);
|
||||
INSTALL_HOOK (bngrw_GetRetryCount);
|
||||
INSTALL_HOOK (bngrw_IsCmdExec);
|
||||
INSTALL_HOOK (bngrw_ReqAction);
|
||||
INSTALL_HOOK (bngrw_ReqAiccAuth);
|
||||
INSTALL_HOOK (bngrw_ReqBeep);
|
||||
INSTALL_HOOK (bngrw_ReqFwCleanup);
|
||||
INSTALL_HOOK (bngrw_ReqFwVersionUp);
|
||||
INSTALL_HOOK (bngrw_ReqLatchID);
|
||||
INSTALL_HOOK (bngrw_ReqLed);
|
||||
INSTALL_HOOK (bngrw_ReqSendMail);
|
||||
INSTALL_HOOK (bngrw_ReqSendUrl);
|
||||
INSTALL_HOOK (bngrw_ReqSetLedPower);
|
||||
INSTALL_HOOK (bngrw_reqCancel);
|
||||
INSTALL_HOOK (bngrw_Init)
|
||||
INSTALL_HOOK (bngrw_attach);
|
||||
INSTALL_HOOK (bngrw_reqWaitTouch);
|
||||
} else {
|
||||
std::cout << "[Init] Card reader emulation disabled" << std::endl;
|
||||
}
|
||||
}
|
||||
} // namespace bnusio
|
||||
|
@ -25,6 +25,9 @@ bool windowed = false;
|
||||
bool autoIME = false;
|
||||
bool jpLayout = false;
|
||||
bool useLayeredFS = false;
|
||||
bool emulateUSIO = true;
|
||||
bool emulateCardReader = true;
|
||||
bool emulateQR = true;
|
||||
std::string datatableKey = "0000000000000000000000000000000000000000000000000000000000000000";
|
||||
std::string fumenKey = "0000000000000000000000000000000000000000000000000000000000000000";
|
||||
|
||||
@ -158,6 +161,12 @@ DllMain (HMODULE module, DWORD reason, LPVOID reserved) {
|
||||
}
|
||||
auto patches = openConfigSection (config, "patches");
|
||||
if (patches) version = readConfigString (patches, "version", version);
|
||||
auto emulation = openConfigSection (config, "emulation");
|
||||
if (emulation) {
|
||||
emulateUSIO = readConfigBool (emulation, "usio", emulateUSIO);
|
||||
emulateCardReader = readConfigBool (emulation, "card_reader", emulateCardReader);
|
||||
emulateQR = readConfigBool (emulation, "qr", emulateQR);
|
||||
}
|
||||
auto graphics = openConfigSection (config, "graphics");
|
||||
if (graphics) windowed = readConfigBool (graphics, "windowed", windowed);
|
||||
auto keyboard = openConfigSection (config, "keyboard");
|
||||
@ -239,9 +248,11 @@ DllMain (HMODULE module, DWORD reason, LPVOID reserved) {
|
||||
case GameVersion::CHN00: patches::CHN00::Init (); break;
|
||||
}
|
||||
|
||||
if (useLayeredFS) patches::LayeredFS::Init ();
|
||||
|
||||
patches::Qr::Init ();
|
||||
patches::Audio::Init ();
|
||||
patches::Dxgi::Init ();
|
||||
patches::AmAuth::Init ();
|
||||
if (useLayeredFS) patches::LayeredFS::Init ();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -56,6 +56,13 @@ const HMODULE MODULE_HANDLE = GetModuleHandle (nullptr);
|
||||
MH_EnableHook ((void *)where##functionName); \
|
||||
}
|
||||
|
||||
#define INSTALL_HOOK_DIRECT(location, locationOfHook) \
|
||||
{ \
|
||||
MH_Initialize (); \
|
||||
MH_CreateHook ((void *)(location), (void *)(locationOfHook), NULL); \
|
||||
MH_EnableHook ((void *)(location)); \
|
||||
}
|
||||
|
||||
#define INSTALL_HOOK_DYNAMIC(functionName, location) \
|
||||
{ \
|
||||
where##functionName = (void *)location; \
|
||||
|
@ -19,6 +19,7 @@ extern Keybindings QR_IMAGE_READ;
|
||||
extern char accessCode1[21];
|
||||
extern char accessCode2[21];
|
||||
extern std::vector<HMODULE> plugins;
|
||||
extern bool emulateQR;
|
||||
|
||||
typedef void event ();
|
||||
typedef void initQrEvent (GameVersion gameVersion);
|
||||
@ -33,7 +34,6 @@ State gState = State::Ready;
|
||||
Mode gMode = Mode::Card;
|
||||
HMODULE gPlugin;
|
||||
std::string accessCode;
|
||||
bool qrEnabled = true;
|
||||
|
||||
std::vector<HMODULE> qrPlugins;
|
||||
bool qrPluginRegistered = false;
|
||||
@ -196,7 +196,7 @@ HOOK_DYNAMIC (i64, __fastcall, copy_data, i64, void *dest, int length) {
|
||||
|
||||
void
|
||||
Update () {
|
||||
if (!qrEnabled) return;
|
||||
if (!emulateQR) return;
|
||||
if (gState == State::Ready) {
|
||||
if (IsButtonTapped (CARD_INSERT_1)) {
|
||||
if (gameVersion != GameVersion::CHN00) return;
|
||||
@ -239,20 +239,7 @@ Update () {
|
||||
|
||||
void
|
||||
Init () {
|
||||
auto configPath = std::filesystem::current_path () / "config.toml";
|
||||
std::unique_ptr<toml_table_t, void (*) (toml_table_t *)> config_ptr (openConfig (configPath), toml_free);
|
||||
if (!config_ptr) {
|
||||
std::cerr << "[Init] Config file not found" << std::endl;
|
||||
return;
|
||||
}
|
||||
auto qr = openConfigSection (config_ptr.get (), "qr");
|
||||
if (!qr) {
|
||||
std::cerr << "[Init] QR config section not found! QR emulation disabled" << std::endl;
|
||||
qrEnabled = false;
|
||||
return;
|
||||
}
|
||||
qrEnabled = readConfigBool (qr, "enabled", true);
|
||||
if (!qrEnabled) {
|
||||
if (!emulateQR) {
|
||||
std::cout << "[Init] QR emulation disabled" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
@ -217,8 +217,5 @@ Init () {
|
||||
WRITE_MEMORY (amHandle + 0x24A85, u8, 0xEB); // CommonLogPathB
|
||||
WRITE_MEMORY (amHandle + 0x24DD1, u8, 0x90, 0x90, 0x90, 0x90, 0x90); // BackupDataPathA
|
||||
WRITE_MEMORY (amHandle + 0x24E47, u8, 0x90, 0x90, 0x90, 0x90, 0x90); // BackupDataPathB
|
||||
|
||||
patches::Audio::Init ();
|
||||
patches::Qr::Init ();
|
||||
}
|
||||
} // namespace patches::CHN00
|
||||
|
@ -107,9 +107,5 @@ Init () {
|
||||
WRITE_MEMORY (amHandle + 0x3282C, u8, 0xEB); // CommonLogPathB
|
||||
WRITE_MEMORY (amHandle + 0x32C2A, u8, 0xEB); // BackupDataPathA
|
||||
WRITE_MEMORY (amHandle + 0x32D7D, u8, 0xEB); // BackupDataPathB
|
||||
|
||||
patches::Audio::Init ();
|
||||
patches::Qr::Init ();
|
||||
patches::AmAuth::Init ();
|
||||
}
|
||||
} // namespace patches::JPN00
|
||||
|
@ -175,9 +175,5 @@ Init () {
|
||||
WRITE_MEMORY (amHandle + 0x3457C, u8, 0xEB); // CommonLogPathB
|
||||
WRITE_MEMORY (amHandle + 0x3497A, u8, 0xEB); // BackupDataPathA
|
||||
WRITE_MEMORY (amHandle + 0x34ACD, u8, 0xEB); // BackupDataPathB
|
||||
|
||||
patches::Audio::Init ();
|
||||
patches::Qr::Init ();
|
||||
patches::AmAuth::Init ();
|
||||
}
|
||||
} // namespace patches::JPN08
|
||||
|
@ -132,9 +132,5 @@ Init () {
|
||||
// Redirect garmc requests
|
||||
auto garmcHandle = (u64)GetModuleHandle ("garmc.dll");
|
||||
INSTALL_HOOK_DYNAMIC (curl_easy_setopt, (void *)(garmcHandle + 0x1FBBB0));
|
||||
|
||||
patches::Audio::Init ();
|
||||
patches::Qr::Init ();
|
||||
patches::AmAuth::Init ();
|
||||
}
|
||||
} // namespace patches::JPN39
|
Loading…
x
Reference in New Issue
Block a user