feat: Integrate frame time performance graph into iidxhook 1-8

Integrate the previously created frame time graph component
into iidxhook 1 to 8. iidxhook9 uses d3d9ex which still requires
a separate hook implementation for imgui.

Guard the feature with a switch as it might have some performance
impact and it’s something that is only required to be turned on
when needed.
This commit is contained in:
icex2 2025-02-07 15:10:30 +01:00
parent 8efeb68c75
commit 8b82b32894
46 changed files with 635 additions and 47 deletions

View File

@ -1,3 +1,6 @@
# Enable frame performance graph overlay
debug.enable_frame_perf_graph=false
# Magnetic card type, format XXX, 3 digit string (supports: C02, D01, E11, ECO)
eamuse.card_type=C02

View File

@ -1,3 +1,6 @@
# Enable frame performance graph overlay
debug.enable_frame_perf_graph=false
# Magnetic card type, format XXX, 3 digit string (supports: C02, D01, E11, ECO)
eamuse.card_type=D01

View File

@ -1,3 +1,6 @@
# Enable frame performance graph overlay
debug.enable_frame_perf_graph=false
# Magnetic card type, format XXX, 3 digit string (supports: C02, D01, E11, ECO)
eamuse.card_type=E11

View File

@ -1,3 +1,6 @@
# Enable frame performance graph overlay
debug.enable_frame_perf_graph=false
# Magnetic card type, format XXX, 3 digit string (supports: C02, D01, E11, ECO)
eamuse.card_type=ECO

View File

@ -1,3 +1,6 @@
# Enable frame performance graph overlay
debug.enable_frame_perf_graph=false
# Magnetic card type, format XXX, 3 digit string (supports: C02, D01, E11, ECO)
eamuse.card_type=C02

View File

@ -1,3 +1,6 @@
# Enable frame performance graph overlay
debug.enable_frame_perf_graph=false
# URL (e.g. http://my.eamuse.server:80/whatever) or IPV4 (e.g. 127.0.0.1:80) of the target eamuse server. The port is optional but defaults to 80.
eamuse.server=localhost:80

View File

@ -1,3 +1,6 @@
# Enable frame performance graph overlay
debug.enable_frame_perf_graph=false
# URL (e.g. http://my.eamuse.server:80/whatever) or IPV4 (e.g. 127.0.0.1:80) of the target eamuse server. The port is optional but defaults to 80.
eamuse.server=localhost:80

View File

@ -1,3 +1,6 @@
# Enable frame performance graph overlay
debug.enable_frame_perf_graph=false
# URL (e.g. http://my.eamuse.server:80/whatever) or IPV4 (e.g. 127.0.0.1:80) of the target eamuse server. The port is optional but defaults to 80.
eamuse.server=localhost:80

View File

@ -1,3 +1,6 @@
# Enable frame performance graph overlay
debug.enable_frame_perf_graph=false
# URL (e.g. http://my.eamuse.server:80/whatever) or IPV4 (e.g. 127.0.0.1:80) of the target eamuse server. The port is optional but defaults to 80.
eamuse.server=localhost:80

View File

@ -1,3 +1,6 @@
# Enable frame performance graph overlay
debug.enable_frame_perf_graph=false
# PCBID
eamuse.pcbid=0101020304050607086F

View File

@ -1,3 +1,6 @@
# Enable frame performance graph overlay
debug.enable_frame_perf_graph=false
# Run the game in a framed window (requires windowed option)
gfx.framed=false

View File

@ -1,3 +1,6 @@
# Enable frame performance graph overlay
debug.enable_frame_perf_graph=false
# Run the game in a framed window (requires windowed option)
gfx.framed=false

View File

@ -1,3 +1,6 @@
# Enable frame performance graph overlay
debug.enable_frame_perf_graph=false
# PCBID
eamuse.pcbid=0101020304050607086F

View File

@ -1,3 +1,6 @@
# Enable frame performance graph overlay
debug.enable_frame_perf_graph=false
# Run the game in a framed window (requires windowed option)
gfx.framed=false

View File

@ -1,3 +1,6 @@
# Enable frame performance graph overlay
debug.enable_frame_perf_graph=false
# Run the game in a framed window (requires windowed option)
gfx.framed=false

View File

@ -1,3 +1,6 @@
# Enable frame performance graph overlay
debug.enable_frame_perf_graph=false
# Run the game in a framed window (requires windowed option)
gfx.framed=false

View File

@ -1,3 +1,6 @@
# Enable frame performance graph overlay
debug.enable_frame_perf_graph=false
# Run the game in a framed window (requires windowed option)
gfx.framed=false

View File

@ -1,3 +1,6 @@
# Enable frame performance graph overlay
debug.enable_frame_perf_graph=false
# Run the game in a framed window (requires windowed option)
gfx.framed=false

View File

@ -1,3 +1,6 @@
# Enable frame performance graph overlay
debug.enable_frame_perf_graph=false
# Run the game in a framed window (requires windowed option)
gfx.framed=false

View File

@ -1,3 +1,6 @@
# Enable frame performance graph overlay
debug.enable_frame_perf_graph=false
# Run the game in a framed window (requires windowed option)
gfx.framed=false

View File

@ -7,6 +7,7 @@ src_iidxhook-util := \
acio.c \
chart-patch.c \
clock.c \
config-debug.c \
config-eamuse.c \
config-ezusb.c \
config-gfx.c \

View File

