mirror of
https://gitea.tendokyu.moe/Hay1tsme/bananatools.git
synced 2026-04-26 01:31:49 -05:00
taiko: fix vfs redirect
This commit is contained in:
parent
66d88423f5
commit
1f30821ba4
|
|
@ -122,7 +122,7 @@ static HRESULT bp_handle_irp_locked(struct irp *irp)
|
|||
if (irp->op == IRP_OP_WRITE) {
|
||||
read_ct = 0;
|
||||
if (bp_uart.written.bytes[0] == 0x55) {
|
||||
dprintf("Reader: Hello\n");
|
||||
dprintf("Reader: port opened\n");
|
||||
bp_uart.written.pos = 0; // consume the written buffer
|
||||
}
|
||||
else if (bp_uart.written.bytes[3] == 0x00) {
|
||||
|
|
|
|||
|
|
@ -195,4 +195,4 @@ static HRESULT qr_handle_irp_locked(struct irp* irp)
|
|||
qr_uart.written.pos = 0;
|
||||
|
||||
return hr;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
129
hooklib/path.c
129
hooklib/path.c
|
|
@ -200,6 +200,23 @@ static UINT WINAPI hook_GetDriveTypeW(
|
|||
LPCWSTR lpRootPathName
|
||||
);
|
||||
|
||||
static HFILE WINAPI hook_OpenFile(
|
||||
LPCSTR lpFileName,
|
||||
LPOFSTRUCT lpReOpenBuff,
|
||||
UINT uStyle);
|
||||
|
||||
static DWORD WINAPI hook_GetFullPathNameA(
|
||||
LPCSTR lpFileName,
|
||||
DWORD nBufferLength,
|
||||
LPSTR lpBuffer,
|
||||
LPSTR *lpFilePart);
|
||||
|
||||
static DWORD WINAPI hook_GetFullPathNameW(
|
||||
LPCWSTR lpFileName,
|
||||
DWORD nBufferLength,
|
||||
LPWSTR lpBuffer,
|
||||
LPWSTR *lpFilePart);
|
||||
|
||||
/* Link pointers */
|
||||
|
||||
static BOOL (WINAPI *next_CreateDirectoryA)(
|
||||
|
|
@ -395,6 +412,23 @@ static UINT (WINAPI *next_GetDriveTypeA)(
|
|||
LPCSTR lpRootPathName
|
||||
);
|
||||
|
||||
static HFILE (WINAPI *next_OpenFile)(
|
||||
LPCSTR lpFileName,
|
||||
LPOFSTRUCT lpReOpenBuff,
|
||||
UINT uStyle);
|
||||
|
||||
static DWORD (WINAPI *next_GetFullPathNameA)(
|
||||
LPCSTR lpFileName,
|
||||
DWORD nBufferLength,
|
||||
LPSTR lpBuffer,
|
||||
LPSTR *lpFilePart);
|
||||
|
||||
static DWORD (WINAPI *next_GetFullPathNameW)(
|
||||
LPCWSTR lpFileName,
|
||||
DWORD nBufferLength,
|
||||
LPWSTR lpBuffer,
|
||||
LPWSTR *lpFilePart);
|
||||
|
||||
/* Hook table */
|
||||
|
||||
static const struct hook_symbol path_hook_syms[] = {
|
||||
|
|
@ -538,7 +572,19 @@ static const struct hook_symbol path_hook_syms[] = {
|
|||
.name = "GetDriveTypeW",
|
||||
.patch = hook_GetDriveTypeW,
|
||||
.link = (void **) &next_GetDriveTypeW,
|
||||
}
|
||||
}, {
|
||||
.name = "OpenFile",
|
||||
.patch = hook_OpenFile,
|
||||
.link = (void **) &next_OpenFile,
|
||||
}, {
|
||||
.name = "GetFullPathNameA",
|
||||
.patch = hook_GetFullPathNameA,
|
||||
.link = (void **) &next_GetFullPathNameA,
|
||||
}, {
|
||||
.name = "GetFullPathNameW",
|
||||
.patch = hook_GetFullPathNameW,
|
||||
.link = (void **) &next_GetFullPathNameW,
|
||||
},
|
||||
};
|
||||
|
||||
static bool path_hook_initted;
|
||||
|
|
@ -1886,4 +1932,83 @@ BOOL path_transform_args_w(const wchar_t* str, wchar_t delimiter, wchar_t* buf,
|
|||
free(copy);
|
||||
|
||||
return !failed;
|
||||
}
|
||||
}
|
||||
|
||||
static HFILE WINAPI hook_OpenFile(
|
||||
LPCSTR lpFileName,
|
||||
LPOFSTRUCT lpReOpenBuff,
|
||||
UINT uStyle)
|
||||
{
|
||||
char *trans;
|
||||
HFILE result;
|
||||
BOOL ok;
|
||||
|
||||
ok = path_transform_a(&trans, lpFileName);
|
||||
|
||||
if (!ok) {
|
||||
return HFILE_ERROR;
|
||||
}
|
||||
|
||||
result = next_OpenFile(
|
||||
trans ? trans : lpFileName,
|
||||
lpReOpenBuff,
|
||||
uStyle);
|
||||
|
||||
free(trans);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static DWORD WINAPI hook_GetFullPathNameA(
|
||||
LPCSTR lpFileName,
|
||||
DWORD nBufferLength,
|
||||
LPSTR lpBuffer,
|
||||
LPSTR *lpFilePart)
|
||||
{
|
||||
char *trans;
|
||||
DWORD result;
|
||||
BOOL ok;
|
||||
|
||||
ok = path_transform_a(&trans, lpFileName);
|
||||
|
||||
if (!ok) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = next_GetFullPathNameA(
|
||||
trans ? trans : lpFileName,
|
||||
nBufferLength,
|
||||
lpBuffer,
|
||||
lpFilePart);
|
||||
|
||||
free(trans);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static DWORD WINAPI hook_GetFullPathNameW(
|
||||
LPCWSTR lpFileName,
|
||||
DWORD nBufferLength,
|
||||
LPWSTR lpBuffer,
|
||||
LPWSTR *lpFilePart)
|
||||
{
|
||||
wchar_t *trans;
|
||||
DWORD result;
|
||||
BOOL ok;
|
||||
|
||||
ok = path_transform_w(&trans, lpFileName);
|
||||
|
||||
if (!ok) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = next_GetFullPathNameW(
|
||||
trans ? trans : lpFileName,
|
||||
nBufferLength,
|
||||
lpBuffer,
|
||||
lpFilePart);
|
||||
|
||||
free(trans);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -299,8 +299,9 @@ HRESULT vfs_path_hook(const wchar_t *src, wchar_t *dest, size_t *count)
|
|||
|
||||
assert(src != NULL);
|
||||
assert(count != NULL);
|
||||
|
||||
if (src[0] == L'\0' || src[1] != L':' || !path_is_separator_w(src[2])) {
|
||||
|
||||
// Allow null terminator, separators (\ or /), OR the wildcard (*)
|
||||
if (src[0] == L'\0' || src[1] != L':' || (!path_is_separator_w(src[2]) && src[2] != L'*')) {
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include "hook/iohook.h"
|
||||
|
||||
#include "hooklib/dll.h"
|
||||
#include "hooklib/reg.h"
|
||||
#include "hooklib/path.h"
|
||||
#include "hooklib/setupapi.h"
|
||||
#include "hooklib/serial.h"
|
||||
|
|
@ -49,6 +50,14 @@ static const struct hook_symbol kernel32_syms[] = {
|
|||
}
|
||||
};
|
||||
|
||||
static void dll_hook_insert_hooks(HMODULE target) {
|
||||
hook_table_apply(
|
||||
target,
|
||||
"kernel32.dll",
|
||||
kernel32_syms,
|
||||
_countof(kernel32_syms));
|
||||
}
|
||||
|
||||
HRESULT amfw_hook_init()
|
||||
{
|
||||
HANDLE hMod;
|
||||
|
|
@ -66,24 +75,17 @@ HRESULT amfw_hook_init()
|
|||
|
||||
dprintf("AMFW: Found AMFrameWork Handle\n");
|
||||
|
||||
dll_hook_insert_hooks(hMod);
|
||||
path_hook_insert_hooks(hMod);
|
||||
setupapi_hook_insert_hooks(hMod);
|
||||
proc_addr_insert_hooks(hMod);
|
||||
|
||||
serial_hook_apply_hooks(hMod);
|
||||
iohook_apply_hooks(hMod);
|
||||
reg_hook_apply_hooks(hMod);
|
||||
proc_addr_insert_hooks(hMod);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static void dll_hook_insert_hooks(HMODULE target) {
|
||||
hook_table_apply(
|
||||
target,
|
||||
"kernel32.dll",
|
||||
kernel32_syms,
|
||||
_countof(kernel32_syms));
|
||||
}
|
||||
|
||||
static HMODULE WINAPI hook_LoadLibraryA(const char *name)
|
||||
{
|
||||
HMODULE result;
|
||||
|
|
|
|||
|
|
@ -33,10 +33,19 @@ static DWORD CALLBACK taiko_pre_startup(void)
|
|||
|
||||
dprintf("--- Begin taiko_pre_startup ---\n");
|
||||
|
||||
/* Load config */
|
||||
|
||||
taiko_hook_config_load(&taiko_hook_cfg, L".\\bananatools.ini");
|
||||
|
||||
/* Hook Win32 APIs */
|
||||
|
||||
gfx_hook_init(&taiko_hook_cfg.gfx);
|
||||
gfx_d3d11_hook_init(&taiko_hook_cfg.gfx, taiko_hook_mod);
|
||||
gfx_dxgi_hook_init(&taiko_hook_cfg.gfx, taiko_hook_mod);
|
||||
serial_hook_init();
|
||||
|
||||
/* Initialize emulation hooks */
|
||||
|
||||
struct dongle_info dinfo;
|
||||
dinfo.pid = 0x0C00;
|
||||
dinfo.vid = 0x0B9A;
|
||||
|
|
@ -71,12 +80,6 @@ static DWORD CALLBACK taiko_pre_startup(void)
|
|||
ExitProcess(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
hr = amfw_hook_init();
|
||||
|
||||
if (FAILED(hr)) {
|
||||
ExitProcess(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
hr = amcus_hook_init(&taiko_hook_cfg.amcus);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
|
|
@ -89,9 +92,16 @@ static DWORD CALLBACK taiko_pre_startup(void)
|
|||
ExitProcess(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
gfx_hook_init(&taiko_hook_cfg.gfx);
|
||||
gfx_d3d11_hook_init(&taiko_hook_cfg.gfx, taiko_hook_mod);
|
||||
gfx_dxgi_hook_init(&taiko_hook_cfg.gfx, taiko_hook_mod);
|
||||
/* Initialize native plugin DLL hooks
|
||||
|
||||
There seems to be an issue with other DLL hooks if `LoadLibraryW` is
|
||||
hooked earlier in the `taikohook` initialization. */
|
||||
|
||||
hr = amfw_hook_init();
|
||||
|
||||
if (FAILED(hr)) {
|
||||
ExitProcess(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
dprintf("--- End taiko_pre_startup ---\n");
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user