1
0
mirror of https://github.com/djhackersdev/bemanitools.git synced 2024-11-23 22:30:56 +01:00

iidxhook9: add fs hook for F drive

This commit is contained in:
Will Xyen 2024-05-11 01:45:20 -07:00 committed by Will
parent ca42257fa2
commit a03c4e0d93
4 changed files with 61 additions and 0 deletions

View File

@ -29,4 +29,5 @@ libs_iidxhook9 := \
src_iidxhook9 := \
config-io.c \
fs-hook.c \
dllmain.c \

View File

@ -26,6 +26,7 @@
#include "bio2emu-iidx/bi2a.h"
#include "iidxhook9/config-io.h"
#include "iidxhook9/fs-hook.h"
#include "camhook/cam.h"
#include "camhook/config-cam.h"
@ -159,6 +160,9 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
} else {
memfile_hook_add_fd("d:\\\\001rom.txt", ABSOLUTE_MATCH, "LDJ", 3);
}
// redirect F:\ drive to vfs (used for video recording)
iidxhook9_fs_hooks_init();
}
rs232_hook_init();

View File

@ -0,0 +1,50 @@
#define LOG_MODULE "fs-hook"
#include <stdint.h>
#include <string.h>
#include "hook/table.h"
#include "imports/avs.h"
#include "iidxhook9/fs-hook.h"
#include "util/log.h"
#include "util/str.h"
static void *(*real_avs_fs_mount)(const char *dest, const char *src, const char *fs_type, const char *options);
static void *my_avs_fs_mount(const char *dest, const char *src, const char *fs_type, const char *options);
static const struct hook_symbol avs_fs_hook_syms[] = {
{.name = "XCgsqzn000004b", // avs_fs_mount
.ordinal = 76,
.patch = my_avs_fs_mount,
.link = (void **) &real_avs_fs_mount},
};
static void *my_avs_fs_mount(const char *dest, const char *src, const char *fs_type, const char *options)
{
// quick check for "F:\"
if (src[0] == 'F' && src[1] == ':' && src[2] == '\0') {
const char* dev_folder_drive = "dev/vfs/drive_f/";
log_misc("Redirecting %s to %s", src, dev_folder_drive);
CreateDirectoryA("dev/vfs/", NULL);
CreateDirectoryA("dev/vfs/drive_f/", NULL);
return real_avs_fs_mount(dest, dev_folder_drive, fs_type, options);
}
return real_avs_fs_mount(dest, src, fs_type, options);
}
void iidxhook9_fs_hooks_init()
{
hook_table_apply(
NULL,
"avs2-core.dll",
avs_fs_hook_syms,
lengthof(avs_fs_hook_syms));
log_info("Inserted avs fs hooks");
}

View File

@ -0,0 +1,6 @@
#ifndef IIDXHOOK9_FS_HOOKS_H
#define IIDXHOOK9_FS_HOOKS_H
void iidxhook9_fs_hooks_init();
#endif