@ -0,0 +1,34 @@
#include "cconfig/cconfig-util.h"
#include "iidxhook-util/config-debug.h"
#include "util/log.h"
#define IIDXHOOK_CONFIG_DEBUG_ENABLE_FRAME_PERF_GRAPH_KEY "debug.enable_frame_perf_graph"
#define IIDXHOOK_CONFIG_DEBUG_DEFAULT_ENABLE_FRAME_PERF_GRAPH_VALUE false
void iidxhook_config_debug_init(struct cconfig *config)
{
cconfig_util_set_bool(
config,
IIDXHOOK_CONFIG_DEBUG_ENABLE_FRAME_PERF_GRAPH_KEY,
IIDXHOOK_CONFIG_DEBUG_DEFAULT_ENABLE_FRAME_PERF_GRAPH_VALUE,
"Enable frame performance graph overlay");
}
void iidxhook_config_debug_get(
struct iidxhook_config_debug *config_debug, struct cconfig *config)
{
if (!cconfig_util_get_bool(
config,
IIDXHOOK_CONFIG_DEBUG_ENABLE_FRAME_PERF_GRAPH_KEY,
&config_debug->enable_frame_perf_graph,
IIDXHOOK_CONFIG_DEBUG_DEFAULT_ENABLE_FRAME_PERF_GRAPH_VALUE)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%d'",
IIDXHOOK_CONFIG_DEBUG_ENABLE_FRAME_PERF_GRAPH_KEY,
IIDXHOOK_CONFIG_DEBUG_DEFAULT_ENABLE_FRAME_PERF_GRAPH_VALUE);
}
}

View File

@ -0,0 +1,17 @@
#ifndef IIDXHOOK_CONFIG_DEBUG_H
#define IIDXHOOK_CONFIG_DEBUG_H
#include <windows.h>
#include "cconfig/cconfig.h"
struct iidxhook_config_debug {
bool enable_frame_perf_graph;
};
void iidxhook_config_debug_init(struct cconfig *config);
void iidxhook_config_debug_get(
struct iidxhook_config_debug *config_debug, struct cconfig *config);
#endif

View File

@ -3,6 +3,9 @@ dlls += iidxhook1
ldflags_iidxhook1 := \
-lws2_32 \
-liphlpapi \
-ld3d9 \
-ldwmapi\
-lgdi32 \
libs_iidxhook1 := \
iidxhook-util \
@ -18,6 +21,9 @@ libs_iidxhook1 := \
cconfig \
util \
ezusb \
imgui-bt \
imgui-debug \
imgui \
src_iidxhook1 := \
config-iidxhook1.c \

View File

@ -27,6 +27,7 @@
#include "iidxhook-util/chart-patch.h"
#include "iidxhook-util/clock.h"
#include "iidxhook-util/config-debug.h"
#include "iidxhook-util/config-eamuse.h"
#include "iidxhook-util/config-ezusb.h"
#include "iidxhook-util/config-gfx.h"
@ -41,6 +42,10 @@
#include "iidxhook1/ezusb-mon.h"
#include "iidxhook1/log-ezusb.h"
#include "imgui-bt/imgui-d3d9-hook.h"
#include "imgui-debug/frame-perf-graph.h"
#include "util/defs.h"
#include "util/log.h"
#include "util/thread.h"
@ -53,6 +58,7 @@
static const hook_d3d9_irp_handler_t iidxhook_d3d9_handlers[] = {
iidxhook_util_d3d9_irp_handler,
imgui_hook_d3d9_irp_handler
};
static HANDLE STDCALL my_OpenProcess(DWORD, BOOL, DWORD);
@ -68,6 +74,17 @@ static const struct hook_symbol init_hook_syms[] = {
},
};
static void iidxhook1_setup_imgui_debug_components(const struct iidxhook_config_debug *config_debug)
{
imgui_bt_component_t debug_frame_graph_component;
if (config_debug->enable_frame_perf_graph) {
imgui_debug_frame_perf_graph_init(60.0f, &debug_frame_graph_component);
imgui_d3d9_hook_init(&debug_frame_graph_component, 1);
}
}
static void iidxhook1_setup_d3d9_hooks(
const struct iidxhook_config_gfx *config_gfx,
const struct iidxhook_config_iidxhook1 *config_iidxhook1)
@ -125,6 +142,7 @@ my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
{
struct cconfig *config;
struct iidxhook_config_debug config_debug;
struct iidxhook_util_config_ezusb config_ezusb;
struct iidxhook_util_config_eamuse config_eamuse;
struct iidxhook_config_gfx config_gfx;
@ -144,6 +162,7 @@ my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
config = cconfig_init();
iidxhook_config_debug_init(config);
iidxhook_util_config_ezusb_init(config);
iidxhook_util_config_eamuse_init(config);
iidxhook_config_gfx_init(config);
@ -159,6 +178,7 @@ my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
exit(EXIT_FAILURE);
}
iidxhook_config_debug_get(&config_debug, config);
iidxhook_util_config_ezusb_get(&config_ezusb, config);
iidxhook_util_config_eamuse_get(&config_eamuse, config);
iidxhook_config_gfx_get(&config_gfx, config);
@ -202,6 +222,8 @@ my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
settings_hook_set_path(config_misc.settings_path);
}
iidxhook1_setup_imgui_debug_components(&config_debug);
/* Direct3D and USER32 hooks */
iidxhook1_setup_d3d9_hooks(&config_gfx, &config_iidxhook1);

View File

@ -3,6 +3,9 @@ avsdlls += iidxhook2
ldflags_iidxhook2 := \
-lws2_32 \
-liphlpapi \
-ld3d9 \
-ldwmapi\
-lgdi32 \
libs_iidxhook2 := \
iidxhook-util \
@ -18,6 +21,9 @@ libs_iidxhook2 := \
cconfig \
util \
ezusb \
imgui-bt \
imgui-debug \
imgui \
src_iidxhook2 := \
config-iidxhook2.c \

View File

