95 lines
2.4 KiB
C
95 lines
2.4 KiB
C
#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"
|
|
|
|
/*
|
|
* AMFrameWork (AMFW) is a DLL that contains many helper classes
|
|
* for things like input, network, dongle, and other functions that
|
|
* 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
|
|
* that AMFW uses and let it talk to the game for us.
|
|
*/
|
|
void amfw_dongle_insert_hooks(HMODULE target);
|
|
|
|
static int my_nbamUsbFinderInitialize();
|
|
static int my_nbamUsbFinderGetSerialNumber(int a1, char serial[32]);
|
|
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");
|
|
|
|
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);
|
|
|
|
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;
|
|
}
|