1
0
mirror of synced 2024-11-23 22:51:02 +01:00

Replace bnusio.dll

This commit is contained in:
BroGamer 2022-06-22 06:16:41 +12:00
parent 5febd7b84f
commit 722ca5c01e
4 changed files with 59 additions and 112 deletions

View File

@ -6,46 +6,48 @@ HOOK_DYNAMIC (u32, __stdcall, XinputSetState, u32 index, void *state) { return E
HOOK_DYNAMIC (u32, __stdcall, XinputGetCapabilites, u32 index, u32 flags, void *state) { return ERROR_DEVICE_NOT_CONNECTED; }
// bnusio stuff
HOOK_DYNAMIC (i64, __stdcall, ClearSram) { return 0; }
HOOK_DYNAMIC (i64, __stdcall, Close) { return 0; }
HOOK_DYNAMIC (i64, __fastcall, Communication, i32 a1) { return 0; }
HOOK_DYNAMIC (i64, __fastcall, DecService, i32 a1, u16 a2) { return 0; }
HOOK_DYNAMIC (void *, __fastcall, GetBuffer, u16 a1, i64 a2, i16 a3) { return 0; }
HOOK_DYNAMIC (i64, __fastcall, GetCDOut, u8 a1) { return 0; }
HOOK_DYNAMIC (void *, __fastcall, GetCoinError, i32 a1) { return 0; }
HOOK_DYNAMIC (i64, __fastcall, GetCoinLock, u8 a1) { return 0; }
HOOK_DYNAMIC (u64, __stdcall, GetEncoder) { return 0; }
HOOK_DYNAMIC (void *, __stdcall, GetExpansionMode) { return 0; }
HOOK_DYNAMIC (void *, __stdcall, GetFirmwareVersion) { return (void *)(u16)126; }
HOOK_DYNAMIC (u8, __stdcall, GetGout, u8 a1) { return 0; }
HOOK_DYNAMIC (i64, __stdcall, GetHopOut, u8 a1) { return 0; }
HOOK_DYNAMIC (char *, __stdcall, GetIoBoardName) { return 0; }
HOOK_DYNAMIC (u16, __fastcall, GetRegisterU16, i16 a1) { return 0; }
HOOK_DYNAMIC (u8, __fastcall, GetRegisterU8, u16 a1) { return 0; }
HOOK_DYNAMIC (void *, __fastcall, GetService, i32 a1) { return 0; }
HOOK_DYNAMIC (void *, __fastcall, GetServiceError, i32 a1) { return 0; }
HOOK_DYNAMIC (u16, __fastcall, GetStatusU16, u16 a1) { return 0; }
HOOK_DYNAMIC (u8, __fastcall, GetStatusU8, u16 a1) { return 0; }
HOOK_DYNAMIC (u64, __stdcall, GetSwIn64) { return 0; }
HOOK_DYNAMIC (void *, __stdcall, GetSystemError) { return 0; }
HOOK_DYNAMIC (u8, __stdcall, IsConnected) { return 0; }
HOOK_DYNAMIC (u8, __stdcall, IsWideUsio) { return 0; }
HOOK_DYNAMIC (i64, __stdcall, Open) { return 0; }
HOOK_DYNAMIC (i32, __stdcall, ResetIoBoard) { return 0; }
HOOK_DYNAMIC (i64, __fastcall, SetBuffer, u16 a1, i32 a2, i16 a3) { return 0; }
HOOK_DYNAMIC (i64, __fastcall, SetCDOut, u8 a1, u8 a2) { return 0; }
HOOK_DYNAMIC (i64, __fastcall, SetCoinLock, u8 a1, u8 a2) { return 0; }
HOOK_DYNAMIC (i64, __fastcall, SetExpansionMode, i16 a1) { return 0; }
HOOK_DYNAMIC (i64, __fastcall, SetGout, u8 a1, u8 a2) { return 0; }
HOOK_DYNAMIC (i64, __fastcall, SetHopOut, u8 a1, u8 a2) { return 0; }
HOOK_DYNAMIC (i64, __fastcall, SetHopperLimit, u16 a1, i16 a2) { return 0; }
HOOK_DYNAMIC (i64, __fastcall, SetHopperRequest, u16 a1, i16 a2) { return 0; }
HOOK_DYNAMIC (void *, __fastcall, SetPLCounter, i16 a1) { return 0; }
HOOK_DYNAMIC (i64, __fastcall, SetRegisterU16, u16 a1, u16 a2) { return 0; }
HOOK_DYNAMIC (i64, __fastcall, SetRegisterU8, u16 a1, u8 a2) { return 0; }
HOOK_DYNAMIC (i64, __fastcall, SetSystemError, i16 a1) { return 0; }
HOOK_DYNAMIC (i64, __fastcall, SramRead, i32 a1, u8 a2, i32 a3, u16 a4) { return 0; }
HOOK_DYNAMIC (i64, __fastcall, SramWrite, i32 a1, u8 a2, i32 a3, u16 a4) { return 0; }
RETURN_FALSE (i64, __stdcall, bnusio_ClearSram)
RETURN_FALSE (i64, __stdcall, bnusio_Close)
RETURN_FALSE (i64, __fastcall, bnusio_Communication, i32 a1)
RETURN_FALSE (i64, __fastcall, bnusio_DecService, i32 a1, u16 a2)
RETURN_FALSE (void *, __fastcall, bnusio_GetBuffer, u16 a1, i64 a2, i16 a3)
RETURN_FALSE (i64, __fastcall, bnusio_GetCDOut, u8 a1)
RETURN_FALSE (void *, __fastcall, bnusio_GetCoinError, i32 a1)
RETURN_FALSE (i64, __fastcall, bnusio_GetCoinLock, u8 a1)
RETURN_FALSE (u64, __stdcall, bnusio_GetEncoder)
RETURN_FALSE (void *, __stdcall, bnusio_GetExpansionMode)
void *__stdcall bnusio_GetFirmwareVersion () { return (void *)(u16)126; }
RETURN_FALSE (u8, __stdcall, bnusio_GetGout, u8 a1)
RETURN_FALSE (i64, __stdcall, bnusio_GetHopOut, u8 a1)
RETURN_FALSE (char *, __stdcall, bnusio_GetIoBoardName)
RETURN_FALSE (u16, __fastcall, bnusio_GetRegisterU16, i16 a1)
RETURN_FALSE (u8, __fastcall, bnusio_GetRegisterU8, u16 a1)
RETURN_FALSE (void *, __fastcall, bnusio_GetService, i32 a1)
RETURN_FALSE (void *, __fastcall, bnusio_GetServiceError, i32 a1)
RETURN_FALSE (u16, __fastcall, bnusio_GetStatusU16, u16 a1)
RETURN_FALSE (u8, __fastcall, bnusio_GetStatusU8, u16 a1)
RETURN_FALSE (u64, __stdcall, bnusio_GetSwIn64)
RETURN_FALSE (void *, __stdcall, bnusio_GetSystemError)
RETURN_FALSE (u8, __stdcall, bnusio_IsConnected)
RETURN_FALSE (u8, __stdcall, bnusio_IsWideUsio)
RETURN_FALSE (i64, __stdcall, bnusio_Open)
RETURN_FALSE (i32, __stdcall, bnusio_ResetIoBoard)
RETURN_FALSE (i64, __fastcall, bnusio_SetBuffer, u16 a1, i32 a2, i16 a3)
RETURN_FALSE (i64, __fastcall, bnusio_SetCDOut, u8 a1, u8 a2)
RETURN_FALSE (i64, __fastcall, bnusio_SetCoinLock, u8 a1, u8 a2)
RETURN_FALSE (i64, __fastcall, bnusio_SetExpansionMode, i16 a1)
RETURN_FALSE (i64, __fastcall, bnusio_SetGout, u8 a1, u8 a2)
RETURN_FALSE (i64, __fastcall, bnusio_SetHopOut, u8 a1, u8 a2)
RETURN_FALSE (i64, __fastcall, bnusio_SetHopperLimit, u16 a1, i16 a2)
RETURN_FALSE (i64, __fastcall, bnusio_SetHopperRequest, u16 a1, i16 a2)
RETURN_FALSE (void *, __fastcall, bnusio_SetPLCounter, i16 a1)
RETURN_FALSE (i64, __fastcall, bnusio_SetRegisterU16, u16 a1, u16 a2)
RETURN_FALSE (i64, __fastcall, bnusio_SetRegisterU8, u16 a1, u8 a2)
RETURN_FALSE (i64, __fastcall, bnusio_SetSystemError, i16 a1)
RETURN_FALSE (i64, __fastcall, bnusio_SramRead, i32 a1, u8 a2, i32 a3, u16 a4)
RETURN_FALSE (i64, __fastcall, bnusio_SramWrite, i32 a1, u8 a2, i32 a3, u16 a4)
RETURN_FALSE (i64, __stdcall, bnusio_ResetCoin)
RETURN_FALSE (i64, __fastcall, bnusio_DecCoin, i32 a1, u16 a2)
HOOK_DYNAMIC (i64, __stdcall, UsbFinderInitialize) { return 0; }
HOOK_DYNAMIC (i64, __stdcall, UsbFinderRelease) { return 0; }
HOOK_DYNAMIC (i64, __fastcall, UsbFinderGetSerialNumber, i32 a1, i64 a2) { return 1; }
@ -56,47 +58,6 @@ init_boilerplate () {
INSTALL_HOOK_DYNAMIC (XinputSetState, PROC_ADDRESS ("xinput9_1_0.dll", "XInputSetState"));
INSTALL_HOOK_DYNAMIC (XinputGetCapabilites, PROC_ADDRESS ("xinput9_1_0.dll", "XInputGetCapabilities"));
INSTALL_HOOK_DYNAMIC (ClearSram, PROC_ADDRESS ("bnusio.dll", "bnusio_ClearSram"));
INSTALL_HOOK_DYNAMIC (Close, PROC_ADDRESS ("bnusio.dll", "bnusio_Close"));
INSTALL_HOOK_DYNAMIC (Communication, PROC_ADDRESS ("bnusio.dll", "bnusio_Communication"));
INSTALL_HOOK_DYNAMIC (DecService, PROC_ADDRESS ("bnusio.dll", "bnusio_DecService"));
INSTALL_HOOK_DYNAMIC (GetBuffer, PROC_ADDRESS ("bnusio.dll", "bnusio_GetBuffer"));
INSTALL_HOOK_DYNAMIC (GetCDOut, PROC_ADDRESS ("bnusio.dll", "bnusio_GetCDOut"));
INSTALL_HOOK_DYNAMIC (GetCoinError, PROC_ADDRESS ("bnusio.dll", "bnusio_GetCoinError"));
INSTALL_HOOK_DYNAMIC (GetCoinLock, PROC_ADDRESS ("bnusio.dll", "bnusio_GetCoinLock"));
INSTALL_HOOK_DYNAMIC (GetEncoder, PROC_ADDRESS ("bnusio.dll", "bnusio_GetEncoder"));
INSTALL_HOOK_DYNAMIC (GetExpansionMode, PROC_ADDRESS ("bnusio.dll", "bnusio_GetExpansionMode"));
INSTALL_HOOK_DYNAMIC (GetFirmwareVersion, PROC_ADDRESS ("bnusio.dll", "bnusio_GetFirmwareVersion"));
INSTALL_HOOK_DYNAMIC (GetGout, PROC_ADDRESS ("bnusio.dll", "bnusio_GetGout"));
INSTALL_HOOK_DYNAMIC (GetHopOut, PROC_ADDRESS ("bnusio.dll", "bnusio_GetHopOut"));
INSTALL_HOOK_DYNAMIC (GetIoBoardName, PROC_ADDRESS ("bnusio.dll", "bnusio_GetIoBoardName"));
INSTALL_HOOK_DYNAMIC (GetRegisterU16, PROC_ADDRESS ("bnusio.dll", "bnusio_GetRegisterU16"));
INSTALL_HOOK_DYNAMIC (GetRegisterU8, PROC_ADDRESS ("bnusio.dll", "bnusio_GetRegisterU8"));
INSTALL_HOOK_DYNAMIC (GetService, PROC_ADDRESS ("bnusio.dll", "bnusio_GetService"));
INSTALL_HOOK_DYNAMIC (GetServiceError, PROC_ADDRESS ("bnusio.dll", "bnusio_GetServiceError"));
INSTALL_HOOK_DYNAMIC (GetStatusU16, PROC_ADDRESS ("bnusio.dll", "bnusio_GetStatusU16"));
INSTALL_HOOK_DYNAMIC (GetStatusU8, PROC_ADDRESS ("bnusio.dll", "bnusio_GetStatusU8"));
INSTALL_HOOK_DYNAMIC (GetSwIn64, PROC_ADDRESS ("bnusio.dll", "bnusio_GetSwIn64"));
INSTALL_HOOK_DYNAMIC (GetSystemError, PROC_ADDRESS ("bnusio.dll", "bnusio_GetSystemError"));
INSTALL_HOOK_DYNAMIC (IsConnected, PROC_ADDRESS ("bnusio.dll", "bnusio_IsConnected"));
INSTALL_HOOK_DYNAMIC (IsWideUsio, PROC_ADDRESS ("bnusio.dll", "bnusio_IsWideUsio"));
INSTALL_HOOK_DYNAMIC (Open, PROC_ADDRESS ("bnusio.dll", "bnusio_Open"));
INSTALL_HOOK_DYNAMIC (ResetIoBoard, PROC_ADDRESS ("bnusio.dll", "bnusio_ResetIoBoard"));
INSTALL_HOOK_DYNAMIC (SetBuffer, PROC_ADDRESS ("bnusio.dll", "bnusio_SetBuffer"));
INSTALL_HOOK_DYNAMIC (SetCDOut, PROC_ADDRESS ("bnusio.dll", "bnusio_SetCDOut"));
INSTALL_HOOK_DYNAMIC (SetCoinLock, PROC_ADDRESS ("bnusio.dll", "bnusio_SetCoinLock"));
INSTALL_HOOK_DYNAMIC (SetExpansionMode, PROC_ADDRESS ("bnusio.dll", "bnusio_SetExpansionMode"));
INSTALL_HOOK_DYNAMIC (SetGout, PROC_ADDRESS ("bnusio.dll", "bnusio_SetGout"));
INSTALL_HOOK_DYNAMIC (SetHopOut, PROC_ADDRESS ("bnusio.dll", "bnusio_SetHopOut"));
INSTALL_HOOK_DYNAMIC (SetHopperLimit, PROC_ADDRESS ("bnusio.dll", "bnusio_SetHopperLimit"));
INSTALL_HOOK_DYNAMIC (SetHopperRequest, PROC_ADDRESS ("bnusio.dll", "bnusio_SetHopperRequest"));
INSTALL_HOOK_DYNAMIC (SetPLCounter, PROC_ADDRESS ("bnusio.dll", "bnusio_SetPLCounter"));
INSTALL_HOOK_DYNAMIC (SetRegisterU16, PROC_ADDRESS ("bnusio.dll", "bnusio_SetRegisterU16"));
INSTALL_HOOK_DYNAMIC (SetRegisterU8, PROC_ADDRESS ("bnusio.dll", "bnusio_SetRegisterU8"));
INSTALL_HOOK_DYNAMIC (SetSystemError, PROC_ADDRESS ("bnusio.dll", "bnusio_SetSystemError"));
INSTALL_HOOK_DYNAMIC (SramRead, PROC_ADDRESS ("bnusio.dll", "bnusio_SramRead"));
INSTALL_HOOK_DYNAMIC (SramWrite, PROC_ADDRESS ("bnusio.dll", "bnusio_SramWrite"));
INSTALL_HOOK_DYNAMIC (UsbFinderInitialize, PROC_ADDRESS ("nbamUsbFinder.dll", "nbamUsbFinderInitialize"));
INSTALL_HOOK_DYNAMIC (UsbFinderRelease, PROC_ADDRESS ("nbamUsbFinder.dll", "nbamUsbFinderRelease"));
INSTALL_HOOK_DYNAMIC (UsbFinderGetSerialNumber, PROC_ADDRESS ("nbamUsbFinderGetSerialNumber.dll", "nbamUsbFinderRelease"));

View File

@ -36,16 +36,9 @@ struct Keybindings P2_LEFT_RED = {};
struct Keybindings P2_RIGHT_RED = {};
struct Keybindings P2_RIGHT_BLUE = {};
int coin_count = 0;
bool testEnabled = false;
bool inited = false;
HOOK_DYNAMIC (i64, __fastcall, DecCoin, i32 a1, u16 a2) {
coin_count -= a2;
return false;
}
HOOK_DYNAMIC (u16, __fastcall, GetAnalogIn, u8 which) {
u16 __fastcall bnusio_GetAnalogIn (u8 which) {
switch (which) {
case 0: return ON_HIT (P1_LEFT_BLUE); // Player 1 Left Blue
case 1: return ON_HIT (P1_LEFT_RED); // Player 1 Left Red
@ -59,8 +52,10 @@ HOOK_DYNAMIC (u16, __fastcall, GetAnalogIn, u8 which) {
}
}
HOOK_DYNAMIC (u16, __fastcall, GetCoin, i32 a1) {
u16 __fastcall bnusio_GetCoin (i32 a1) {
static int coin_count = 0;
if (a1 == 1) {
static bool inited = false;
if (!inited) {
EnumWindows (enumWindows, 0);
InitializePoll (windowHandle);
@ -93,26 +88,22 @@ HOOK_DYNAMIC (u16, __fastcall, GetCoin, i32 a1) {
}
UpdatePoll (windowHandle);
if (IsButtonTapped (COIN_ADD)) coin_count++;
if (IsButtonTapped (COIN_ADD) && !testEnabled) coin_count++;
if (IsButtonTapped (TEST)) testEnabled = !testEnabled;
if (IsButtonTapped (EXIT)) ExitProcess (0);
}
printf ("%d %d\n", a1, coin_count);
return coin_count;
}
HOOK_DYNAMIC (u32, __stdcall, GetSwIn) {
u32 mask = 0;
mask |= (u32)testEnabled << 7;
mask |= (u32)IsButtonDown (DEBUG_ENTER) << 9;
mask |= (u32)IsButtonDown (DEBUG_DOWN) << 12;
mask |= (u32)IsButtonDown (DEBUG_UP) << 13;
mask |= (u32)IsButtonDown (SERVICE) << 14;
return mask;
}
HOOK_DYNAMIC (i64, __stdcall, ResetCoin) {
coin_count = 0;
return false;
u32 __stdcall bnusio_GetSwIn () {
u32 sw = 0;
sw |= (u32)testEnabled << 7;
sw |= (u32)IsButtonDown (DEBUG_ENTER) << 9;
sw |= (u32)IsButtonDown (DEBUG_DOWN) << 12;
sw |= (u32)IsButtonDown (DEBUG_UP) << 13;
sw |= (u32)IsButtonDown (SERVICE) << 14;
return sw;
}
HOOK (i32, __stdcall, CrtMain, 0x140666d2c, HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, i32 nShowCmd) {
@ -135,12 +126,6 @@ i32 __stdcall DllMain (HMODULE mod, DWORD cause, void *ctx) {
if (cause != DLL_PROCESS_ATTACH) return true;
INSTALL_HOOK (CrtMain);
INSTALL_HOOK_DYNAMIC (ShowMouse, PROC_ADDRESS ("user32.dll", "ShowCursor"));
INSTALL_HOOK_DYNAMIC (DecCoin, PROC_ADDRESS ("bnusio.dll", "bnusio_DecCoin"));
INSTALL_HOOK_DYNAMIC (GetAnalogIn, PROC_ADDRESS ("bnusio.dll", "bnusio_GetAnalogIn"));
INSTALL_HOOK_DYNAMIC (GetCoin, PROC_ADDRESS ("bnusio.dll", "bnusio_GetCoin"));
INSTALL_HOOK_DYNAMIC (GetSwIn, PROC_ADDRESS ("bnusio.dll", "bnusio_GetSwIn"));
INSTALL_HOOK_DYNAMIC (ResetCoin, PROC_ADDRESS ("bnusio.dll", "bnusio_ResetCoin"));
init_boilerplate ();
return true;

View File

@ -7,8 +7,7 @@ char *
configPath (char *name) {
static char buffer[MAX_PATH];
GetModuleFileNameA (NULL, buffer, MAX_PATH);
*strrchr (buffer, '\\') = 0;
strcat (buffer, "\\plugins\\");
*(strrchr (buffer, '\\') + 1) = 0;
strcat (buffer, name);
return buffer;
}

View File

@ -83,6 +83,8 @@ typedef uint64_t u64;
}
#define COUNTOFARR(arr) sizeof (arr) / sizeof (arr[0])
#define RETURN_FALSE(returnType, callingConvention, functionName, ...) \
returnType callingConvention functionName (__VA_ARGS__) { return 0; }
#define INFO_COLOUR FOREGROUND_GREEN
#define WARNING_COLOUR (FOREGROUND_RED | FOREGROUND_GREEN)