2023-01-03 05:35:53 +01:00
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
#include "taikohook/bnusio.h"
|
|
|
|
#include "taikohook/qr.h"
|
|
|
|
#include "taikohook/config.h"
|
|
|
|
|
|
|
|
#include "hook/table.h"
|
|
|
|
|
|
|
|
#include "hooklib/path.h"
|
|
|
|
|
|
|
|
#include "util/dprintf.h"
|
|
|
|
|
2023-01-04 20:24:44 +01:00
|
|
|
/*
|
|
|
|
* AMFrameWork (AMFW) is a DLL that contains many helper classes
|
2023-01-03 05:35:53 +01:00
|
|
|
* for things like input, network, dongle, and other functions that
|
2023-01-04 20:24:44 +01:00
|
|
|
* it would be useful for us to have control of. Luckily we don't have
|
|
|
|
* to reinvent the wheel for the most part, we can just hook the functions
|
2023-01-03 05:35:53 +01:00
|
|
|
* that AMFW uses and let it talk to the game for us.
|
|
|
|
*/
|
|
|
|
void amfw_dongle_insert_hooks(HMODULE target);
|
|
|
|
|
|
|
|
static int my_nbamUsbFinderInitialize();
|
2023-01-04 20:24:44 +01:00
|
|
|
static int my_nbamUsbFinderGetSerialNumber(int a1, char serial[32]);
|
2023-01-03 05:35:53 +01:00
|
|
|
static int my_nbamUsbFinder_GetInformation(int a1, int a2, uint64_t a3, uint16_t a4, void *a5);
|
|
|
|
|
|
|
|
static const struct hook_symbol dongle_hooks[] = {
|
|
|
|
{
|
|
|
|
.name = "nbamUsbFinderInitialize",
|
|
|
|
.patch = my_nbamUsbFinderInitialize
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "nbamUsbFinderGetSerialNumber",
|
|
|
|
.patch = my_nbamUsbFinderGetSerialNumber
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "nbamUsbFinder_GetInformation",
|
|
|
|
.patch = my_nbamUsbFinder_GetInformation
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
char g_serial[13] = {0};
|
|
|
|
|
|
|
|
HRESULT amfw_hook_init(wchar_t serial[13])
|
|
|
|
{
|
|
|
|
HANDLE hMod;
|
|
|
|
|
|
|
|
dprintf("AMFW: Init\n");
|
|
|
|
|
|
|
|
hMod = GetModuleHandle("AMFrameWork.dll");
|
2023-01-04 20:24:44 +01:00
|
|
|
|
2023-01-03 05:35:53 +01:00
|
|
|
if (hMod == NULL) {
|
|
|
|
dprintf("AMFW: DLL not found, disabling\n");
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
dprintf("AMFW: Found AMFrameWork Handle\n");
|
|
|
|
|
|
|
|
bnusio_insert_hooks(hMod);
|
|
|
|
amfw_dongle_insert_hooks(hMod);
|
|
|
|
path_hook_insert_hooks(hMod);
|
|
|
|
qr_insert_hooks(hMod);
|
|
|
|
wcstombs_s(NULL, g_serial, sizeof(g_serial), serial, 26);
|
2023-01-04 20:24:44 +01:00
|
|
|
|
2023-01-03 05:35:53 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void amfw_dongle_insert_hooks(HMODULE target) {
|
|
|
|
hook_table_apply(
|
|
|
|
target,
|
|
|
|
"nbamUsbFinder.dll",
|
|
|
|
dongle_hooks,
|
|
|
|
_countof(dongle_hooks));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int my_nbamUsbFinderInitialize()
|
|
|
|
{
|
|
|
|
dprintf("AMFW: nbamUsbFinderInitialize\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int my_nbamUsbFinderGetSerialNumber(int a1, char serial[32])
|
|
|
|
{
|
|
|
|
dprintf("AMFW: nbamUsbFinderGetSerialNumber %d serial %s\n", a1, g_serial);
|
|
|
|
strcpy_s(serial, 32, g_serial);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int my_nbamUsbFinder_GetInformation(int a1, int a2, uint64_t a3, uint16_t a4, void *a5)
|
|
|
|
{
|
|
|
|
dprintf("AMFW: nbamUsbFinder_GetInformation %d\n", a1);
|
|
|
|
memset(a5, 0x00, 0x628);
|
|
|
|
//memcpy(a5 + 0x428, L"123456789012\0", 26);
|
|
|
|
return 0;
|
2023-01-04 20:24:44 +01:00
|
|
|
}
|