1
0
mirror of https://gitea.tendokyu.moe/Dniel97/segatools.git synced 2024-11-27 22:40:48 +01:00

idzhook: Fold zinput into idzhook

This commit is contained in:
Tau 2019-11-03 16:12:58 -05:00
parent dfc1e13397
commit 59ad491d08
9 changed files with 64 additions and 25 deletions

View File

@ -19,4 +19,13 @@ void idz_hook_config_load(
platform_config_load(&cfg->platform, filename);
amex_config_load(&cfg->amex, filename);
aime_config_load(&cfg->aime, filename);
zinput_config_load(&cfg->zinput, filename);
}
void zinput_config_load(struct zinput_config *cfg, const wchar_t *filename)
{
assert(cfg != NULL);
assert(filename != NULL);
cfg->enable = GetPrivateProfileIntW(L"zinput", L"enable", 1, filename);
}

View File

@ -1,5 +1,6 @@
#pragma once
#include <stdbool.h>
#include <stddef.h>
#include "amex/config.h"
@ -8,12 +9,19 @@
#include "platform/config.h"
struct zinput_config {
bool enable;
};
struct idz_hook_config {
struct platform_config platform;
struct amex_config amex;
struct aime_config aime;
struct zinput_config zinput;
};
void idz_hook_config_load(
struct idz_hook_config *cfg,
const wchar_t *filename);
void zinput_config_load(struct zinput_config *cfg, const wchar_t *filename);

View File

@ -15,6 +15,7 @@
#include "idzhook/config.h"
#include "idzhook/jvs.h"
#include "idzhook/zinput.h"
#include "platform/platform.h"
@ -35,6 +36,7 @@ static DWORD CALLBACK idz_pre_startup(void)
/* Hook Win32 APIs */
serial_hook_init();
zinput_hook_init(&idz_hook_cfg.zinput);
/* Initialize emulation hooks */

View File

@ -26,5 +26,7 @@ shared_library(
'dllmain.c',
'jvs.c',
'jvs.h',
'zinput.c',
'zinput.h',
],
)

View File

@ -5,11 +5,20 @@
#include <stdlib.h>
#include <string.h>
#include "hook/process.h"
#include "idzhook/config.h"
#include "idzhook/zinput.h"
#include "hook/table.h"
#include "util/dprintf.h"
HRESULT WINAPI hook_DirectInput8Create(
HINSTANCE hinst,
DWORD dwVersion,
REFIID riidltf,
LPVOID *ppvOut,
LPUNKNOWN punkOuter);
static unsigned long WINAPI my_AddRef(IUnknown *self);
static unsigned long WINAPI my_Release(IUnknown *self);
@ -64,14 +73,38 @@ static const IDirectInputDevice8WVtbl dev_vtbl = {
static const IDirectInputDevice8W dev = { (void *) &dev_vtbl };
HRESULT WINAPI DirectInput8Create(
static const struct hook_symbol zinput_hook_syms[] = {
{
.name = "DirectInput8Create",
.patch = hook_DirectInput8Create,
}
};
HRESULT zinput_hook_init(struct zinput_config *cfg)
{
assert(cfg != NULL);
if (!cfg->enable) {
return S_FALSE;
}
hook_table_apply(
NULL,
"dinput8.dll",
zinput_hook_syms,
_countof(zinput_hook_syms));
return S_OK;
}
HRESULT WINAPI hook_DirectInput8Create(
HINSTANCE hinst,
DWORD dwVersion,
REFIID riidltf,
LPVOID *ppvOut,
LPUNKNOWN punkOuter)
{
dprintf("%s\n", __func__);
dprintf("ZInput: Blocking built-in DirectInput support\n");
*ppvOut = (void *) &api;
return S_OK;

7
idzhook/zinput.h Normal file
View File

@ -0,0 +1,7 @@
#pragma once
#include <windows.h>
#include "idzhook/config.h"
HRESULT zinput_hook_init(struct zinput_config *cfg);

View File

@ -51,4 +51,3 @@ subdir('divahook')
subdir('idzhook')
subdir('minihook')
subdir('mu3hook')
subdir('zinput')

View File

@ -1,17 +0,0 @@
shared_library(
'zinput',
name_prefix : '',
include_directories : inc,
implicit_include_directories : false,
vs_module_defs : 'zinput.def',
c_pch : '../precompiled.h',
dependencies : [
capnhook.get_variable('hook_dep'),
],
link_with : [
util_lib,
],
sources : [
'dllmain.c',
],
)

View File

@ -1,4 +0,0 @@
LIBRARY zinput
EXPORTS
DirectInput8Create@20