@ -29,6 +29,7 @@
#include "iidxhook-util/acio.h"
#include "iidxhook-util/chart-patch.h"
#include "iidxhook-util/clock.h"
#include "iidxhook-util/config-debug.h"
#include "iidxhook-util/config-eamuse.h"
#include "iidxhook-util/config-ezusb.h"
#include "iidxhook-util/config-gfx.h"
@ -41,6 +42,10 @@
#include "iidxhook2/config-iidxhook2.h"
#include "imgui-bt/imgui-d3d9-hook.h"
#include "imgui-debug/frame-perf-graph.h"
#include "util/log.h"
#include "util/thread.h"
@ -52,6 +57,7 @@
static const hook_d3d9_irp_handler_t iidxhook_d3d9_handlers[] = {
iidxhook_util_d3d9_irp_handler,
imgui_hook_d3d9_irp_handler,
};
static HANDLE STDCALL my_OpenProcess(DWORD, BOOL, DWORD);
@ -65,6 +71,17 @@ static const struct hook_symbol init_hook_syms[] = {
.link = (void **) &real_OpenProcess},
};
static void iidxhook2_setup_imgui_debug_components(const struct iidxhook_config_debug *config_debug)
{
imgui_bt_component_t debug_frame_graph_component;
if (config_debug->enable_frame_perf_graph) {
imgui_debug_frame_perf_graph_init(60.0f, &debug_frame_graph_component);
imgui_d3d9_hook_init(&debug_frame_graph_component, 1);
}
}
static void iidxhook2_setup_d3d9_hooks(
const struct iidxhook_config_gfx *config_gfx,
const struct iidxhook_config_iidxhook2 *config_iidxhook2)
@ -122,6 +139,7 @@ my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
{
struct cconfig *config;
struct iidxhook_config_debug config_debug;
struct iidxhook_util_config_ezusb config_ezusb;
struct iidxhook_util_config_eamuse config_eamuse;
struct iidxhook_config_gfx config_gfx;
@ -141,6 +159,7 @@ my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
config = cconfig_init();
iidxhook_config_debug_init(config);
iidxhook_util_config_ezusb_init(config);
iidxhook_util_config_eamuse_init(config);
iidxhook_config_gfx_init(config);
@ -156,6 +175,7 @@ my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
exit(EXIT_FAILURE);
}
iidxhook_config_debug_get(&config_debug, config);
iidxhook_util_config_ezusb_get(&config_ezusb, config);
iidxhook_util_config_eamuse_get(&config_eamuse, config);
iidxhook_config_gfx_get(&config_gfx, config);
@ -194,6 +214,8 @@ my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
settings_hook_set_path(config_misc.settings_path);
}
iidxhook2_setup_imgui_debug_components(&config_debug);
/* Direct3D and USER32 hooks */
iidxhook2_setup_d3d9_hooks(&config_gfx, &config_iidxhook2);

View File

@ -3,9 +3,13 @@ avsdlls += iidxhook3
ldflags_iidxhook3 := \
-lws2_32 \
-liphlpapi \
-ld3d9 \
-ldwmapi\
-lgdi32 \
libs_iidxhook3 := \
iidxhook-util \
iidxhook-d3d9 \
ezusb-emu \
ezusb-iidx-16seg-emu \
ezusb2-emu \
@ -20,6 +24,9 @@ libs_iidxhook3 := \
cconfig \
util \
ezusb \
imgui-bt \
imgui-debug \
imgui \
src_iidxhook3 := \
dllmain.c \

View File

@ -30,6 +30,7 @@
#include "iidxhook-util/acio.h"
#include "iidxhook-util/chart-patch.h"
#include "iidxhook-util/clock.h"
#include "iidxhook-util/config-debug.h"
#include "iidxhook-util/config-eamuse.h"
#include "iidxhook-util/config-gfx.h"
#include "iidxhook-util/config-misc.h"
@ -38,6 +39,10 @@
#include "iidxhook-util/eamuse.h"
#include "iidxhook-util/settings.h"
#include "imgui-bt/imgui-d3d9-hook.h"
#include "imgui-debug/frame-perf-graph.h"
#include "security/rp-sign-key.h"
#include "util/log.h"
@ -52,6 +57,7 @@
static const hook_d3d9_irp_handler_t iidxhook_d3d9_handlers[] = {
iidxhook_util_d3d9_irp_handler,
imgui_hook_d3d9_irp_handler,
};
static HANDLE STDCALL my_OpenProcess(DWORD, BOOL, DWORD);
@ -64,6 +70,17 @@ static const struct hook_symbol init_hook_syms[] = {
.link = (void **) &real_OpenProcess},
};
static void iidxhook3_setup_imgui_debug_components(const struct iidxhook_config_debug *config_debug)
{
imgui_bt_component_t debug_frame_graph_component;
if (config_debug->enable_frame_perf_graph) {
imgui_debug_frame_perf_graph_init(60.0f, &debug_frame_graph_component);
imgui_d3d9_hook_init(&debug_frame_graph_component, 1);
}
}
static void
iidxhook3_setup_d3d9_hooks(const struct iidxhook_config_gfx *config_gfx)
{
@ -120,6 +137,7 @@ my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
{
struct cconfig *config;
struct iidxhook_config_debug config_debug;
struct iidxhook_util_config_eamuse config_eamuse;
struct iidxhook_config_gfx config_gfx;
struct iidxhook_config_misc config_misc;
@ -137,6 +155,7 @@ my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
config = cconfig_init();
iidxhook_config_debug_init(config);
iidxhook_util_config_eamuse_init(config);
iidxhook_config_gfx_init(config);
iidxhook_config_misc_init(config);
@ -150,6 +169,7 @@ my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
exit(EXIT_FAILURE);
}
iidxhook_config_debug_get(&config_debug, config);
iidxhook_util_config_eamuse_get(&config_eamuse, config);
iidxhook_config_gfx_get(&config_gfx, config);
iidxhook_config_misc_get(&config_misc, config);
@ -187,6 +207,8 @@ my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
settings_hook_set_path(config_misc.settings_path);
}
iidxhook3_setup_imgui_debug_components(&config_debug);
/* Direct3D and USER32 hooks */
iidxhook3_setup_d3d9_hooks(&config_gfx);

