bananatools/taikohook/qr.c
2023-01-02 23:39:03 -05:00

80 lines
1.6 KiB
C

#include <windows.h>
#include <stdbool.h>
#include <stdint.h>
#include "taikohook/qr.h"
#include "hook/table.h"
#include "hook/iobuf.h"
#include "hook/iohook.h"
#include "hooklib/uart.h"
#include "hooklib/fdshark.h"
#include "util/dprintf.h"
#include "util/dump.h"
static int my_nbamQrInitialize(void *qr);
static int my_nbamQrEncode(void *qr, void *info);
static int my_nbamQrGetQrImageSize(void *qr, void *info);
static const struct hook_symbol qr_hooks[] = {
{
.name = "nbamQrInitialize(void * *)",
.patch = my_nbamQrInitialize,
.ordinal = 6
},
{
.name = "nbamQrEncode(void *,nbamQr_encode_info_t *)",
.patch = my_nbamQrInitialize,
.ordinal = 3
},
{
.name = "nbamQrGetQrImageSize(void *,nbamQr_encode_info_t *)",
.patch = my_nbamQrInitialize,
.ordinal = 5
},
};
HRESULT qr_hook_init(const struct qr_config *cfg)
{
assert(cfg != NULL);
if (!cfg->enable) {
return S_FALSE;
}
dprintf("QR: Init\n");
// Hook the DLL the game loads
qr_insert_hooks(NULL);
return S_OK;
}
void qr_insert_hooks(HMODULE target)
{
hook_table_apply(
target,
"Nbam_QR_Code.dll",
qr_hooks,
_countof(qr_hooks));
}
static int my_nbamQrInitialize(void *qr)
{
dprintf("QR: nbamQrInitialize\n");
return 0;
}
static int my_nbamQrEncode(void *qr, void *info)
{
dprintf("QR: nbamQrEncode\n");
return 0;
}
static int my_nbamQrGetQrImageSize(void *qr, void *info)
{
dprintf("QR: nbamQrGetQrImageSize\n");
return 0;
}