[memfile] Add support for faking files in memory

This commit is contained in:
Will Xyen
2020-10-18 14:46:34 -07:00
parent be5a773cb7
commit 3d4df4cd64
9 changed files with 375 additions and 1 deletions
+30 -1
View File
@@ -14,6 +14,7 @@
#include "hooklib/adapter.h"
#include "hooklib/app.h"
#include "hooklib/config-adapter.h"
#include "hooklib/memfile.h"
#include "hooklib/rs232.h"
#include "bio2emu/emu.h"
@@ -51,6 +52,21 @@ static struct bio2emu_port bio2_emu = {
.dispatcher = bio2_emu_bi2a_dispatch_request,
};
static void attach_dest_fd_intercept(const char *sidcode)
{
char region = sidcode[3];
if (region == 'X') {
region = 'J';
}
char target_file[8] = "\\x.dest";
target_file[1] = tolower(region);
// can only capture these by ending path due to /dev/raw being mountable
memfile_hook_add_fd(target_file, ENDING_MATCH, NULL, 0);
}
static bool my_dll_entry_init(char *sidcode, struct property_node *param)
{
struct cconfig *config;
@@ -113,12 +129,21 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
iohook_push_handler(ac_io_port_dispatch_irp);
iohook_push_handler(bio2emu_port_dispatch_irp);
if (!config_io.disable_file_hooks) {
memfile_hook_init();
iohook_push_handler(memfile_hook_dispatch_irp);
attach_dest_fd_intercept(sidcode);
}
rs232_hook_init();
rs232_hook_limit_hooks();
if (!config_io.disable_bio2_emu) {
bio2emu_init();
bio2_emu_bi2a_init(&bio2_emu, config_io.disable_poll_limiter, config_io.force_headphones);
bio2_emu_bi2a_init(
&bio2_emu,
config_io.disable_poll_limiter,
config_io.force_headphones);
}
if (!config_io.disable_card_reader_emu) {
@@ -157,6 +182,10 @@ static bool my_dll_entry_main(void)
sdvx_io_fini();
}
if (!config_io.disable_file_hooks) {
memfile_hook_fini();
}
return result;
}