View File

@ -3,6 +3,9 @@ avsdlls += iidxhook4-cn
ldflags_iidxhook4-cn := \
-liphlpapi \
-lws2_32 \
-ld3d9 \
-ldwmapi\
-lgdi32 \
deplibs_iidxhook4-cn := \
avs \
@ -20,6 +23,9 @@ libs_iidxhook4-cn := \
cconfig \
util \
ezusb \
imgui-bt \
imgui-debug \
imgui \
src_iidxhook4-cn := \
avs-boot.c \

View File

@ -25,6 +25,7 @@
#include "iidxhook4-cn/path.h"
#include "iidxhook-util/chart-patch.h"
#include "iidxhook-util/config-debug.h"
#include "iidxhook-util/config-eamuse.h"
#include "iidxhook-util/config-gfx.h"
#include "iidxhook-util/config-io.h"
@ -33,6 +34,10 @@
#include "iidxhook-util/d3d9.h"
#include "iidxhook-util/settings.h"
#include "imgui-bt/imgui-d3d9-hook.h"
#include "imgui-debug/frame-perf-graph.h"
#include "security/rp-sign-key.h"
#include "imports/avs.h"
@ -51,6 +56,7 @@ static bool iidxhook_init_check;
static const hook_d3d9_irp_handler_t iidxhook_d3d9_handlers[] = {
iidxhook_util_d3d9_irp_handler,
imgui_hook_d3d9_irp_handler,
};
static const struct hook_symbol init_hook_syms[] = {
@ -61,6 +67,17 @@ static const struct hook_symbol init_hook_syms[] = {
static struct iidxhook_config_io config_io;
static void iidxhook4_cn_setup_imgui_debug_components(const struct iidxhook_config_debug *config_debug)
{
imgui_bt_component_t debug_frame_graph_component;
if (config_debug->enable_frame_perf_graph) {
imgui_debug_frame_perf_graph_init(60.0f, &debug_frame_graph_component);
imgui_d3d9_hook_init(&debug_frame_graph_component, 1);
}
}
static void
iidxhook4_cn_setup_d3d9_hooks(const struct iidxhook_config_gfx *config_gfx)
{
@ -117,6 +134,7 @@ my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
{
struct cconfig *config;
struct iidxhook_config_debug config_debug;
struct iidxhook_util_config_eamuse config_eamuse;
struct iidxhook_config_gfx config_gfx;
struct iidxhook_config_sec config_sec;
@ -134,6 +152,7 @@ my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
config = cconfig_init();
iidxhook_config_debug_init(config);
iidxhook_util_config_eamuse_init(config);
iidxhook_config_gfx_init(config);
iidxhook_config_io_init(config);
@ -148,6 +167,7 @@ my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
exit(EXIT_FAILURE);
}
iidxhook_config_debug_get(&config_debug, config);
iidxhook_util_config_eamuse_get(&config_eamuse, config);
iidxhook_config_gfx_get(&config_gfx, config);
iidxhook_config_io_get(&config_io, config);
@ -174,6 +194,8 @@ my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
&config_sec.black_plug_mcode);
ezusb_iidx_emu_node_security_plug_set_pcbid(&config_eamuse.pcbid);
iidxhook4_cn_setup_imgui_debug_components(&config_debug);
iidxhook4_cn_setup_d3d9_hooks(&config_gfx);
if (strlen(config_misc.settings_path) > 0) {

View File

@ -2,6 +2,9 @@ avsdlls += iidxhook4
ldflags_iidxhook4 := \
-liphlpapi \
-ld3d9 \
-ldwmapi\
-lgdi32 \
deplibs_iidxhook4 := \
avs \
@ -22,6 +25,9 @@ libs_iidxhook4 := \
cconfig \
util \
ezusb \
imgui-bt \
imgui-debug \
imgui \
src_iidxhook4 := \
dllmain.c \

View File

@ -27,6 +27,7 @@
#include "iidxhook-util/acio.h"
#include "iidxhook-util/chart-patch.h"
#include "iidxhook-util/config-debug.h"
#include "iidxhook-util/config-gfx.h"
#include "iidxhook-util/config-io.h"
#include "iidxhook-util/config-misc.h"
@ -34,6 +35,10 @@
#include "iidxhook-util/log-server.h"
#include "iidxhook-util/settings.h"
#include "imgui-bt/imgui-d3d9-hook.h"
#include "imgui-debug/frame-perf-graph.h"
#include "imports/avs.h"
#include "util/log.h"
@ -48,10 +53,22 @@
static const hook_d3d9_irp_handler_t iidxhook_d3d9_handlers[] = {
iidxhook_util_d3d9_irp_handler,
imgui_hook_d3d9_irp_handler,
};
static struct iidxhook_config_io config_io;
static void iidxhook4_setup_imgui_debug_components(const struct iidxhook_config_debug *config_debug)
{
imgui_bt_component_t debug_frame_graph_component;
if (config_debug->enable_frame_perf_graph) {
imgui_debug_frame_perf_graph_init(60.0f, &debug_frame_graph_component);
imgui_d3d9_hook_init(&debug_frame_graph_component, 1);
}
}
static void
iidxhook4_setup_d3d9_hooks(const struct iidxhook_config_gfx *config_gfx)
{
@ -101,6 +118,7 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
{
struct cconfig *config;
struct iidxhook_config_debug config_debug;
struct iidxhook_config_gfx config_gfx;
struct iidxhook_config_misc config_misc;
@ -111,6 +129,7 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
config = cconfig_init();
iidxhook_config_debug_init(config);
iidxhook_config_gfx_init(config);
iidxhook_config_io_init(config);
iidxhook_config_misc_init(config);
@ -124,6 +143,7 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
exit(EXIT_FAILURE);
}
iidxhook_config_debug_get(&config_debug, config);
iidxhook_config_gfx_get(&config_gfx, config);
iidxhook_config_io_get(&config_io, config);
iidxhook_config_misc_get(&config_misc, config);
@ -133,6 +153,8 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
log_info(IIDXHOOK4_INFO_HEADER);
log_info("Initializing iidxhook...");
iidxhook4_setup_imgui_debug_components(&config_debug);
iidxhook4_setup_d3d9_hooks(&config_gfx);
if (strlen(config_misc.settings_path) > 0) {

View File

@ -3,6 +3,9 @@ avsdlls += iidxhook5-cn
ldflags_iidxhook5-cn := \
-liphlpapi \
-lws2_32 \
-ld3d9 \
-ldwmapi\
-lgdi32 \
deplibs_iidxhook5-cn := \
avs \
@ -20,6 +23,9 @@ libs_iidxhook5-cn := \
cconfig \
util \
ezusb \
imgui-bt \
imgui-debug \
imgui \
src_iidxhook5-cn := \
avs-boot.c \

View File

@ -25,6 +25,7 @@
#include "iidxhook5-cn/avs-boot.h"
#include "iidxhook5-cn/path.h"
#include "iidxhook-util/config-debug.h"
#include "iidxhook-util/config-eamuse.h"
#include "iidxhook-util/config-gfx.h"
#include "iidxhook-util/config-io.h"
@ -33,6 +34,10 @@
#include "iidxhook-util/d3d9.h"
#include "iidxhook-util/settings.h"
#include "imgui-bt/imgui-d3d9-hook.h"
#include "imgui-debug/frame-perf-graph.h"
#include "security/rp-sign-key.h"
#include "imports/avs.h"
@ -51,6 +56,7 @@ static bool iidxhook_init_check;
static const hook_d3d9_irp_handler_t iidxhook_d3d9_handlers[] = {
iidxhook_util_d3d9_irp_handler,
imgui_hook_d3d9_irp_handler,
};
static const struct hook_symbol init_hook_user32_syms[] = {
@ -61,6 +67,17 @@ static const struct hook_symbol init_hook_user32_syms[] = {
static struct iidxhook_config_io config_io;
static void iidxhook5_cn_setup_imgui_debug_components(const struct iidxhook_config_debug *config_debug)
{
imgui_bt_component_t debug_frame_graph_component;
if (config_debug->enable_frame_perf_graph) {
imgui_debug_frame_perf_graph_init(60.0f, &debug_frame_graph_component);
imgui_d3d9_hook_init(&debug_frame_graph_component, 1);
}
}
static void
iidxhook5_cn_setup_d3d9_hooks(const struct iidxhook_config_gfx *config_gfx)
{
@ -97,6 +114,7 @@ static ATOM WINAPI my_RegisterClassA(const WNDCLASSA *lpWndClass)
{
struct cconfig *config;
struct iidxhook_config_debug config_debug;
struct iidxhook_util_config_eamuse config_eamuse;
struct iidxhook_config_gfx config_gfx;
struct iidxhook_config_sec config_sec;
@ -114,6 +132,7 @@ static ATOM WINAPI my_RegisterClassA(const WNDCLASSA *lpWndClass)
config = cconfig_init();
iidxhook_config_debug_init(config);
iidxhook_util_config_eamuse_init(config);
iidxhook_config_gfx_init(config);
iidxhook_config_io_init(config);
@ -128,6 +147,7 @@ static ATOM WINAPI my_RegisterClassA(const WNDCLASSA *lpWndClass)
exit(EXIT_FAILURE);
}
iidxhook_config_debug_get(&config_debug, config);
iidxhook_util_config_eamuse_get(&config_eamuse, config);
iidxhook_config_gfx_get(&config_gfx, config);
iidxhook_config_io_get(&config_io, config);
@ -154,6 +174,8 @@ static ATOM WINAPI my_RegisterClassA(const WNDCLASSA *lpWndClass)
&config_sec.black_plug_mcode);
ezusb_iidx_emu_node_security_plug_set_pcbid(&config_eamuse.pcbid);
iidxhook5_cn_setup_imgui_debug_components(&config_debug);
iidxhook5_cn_setup_d3d9_hooks(&config_gfx);
if (strlen(config_misc.settings_path) > 0) {

View File

@ -2,6 +2,9 @@ avsdlls += iidxhook5
ldflags_iidxhook5 := \
-liphlpapi \
-ld3d9 \
-ldwmapi\
-lgdi32 \
deplibs_iidxhook5 := \
avs \
@ -22,6 +25,9 @@ libs_iidxhook5 := \
cconfig \
util \
ezusb \
imgui-bt \
imgui-debug \
imgui \
src_iidxhook5 := \
dllmain.c \

View File

@ -27,6 +27,7 @@
#include "iidxhook-util/acio.h"
#include "iidxhook-util/chart-patch.h"
#include "iidxhook-util/config-debug.h"
#include "iidxhook-util/config-gfx.h"
#include "iidxhook-util/config-io.h"
#include "iidxhook-util/config-misc.h"
@ -34,6 +35,10 @@
#include "iidxhook-util/log-server.h"
#include "iidxhook-util/settings.h"
#include "imgui-bt/imgui-d3d9-hook.h"
#include "imgui-debug/frame-perf-graph.h"
#include "imports/avs.h"
#include "util/log.h"
@ -50,10 +55,22 @@
static const hook_d3d9_irp_handler_t iidxhook_d3d9_handlers[] = {
iidxhook_util_d3d9_irp_handler,
imgui_hook_d3d9_irp_handler,
};
static struct iidxhook_config_io config_io;
static void iidxhook5_setup_imgui_debug_components(const struct iidxhook_config_debug *config_debug)
{
imgui_bt_component_t debug_frame_graph_component;
if (config_debug->enable_frame_perf_graph) {
imgui_debug_frame_perf_graph_init(60.0f, &debug_frame_graph_component);
imgui_d3d9_hook_init(&debug_frame_graph_component, 1);
}
}
static void
iidxhook5_setup_d3d9_hooks(const struct iidxhook_config_gfx *config_gfx)
{
@ -103,6 +120,7 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
{
struct cconfig *config;
struct iidxhook_config_debug config_debug;
struct iidxhook_config_gfx config_gfx;
struct iidxhook_config_misc config_misc;
@ -113,6 +131,7 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
config = cconfig_init();
iidxhook_config_debug_init(config);
iidxhook_config_gfx_init(config);
iidxhook_config_io_init(config);
iidxhook_config_misc_init(config);
@ -126,6 +145,7 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
exit(EXIT_FAILURE);
}
iidxhook_config_debug_get(&config_debug, config);
iidxhook_config_gfx_get(&config_gfx, config);
iidxhook_config_io_get(&config_io, config);
iidxhook_config_misc_get(&config_misc, config);
@ -135,6 +155,8 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
log_info(IIDXHOOK5_INFO_HEADER);
log_info("Initializing iidxhook...");
iidxhook5_setup_imgui_debug_components(&config_debug);
iidxhook5_setup_d3d9_hooks(&config_gfx);
if (strlen(config_misc.settings_path) > 0) {

View File

@ -2,6 +2,9 @@ avsdlls += iidxhook6
ldflags_iidxhook6 := \
-liphlpapi \
-ld3d9 \
-ldwmapi\
-lgdi32 \
deplibs_iidxhook6 := \
avs \
@ -23,6 +26,9 @@ libs_iidxhook6 := \
cconfig \
util \
ezusb \
imgui-bt \
imgui-debug \
imgui \
src_iidxhook6 := \
dllmain.c \

View File

@ -28,11 +28,16 @@
#include "iidxhook-d3d9/bb-scale-hd.h"
#include "iidxhook-util/acio.h"
#include "iidxhook-util/config-debug.h"
#include "iidxhook-util/config-gfx.h"
#include "iidxhook-util/config-io.h"
#include "iidxhook-util/d3d9.h"
#include "iidxhook-util/log-server.h"
#include "imgui-bt/imgui-d3d9-hook.h"
#include "imgui-debug/frame-perf-graph.h"
#include "imports/avs.h"
#include "util/log.h"
@ -48,10 +53,22 @@
static const hook_d3d9_irp_handler_t iidxhook_d3d9_handlers[] = {
iidxhook_d3d9_bb_scale_hd_d3d9_irp_handler,
iidxhook_util_d3d9_irp_handler,
imgui_hook_d3d9_irp_handler,
};
static struct iidxhook_config_io config_io;
static void iidxhook6_setup_imgui_debug_components(const struct iidxhook_config_debug *config_debug)
{
imgui_bt_component_t debug_frame_graph_component;
if (config_debug->enable_frame_perf_graph) {
imgui_debug_frame_perf_graph_init(60.0f, &debug_frame_graph_component);
imgui_d3d9_hook_init(&debug_frame_graph_component, 1);
}
}
static void
iidxhook6_setup_d3d9_hooks(const struct iidxhook_config_gfx *config_gfx)
{
@ -87,6 +104,7 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
{
struct cconfig *config;
struct iidxhook_config_debug config_debug;
struct iidxhook_config_gfx config_gfx;
log_server_init();
@ -96,6 +114,7 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
config = cconfig_init();
iidxhook_config_debug_init(config);
iidxhook_config_gfx_init(config);
iidxhook_config_io_init(config);
@ -108,6 +127,7 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
exit(EXIT_FAILURE);
}
iidxhook_config_debug_get(&config_debug, config);
iidxhook_config_gfx_get(&config_gfx, config);
iidxhook_config_io_get(&config_io, config);
@ -116,6 +136,8 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
log_info(IIDXHOOK6_INFO_HEADER);
log_info("Initializing iidxhook...");
iidxhook6_setup_imgui_debug_components(&config_debug);
iidxhook6_setup_d3d9_hooks(&config_gfx);
if (!config_io.disable_io_emu) {

View File

@ -3,6 +3,8 @@ avsdlls += iidxhook7
ldflags_iidxhook7 := \
-liphlpapi \
-ld3d9 \
-ldwmapi\
-lgdi32 \
deplibs_iidxhook7 := \
avs \
@ -24,6 +26,9 @@ libs_iidxhook7 := \
iidxio \
util \
ezusb \
imgui-bt \
imgui-debug \
imgui \
src_iidxhook7 := \
dllmain.c \

View File

@ -28,11 +28,16 @@
#include "iidxhook-d3d9/bb-scale-hd.h"
#include "iidxhook-util/acio.h"
#include "iidxhook-util/config-debug.h"
#include "iidxhook-util/config-gfx.h"
#include "iidxhook-util/config-io.h"
#include "iidxhook-util/d3d9.h"
#include "iidxhook-util/log-server.h"
#include "imgui-bt/imgui-d3d9-hook.h"
#include "imgui-debug/frame-perf-graph.h"
#include "imports/avs.h"
#include "util/log.h"
@ -48,10 +53,22 @@
static const hook_d3d9_irp_handler_t iidxhook_d3d9_handlers[] = {
iidxhook_d3d9_bb_scale_hd_d3d9_irp_handler,
iidxhook_util_d3d9_irp_handler,
imgui_hook_d3d9_irp_handler,
};
static struct iidxhook_config_io config_io;
static void iidxhook7_setup_imgui_debug_components(const struct iidxhook_config_debug *config_debug)
{
imgui_bt_component_t debug_frame_graph_component;
if (config_debug->enable_frame_perf_graph) {
imgui_debug_frame_perf_graph_init(60.0f, &debug_frame_graph_component);
imgui_d3d9_hook_init(&debug_frame_graph_component, 1);
}
}
static void
iidxhook7_setup_d3d9_hooks(const struct iidxhook_config_gfx *config_gfx)
{
@ -87,6 +104,7 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
{
struct cconfig *config;
struct iidxhook_config_debug config_debug;
struct iidxhook_config_gfx config_gfx;
log_server_init();
@ -96,6 +114,7 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
config = cconfig_init();
iidxhook_config_debug_init(config);
iidxhook_config_gfx_init(config);
iidxhook_config_io_init(config);
@ -108,6 +127,11 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
exit(EXIT_FAILURE);
}
iidxhook_config_debug_init(config);
iidxhook_config_gfx_init(config);
iidxhook_config_io_init(config);
iidxhook_config_debug_get(&config_debug, config);
iidxhook_config_gfx_get(&config_gfx, config);
iidxhook_config_io_get(&config_io, config);
@ -116,6 +140,8 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
log_info(IIDXHOOK7_INFO_HEADER);
log_info("Initializing iidxhook...");
iidxhook7_setup_imgui_debug_components(&config_debug);
iidxhook7_setup_d3d9_hooks(&config_gfx);
if (!config_io.disable_io_emu) {

View File

@ -7,6 +7,9 @@ ldflags_iidxhook8 := \
-lmf \
-lmfplat \
-lole32 \
-ld3d9 \
-ldwmapi\
-lgdi32 \
deplibs_iidxhook8 := \
avs \
@ -24,7 +27,10 @@ libs_iidxhook8 := \
cconfig \
util \
eamio \
imgui-bt \
imgui-debug \
imgui \
src_iidxhook8 := \
config-io.c \
dllmain.c \

View File

@ -21,10 +21,15 @@
#include "iidxhook-d3d9/bb-scale-hd.h"
#include "iidxhook-util/acio.h"
#include "iidxhook-util/config-debug.h"
#include "iidxhook-util/config-gfx.h"
#include "iidxhook-util/d3d9.h"
#include "iidxhook-util/log-server.h"
#include "imgui-bt/imgui-d3d9-hook.h"
#include "imgui-debug/frame-perf-graph.h"
#include "bio2emu-iidx/bi2a.h"
#include "bio2emu/emu.h"
@ -47,8 +52,19 @@
static const hook_d3d9_irp_handler_t iidxhook_d3d9_handlers[] = {
iidxhook_d3d9_bb_scale_hd_d3d9_irp_handler,
iidxhook_util_d3d9_irp_handler,
imgui_hook_d3d9_irp_handler,
};
static void iidxhook8_setup_imgui_debug_components(const struct iidxhook_config_debug *config_debug)
{
imgui_bt_component_t debug_frame_graph_component;
if (config_debug->enable_frame_perf_graph) {
imgui_debug_frame_perf_graph_init(60.0f, &debug_frame_graph_component);
imgui_d3d9_hook_init(&debug_frame_graph_component, 1);
}
}
static void
iidxhook8_setup_d3d9_hooks(const struct iidxhook_config_gfx *config_gfx)
{
@ -93,6 +109,7 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
{
struct cconfig *config;
struct iidxhook_config_debug config_debug;
struct iidxhook_config_gfx config_gfx;
// log_server_init is required due to IO occuring in a non avs_thread
@ -104,6 +121,7 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
config = cconfig_init();
iidxhook_config_debug_init(config);
iidxhook_config_gfx_init(config);
iidxhook8_config_io_init(config);
camhook_config_cam_init(config, 2);
@ -117,6 +135,7 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
exit(EXIT_FAILURE);
}
iidxhook_config_debug_get(&config_debug, config);
iidxhook_config_gfx_get(&config_gfx, config);
iidxhook8_config_io_get(&iidxhook8_config_io, config);
camhook_config_cam_get(&config_cam, config, 2);
@ -126,6 +145,8 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
log_info(IIDXHOOK8_INFO_HEADER);
log_info("Initializing iidxhook...");
iidxhook8_setup_imgui_debug_components(&config_debug);
iidxhook8_setup_d3d9_hooks(&config_gfx);
/* Start up IIDXIO.DLL */

View File

@ -20,5 +20,6 @@ src_util := \
str.c \
thread.c \
time.c \
winerr.c \
winres.c \

View File

@ -1,54 +1,25 @@
#define LOG_MODULE "util-proc"
#include <windows.h>
#include <winnt.h>
#include <stdbool.h>
#include <stdint.h>
#include <winternl.h>
#include <tlhelp32.h>
#include <ntstatus.h>
#include "util/defs.h"
#include "util/log.h"
#include "util/mem.h"
#include "util/str.h"
#include "util/winerr.h"
bool proc_is_running_as_admin_user()
{
SID_IDENTIFIER_AUTHORITY authority = SECURITY_NT_AUTHORITY;
PSID sid;
BOOL res;
BOOL is_admin;
#include "proc.h"
res = AllocateAndInitializeSid(
&authority,
2,
SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_ADMINS,
0,
0,
0,
0,
0,
0,
&sid);
if (!res) {
log_warning(
"Failed to allocate memory for is admin check: %lX",
GetLastError());
return false;
}
is_admin = false;
res = CheckTokenMembership(NULL, sid, &is_admin);
if (!res) {
log_warning(
"Failed to check admin group membership: %lX", GetLastError());
return false;
}
FreeSid(sid);
return is_admin;
}
typedef NTSTATUS (NTAPI *PNtQueryInformationThread)(
HANDLE ThreadHandle,
THREADINFOCLASS ThreadInformationClass,
PVOID ThreadInformation,
ULONG ThreadInformationLength,
PULONG ReturnLength
);
void proc_terminate_current_process(uint32_t exit_code)
{
@ -58,4 +29,196 @@ void proc_terminate_current_process(uint32_t exit_code)
SYNCHRONIZE | PROCESS_TERMINATE, TRUE, GetCurrentProcessId());
TerminateProcess(hnd, exit_code);
}
void* proc_thread_get_proc_address(int thread_id)
{
HANDLE thread;
char* err_str;
HMODULE nt_dll;
PNtQueryInformationThread ntQueryInformationThread;
NTSTATUS status;
PVOID thread_start_address;
ULONG return_len;
thread = proc_thread_get_handle(thread_id);
if (thread == NULL) {
err_str = util_winerr_format_last_error_code();
log_fatal("Failed to open thread with id %d: %s", thread_id, err_str);
}
nt_dll = LoadLibrary("ntdll.dll");
ntQueryInformationThread = (PNtQueryInformationThread) GetProcAddress(nt_dll, "NtQueryInformationThread");
status = ntQueryInformationThread(thread, ThreadQuerySetWin32StartAddress, &thread_start_address, sizeof(thread_start_address), &return_len);
CloseHandle(thread);
FreeLibrary(nt_dll);
if (status != STATUS_SUCCESS) {
log_fatal("Failed to get start address for thread %d: 0x%lx\n", thread_id, status);
}
return thread_start_address;
}
HMODULE proc_thread_proc_get_origin_module(void* proc_addr)
{
HMODULE module;
log_assert(proc_addr);
if (!GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
(LPCTSTR) proc_addr, &module)) {
return NULL;
} else {
return module;
}
}
bool proc_thread_proc_get_origin_module_path(void* proc_addr, char* buffer, size_t len)
{
HMODULE module;
module = proc_thread_proc_get_origin_module(proc_addr);
if (module != NULL) {
if (GetModuleFileNameA(module, buffer, len) == 0) {
return false;
} else {
return true;
}
} else {
return false;
}
}
bool proc_thread_proc_get_origin_module_name(void* proc_addr, char* buffer, size_t len)
{
HMODULE module;
char path_buffer[MAX_PATH];
const char* filename;
module = proc_thread_proc_get_origin_module(proc_addr);
if (module != NULL) {
if (GetModuleFileNameA(module, path_buffer, sizeof(path_buffer)) == 0) {
return false;
} else {
filename = strrchr(path_buffer, '\\');
if (filename == NULL) {
// no backslashes found, use the entire path
filename = path_buffer;
} else {
// skip the backslash
filename++;
}
str_cpy(buffer, len, filename);
return true;
}
} else {
return false;
}
}
size_t proc_thread_scan_threads_current_process(struct proc_thread_info** info)
{
DWORD pid;
HANDLE snapshot;
char* err_str;
THREADENTRY32 thread_entry;
size_t idx;
HANDLE thread;
log_assert(info);
pid = GetCurrentProcessId();
// Create a snapshot of the running threads in the target process.
snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, pid);
if (snapshot == INVALID_HANDLE_VALUE) {
err_str = util_winerr_format_last_error_code();
log_fatal("Failed to create snapshot of threads: %s", err_str);
}
thread_entry.dwSize = sizeof(THREADENTRY32);
idx = 0;
*info = NULL;
// Count entries for allocation of return value
if (Thread32First(snapshot, &thread_entry)) {
do {
if (thread_entry.th32OwnerProcessID == pid) {
*info = xrealloc(*info, (idx + 1) * sizeof(struct proc_thread_info));
thread = proc_thread_get_handle(thread_entry.th32ThreadID);
(*info)[idx].id = thread_entry.th32ThreadID;
(*info)[idx].proc = proc_thread_get_proc_address(thread_entry.th32ThreadID);
(*info)[idx].priority = GetThreadPriority(thread);
(*info)[idx].origin_module = proc_thread_proc_get_origin_module((*info)[idx].proc);
CloseHandle(thread);
idx++;
}
} while (Thread32Next(snapshot, &thread_entry));
}
CloseHandle(snapshot);
return idx;
}
HANDLE proc_thread_get_handle(int thread_id)
{
HANDLE handle;
handle = OpenThread(THREAD_ALL_ACCESS, FALSE, thread_id);
return handle;
}
bool proc_thread_set_priority(int thread_id, int priority)
{
HANDLE thread;
BOOL res;
thread = proc_thread_get_handle(thread_id);
if (thread == NULL) {
return false;
}
res = SetThreadPriority(thread, priority);
CloseHandle(thread);
return res;
}
bool proc_thread_set_affinity(int thread_id, uint32_t cpu_mask)
{
HANDLE thread;
DWORD_PTR affinity_mask;
DWORD_PTR prev_affinity_mask;
thread = proc_thread_get_handle(thread_id);
if (thread == NULL) {
return false;
}
affinity_mask = cpu_mask;
prev_affinity_mask = SetThreadAffinityMask(thread, affinity_mask);
CloseHandle(thread);
return prev_affinity_mask != 0;
}

View File

@ -1,8 +1,37 @@
#pragma once
#include <windows.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
bool proc_is_running_as_admin_user();
#define PROC_THREAD_CPU_AFFINITY_CORE(c) (1 << c)
void proc_terminate_current_process(uint32_t exit_code);
struct proc_thread_info {
int id;
void* proc;
// According to
// https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getthreadpriority#return-value
int priority;
HMODULE origin_module;
};
void proc_terminate_current_process(uint32_t exit_code);
void* proc_thread_get_proc_address(int thread_id);
HMODULE proc_thread_proc_get_origin_module(void* proc_addr);
bool proc_thread_proc_get_origin_module_path(void* proc_addr, char* buffer, size_t len);
bool proc_thread_proc_get_origin_module_name(void* proc_addr, char* buffer, size_t len);
size_t proc_thread_scan_threads_current_process(struct proc_thread_info** info);
HANDLE proc_thread_get_handle(int thread_id);
bool proc_thread_set_priority(int thread_id, int priority);
// cpu starts with 0, specify multiple to set affinity to these cores
bool proc_thread_set_affinity(int thread_id, uint32_t cpu_mask);