Add fs hook for F drive in iidxhook9 #303
@@ -29,4 +29,5 @@ libs_iidxhook9 := \
|
||||
|
||||
src_iidxhook9 := \
|
||||
config-io.c \
|
||||
fs-hook.c \
|
||||
dllmain.c \
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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') {
|
||||
|
question: Is it always capital 'F'? Seen some odd stuff in the past where they also used the lower-case drive letters because reasons. question: Is it always capital 'F'? Seen some odd stuff in the past where they also used the lower-case drive letters because reasons.
Yes Yes
|
||||
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);
|
||||
|
suggestion: Not happy with the solution as it forces you to a hardcoded path. Maybe someone still wants these recordings on a separate disk or usb thumb drive? How about making this path configurable? We also got d and e folders configurable, iirc. suggestion: Not happy with the solution as it forces you to a hardcoded path. Maybe someone still wants these recordings on a separate disk or usb thumb drive? How about making this path configurable? We also got d and e folders configurable, iirc.
Sounds reasonable, however this is not a regular path, but an AVS fs path instead, so I think exposing it might cause confusion, whereas most people should have a dev folder setup. Sounds reasonable, however this is not a regular path, but an AVS fs path instead, so I think exposing it might cause confusion, whereas most people should have a dev folder setup.
|
||||
|
||||
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");
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef IIDXHOOK9_FS_HOOKS_H
|
||||
#define IIDXHOOK9_FS_HOOKS_H
|
||||
|
||||
void iidxhook9_fs_hooks_init();
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user
suggestion: I guess it's fine to hook it like that, but that might introduce re-usability issues with different AVS versions. I suggest to at least ifdef guard it and check that the AVS_VERSION define is within the right version range. Probably just throw an error for now if it isn't, so the next dev has visibility on that matter at least and needs to double check.
The hook is scoped to iidxhook9, so the symbol will always be that.
Right, thanks for highlighting. Kinda missed that detail.