Apply clang-format code style to all source files
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#include <windows.h>
|
||||
|
||||
#include <ntdef.h>
|
||||
#include <devioctl.h>
|
||||
#include <ntddser.h>
|
||||
#include <ntdef.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
@@ -38,9 +38,9 @@ void iidxhook_util_acio_init(bool legacy_mode)
|
||||
|
||||
ac_io_emu_init(&iidxhook_util_acio_emu, L"COM1");
|
||||
|
||||
for (i = 0 ; i < lengthof(iidxhook_util_acio_emu_icca) ; i++) {
|
||||
ac_io_emu_icca_init(&iidxhook_util_acio_emu_icca[i],
|
||||
&iidxhook_util_acio_emu, i);
|
||||
for (i = 0; i < lengthof(iidxhook_util_acio_emu_icca); i++) {
|
||||
ac_io_emu_icca_init(
|
||||
&iidxhook_util_acio_emu_icca[i], &iidxhook_util_acio_emu, i);
|
||||
}
|
||||
|
||||
rs232_hook_add_fd(iidxhook_util_acio_emu.fd);
|
||||
@@ -51,7 +51,8 @@ void iidxhook_util_acio_fini(void)
|
||||
ac_io_emu_fini(&iidxhook_util_acio_emu);
|
||||
}
|
||||
|
||||
HRESULT iidxhook_util_acio_dispatch_irp(struct irp *irp)
|
||||
HRESULT
|
||||
iidxhook_util_acio_dispatch_irp(struct irp *irp)
|
||||
{
|
||||
const struct ac_io_message *msg;
|
||||
HRESULT hr;
|
||||
@@ -72,33 +73,33 @@ HRESULT iidxhook_util_acio_dispatch_irp(struct irp *irp)
|
||||
msg = ac_io_emu_request_peek(&iidxhook_util_acio_emu);
|
||||
|
||||
switch (msg->addr) {
|
||||
case 0:
|
||||
ac_io_emu_cmd_assign_addrs(&iidxhook_util_acio_emu, msg, 2);
|
||||
case 0:
|
||||
ac_io_emu_cmd_assign_addrs(&iidxhook_util_acio_emu, msg, 2);
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
ac_io_emu_icca_dispatch_request(&iidxhook_util_acio_emu_icca[0],
|
||||
msg);
|
||||
case 1:
|
||||
ac_io_emu_icca_dispatch_request(
|
||||
&iidxhook_util_acio_emu_icca[0], msg);
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
ac_io_emu_icca_dispatch_request(&iidxhook_util_acio_emu_icca[1],
|
||||
msg);
|
||||
case 2:
|
||||
ac_io_emu_icca_dispatch_request(
|
||||
&iidxhook_util_acio_emu_icca[1], msg);
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case AC_IO_BROADCAST:
|
||||
log_warning("Broadcast(?) message on IIDX ACIO bus?");
|
||||
case AC_IO_BROADCAST:
|
||||
log_warning("Broadcast(?) message on IIDX ACIO bus?");
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
default:
|
||||
log_warning("ACIO message on unhandled bus address: %d",
|
||||
msg->addr);
|
||||
default:
|
||||
log_warning(
|
||||
"ACIO message on unhandled bus address: %d", msg->addr);
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
ac_io_emu_request_pop(&iidxhook_util_acio_emu);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
/**
|
||||
* Initialize an emulated ACIO on COM1 for IIDX.
|
||||
*
|
||||
*
|
||||
* @param legacy_mode Set to true if running on slotted readers on iidx 13-18.
|
||||
* Old games using slotted readers might use an old libacio version that
|
||||
* does not support handling of multi messages per package. Instead,
|
||||
|
||||
@@ -61,15 +61,15 @@ static struct chart_patch_file chart_patch_file_1;
|
||||
static struct chart_patch_file chart_patch_file_checksum;
|
||||
static CRITICAL_SECTION chart_patch_lock;
|
||||
|
||||
static bool chart_patch_file_load(struct irp* irp_open,
|
||||
struct chart_patch_file *file, const wchar_t* path)
|
||||
static bool chart_patch_file_load(
|
||||
struct irp *irp_open, struct chart_patch_file *file, const wchar_t *path)
|
||||
{
|
||||
struct irp irp;
|
||||
void *bytes;
|
||||
size_t nbytes;
|
||||
HANDLE fd;
|
||||
HRESULT hr;
|
||||
char* tmp;
|
||||
char *tmp;
|
||||
|
||||
/* Reset file to ensure consistent not-available state */
|
||||
memset(file, 0, sizeof(struct chart_patch_file));
|
||||
@@ -158,7 +158,7 @@ static bool chart_patch_file_load(struct irp* irp_open,
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool chart_patch_is_chart_id(const wchar_t* str)
|
||||
static bool chart_patch_is_chart_id(const wchar_t *str)
|
||||
{
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (!(str[i] >= L'0' && str[i] <= L'9')) {
|
||||
@@ -184,24 +184,27 @@ static void chart_patch_execute_patch_1()
|
||||
factor = chart_patch_hz / chart_patch_timebase;
|
||||
toc = (struct chart_toc_entry *) chart_patch_file_1.state.bytes;
|
||||
|
||||
log_misc("Patching chart: orig %f, target %f, factor %f",
|
||||
chart_patch_timebase, chart_patch_hz, factor);
|
||||
log_misc(
|
||||
"Patching chart: orig %f, target %f, factor %f",
|
||||
chart_patch_timebase,
|
||||
chart_patch_hz,
|
||||
factor);
|
||||
|
||||
for (i = 0 ; i < 12 ; i++) {
|
||||
for (i = 0; i < 12; i++) {
|
||||
if (toc[i].offset == 0) {
|
||||
continue; /* No such chart */
|
||||
}
|
||||
|
||||
for ( chart_offset = toc[i].offset ;
|
||||
chart_offset < toc[i].offset + toc[i].length ;
|
||||
chart_offset += sizeof(struct chart_event)) {
|
||||
event = (struct chart_event *)
|
||||
&chart_patch_file_1.state.bytes[chart_offset];
|
||||
for (chart_offset = toc[i].offset;
|
||||
chart_offset < toc[i].offset + toc[i].length;
|
||||
chart_offset += sizeof(struct chart_event)) {
|
||||
event = (struct chart_event *) &chart_patch_file_1.state
|
||||
.bytes[chart_offset];
|
||||
|
||||
/* Don't clobber the end-of-chart marker */
|
||||
|
||||
if (event->time != 0x7FFFFFFF) {
|
||||
event->time = (uint32_t) round(event->time * factor);
|
||||
event->time = (uint32_t) round(event->time * factor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -218,18 +221,17 @@ static void chart_patch_execute_patch_checksum()
|
||||
size_t i;
|
||||
|
||||
header = (struct ospreybin *) &chart_patch_file_checksum.state.bytes[0];
|
||||
entries = (struct ospreybin_entry *)
|
||||
&chart_patch_file_checksum.state.bytes[sizeof(*header)];
|
||||
entries = (struct ospreybin_entry *) &chart_patch_file_checksum.state
|
||||
.bytes[sizeof(*header)];
|
||||
|
||||
for (i = 0 ; i < header->num_entries ; i++) {
|
||||
for (i = 0; i < header->num_entries; i++) {
|
||||
entry = &entries[i];
|
||||
|
||||
if (!str_eq(chart_patch_file_1_name, entry->filename)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
span_start =
|
||||
&chart_patch_file_1.state.bytes[entry->offset_in_file];
|
||||
span_start = &chart_patch_file_1.state.bytes[entry->offset_in_file];
|
||||
span_len = entry->checksum_length;
|
||||
checksum = crc32(span_start, span_len, 0);
|
||||
|
||||
@@ -242,7 +244,7 @@ static void chart_patch_execute_patch_checksum()
|
||||
log_warning("Could not find checksum row for %s", chart_patch_file_1_name);
|
||||
}
|
||||
|
||||
static bool chart_patch_file_trap(struct irp* irp)
|
||||
static bool chart_patch_file_trap(struct irp *irp)
|
||||
{
|
||||
wchar_t buffer_1_path[1024];
|
||||
wchar_t buffer_checksum_path[1024];
|
||||
@@ -250,7 +252,7 @@ static bool chart_patch_file_trap(struct irp* irp)
|
||||
wchar_t chart_file[7];
|
||||
bool is_1_file;
|
||||
bool is_checksum_file;
|
||||
char* tmp;
|
||||
char *tmp;
|
||||
|
||||
/* This has to trap three different scenarios:
|
||||
1. open .1 chart file only
|
||||
@@ -259,9 +261,14 @@ static bool chart_patch_file_trap(struct irp* irp)
|
||||
In the end, we have to serve either just the .1 file or both the .1
|
||||
and checksum file from memory until the application closes one or both
|
||||
files */
|
||||
if (swscanf(irp->open_filename, L"..\\data\\sd_data%*[\\/]%c%c%c%c%*[\\/]",
|
||||
&chart_id[0], &chart_id[1], &chart_id[2], &chart_id[3]) == 4 &&
|
||||
chart_patch_is_chart_id(chart_id)) {
|
||||
if (swscanf(
|
||||
irp->open_filename,
|
||||
L"..\\data\\sd_data%*[\\/]%c%c%c%c%*[\\/]",
|
||||
&chart_id[0],
|
||||
&chart_id[1],
|
||||
&chart_id[2],
|
||||
&chart_id[3]) == 4 &&
|
||||
chart_patch_is_chart_id(chart_id)) {
|
||||
chart_id[4] = '\0';
|
||||
|
||||
wstr_narrow(irp->open_filename, &tmp);
|
||||
@@ -300,13 +307,18 @@ static bool chart_patch_file_trap(struct irp* irp)
|
||||
log_misc("Preparing in-memory chart %s...", tmp);
|
||||
free(tmp);
|
||||
|
||||
wsprintfW(buffer_1_path, L"..\\data\\sd_data\\\\%s\\%s.1", chart_id,
|
||||
wsprintfW(
|
||||
buffer_1_path,
|
||||
L"..\\data\\sd_data\\\\%s\\%s.1",
|
||||
chart_id,
|
||||
chart_id);
|
||||
wsprintfW(
|
||||
buffer_checksum_path,
|
||||
L"..\\data\\sd_data\\%s\\osprey.bin",
|
||||
chart_id);
|
||||
wsprintfW(buffer_checksum_path,
|
||||
L"..\\data\\sd_data\\%s\\osprey.bin", chart_id);
|
||||
|
||||
if (!chart_patch_file_load(irp, &chart_patch_file_1,
|
||||
buffer_1_path)) {
|
||||
if (!chart_patch_file_load(
|
||||
irp, &chart_patch_file_1, buffer_1_path)) {
|
||||
wstr_narrow(buffer_1_path, &tmp);
|
||||
log_fatal("Cannot load .1 file %s", tmp);
|
||||
free(tmp);
|
||||
@@ -315,13 +327,13 @@ static bool chart_patch_file_trap(struct irp* irp)
|
||||
chart_patch_execute_patch_1();
|
||||
|
||||
wstr_narrow(chart_file, &tmp);
|
||||
memcpy(chart_patch_file_1_name, tmp,
|
||||
sizeof(chart_patch_file_1_name));
|
||||
memcpy(
|
||||
chart_patch_file_1_name, tmp, sizeof(chart_patch_file_1_name));
|
||||
free(tmp);
|
||||
|
||||
/* Optional on some games */
|
||||
if (chart_patch_file_load(irp, &chart_patch_file_checksum,
|
||||
buffer_checksum_path)) {
|
||||
if (chart_patch_file_load(
|
||||
irp, &chart_patch_file_checksum, buffer_checksum_path)) {
|
||||
chart_patch_execute_patch_checksum();
|
||||
}
|
||||
|
||||
@@ -349,16 +361,15 @@ static bool chart_patch_file_trap(struct irp* irp)
|
||||
return false;
|
||||
}
|
||||
|
||||
static HRESULT chart_patch_file_close_irp(
|
||||
struct chart_patch_file *file,
|
||||
struct irp *irp_close)
|
||||
static HRESULT
|
||||
chart_patch_file_close_irp(struct chart_patch_file *file, struct irp *irp_close)
|
||||
{
|
||||
HRESULT hr;
|
||||
struct irp irp;
|
||||
|
||||
file->active = false;
|
||||
|
||||
// log_misc("chart_patch_file_close_irp %d %p %d %p",
|
||||
// log_misc("chart_patch_file_close_irp %d %p %d %p",
|
||||
// chart_patch_file_1.active,
|
||||
// chart_patch_file_1.fd,
|
||||
// chart_patch_file_checksum.active,
|
||||
@@ -373,12 +384,12 @@ static HRESULT chart_patch_file_close_irp(
|
||||
irp.fd = chart_patch_file_1.fd;
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
|
||||
|
||||
if (hr != S_OK) {
|
||||
log_warning("Closing dummy .1 file handle failed");
|
||||
}
|
||||
|
||||
free((void*) chart_patch_file_1.state.bytes);
|
||||
|
||||
free((void *) chart_patch_file_1.state.bytes);
|
||||
memset(&chart_patch_file_1, 0, sizeof(struct chart_patch_file));
|
||||
}
|
||||
|
||||
@@ -392,9 +403,9 @@ static HRESULT chart_patch_file_close_irp(
|
||||
log_warning("Closing dummy checksum file handle failed");
|
||||
}
|
||||
|
||||
free((void*) chart_patch_file_checksum.state.bytes);
|
||||
memset(&chart_patch_file_checksum, 0,
|
||||
sizeof(struct chart_patch_file));
|
||||
free((void *) chart_patch_file_checksum.state.bytes);
|
||||
memset(
|
||||
&chart_patch_file_checksum, 0, sizeof(struct chart_patch_file));
|
||||
}
|
||||
|
||||
chart_patch_file_detour = false;
|
||||
@@ -405,9 +416,8 @@ static HRESULT chart_patch_file_close_irp(
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT chart_patch_file_read(
|
||||
struct chart_patch_file *file,
|
||||
struct irp *irp)
|
||||
static HRESULT
|
||||
chart_patch_file_read(struct chart_patch_file *file, struct irp *irp)
|
||||
{
|
||||
// log_misc("chart_patch_file_read %p", file->fd);
|
||||
|
||||
@@ -416,30 +426,29 @@ static HRESULT chart_patch_file_read(
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT chart_patch_file_seek(
|
||||
struct chart_patch_file *file,
|
||||
struct irp *irp)
|
||||
static HRESULT
|
||||
chart_patch_file_seek(struct chart_patch_file *file, struct irp *irp)
|
||||
{
|
||||
ssize_t pos;
|
||||
|
||||
switch (irp->seek_origin) {
|
||||
case FILE_BEGIN:
|
||||
pos = irp->seek_offset;
|
||||
case FILE_BEGIN:
|
||||
pos = irp->seek_offset;
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case FILE_CURRENT:
|
||||
pos = irp->seek_offset + file->state.pos;
|
||||
case FILE_CURRENT:
|
||||
pos = irp->seek_offset + file->state.pos;
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case FILE_END:
|
||||
pos = irp->seek_offset + file->state.nbytes;
|
||||
case FILE_END:
|
||||
pos = irp->seek_offset + file->state.nbytes;
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
default:
|
||||
return E_INVALIDARG;
|
||||
default:
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
file->state.pos = max(0, min(pos, file->state.nbytes));
|
||||
@@ -448,18 +457,22 @@ static HRESULT chart_patch_file_seek(
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT chart_patch_file_dispatch_irp(
|
||||
struct chart_patch_file *file,
|
||||
struct irp *irp)
|
||||
static HRESULT
|
||||
chart_patch_file_dispatch_irp(struct chart_patch_file *file, struct irp *irp)
|
||||
{
|
||||
// log_misc("chart_patch_file_dispatch_irp %p", file->fd);
|
||||
|
||||
switch (irp->op) {
|
||||
case IRP_OP_CLOSE: return chart_patch_file_close_irp(file, irp);
|
||||
case IRP_OP_READ: return chart_patch_file_read(file, irp);
|
||||
case IRP_OP_WRITE: return HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED);
|
||||
case IRP_OP_SEEK: return chart_patch_file_seek(file, irp);
|
||||
default: return E_NOTIMPL;
|
||||
case IRP_OP_CLOSE:
|
||||
return chart_patch_file_close_irp(file, irp);
|
||||
case IRP_OP_READ:
|
||||
return chart_patch_file_read(file, irp);
|
||||
case IRP_OP_WRITE:
|
||||
return HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED);
|
||||
case IRP_OP_SEEK:
|
||||
return chart_patch_file_seek(file, irp);
|
||||
default:
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -498,7 +511,8 @@ void iidxhook_util_chart_patch_set_refresh_rate(double hz)
|
||||
log_info("Set target refresh rate %f", chart_patch_hz);
|
||||
}
|
||||
|
||||
HRESULT iidxhook_util_chart_patch_dispatch_irp(struct irp *irp)
|
||||
HRESULT
|
||||
iidxhook_util_chart_patch_dispatch_irp(struct irp *irp)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
@@ -516,8 +530,8 @@ HRESULT iidxhook_util_chart_patch_dispatch_irp(struct irp *irp)
|
||||
} else {
|
||||
if (irp->fd != INVALID_HANDLE_VALUE && irp->fd != NULL) {
|
||||
if (irp->fd == chart_patch_file_1.fd) {
|
||||
hr = chart_patch_file_dispatch_irp(&chart_patch_file_1,
|
||||
irp);
|
||||
hr =
|
||||
chart_patch_file_dispatch_irp(&chart_patch_file_1, irp);
|
||||
} else if (irp->fd == chart_patch_file_checksum.fd) {
|
||||
hr = chart_patch_file_dispatch_irp(
|
||||
&chart_patch_file_checksum, irp);
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* the charts in-memory to modify their timestamps and making the game run
|
||||
* on-sync on non-stock setups with different display refresh rates than
|
||||
* 59.94 or 60.04 (depending on game version).
|
||||
*
|
||||
*
|
||||
* @param orig_timebase The original refresh rate (timebase value) of the game.
|
||||
* Use one of the defined macros.
|
||||
*/
|
||||
@@ -30,8 +30,8 @@ void iidxhook_util_chart_patch_fini(void);
|
||||
* Set the target refresh rate of the display. Determine this value either
|
||||
* by using the d3d8 or d3d9 monitor check of bemanitools or get it from another
|
||||
* source (e.g. one of the newer games in-built monitor checks).
|
||||
*
|
||||
* @param hz Refresh rate of the display. Ensure your display provides a
|
||||
*
|
||||
* @param hz Refresh rate of the display. Ensure your display provides a
|
||||
* constant value.
|
||||
*/
|
||||
void iidxhook_util_chart_patch_set_refresh_rate(double hz);
|
||||
|
||||
@@ -7,18 +7,16 @@
|
||||
#include "util/defs.h"
|
||||
#include "util/log.h"
|
||||
|
||||
static BOOL STDCALL my_SetLocalTime(const SYSTEMTIME* lpSystemTime);
|
||||
static BOOL (STDCALL *real_SetLocalTime)(const SYSTEMTIME* lpSystemTime);
|
||||
static BOOL STDCALL my_SetLocalTime(const SYSTEMTIME *lpSystemTime);
|
||||
static BOOL(STDCALL *real_SetLocalTime)(const SYSTEMTIME *lpSystemTime);
|
||||
|
||||
static const struct hook_symbol clock_hook_syms[] = {
|
||||
{
|
||||
.name = "SetLocalTime",
|
||||
.patch = my_SetLocalTime,
|
||||
.link = (void **) &real_SetLocalTime
|
||||
},
|
||||
{.name = "SetLocalTime",
|
||||
.patch = my_SetLocalTime,
|
||||
.link = (void **) &real_SetLocalTime},
|
||||
};
|
||||
|
||||
static BOOL STDCALL my_SetLocalTime(const SYSTEMTIME* lpSystemTime)
|
||||
static BOOL STDCALL my_SetLocalTime(const SYSTEMTIME *lpSystemTime)
|
||||
{
|
||||
/* Stub, don't mess with system clock */
|
||||
log_misc("Blocked setting system clock time");
|
||||
@@ -28,10 +26,7 @@ static BOOL STDCALL my_SetLocalTime(const SYSTEMTIME* lpSystemTime)
|
||||
void iidxhook_util_clock_hook_init(void)
|
||||
{
|
||||
hook_table_apply(
|
||||
NULL,
|
||||
"kernel32.dll",
|
||||
clock_hook_syms,
|
||||
lengthof(clock_hook_syms));
|
||||
NULL, "kernel32.dll", clock_hook_syms, lengthof(clock_hook_syms));
|
||||
|
||||
log_info("Inserted clock hooks");
|
||||
}
|
||||
|
||||
@@ -13,12 +13,15 @@
|
||||
#define IIDXHOOK_CONFIG_EAMUSE_PCBID_KEY "eamuse.pcbid"
|
||||
#define IIDXHOOK_CONFIG_EAMUSE_EAMID_KEY "eamuse.eamid"
|
||||
|
||||
#define IIDXHOOK_CONFIG_EAMUSE_DEFAULT_CARD_TYPE_VALUE SECURITY_MCODE_GAME_IIDX_9
|
||||
#define IIDXHOOK_CONFIG_EAMUSE_DEFAULT_CARD_TYPE_VALUE \
|
||||
SECURITY_MCODE_GAME_IIDX_9
|
||||
#define IIDXHOOK_CONFIG_EAMUSE_DEFAULT_SERVER_VALUE "localhost:80"
|
||||
#define IIDXHOOK_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE security_id_default
|
||||
#define IIDXHOOK_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE_LEN sizeof(security_id_default)
|
||||
#define IIDXHOOK_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE_LEN \
|
||||
sizeof(security_id_default)
|
||||
#define IIDXHOOK_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE security_id_default
|
||||
#define IIDXHOOK_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE_LEN sizeof(security_id_default)
|
||||
#define IIDXHOOK_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE_LEN \
|
||||
sizeof(security_id_default)
|
||||
|
||||
const struct net_addr iidxhook_eamuse_default_server = {
|
||||
.type = NET_ADDR_TYPE_HOSTNAME,
|
||||
@@ -26,103 +29,140 @@ const struct net_addr iidxhook_eamuse_default_server = {
|
||||
.hostname.port = 80,
|
||||
};
|
||||
|
||||
void iidxhook_util_config_eamuse_init(struct cconfig* config)
|
||||
void iidxhook_util_config_eamuse_init(struct cconfig *config)
|
||||
{
|
||||
cconfig_util_set_str(config,
|
||||
cconfig_util_set_str(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_EAMUSE_CARD_TYPE_KEY,
|
||||
IIDXHOOK_CONFIG_EAMUSE_DEFAULT_CARD_TYPE_VALUE,
|
||||
"Magnetic card type, format XXX, 3 digit string (supports: C02, D01, "
|
||||
"Magnetic card type, format XXX, 3 digit string (supports: C02, "
|
||||
"D01, "
|
||||
"E11, ECO)");
|
||||
|
||||
cconfig_util_set_str(config,
|
||||
cconfig_util_set_str(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_EAMUSE_SERVER_KEY,
|
||||
IIDXHOOK_CONFIG_EAMUSE_DEFAULT_SERVER_VALUE,
|
||||
"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 "
|
||||
"(e.g. 127.0.0.1:80) of the target eamuse server. The port is "
|
||||
"optional "
|
||||
"but defaults to 80.");
|
||||
|
||||
cconfig_util_set_data(config, IIDXHOOK_CONFIG_EAMUSE_PCBID_KEY,
|
||||
(uint8_t*) &IIDXHOOK_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE,
|
||||
IIDXHOOK_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE_LEN, "PCBID");
|
||||
cconfig_util_set_data(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_EAMUSE_PCBID_KEY,
|
||||
(uint8_t *) &IIDXHOOK_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE,
|
||||
IIDXHOOK_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE_LEN,
|
||||
"PCBID");
|
||||
|
||||
cconfig_util_set_data(config, IIDXHOOK_CONFIG_EAMUSE_EAMID_KEY,
|
||||
(uint8_t*) &IIDXHOOK_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE,
|
||||
IIDXHOOK_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE_LEN, "EAMID");
|
||||
cconfig_util_set_data(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_EAMUSE_EAMID_KEY,
|
||||
(uint8_t *) &IIDXHOOK_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE,
|
||||
IIDXHOOK_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE_LEN,
|
||||
"EAMID");
|
||||
}
|
||||
|
||||
void iidxhook_util_config_eamuse_get(
|
||||
struct iidxhook_util_config_eamuse* config_eamuse,
|
||||
struct cconfig* config)
|
||||
struct iidxhook_util_config_eamuse *config_eamuse, struct cconfig *config)
|
||||
{
|
||||
char server_url[1024];
|
||||
char* tmp;
|
||||
char* tmp2;
|
||||
char *tmp;
|
||||
char *tmp2;
|
||||
|
||||
memset(config_eamuse, 0, sizeof(struct iidxhook_util_config_eamuse));
|
||||
|
||||
if (!cconfig_util_get_str(config, IIDXHOOK_CONFIG_EAMUSE_CARD_TYPE_KEY,
|
||||
config_eamuse->card_type, sizeof(config_eamuse->card_type) - 1,
|
||||
if (!cconfig_util_get_str(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_EAMUSE_CARD_TYPE_KEY,
|
||||
config_eamuse->card_type,
|
||||
sizeof(config_eamuse->card_type) - 1,
|
||||
IIDXHOOK_CONFIG_EAMUSE_DEFAULT_CARD_TYPE_VALUE)) {
|
||||
log_warning("Invalid value for key '%s' specified, fallback "
|
||||
"to default '%s'", IIDXHOOK_CONFIG_EAMUSE_CARD_TYPE_KEY,
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%s'",
|
||||
IIDXHOOK_CONFIG_EAMUSE_CARD_TYPE_KEY,
|
||||
IIDXHOOK_CONFIG_EAMUSE_DEFAULT_CARD_TYPE_VALUE);
|
||||
}
|
||||
|
||||
if (!cconfig_util_get_str(config, IIDXHOOK_CONFIG_EAMUSE_SERVER_KEY,
|
||||
server_url, sizeof(server_url),
|
||||
if (!cconfig_util_get_str(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_EAMUSE_SERVER_KEY,
|
||||
server_url,
|
||||
sizeof(server_url),
|
||||
IIDXHOOK_CONFIG_EAMUSE_DEFAULT_SERVER_VALUE)) {
|
||||
log_warning("Invalid value for key '%s' specified, fallback "
|
||||
"to default '%s'", IIDXHOOK_CONFIG_EAMUSE_SERVER_KEY,
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%s'",
|
||||
IIDXHOOK_CONFIG_EAMUSE_SERVER_KEY,
|
||||
IIDXHOOK_CONFIG_EAMUSE_DEFAULT_SERVER_VALUE);
|
||||
}
|
||||
|
||||
if (!net_str_parse(server_url, &config_eamuse->server)) {
|
||||
memcpy(&config_eamuse->server, &iidxhook_eamuse_default_server,
|
||||
memcpy(
|
||||
&config_eamuse->server,
|
||||
&iidxhook_eamuse_default_server,
|
||||
sizeof(config_eamuse->server));
|
||||
tmp = net_addr_to_str(&config_eamuse->server);
|
||||
log_warning("Invalid value for key '%s' specified, fallback "
|
||||
"to default", tmp);
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default",
|
||||
tmp);
|
||||
free(tmp);
|
||||
}
|
||||
|
||||
if (!cconfig_util_get_data(config, IIDXHOOK_CONFIG_EAMUSE_PCBID_KEY,
|
||||
(uint8_t*) &config_eamuse->pcbid,
|
||||
if (!cconfig_util_get_data(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_EAMUSE_PCBID_KEY,
|
||||
(uint8_t *) &config_eamuse->pcbid,
|
||||
IIDXHOOK_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE_LEN,
|
||||
(uint8_t*) &IIDXHOOK_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE)) {
|
||||
tmp = security_id_to_str(&IIDXHOOK_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE,
|
||||
false);
|
||||
log_warning("Invalid value for key '%s' specified, fallback "
|
||||
"to default", tmp);
|
||||
(uint8_t *) &IIDXHOOK_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE)) {
|
||||
tmp = security_id_to_str(
|
||||
&IIDXHOOK_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE, false);
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default",
|
||||
tmp);
|
||||
free(tmp);
|
||||
}
|
||||
|
||||
if (!security_id_verify(&config_eamuse->pcbid)) {
|
||||
tmp = security_id_to_str(&IIDXHOOK_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE,
|
||||
false);
|
||||
tmp = security_id_to_str(
|
||||
&IIDXHOOK_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE, false);
|
||||
tmp2 = security_id_to_str(&config_eamuse->pcbid, false);
|
||||
log_warning("PCBID verification of '%s' failed, fallback to default "
|
||||
"PCBID '%s'", tmp2, tmp);
|
||||
log_warning(
|
||||
"PCBID verification of '%s' failed, fallback to default "
|
||||
"PCBID '%s'",
|
||||
tmp2,
|
||||
tmp);
|
||||
free(tmp);
|
||||
free(tmp2);
|
||||
}
|
||||
|
||||
if (!cconfig_util_get_data(config, IIDXHOOK_CONFIG_EAMUSE_EAMID_KEY,
|
||||
(uint8_t*) &config_eamuse->eamid,
|
||||
|
||||
if (!cconfig_util_get_data(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_EAMUSE_EAMID_KEY,
|
||||
(uint8_t *) &config_eamuse->eamid,
|
||||
IIDXHOOK_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE_LEN,
|
||||
(uint8_t*) &IIDXHOOK_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE)) {
|
||||
tmp = security_id_to_str(&IIDXHOOK_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE,
|
||||
false);
|
||||
log_warning("Invalid value for key '%s' specified, fallback "
|
||||
"to default", tmp);
|
||||
(uint8_t *) &IIDXHOOK_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE)) {
|
||||
tmp = security_id_to_str(
|
||||
&IIDXHOOK_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE, false);
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default",
|
||||
tmp);
|
||||
free(tmp);
|
||||
}
|
||||
|
||||
if (!security_id_verify(&config_eamuse->eamid)) {
|
||||
tmp = security_id_to_str(&IIDXHOOK_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE,
|
||||
false);
|
||||
tmp = security_id_to_str(
|
||||
&IIDXHOOK_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE, false);
|
||||
tmp2 = security_id_to_str(&config_eamuse->eamid, false);
|
||||
log_warning("EAMID verification of '%s' failed, fallback to default "
|
||||
"EAMID '%s'", tmp2, tmp);
|
||||
log_warning(
|
||||
"EAMID verification of '%s' failed, fallback to default "
|
||||
"EAMID '%s'",
|
||||
tmp2,
|
||||
tmp);
|
||||
free(tmp);
|
||||
free(tmp2);
|
||||
}
|
||||
|
||||
@@ -14,10 +14,9 @@ struct iidxhook_util_config_eamuse {
|
||||
struct security_id eamid;
|
||||
};
|
||||
|
||||
void iidxhook_util_config_eamuse_init(struct cconfig* config);
|
||||
void iidxhook_util_config_eamuse_init(struct cconfig *config);
|
||||
|
||||
void iidxhook_util_config_eamuse_get(
|
||||
struct iidxhook_util_config_eamuse* config_eamuse,
|
||||
struct cconfig* config);
|
||||
struct iidxhook_util_config_eamuse *config_eamuse, struct cconfig *config);
|
||||
|
||||
#endif
|
||||
@@ -14,9 +14,12 @@
|
||||
#define IIDXHOOK_CONFIG_GFX_WINDOWED_KEY "gfx.windowed"
|
||||
#define IIDXHOOK_CONFIG_GFX_WINDOW_WIDTH_KEY "gfx.window_width"
|
||||
#define IIDXHOOK_CONFIG_GFX_WINDOW_HEIGHT_KEY "gfx.window_height"
|
||||
#define IIDXHOOK_CONFIG_GFX_SCALE_BACK_BUFFER_WIDTH_KEY "gfx.scale_back_buffer_width"
|
||||
#define IIDXHOOK_CONFIG_GFX_SCALE_BACK_BUFFER_HEIGHT_KEY "gfx.scale_back_buffer_height"
|
||||
#define IIDXHOOK_CONFIG_GFX_SCALE_BACK_BUFFER_FILTER_KEY "gfx.scale_back_buffer_filter"
|
||||
#define IIDXHOOK_CONFIG_GFX_SCALE_BACK_BUFFER_WIDTH_KEY \
|
||||
"gfx.scale_back_buffer_width"
|
||||
#define IIDXHOOK_CONFIG_GFX_SCALE_BACK_BUFFER_HEIGHT_KEY \
|
||||
"gfx.scale_back_buffer_height"
|
||||
#define IIDXHOOK_CONFIG_GFX_SCALE_BACK_BUFFER_FILTER_KEY \
|
||||
"gfx.scale_back_buffer_filter"
|
||||
|
||||
#define IIDXHOOK_CONFIG_GFX_DEFAULT_BGVIDEO_UV_FIX_VALUE false
|
||||
#define IIDXHOOK_CONFIG_GFX_DEFAULT_FRAMED_VALUE false
|
||||
@@ -30,36 +33,48 @@
|
||||
#define IIDXHOOK_CONFIG_GFX_DEFAULT_SCALE_BACK_BUFFER_HEIGHT_VALUE 0
|
||||
#define IIDXHOOK_CONFIG_GFX_DEFAULT_SCALE_BACK_BUFFER_FILTER_VALUE "none"
|
||||
|
||||
void iidxhook_config_gfx_init(struct cconfig* config)
|
||||
void iidxhook_config_gfx_init(struct cconfig *config)
|
||||
{
|
||||
cconfig_util_set_bool(config,
|
||||
IIDXHOOK_CONFIG_GFX_BGVIDEO_UV_FIX_KEY,
|
||||
cconfig_util_set_bool(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_GFX_BGVIDEO_UV_FIX_KEY,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_BGVIDEO_UV_FIX_VALUE,
|
||||
"Fix stretched BG videos on newer GPUs. Might appear on Red and newer");
|
||||
"Fix stretched BG videos on newer GPUs. Might appear on Red and "
|
||||
"newer");
|
||||
|
||||
cconfig_util_set_bool(config,
|
||||
cconfig_util_set_bool(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_GFX_FRAMED_KEY,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_FRAMED_VALUE,
|
||||
"Run the game in a framed window (requires windowed option)");
|
||||
|
||||
cconfig_util_set_float(config,
|
||||
cconfig_util_set_float(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_GFX_FRAME_RATE_LIMIT_KEY,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_FRAME_RATE_LIMIT_VALUE,
|
||||
"Software limit the frame rate of the rendering loop in hz, e.g. 60 or 59.95 (0.0 = no software limit)");
|
||||
"Software limit the frame rate of the rendering loop in hz, e.g. "
|
||||
"60 or 59.95 (0.0 = no software limit)");
|
||||
|
||||
cconfig_util_set_float(config,
|
||||
cconfig_util_set_float(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_GFX_MONITOR_CHECK_KEY,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_MONITOR_CHECK_VALUE,
|
||||
"Enable/disable software monitor check/auto timebase or set "
|
||||
"a pre-determined refresh value. -1 disables this feature. 0 enables "
|
||||
"a pre-determined refresh value. -1 disables this feature. 0 "
|
||||
"enables "
|
||||
"auto detecting the current refresh rate on startup. Setting any "
|
||||
"positive value > 0 allows you to set a pre-determined refresh rate "
|
||||
"(e.g. retrieved from the monitor check on newer IIDX games). Either "
|
||||
"the auto detected value or pre-determined value is used to patch any "
|
||||
"chart files in-memory to fix song synchronization issues. Requires "
|
||||
"positive value > 0 allows you to set a pre-determined refresh "
|
||||
"rate "
|
||||
"(e.g. retrieved from the monitor check on newer IIDX games). "
|
||||
"Either "
|
||||
"the auto detected value or pre-determined value is used to patch "
|
||||
"any "
|
||||
"chart files in-memory to fix song synchronization issues. "
|
||||
"Requires "
|
||||
"constant refresh rate!!!");
|
||||
|
||||
cconfig_util_set_str(config,
|
||||
cconfig_util_set_str(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_GFX_PCI_ID_KEY,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_PCI_ID_VALUE,
|
||||
"Patch the GPU device ID detection (leave empty to"
|
||||
@@ -67,96 +82,141 @@ void iidxhook_config_gfx_init(struct cconfig* config)
|
||||
" Examples: 1002:7146 (RV515, Radeon X1300), 1002:95C5 (RV620 LE,"
|
||||
" Radeon HD3450)");
|
||||
|
||||
cconfig_util_set_bool(config,
|
||||
cconfig_util_set_bool(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_GFX_WINDOWED_KEY,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_WINDOWED_VALUE,
|
||||
"Run the game windowed");
|
||||
|
||||
cconfig_util_set_int(config,
|
||||
cconfig_util_set_int(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_GFX_WINDOW_WIDTH_KEY,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_WINDOW_WIDTH_VALUE,
|
||||
"Windowed width, -1 for default size");
|
||||
|
||||
cconfig_util_set_int(config,
|
||||
cconfig_util_set_int(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_GFX_WINDOW_HEIGHT_KEY,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_WINDOW_HEIGHT_VALUE,
|
||||
"Windowed height, -1 for default size");
|
||||
|
||||
cconfig_util_set_int(config,
|
||||
cconfig_util_set_int(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_GFX_SCALE_BACK_BUFFER_WIDTH_KEY,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_SCALE_BACK_BUFFER_WIDTH_VALUE,
|
||||
"Up-/downscale the back buffer's width. This does not change the game's rendering resolution but scales the "
|
||||
"final frame. Use this to target the native resolution of your monitor/TV, e.g. to avoid over-/underscan, bad "
|
||||
"image quality or latency caused by the monitors internal upscaler. 0 to disable this feature. Must be set in "
|
||||
"Up-/downscale the back buffer's width. This does not change the "
|
||||
"game's rendering resolution but scales "
|
||||
"the "
|
||||
"final frame. Use this to target the native resolution of your "
|
||||
"monitor/TV, e.g. to avoid over-/underscan, "
|
||||
"bad "
|
||||
"image quality or latency caused by the monitors internal "
|
||||
"upscaler. 0 to disable this feature. Must be set "
|
||||
"in "
|
||||
"combination with the corresponding height parameter.");
|
||||
|
||||
cconfig_util_set_int(config,
|
||||
cconfig_util_set_int(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_GFX_SCALE_BACK_BUFFER_HEIGHT_KEY,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_SCALE_BACK_BUFFER_HEIGHT_VALUE,
|
||||
"Up-/downscale the back buffer's height. This does not change the game's rendering resolution but scales the "
|
||||
"final frame. Use this to target the native resolution of your monitor/TV, e.g. to avoid over-/underscan, bad "
|
||||
"image quality or latency caused by the monitors internal upscaler. 0 to disable this feature. Must be set in "
|
||||
"Up-/downscale the back buffer's height. This does not change the "
|
||||
"game's rendering resolution but scales "
|
||||
"the "
|
||||
"final frame. Use this to target the native resolution of your "
|
||||
"monitor/TV, e.g. to avoid over-/underscan, "
|
||||
"bad "
|
||||
"image quality or latency caused by the monitors internal "
|
||||
"upscaler. 0 to disable this feature. Must be set "
|
||||
"in "
|
||||
"combination with the corresponding width parameter.");
|
||||
|
||||
cconfig_util_set_str(config,
|
||||
cconfig_util_set_str(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_GFX_SCALE_BACK_BUFFER_FILTER_KEY,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_SCALE_BACK_BUFFER_FILTER_VALUE,
|
||||
"Filter type to use for up-/downscaling the back buffer. Only used if scaling feature was enabled by setting "
|
||||
"the scaling width and height parameters. Available types: none, linear, point (refer to D3DTEXTUREFILTERTYPE "
|
||||
"Filter type to use for up-/downscaling the back buffer. Only used "
|
||||
"if scaling feature was enabled by "
|
||||
"setting "
|
||||
"the scaling width and height parameters. Available types: none, "
|
||||
"linear, point (refer to "
|
||||
"D3DTEXTUREFILTERTYPE "
|
||||
" for explanation).");
|
||||
}
|
||||
|
||||
void iidxhook_config_gfx_get(struct iidxhook_config_gfx* config_gfx,
|
||||
struct cconfig* config)
|
||||
void iidxhook_config_gfx_get(
|
||||
struct iidxhook_config_gfx *config_gfx, struct cconfig *config)
|
||||
{
|
||||
char tmp[10];
|
||||
char* vid;
|
||||
char* pid;
|
||||
char *vid;
|
||||
char *pid;
|
||||
int32_t tmp_int;
|
||||
|
||||
if (!cconfig_util_get_bool(config, IIDXHOOK_CONFIG_GFX_BGVIDEO_UV_FIX_KEY,
|
||||
if (!cconfig_util_get_bool(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_GFX_BGVIDEO_UV_FIX_KEY,
|
||||
&config_gfx->bgvideo_uv_fix,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_BGVIDEO_UV_FIX_VALUE)) {
|
||||
log_warning("Invalid value for key '%s' specified, fallback "
|
||||
"to default '%d'", IIDXHOOK_CONFIG_GFX_BGVIDEO_UV_FIX_KEY,
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%d'",
|
||||
IIDXHOOK_CONFIG_GFX_BGVIDEO_UV_FIX_KEY,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_BGVIDEO_UV_FIX_VALUE);
|
||||
}
|
||||
|
||||
if (!cconfig_util_get_bool(config, IIDXHOOK_CONFIG_GFX_FRAMED_KEY,
|
||||
if (!cconfig_util_get_bool(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_GFX_FRAMED_KEY,
|
||||
&config_gfx->framed,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_FRAMED_VALUE)) {
|
||||
log_warning("Invalid value for key '%s' specified, fallback "
|
||||
"to default '%d'", IIDXHOOK_CONFIG_GFX_FRAMED_KEY,
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%d'",
|
||||
IIDXHOOK_CONFIG_GFX_FRAMED_KEY,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_FRAMED_VALUE);
|
||||
}
|
||||
|
||||
if (!cconfig_util_get_float(config, IIDXHOOK_CONFIG_GFX_FRAME_RATE_LIMIT_KEY,
|
||||
if (!cconfig_util_get_float(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_GFX_FRAME_RATE_LIMIT_KEY,
|
||||
&config_gfx->frame_rate_limit,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_FRAME_RATE_LIMIT_VALUE)) {
|
||||
log_warning("Invalid value for key '%s' specified, fallback "
|
||||
"to default '%f'", IIDXHOOK_CONFIG_GFX_FRAME_RATE_LIMIT_KEY,
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%f'",
|
||||
IIDXHOOK_CONFIG_GFX_FRAME_RATE_LIMIT_KEY,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_FRAME_RATE_LIMIT_VALUE);
|
||||
}
|
||||
|
||||
if (!cconfig_util_get_float(config, IIDXHOOK_CONFIG_GFX_MONITOR_CHECK_KEY,
|
||||
if (!cconfig_util_get_float(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_GFX_MONITOR_CHECK_KEY,
|
||||
&config_gfx->monitor_check,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_MONITOR_CHECK_VALUE)) {
|
||||
log_warning("Invalid value for key '%s' specified, fallback "
|
||||
"to default '%f'", IIDXHOOK_CONFIG_GFX_MONITOR_CHECK_KEY,
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%f'",
|
||||
IIDXHOOK_CONFIG_GFX_MONITOR_CHECK_KEY,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_MONITOR_CHECK_VALUE);
|
||||
}
|
||||
|
||||
if (!cconfig_util_get_str(config, IIDXHOOK_CONFIG_GFX_PCI_ID_KEY,
|
||||
tmp, sizeof(tmp) - 1,
|
||||
if (!cconfig_util_get_str(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_GFX_PCI_ID_KEY,
|
||||
tmp,
|
||||
sizeof(tmp) - 1,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_PCI_ID_VALUE)) {
|
||||
log_warning("Invalid value for key '%s' specified, fallback "
|
||||
"to default '%s'", IIDXHOOK_CONFIG_GFX_PCI_ID_KEY,
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%s'",
|
||||
IIDXHOOK_CONFIG_GFX_PCI_ID_KEY,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_PCI_ID_VALUE);
|
||||
}
|
||||
|
||||
if (tmp[4] != ':') {
|
||||
log_warning("Invalid format for value for key '%s' specified, fallback "
|
||||
"to default '%s'", IIDXHOOK_CONFIG_GFX_PCI_ID_KEY,
|
||||
log_warning(
|
||||
"Invalid format for value for key '%s' specified, fallback "
|
||||
"to default '%s'",
|
||||
IIDXHOOK_CONFIG_GFX_PCI_ID_KEY,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_PCI_ID_VALUE);
|
||||
strcpy(tmp, IIDXHOOK_CONFIG_GFX_DEFAULT_PCI_ID_VALUE);
|
||||
}
|
||||
@@ -167,69 +227,102 @@ void iidxhook_config_gfx_get(struct iidxhook_config_gfx* config_gfx,
|
||||
config_gfx->pci_id_vid = strtol(vid, NULL, 16);
|
||||
config_gfx->pci_id_pid = strtol(pid, NULL, 16);
|
||||
|
||||
if (!cconfig_util_get_bool(config, IIDXHOOK_CONFIG_GFX_WINDOWED_KEY,
|
||||
if (!cconfig_util_get_bool(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_GFX_WINDOWED_KEY,
|
||||
&config_gfx->windowed,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_WINDOWED_VALUE)) {
|
||||
log_warning("Invalid value for key '%s' specified, fallback "
|
||||
"to default '%d'", IIDXHOOK_CONFIG_GFX_WINDOWED_KEY,
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%d'",
|
||||
IIDXHOOK_CONFIG_GFX_WINDOWED_KEY,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_WINDOWED_VALUE);
|
||||
}
|
||||
|
||||
if (!cconfig_util_get_int(config, IIDXHOOK_CONFIG_GFX_WINDOW_WIDTH_KEY,
|
||||
&config_gfx->window_width, IIDXHOOK_CONFIG_GFX_DEFAULT_WINDOW_WIDTH_VALUE)) {
|
||||
log_warning("Invalid value for key '%s' specified, fallback "
|
||||
"to default '%d'", IIDXHOOK_CONFIG_GFX_WINDOW_WIDTH_KEY,
|
||||
if (!cconfig_util_get_int(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_GFX_WINDOW_WIDTH_KEY,
|
||||
&config_gfx->window_width,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_WINDOW_WIDTH_VALUE)) {
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%d'",
|
||||
IIDXHOOK_CONFIG_GFX_WINDOW_WIDTH_KEY,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_WINDOW_WIDTH_VALUE);
|
||||
}
|
||||
|
||||
if (!cconfig_util_get_int(config, IIDXHOOK_CONFIG_GFX_WINDOW_HEIGHT_KEY,
|
||||
&config_gfx->window_height, IIDXHOOK_CONFIG_GFX_DEFAULT_WINDOW_HEIGHT_VALUE)) {
|
||||
log_warning("Invalid value for key '%s' specified, fallback "
|
||||
"to default '%d'", IIDXHOOK_CONFIG_GFX_WINDOW_HEIGHT_KEY,
|
||||
if (!cconfig_util_get_int(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_GFX_WINDOW_HEIGHT_KEY,
|
||||
&config_gfx->window_height,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_WINDOW_HEIGHT_VALUE)) {
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%d'",
|
||||
IIDXHOOK_CONFIG_GFX_WINDOW_HEIGHT_KEY,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_WINDOW_HEIGHT_VALUE);
|
||||
}
|
||||
|
||||
if (!cconfig_util_get_int(config, IIDXHOOK_CONFIG_GFX_SCALE_BACK_BUFFER_WIDTH_KEY,
|
||||
if (!cconfig_util_get_int(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_GFX_SCALE_BACK_BUFFER_WIDTH_KEY,
|
||||
&tmp_int,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_SCALE_BACK_BUFFER_WIDTH_VALUE) ||
|
||||
tmp_int < 0 || tmp_int > 0xFFFF) {
|
||||
log_warning("Invalid value for key '%s' specified, fallback "
|
||||
"to default '%d'", IIDXHOOK_CONFIG_GFX_SCALE_BACK_BUFFER_WIDTH_KEY,
|
||||
tmp_int < 0 || tmp_int > 0xFFFF) {
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%d'",
|
||||
IIDXHOOK_CONFIG_GFX_SCALE_BACK_BUFFER_WIDTH_KEY,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_SCALE_BACK_BUFFER_WIDTH_VALUE);
|
||||
}
|
||||
|
||||
config_gfx->scale_back_buffer_width = (uint16_t) tmp_int;
|
||||
|
||||
if (!cconfig_util_get_int(config, IIDXHOOK_CONFIG_GFX_SCALE_BACK_BUFFER_HEIGHT_KEY,
|
||||
if (!cconfig_util_get_int(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_GFX_SCALE_BACK_BUFFER_HEIGHT_KEY,
|
||||
&tmp_int,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_SCALE_BACK_BUFFER_HEIGHT_VALUE) ||
|
||||
tmp_int < 0 || tmp_int > 0xFFFF) {
|
||||
log_warning("Invalid value for key '%s' specified, fallback "
|
||||
"to default '%d'", IIDXHOOK_CONFIG_GFX_SCALE_BACK_BUFFER_HEIGHT_KEY,
|
||||
tmp_int < 0 || tmp_int > 0xFFFF) {
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%d'",
|
||||
IIDXHOOK_CONFIG_GFX_SCALE_BACK_BUFFER_HEIGHT_KEY,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_SCALE_BACK_BUFFER_HEIGHT_VALUE);
|
||||
}
|
||||
|
||||
config_gfx->scale_back_buffer_height = (uint16_t) tmp_int;
|
||||
|
||||
if (!cconfig_util_get_str(config, IIDXHOOK_CONFIG_GFX_SCALE_BACK_BUFFER_FILTER_KEY,
|
||||
tmp, sizeof(tmp) - 1,
|
||||
if (!cconfig_util_get_str(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_GFX_SCALE_BACK_BUFFER_FILTER_KEY,
|
||||
tmp,
|
||||
sizeof(tmp) - 1,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_SCALE_BACK_BUFFER_FILTER_VALUE)) {
|
||||
log_warning("Invalid value for key '%s' specified, fallback "
|
||||
"to default '%s'", IIDXHOOK_CONFIG_GFX_SCALE_BACK_BUFFER_FILTER_KEY,
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%s'",
|
||||
IIDXHOOK_CONFIG_GFX_SCALE_BACK_BUFFER_FILTER_KEY,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_SCALE_BACK_BUFFER_FILTER_VALUE);
|
||||
}
|
||||
|
||||
if (!strcmp(tmp, "none")) {
|
||||
config_gfx->scale_back_buffer_filter = IIDXHOOK_UTIL_D3D9_BACK_BUFFER_SCALE_FILTER_NONE;
|
||||
config_gfx->scale_back_buffer_filter =
|
||||
IIDXHOOK_UTIL_D3D9_BACK_BUFFER_SCALE_FILTER_NONE;
|
||||
} else if (!strcmp(tmp, "linear")) {
|
||||
config_gfx->scale_back_buffer_filter = IIDXHOOK_UTIL_D3D9_BACK_BUFFER_SCALE_FILTER_LINEAR;
|
||||
config_gfx->scale_back_buffer_filter =
|
||||
IIDXHOOK_UTIL_D3D9_BACK_BUFFER_SCALE_FILTER_LINEAR;
|
||||
} else if (!strcmp(tmp, "point")) {
|
||||
config_gfx->scale_back_buffer_filter = IIDXHOOK_UTIL_D3D9_BACK_BUFFER_SCALE_FILTER_POINT;
|
||||
config_gfx->scale_back_buffer_filter =
|
||||
IIDXHOOK_UTIL_D3D9_BACK_BUFFER_SCALE_FILTER_POINT;
|
||||
} else {
|
||||
config_gfx->scale_back_buffer_filter = IIDXHOOK_UTIL_D3D9_BACK_BUFFER_SCALE_FILTER_NONE;
|
||||
config_gfx->scale_back_buffer_filter =
|
||||
IIDXHOOK_UTIL_D3D9_BACK_BUFFER_SCALE_FILTER_NONE;
|
||||
|
||||
log_warning("Invalid value for key '%s' specified, fallback "
|
||||
"to default '%s'", IIDXHOOK_CONFIG_GFX_SCALE_BACK_BUFFER_FILTER_KEY,
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%s'",
|
||||
IIDXHOOK_CONFIG_GFX_SCALE_BACK_BUFFER_FILTER_KEY,
|
||||
IIDXHOOK_CONFIG_GFX_DEFAULT_SCALE_BACK_BUFFER_FILTER_VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,9 +20,9 @@ struct iidxhook_config_gfx {
|
||||
enum iidxhook_util_d3d9_back_buffer_scale_filter scale_back_buffer_filter;
|
||||
};
|
||||
|
||||
void iidxhook_config_gfx_init(struct cconfig* config);
|
||||
void iidxhook_config_gfx_init(struct cconfig *config);
|
||||
|
||||
void iidxhook_config_gfx_get(struct iidxhook_config_gfx* config_gfx,
|
||||
struct cconfig* config);
|
||||
void iidxhook_config_gfx_get(
|
||||
struct iidxhook_config_gfx *config_gfx, struct cconfig *config);
|
||||
|
||||
#endif
|
||||
@@ -10,36 +10,45 @@
|
||||
#define IIDXHOOK_CONFIG_MISC_DEFAULT_DISABLE_CLOCK_SET_VALUE false
|
||||
#define IIDXHOOK_CONFIG_MISC_DEFAULT_RTEFFECT_STUB_VALUE false
|
||||
|
||||
void iidxhook_config_misc_init(struct cconfig* config)
|
||||
void iidxhook_config_misc_init(struct cconfig *config)
|
||||
{
|
||||
cconfig_util_set_bool(config,
|
||||
IIDXHOOK_CONFIG_MISC_DISABLE_CLOCK_SET_KEY,
|
||||
cconfig_util_set_bool(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_MISC_DISABLE_CLOCK_SET_KEY,
|
||||
IIDXHOOK_CONFIG_MISC_DEFAULT_DISABLE_CLOCK_SET_VALUE,
|
||||
"Disable operator clock setting system clock time");
|
||||
|
||||
cconfig_util_set_bool(config,
|
||||
IIDXHOOK_CONFIG_MISC_RTEFFECT_STUB_KEY,
|
||||
cconfig_util_set_bool(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_MISC_RTEFFECT_STUB_KEY,
|
||||
IIDXHOOK_CONFIG_MISC_DEFAULT_RTEFFECT_STUB_VALUE,
|
||||
"Stub calls to rteffect.dll (10th to DistorteD)");
|
||||
}
|
||||
|
||||
void iidxhook_config_misc_get(struct iidxhook_config_misc* config_misc,
|
||||
struct cconfig* config)
|
||||
void iidxhook_config_misc_get(
|
||||
struct iidxhook_config_misc *config_misc, struct cconfig *config)
|
||||
{
|
||||
if (!cconfig_util_get_bool(config,
|
||||
if (!cconfig_util_get_bool(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_MISC_DISABLE_CLOCK_SET_KEY,
|
||||
&config_misc->disable_clock_set,
|
||||
IIDXHOOK_CONFIG_MISC_DEFAULT_DISABLE_CLOCK_SET_VALUE)) {
|
||||
log_warning("Invalid value for key '%s' specified, fallback "
|
||||
"to default '%d'", IIDXHOOK_CONFIG_MISC_DISABLE_CLOCK_SET_KEY,
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%d'",
|
||||
IIDXHOOK_CONFIG_MISC_DISABLE_CLOCK_SET_KEY,
|
||||
IIDXHOOK_CONFIG_MISC_DEFAULT_DISABLE_CLOCK_SET_VALUE);
|
||||
}
|
||||
|
||||
if (!cconfig_util_get_bool(config, IIDXHOOK_CONFIG_MISC_RTEFFECT_STUB_KEY,
|
||||
if (!cconfig_util_get_bool(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_MISC_RTEFFECT_STUB_KEY,
|
||||
&config_misc->rteffect_stub,
|
||||
IIDXHOOK_CONFIG_MISC_DEFAULT_RTEFFECT_STUB_VALUE)) {
|
||||
log_warning("Invalid value for key '%s' specified, fallback "
|
||||
"to default '%d'", IIDXHOOK_CONFIG_MISC_RTEFFECT_STUB_KEY,
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%d'",
|
||||
IIDXHOOK_CONFIG_MISC_RTEFFECT_STUB_KEY,
|
||||
IIDXHOOK_CONFIG_MISC_DEFAULT_RTEFFECT_STUB_VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@ struct iidxhook_config_misc {
|
||||
bool rteffect_stub;
|
||||
};
|
||||
|
||||
void iidxhook_config_misc_init(struct cconfig* config);
|
||||
void iidxhook_config_misc_init(struct cconfig *config);
|
||||
|
||||
void iidxhook_config_misc_get(struct iidxhook_config_misc* config_misc,
|
||||
struct cconfig* config);
|
||||
void iidxhook_config_misc_get(
|
||||
struct iidxhook_config_misc *config_misc, struct cconfig *config);
|
||||
|
||||
#endif
|
||||
@@ -16,9 +16,12 @@
|
||||
#define IIDXHOOK_CONFIG_SEC_BLACK_PLUG_MCODE_KEY "sec.black_plug_mcode"
|
||||
|
||||
/* Use C02 defaults */
|
||||
#define IIDXHOOK_CONFIG_SEC_DEFAULT_BOOT_VERSION_VALUE iidxhook_security_default_boot_version
|
||||
#define IIDXHOOK_CONFIG_SEC_DEFAULT_BOOT_SEEDS_VALUE iidxhook_security_default_boot_seeds
|
||||
#define IIDXHOOK_CONFIG_SEC_DEFAULT_BLACK_PLUG_MCODE_VALUE iidxhook_security_default_black_plug_mcode
|
||||
#define IIDXHOOK_CONFIG_SEC_DEFAULT_BOOT_VERSION_VALUE \
|
||||
iidxhook_security_default_boot_version
|
||||
#define IIDXHOOK_CONFIG_SEC_DEFAULT_BOOT_SEEDS_VALUE \
|
||||
iidxhook_security_default_boot_seeds
|
||||
#define IIDXHOOK_CONFIG_SEC_DEFAULT_BLACK_PLUG_MCODE_VALUE \
|
||||
iidxhook_security_default_black_plug_mcode
|
||||
|
||||
/* IIDX 09 default */
|
||||
static const struct security_mcode iidxhook_security_default_boot_version = {
|
||||
@@ -34,18 +37,19 @@ static const struct security_mcode iidxhook_security_default_boot_version = {
|
||||
static const uint32_t iidxhook_security_default_boot_seeds[3] = {0, 0, 0};
|
||||
|
||||
/* IIDX 09 default */
|
||||
static const struct security_mcode iidxhook_security_default_black_plug_mcode = {
|
||||
.header = SECURITY_MCODE_HEADER,
|
||||
.unkn = SECURITY_MCODE_UNKN_Q,
|
||||
.game = SECURITY_MCODE_GAME_IIDX_9,
|
||||
.region = SECURITY_MCODE_REGION_JAPAN,
|
||||
.cabinet = SECURITY_MCODE_CABINET_A,
|
||||
.revision = SECURITY_MCODE_REVISION_A,
|
||||
static const struct security_mcode iidxhook_security_default_black_plug_mcode =
|
||||
{
|
||||
.header = SECURITY_MCODE_HEADER,
|
||||
.unkn = SECURITY_MCODE_UNKN_Q,
|
||||
.game = SECURITY_MCODE_GAME_IIDX_9,
|
||||
.region = SECURITY_MCODE_REGION_JAPAN,
|
||||
.cabinet = SECURITY_MCODE_CABINET_A,
|
||||
.revision = SECURITY_MCODE_REVISION_A,
|
||||
};
|
||||
|
||||
static char* iidxhook_config_boot_seeds_to_str(const uint32_t* seeds)
|
||||
static char *iidxhook_config_boot_seeds_to_str(const uint32_t *seeds)
|
||||
{
|
||||
char* res;
|
||||
char *res;
|
||||
size_t len;
|
||||
|
||||
len = snprintf(NULL, 0, "%d:%d:%d", seeds[0], seeds[1], seeds[2]);
|
||||
@@ -55,7 +59,7 @@ static char* iidxhook_config_boot_seeds_to_str(const uint32_t* seeds)
|
||||
return res;
|
||||
}
|
||||
|
||||
static bool iidxhook_config_boot_seeds_parse(const char* str, uint32_t* seeds)
|
||||
static bool iidxhook_config_boot_seeds_parse(const char *str, uint32_t *seeds)
|
||||
{
|
||||
if (strlen(str) < 5) {
|
||||
return false;
|
||||
@@ -71,25 +75,30 @@ static bool iidxhook_config_boot_seeds_parse(const char* str, uint32_t* seeds)
|
||||
}
|
||||
}
|
||||
|
||||
void iidxhook_config_sec_init(struct cconfig* config)
|
||||
void iidxhook_config_sec_init(struct cconfig *config)
|
||||
{
|
||||
char* tmp;
|
||||
char *tmp;
|
||||
|
||||
tmp = security_mcode_to_str(
|
||||
&IIDXHOOK_CONFIG_SEC_DEFAULT_BOOT_VERSION_VALUE);
|
||||
tmp =
|
||||
security_mcode_to_str(&IIDXHOOK_CONFIG_SEC_DEFAULT_BOOT_VERSION_VALUE);
|
||||
|
||||
cconfig_util_set_str(config,
|
||||
IIDXHOOK_CONFIG_SEC_BOOT_VERSION_KEY, tmp,
|
||||
cconfig_util_set_str(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_SEC_BOOT_VERSION_KEY,
|
||||
tmp,
|
||||
"Security boot version (e.g. GEC02).");
|
||||
|
||||
free(tmp);
|
||||
|
||||
|
||||
tmp = iidxhook_config_boot_seeds_to_str(
|
||||
IIDXHOOK_CONFIG_SEC_DEFAULT_BOOT_SEEDS_VALUE);
|
||||
|
||||
cconfig_util_set_str(config,
|
||||
IIDXHOOK_CONFIG_SEC_BOOT_SEEDS_KEY, tmp,
|
||||
"Security boot seeds for ezusb, format: X:X:X where X is a number of "
|
||||
cconfig_util_set_str(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_SEC_BOOT_SEEDS_KEY,
|
||||
tmp,
|
||||
"Security boot seeds for ezusb, format: X:X:X where X is a number "
|
||||
"of "
|
||||
"0-9 (e.g. 0:0:0).");
|
||||
|
||||
free(tmp);
|
||||
@@ -97,33 +106,46 @@ void iidxhook_config_sec_init(struct cconfig* config)
|
||||
tmp = security_mcode_to_str(
|
||||
&IIDXHOOK_CONFIG_SEC_DEFAULT_BLACK_PLUG_MCODE_VALUE);
|
||||
|
||||
cconfig_util_set_str(config,
|
||||
IIDXHOOK_CONFIG_SEC_BLACK_PLUG_MCODE_KEY, tmp,
|
||||
cconfig_util_set_str(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_SEC_BLACK_PLUG_MCODE_KEY,
|
||||
tmp,
|
||||
"Security black plug mcode id string (e.g. GQC02JAA).");
|
||||
|
||||
free(tmp);
|
||||
}
|
||||
|
||||
void iidxhook_config_sec_get(struct iidxhook_config_sec* config_sec,
|
||||
struct cconfig* config)
|
||||
void iidxhook_config_sec_get(
|
||||
struct iidxhook_config_sec *config_sec, struct cconfig *config)
|
||||
{
|
||||
char tmp_seeds[6];
|
||||
char tmp_mcode[sizeof(struct security_mcode) + 1];
|
||||
char* tmp_str;
|
||||
char *tmp_str;
|
||||
|
||||
tmp_str = security_mcode_to_str(
|
||||
&IIDXHOOK_CONFIG_SEC_DEFAULT_BOOT_VERSION_VALUE);
|
||||
tmp_str =
|
||||
security_mcode_to_str(&IIDXHOOK_CONFIG_SEC_DEFAULT_BOOT_VERSION_VALUE);
|
||||
|
||||
if (!cconfig_util_get_str(config, IIDXHOOK_CONFIG_SEC_BOOT_VERSION_KEY,
|
||||
tmp_mcode, sizeof(tmp_mcode) - 1, tmp_str)) {
|
||||
log_warning("Invalid value for key '%s' specified, fallback "
|
||||
"to default '%s'", IIDXHOOK_CONFIG_SEC_BOOT_VERSION_KEY, tmp_str);
|
||||
if (!cconfig_util_get_str(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_SEC_BOOT_VERSION_KEY,
|
||||
tmp_mcode,
|
||||
sizeof(tmp_mcode) - 1,
|
||||
tmp_str)) {
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%s'",
|
||||
IIDXHOOK_CONFIG_SEC_BOOT_VERSION_KEY,
|
||||
tmp_str);
|
||||
}
|
||||
|
||||
if (!security_mcode_parse(tmp_mcode, &config_sec->boot_version)) {
|
||||
log_warning("Invalid format for value of key '%s' specified, fallback "
|
||||
"to default '%s'", IIDXHOOK_CONFIG_SEC_BOOT_VERSION_KEY, tmp_str);
|
||||
memcpy(&config_sec->boot_version,
|
||||
log_warning(
|
||||
"Invalid format for value of key '%s' specified, fallback "
|
||||
"to default '%s'",
|
||||
IIDXHOOK_CONFIG_SEC_BOOT_VERSION_KEY,
|
||||
tmp_str);
|
||||
memcpy(
|
||||
&config_sec->boot_version,
|
||||
&IIDXHOOK_CONFIG_SEC_DEFAULT_BOOT_VERSION_VALUE,
|
||||
sizeof(IIDXHOOK_CONFIG_SEC_DEFAULT_BOOT_VERSION_VALUE));
|
||||
}
|
||||
@@ -133,16 +155,27 @@ void iidxhook_config_sec_get(struct iidxhook_config_sec* config_sec,
|
||||
tmp_str = iidxhook_config_boot_seeds_to_str(
|
||||
IIDXHOOK_CONFIG_SEC_DEFAULT_BOOT_SEEDS_VALUE);
|
||||
|
||||
if (!cconfig_util_get_str(config, IIDXHOOK_CONFIG_SEC_BOOT_SEEDS_KEY,
|
||||
tmp_seeds, sizeof(tmp_seeds) - 1, tmp_str)) {
|
||||
log_warning("Invalid value for key '%s' specified, fallback "
|
||||
"to default '%s'", IIDXHOOK_CONFIG_SEC_BOOT_SEEDS_KEY, tmp_str);
|
||||
if (!cconfig_util_get_str(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_SEC_BOOT_SEEDS_KEY,
|
||||
tmp_seeds,
|
||||
sizeof(tmp_seeds) - 1,
|
||||
tmp_str)) {
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%s'",
|
||||
IIDXHOOK_CONFIG_SEC_BOOT_SEEDS_KEY,
|
||||
tmp_str);
|
||||
}
|
||||
|
||||
if (!iidxhook_config_boot_seeds_parse(tmp_seeds, config_sec->boot_seeds)) {
|
||||
log_warning("Invalid format for value of key '%s' specified, fallback "
|
||||
"to default '%s'", IIDXHOOK_CONFIG_SEC_BOOT_SEEDS_KEY, tmp_str);
|
||||
memcpy(config_sec->boot_seeds,
|
||||
log_warning(
|
||||
"Invalid format for value of key '%s' specified, fallback "
|
||||
"to default '%s'",
|
||||
IIDXHOOK_CONFIG_SEC_BOOT_SEEDS_KEY,
|
||||
tmp_str);
|
||||
memcpy(
|
||||
config_sec->boot_seeds,
|
||||
IIDXHOOK_CONFIG_SEC_DEFAULT_BOOT_SEEDS_VALUE,
|
||||
sizeof(IIDXHOOK_CONFIG_SEC_DEFAULT_BOOT_SEEDS_VALUE));
|
||||
}
|
||||
@@ -152,18 +185,27 @@ void iidxhook_config_sec_get(struct iidxhook_config_sec* config_sec,
|
||||
tmp_str = security_mcode_to_str(
|
||||
&IIDXHOOK_CONFIG_SEC_DEFAULT_BLACK_PLUG_MCODE_VALUE);
|
||||
|
||||
if (!cconfig_util_get_str(config, IIDXHOOK_CONFIG_SEC_BLACK_PLUG_MCODE_KEY,
|
||||
tmp_mcode, sizeof(tmp_mcode) - 1, tmp_str)) {
|
||||
log_warning("Invalid value for key '%s' specified, fallback "
|
||||
"to default '%s'", IIDXHOOK_CONFIG_SEC_BLACK_PLUG_MCODE_KEY,
|
||||
if (!cconfig_util_get_str(
|
||||
config,
|
||||
IIDXHOOK_CONFIG_SEC_BLACK_PLUG_MCODE_KEY,
|
||||
tmp_mcode,
|
||||
sizeof(tmp_mcode) - 1,
|
||||
tmp_str)) {
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%s'",
|
||||
IIDXHOOK_CONFIG_SEC_BLACK_PLUG_MCODE_KEY,
|
||||
tmp_str);
|
||||
}
|
||||
|
||||
if (!security_mcode_parse(tmp_mcode, &config_sec->black_plug_mcode)) {
|
||||
log_warning("Invalid format for value of key '%s' specified, fallback "
|
||||
"to default '%s'", IIDXHOOK_CONFIG_SEC_BLACK_PLUG_MCODE_KEY,
|
||||
log_warning(
|
||||
"Invalid format for value of key '%s' specified, fallback "
|
||||
"to default '%s'",
|
||||
IIDXHOOK_CONFIG_SEC_BLACK_PLUG_MCODE_KEY,
|
||||
tmp_str);
|
||||
memcpy(&config_sec->black_plug_mcode,
|
||||
memcpy(
|
||||
&config_sec->black_plug_mcode,
|
||||
&IIDXHOOK_CONFIG_SEC_DEFAULT_BLACK_PLUG_MCODE_VALUE,
|
||||
sizeof(IIDXHOOK_CONFIG_SEC_DEFAULT_BLACK_PLUG_MCODE_VALUE));
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@ struct iidxhook_config_sec {
|
||||
struct security_mcode black_plug_mcode;
|
||||
};
|
||||
|
||||
void iidxhook_config_sec_init(struct cconfig* config);
|
||||
void iidxhook_config_sec_init(struct cconfig *config);
|
||||
|
||||
void iidxhook_config_sec_get(struct iidxhook_config_sec* config_sec,
|
||||
struct cconfig* config);
|
||||
void iidxhook_config_sec_get(
|
||||
struct iidxhook_config_sec *config_sec, struct cconfig *config);
|
||||
|
||||
#endif
|
||||
+351
-221
@@ -1,8 +1,8 @@
|
||||
#define LOG_MODULE "d3d9-hook"
|
||||
|
||||
#include <windows.h>
|
||||
#include <d3d9.h>
|
||||
#include <d3dx9core.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include <math.h>
|
||||
#include <stdbool.h>
|
||||
@@ -33,10 +33,19 @@ struct d3d9_vertex {
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
typedef HRESULT WINAPI (*func_D3DXCreateFontA)(struct IDirect3DDevice9 *device,
|
||||
INT height, UINT width, UINT weight, UINT miplevels, BOOL italic,
|
||||
DWORD charset, DWORD precision, DWORD quality, DWORD pitchandfamily,
|
||||
const char *facename, struct ID3DXFont **font);
|
||||
typedef HRESULT WINAPI (*func_D3DXCreateFontA)(
|
||||
struct IDirect3DDevice9 *device,
|
||||
INT height,
|
||||
UINT width,
|
||||
UINT weight,
|
||||
UINT miplevels,
|
||||
BOOL italic,
|
||||
DWORD charset,
|
||||
DWORD precision,
|
||||
DWORD quality,
|
||||
DWORD pitchandfamily,
|
||||
const char *facename,
|
||||
struct ID3DXFont **font);
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
@@ -48,22 +57,23 @@ static struct {
|
||||
uint16_t original_back_buffer_width;
|
||||
uint16_t original_back_buffer_height;
|
||||
|
||||
IDirect3DTexture9* rt_texture;
|
||||
IDirect3DSurface9* rt_surface;
|
||||
IDirect3DSurface9* rt_orig_surface;
|
||||
IDirect3DTexture9 *rt_texture;
|
||||
IDirect3DSurface9 *rt_surface;
|
||||
IDirect3DSurface9 *rt_orig_surface;
|
||||
|
||||
D3DTEXTUREFILTERTYPE filter;
|
||||
} iidxhook_util_d3d9_back_buffer_scaling;
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static bool iidxhook_util_d3d9_float_equal(float a, float b, float eps)
|
||||
{
|
||||
return fabs(a - b) < eps;
|
||||
}
|
||||
|
||||
static void iidxhook_util_d3d9_calc_win_size_with_framed(HWND hwnd, DWORD x, DWORD y, DWORD width, DWORD height,
|
||||
LPWINDOWPOS wp)
|
||||
static void iidxhook_util_d3d9_calc_win_size_with_framed(
|
||||
HWND hwnd, DWORD x, DWORD y, DWORD width, DWORD height, LPWINDOWPOS wp)
|
||||
{
|
||||
/* taken from dxwnd */
|
||||
RECT rect;
|
||||
@@ -102,35 +112,47 @@ static void iidxhook_util_d3d9_calc_win_size_with_framed(HWND hwnd, DWORD x, DWO
|
||||
wp->cy = rect.bottom - rect.top;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static void iidxhook_util_d3d9_patch_gpu_vid_pid(struct hook_d3d9_irp* irp)
|
||||
static void iidxhook_util_d3d9_patch_gpu_vid_pid(struct hook_d3d9_irp *irp)
|
||||
{
|
||||
char pci_id[32];
|
||||
|
||||
log_assert(irp);
|
||||
log_assert(irp->op == HOOK_D3D9_IRP_OP_ENUM_DISPLAY_DEVICES);
|
||||
|
||||
if (iidxhook_util_d3d9_config.pci_vid > 0 && iidxhook_util_d3d9_config.pci_pid > 0) {
|
||||
str_format(pci_id, sizeof(pci_id), "PCI\\VEN_%04X&DEV_%04X", iidxhook_util_d3d9_config.pci_vid,
|
||||
if (iidxhook_util_d3d9_config.pci_vid > 0 &&
|
||||
iidxhook_util_d3d9_config.pci_pid > 0) {
|
||||
|
||||
str_format(
|
||||
pci_id,
|
||||
sizeof(pci_id),
|
||||
"PCI\\VEN_%04X&DEV_%04X",
|
||||
iidxhook_util_d3d9_config.pci_vid,
|
||||
iidxhook_util_d3d9_config.pci_pid);
|
||||
|
||||
/* Apparently Konami didn't read the "Not Used" message in the MSDN
|
||||
docs for DISPLAY_DEVICE */
|
||||
log_misc("Replacing device ID %s with %s", irp->args.enum_display_devices.info->DeviceID, pci_id);
|
||||
log_misc(
|
||||
"Replacing device ID %s with %s",
|
||||
irp->args.enum_display_devices.info->DeviceID,
|
||||
pci_id);
|
||||
|
||||
str_cpy(irp->args.enum_display_devices.info->DeviceID,
|
||||
sizeof(irp->args.enum_display_devices.info->DeviceID),
|
||||
pci_id);
|
||||
str_cpy(
|
||||
irp->args.enum_display_devices.info->DeviceID,
|
||||
sizeof(irp->args.enum_display_devices.info->DeviceID),
|
||||
pci_id);
|
||||
}
|
||||
}
|
||||
|
||||
static void iidxhook_util_d3d9_patch_window(struct hook_d3d9_irp* irp)
|
||||
static void iidxhook_util_d3d9_patch_window(struct hook_d3d9_irp *irp)
|
||||
{
|
||||
log_assert(irp);
|
||||
log_assert(irp->op == HOOK_D3D9_IRP_OP_CREATE_WINDOW_EX);
|
||||
|
||||
if (iidxhook_util_d3d9_config.windowed && iidxhook_util_d3d9_config.framed) {
|
||||
if (iidxhook_util_d3d9_config.windowed &&
|
||||
iidxhook_util_d3d9_config.framed) {
|
||||
/* use a different style */
|
||||
irp->args.create_window_ex.style |= WS_OVERLAPPEDWINDOW;
|
||||
|
||||
@@ -138,24 +160,30 @@ static void iidxhook_util_d3d9_patch_window(struct hook_d3d9_irp* irp)
|
||||
ShowCursor(TRUE);
|
||||
}
|
||||
|
||||
if (iidxhook_util_d3d9_config.override_window_width > 0 && iidxhook_util_d3d9_config.override_window_height) {
|
||||
log_misc("Overriding window size from %dx%d with %dx%d",
|
||||
irp->args.create_window_ex.width,
|
||||
irp->args.create_window_ex.height,
|
||||
if (iidxhook_util_d3d9_config.override_window_width > 0 &&
|
||||
iidxhook_util_d3d9_config.override_window_height) {
|
||||
log_misc(
|
||||
"Overriding window size from %dx%d with %dx%d",
|
||||
irp->args.create_window_ex.width,
|
||||
irp->args.create_window_ex.height,
|
||||
iidxhook_util_d3d9_config.override_window_width,
|
||||
iidxhook_util_d3d9_config.override_window_height);
|
||||
|
||||
irp->args.create_window_ex.width = iidxhook_util_d3d9_config.override_window_width;
|
||||
irp->args.create_window_ex.height = iidxhook_util_d3d9_config.override_window_height;
|
||||
irp->args.create_window_ex.width =
|
||||
iidxhook_util_d3d9_config.override_window_width;
|
||||
irp->args.create_window_ex.height =
|
||||
iidxhook_util_d3d9_config.override_window_height;
|
||||
}
|
||||
}
|
||||
|
||||
static void iidxhook_util_d3d9_fix_window_size_and_pos(struct hook_d3d9_irp* irp)
|
||||
static void
|
||||
iidxhook_util_d3d9_fix_window_size_and_pos(struct hook_d3d9_irp *irp)
|
||||
{
|
||||
log_assert(irp);
|
||||
log_assert(irp->op == HOOK_D3D9_IRP_OP_CREATE_WINDOW_EX);
|
||||
|
||||
if (iidxhook_util_d3d9_config.windowed && iidxhook_util_d3d9_config.framed) {
|
||||
if (iidxhook_util_d3d9_config.windowed &&
|
||||
iidxhook_util_d3d9_config.framed) {
|
||||
/* we have to adjust the window size, because the window needs to be a
|
||||
slightly bigger than the rendering resolution (window caption and
|
||||
stuff is included in the window size) */
|
||||
@@ -168,8 +196,9 @@ static void iidxhook_util_d3d9_fix_window_size_and_pos(struct hook_d3d9_irp* irp
|
||||
irp->args.create_window_ex.width,
|
||||
irp->args.create_window_ex.height,
|
||||
&wp);
|
||||
|
||||
SetWindowPos(irp->args.create_window_ex.result, 0, wp.x, wp.y, wp.cx, wp.cy, 0);
|
||||
|
||||
SetWindowPos(
|
||||
irp->args.create_window_ex.result, 0, wp.x, wp.y, wp.cx, wp.cy, 0);
|
||||
|
||||
irp->args.create_window_ex.x = wp.x;
|
||||
irp->args.create_window_ex.y = wp.y;
|
||||
@@ -178,47 +207,58 @@ static void iidxhook_util_d3d9_fix_window_size_and_pos(struct hook_d3d9_irp* irp
|
||||
}
|
||||
}
|
||||
|
||||
static void iidxhook_util_d3d9_log_create_device_params(struct hook_d3d9_irp* irp)
|
||||
static void
|
||||
iidxhook_util_d3d9_log_create_device_params(struct hook_d3d9_irp *irp)
|
||||
{
|
||||
log_assert(irp);
|
||||
log_assert(irp->op == HOOK_D3D9_IRP_OP_CTX_CREATE_DEVICE);
|
||||
|
||||
log_misc("CreateDevice parameters: adapter %d, type %d, hwnd %p, flags %lX, pdev %p",
|
||||
irp->args.ctx_create_device.adapter,
|
||||
irp->args.ctx_create_device.type,
|
||||
irp->args.ctx_create_device.hwnd,
|
||||
irp->args.ctx_create_device.flags,
|
||||
irp->args.ctx_create_device.pdev);
|
||||
log_misc(
|
||||
"CreateDevice parameters: adapter %d, type %d, hwnd %p, flags %lX, "
|
||||
"pdev %p",
|
||||
irp->args.ctx_create_device.adapter,
|
||||
irp->args.ctx_create_device.type,
|
||||
irp->args.ctx_create_device.hwnd,
|
||||
irp->args.ctx_create_device.flags,
|
||||
irp->args.ctx_create_device.pdev);
|
||||
|
||||
log_misc("D3D9 presenter parameters: BackBufferWidth %d, BackBufferHeight %d, BackBufferFormat %d, "
|
||||
"BackBufferCount %d, MultiSampleType %d, SwapEffect %d, hDeviceWindow %p, Windowed %d, EnableAutoDepthStencil "
|
||||
"%d, AutoDepthStencilFormat %d, Flags %lX, FullScreen_RefreshRateInHz %d",
|
||||
irp->args.ctx_create_device.pp->BackBufferWidth,
|
||||
irp->args.ctx_create_device.pp->BackBufferHeight,
|
||||
irp->args.ctx_create_device.pp->BackBufferFormat,
|
||||
irp->args.ctx_create_device.pp->BackBufferCount,
|
||||
irp->args.ctx_create_device.pp->MultiSampleType,
|
||||
irp->args.ctx_create_device.pp->SwapEffect,
|
||||
irp->args.ctx_create_device.pp->hDeviceWindow,
|
||||
irp->args.ctx_create_device.pp->Windowed,
|
||||
irp->args.ctx_create_device.pp->EnableAutoDepthStencil,
|
||||
irp->args.ctx_create_device.pp->AutoDepthStencilFormat,
|
||||
irp->args.ctx_create_device.pp->Flags,
|
||||
irp->args.ctx_create_device.pp->FullScreen_RefreshRateInHz);
|
||||
log_misc(
|
||||
"D3D9 presenter parameters: BackBufferWidth %d, BackBufferHeight "
|
||||
"%d, BackBufferFormat %d, "
|
||||
"BackBufferCount %d, MultiSampleType %d, SwapEffect %d, "
|
||||
"hDeviceWindow %p, Windowed %d, "
|
||||
"EnableAutoDepthStencil "
|
||||
"%d, AutoDepthStencilFormat %d, Flags %lX, "
|
||||
"FullScreen_RefreshRateInHz %d",
|
||||
irp->args.ctx_create_device.pp->BackBufferWidth,
|
||||
irp->args.ctx_create_device.pp->BackBufferHeight,
|
||||
irp->args.ctx_create_device.pp->BackBufferFormat,
|
||||
irp->args.ctx_create_device.pp->BackBufferCount,
|
||||
irp->args.ctx_create_device.pp->MultiSampleType,
|
||||
irp->args.ctx_create_device.pp->SwapEffect,
|
||||
irp->args.ctx_create_device.pp->hDeviceWindow,
|
||||
irp->args.ctx_create_device.pp->Windowed,
|
||||
irp->args.ctx_create_device.pp->EnableAutoDepthStencil,
|
||||
irp->args.ctx_create_device.pp->AutoDepthStencilFormat,
|
||||
irp->args.ctx_create_device.pp->Flags,
|
||||
irp->args.ctx_create_device.pp->FullScreen_RefreshRateInHz);
|
||||
}
|
||||
|
||||
static void iidxhook_util_d3d9_fix_iidx_bug_software_processing(struct hook_d3d9_irp* irp)
|
||||
static void
|
||||
iidxhook_util_d3d9_fix_iidx_bug_software_processing(struct hook_d3d9_irp *irp)
|
||||
{
|
||||
log_assert(irp);
|
||||
log_assert(irp->op == HOOK_D3D9_IRP_OP_CTX_CREATE_DEVICE);
|
||||
|
||||
/* Fix a long-standing bug in IIDX */
|
||||
if (irp->args.ctx_create_device.flags & D3DCREATE_SOFTWARE_VERTEXPROCESSING) {
|
||||
if (irp->args.ctx_create_device.flags &
|
||||
D3DCREATE_SOFTWARE_VERTEXPROCESSING) {
|
||||
irp->args.ctx_create_device.flags &= ~D3DCREATE_PUREDEVICE;
|
||||
}
|
||||
}
|
||||
|
||||
static void iidxhook_util_d3d9_fix_create_device_apply_window_mode(struct hook_d3d9_irp* irp)
|
||||
static void iidxhook_util_d3d9_fix_create_device_apply_window_mode(
|
||||
struct hook_d3d9_irp *irp)
|
||||
{
|
||||
log_assert(irp);
|
||||
log_assert(irp->op == HOOK_D3D9_IRP_OP_CTX_CREATE_DEVICE);
|
||||
@@ -229,46 +269,62 @@ static void iidxhook_util_d3d9_fix_create_device_apply_window_mode(struct hook_d
|
||||
}
|
||||
}
|
||||
|
||||
static void iidxhook_util_d3d9_fix_back_buffer_format(struct hook_d3d9_irp* irp)
|
||||
static void iidxhook_util_d3d9_fix_back_buffer_format(struct hook_d3d9_irp *irp)
|
||||
{
|
||||
log_assert(irp);
|
||||
log_assert(irp->op == HOOK_D3D9_IRP_OP_CTX_CREATE_DEVICE);
|
||||
|
||||
/* Same fix as on D3D8, orz...
|
||||
If we don't do this, some games one certain platforms (e.g. iidx 14/15 on Windows 10).
|
||||
CreateDevice fails with an "invalid call" on either fullscreen or windowed or even both.
|
||||
Also, further reports about textures with green glowing borders are gone as well when applying this */
|
||||
If we don't do this, some games one certain platforms (e.g. iidx 14/15 on
|
||||
Windows 10). CreateDevice fails with an "invalid call" on either
|
||||
fullscreen or windowed or even both.
|
||||
Also, further reports about textures with green glowing borders are gone
|
||||
as well when applying this */
|
||||
D3DDISPLAYMODE mode;
|
||||
IDirect3D9_GetAdapterDisplayMode(
|
||||
irp->args.ctx_create_device.self,
|
||||
irp->args.ctx_create_device.adapter,
|
||||
irp->args.ctx_create_device.self,
|
||||
irp->args.ctx_create_device.adapter,
|
||||
&mode);
|
||||
|
||||
irp->args.ctx_create_device.pp->BackBufferFormat = mode.Format;
|
||||
}
|
||||
|
||||
static ID3DXFont* iidxhook_util_d3d9_load_and_create_font(IDirect3DDevice9* dev)
|
||||
static ID3DXFont *iidxhook_util_d3d9_load_and_create_font(IDirect3DDevice9 *dev)
|
||||
{
|
||||
HMODULE d3d9_24;
|
||||
HRESULT hr;
|
||||
ID3DXFont* font;
|
||||
|
||||
ID3DXFont *font;
|
||||
|
||||
d3d9_24 = GetModuleHandleA("d3dx9_24.dll");
|
||||
|
||||
if (d3d9_24 == NULL) {
|
||||
log_warning("Failed to load d3dx9_24.dll to create a font for displaying framerate on monitor check.");
|
||||
log_warning(
|
||||
"Failed to load d3dx9_24.dll to create a font for displaying "
|
||||
"framerate on monitor check.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
func_D3DXCreateFontA d3dxCreateFontA =(func_D3DXCreateFontA) GetProcAddress(d3d9_24, "D3DXCreateFontA");
|
||||
func_D3DXCreateFontA d3dxCreateFontA =
|
||||
(func_D3DXCreateFontA) GetProcAddress(d3d9_24, "D3DXCreateFontA");
|
||||
|
||||
if (d3dxCreateFontA == NULL) {
|
||||
log_warning("Failed to find function D3DXCreateFontA");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
hr = d3dxCreateFontA(dev, 22, 0, FW_NORMAL, 1, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY,
|
||||
FF_DONTCARE, "Arial", &font);
|
||||
hr = d3dxCreateFontA(
|
||||
dev,
|
||||
22,
|
||||
0,
|
||||
FW_NORMAL,
|
||||
1,
|
||||
false,
|
||||
DEFAULT_CHARSET,
|
||||
OUT_DEFAULT_PRECIS,
|
||||
ANTIALIASED_QUALITY,
|
||||
FF_DONTCARE,
|
||||
"Arial",
|
||||
&font);
|
||||
|
||||
if (hr != S_OK) {
|
||||
log_warning("Failed to load font for monitor check: %lX", hr);
|
||||
@@ -278,7 +334,7 @@ static ID3DXFont* iidxhook_util_d3d9_load_and_create_font(IDirect3DDevice9* dev)
|
||||
return font;
|
||||
}
|
||||
|
||||
static void iidxhook_util_d3d9_execute_monitor_check(struct hook_d3d9_irp* irp)
|
||||
static void iidxhook_util_d3d9_execute_monitor_check(struct hook_d3d9_irp *irp)
|
||||
{
|
||||
const uint32_t max_iterations = 60 * 30;
|
||||
const uint32_t skip_frames = 60 * 1;
|
||||
@@ -289,7 +345,7 @@ static void iidxhook_util_d3d9_execute_monitor_check(struct hook_d3d9_irp* irp)
|
||||
uint64_t start;
|
||||
|
||||
char text_buffer[256];
|
||||
ID3DXFont* font;
|
||||
ID3DXFont *font;
|
||||
RECT font_rect;
|
||||
|
||||
log_assert(irp);
|
||||
@@ -303,10 +359,13 @@ static void iidxhook_util_d3d9_execute_monitor_check(struct hook_d3d9_irp* irp)
|
||||
result = 0;
|
||||
iterations = 0;
|
||||
|
||||
font = iidxhook_util_d3d9_load_and_create_font(*irp->args.ctx_create_device.pdev);
|
||||
font = iidxhook_util_d3d9_load_and_create_font(
|
||||
*irp->args.ctx_create_device.pdev);
|
||||
|
||||
if (font == NULL) {
|
||||
log_info("Monitor check without on-screen text showing current refresh rate.");
|
||||
log_info(
|
||||
"Monitor check without on-screen text showing current "
|
||||
"refresh rate.");
|
||||
} else {
|
||||
SetRect(&font_rect, 20, 20, 640, 480);
|
||||
}
|
||||
@@ -318,8 +377,8 @@ static void iidxhook_util_d3d9_execute_monitor_check(struct hook_d3d9_irp* irp)
|
||||
"Monitor check...\n"
|
||||
"Elapsed iterations: %d/%d\n"
|
||||
"Refresh rate: %f",
|
||||
iterations + 1,
|
||||
max_iterations,
|
||||
iterations + 1,
|
||||
max_iterations,
|
||||
result);
|
||||
}
|
||||
|
||||
@@ -328,16 +387,30 @@ static void iidxhook_util_d3d9_execute_monitor_check(struct hook_d3d9_irp* irp)
|
||||
|
||||
IDirect3DDevice9_BeginScene(*irp->args.ctx_create_device.pdev);
|
||||
|
||||
IDirect3DDevice9_Clear(*irp->args.ctx_create_device.pdev, 0, NULL, D3DCLEAR_TARGET,
|
||||
D3DCOLOR_XRGB(0xFF, 0xFF, 0xFF), 0.0f, 0);
|
||||
IDirect3DDevice9_Clear(
|
||||
*irp->args.ctx_create_device.pdev,
|
||||
0,
|
||||
NULL,
|
||||
D3DCLEAR_TARGET,
|
||||
D3DCOLOR_XRGB(0xFF, 0xFF, 0xFF),
|
||||
0.0f,
|
||||
0);
|
||||
|
||||
if (font) {
|
||||
ID3DXFont_DrawTextA(font, NULL, text_buffer, -1, &font_rect, DT_LEFT, D3DCOLOR_XRGB(0xFF, 0xFF, 0xFF));
|
||||
ID3DXFont_DrawTextA(
|
||||
font,
|
||||
NULL,
|
||||
text_buffer,
|
||||
-1,
|
||||
&font_rect,
|
||||
DT_LEFT,
|
||||
D3DCOLOR_XRGB(0xFF, 0xFF, 0xFF));
|
||||
}
|
||||
|
||||
IDirect3DDevice9_EndScene(*irp->args.ctx_create_device.pdev);
|
||||
|
||||
IDirect3DDevice9_Present(*irp->args.ctx_create_device.pdev, NULL, NULL, NULL, NULL);
|
||||
IDirect3DDevice9_Present(
|
||||
*irp->args.ctx_create_device.pdev, NULL, NULL, NULL, NULL);
|
||||
|
||||
/* Skip the first inaccurate values */
|
||||
if (iterations > skip_frames) {
|
||||
@@ -348,15 +421,20 @@ static void iidxhook_util_d3d9_execute_monitor_check(struct hook_d3d9_irp* irp)
|
||||
}
|
||||
}
|
||||
|
||||
log_info("Monitor check done (total iterations %d), refesh rate: %f hz",
|
||||
iterations, result);
|
||||
|
||||
log_info(
|
||||
"Monitor check done (total iterations %d), refesh rate: %f hz",
|
||||
iterations,
|
||||
result);
|
||||
|
||||
/* Sanity check to ensure people notice that their current refresh rate
|
||||
is way off. */
|
||||
if (result < 55 || result > 65) {
|
||||
log_warning("Monitor check result (%f hz) is not even near the "
|
||||
"intended refresh rate of 60 hz. Fix your setup to ensure a "
|
||||
"constant and as close to as possible 60 hz refresh rate.", result);
|
||||
log_warning(
|
||||
"Monitor check result (%f hz) is not even near the "
|
||||
"intended refresh rate of 60 hz. Fix your setup to ensure "
|
||||
"a "
|
||||
"constant and as close to as possible 60 hz refresh rate.",
|
||||
result);
|
||||
}
|
||||
|
||||
/* Leave results of monitor check on screen for a moment */
|
||||
@@ -370,7 +448,7 @@ static void iidxhook_util_d3d9_execute_monitor_check(struct hook_d3d9_irp* irp)
|
||||
|
||||
static void iidxhook_util_d3d9_log_result_create_device(HRESULT hr)
|
||||
{
|
||||
char* error;
|
||||
char *error;
|
||||
|
||||
if (hr != S_OK) {
|
||||
switch (hr) {
|
||||
@@ -399,32 +477,33 @@ static void iidxhook_util_d3d9_log_result_create_device(HRESULT hr)
|
||||
}
|
||||
}
|
||||
|
||||
static void iidxhook_util_d3d9_nvidia_fix_iidx14_to_19(struct hook_d3d9_irp* irp)
|
||||
static void
|
||||
iidxhook_util_d3d9_nvidia_fix_iidx14_to_19(struct hook_d3d9_irp *irp)
|
||||
{
|
||||
log_assert(irp);
|
||||
log_assert(irp->op == HOOK_D3D9_IRP_OP_DEV_CREATE_TEXTURE);
|
||||
|
||||
/* Fix non ATI cards not working on Gold (and DJT?). There is a check that
|
||||
creates textures when starting the game. This check fails which results
|
||||
in a message box being shown mentioning something about an aep-lib error.
|
||||
Seems like a combination of parameters is not supported by
|
||||
non ATI cards and throws an error
|
||||
(Fix taken from old Gold cracks by ahnada and tau)
|
||||
in a message box being shown mentioning something about an aep-lib
|
||||
error. Seems like a combination of parameters is not supported by non ATI
|
||||
cards and throws an error (Fix taken from old Gold cracks by ahnada and
|
||||
tau)
|
||||
*/
|
||||
|
||||
if (iidxhook_util_d3d9_config.iidx14_to_19_nvidia_fix &&
|
||||
irp->args.dev_create_texture.width == 256 &&
|
||||
irp->args.dev_create_texture.height == 256 &&
|
||||
irp->args.dev_create_texture.levels == 1 &&
|
||||
irp->args.dev_create_texture.usage == D3DUSAGE_RENDERTARGET &&
|
||||
irp->args.dev_create_texture.format == D3DFMT_A1R5G5B5 &&
|
||||
irp->args.dev_create_texture.pool == D3DPOOL_DEFAULT &&
|
||||
irp->args.dev_create_texture.shared_handle == NULL) {
|
||||
if (iidxhook_util_d3d9_config.iidx14_to_19_nvidia_fix &&
|
||||
irp->args.dev_create_texture.width == 256 &&
|
||||
irp->args.dev_create_texture.height == 256 &&
|
||||
irp->args.dev_create_texture.levels == 1 &&
|
||||
irp->args.dev_create_texture.usage == D3DUSAGE_RENDERTARGET &&
|
||||
irp->args.dev_create_texture.format == D3DFMT_A1R5G5B5 &&
|
||||
irp->args.dev_create_texture.pool == D3DPOOL_DEFAULT &&
|
||||
irp->args.dev_create_texture.shared_handle == NULL) {
|
||||
irp->args.dev_create_texture.format = D3DFMT_A8R8G8B8;
|
||||
}
|
||||
}
|
||||
|
||||
static void iidxhook_util_d3d9_framerate_limiter(struct hook_d3d9_irp* irp)
|
||||
static void iidxhook_util_d3d9_framerate_limiter(struct hook_d3d9_irp *irp)
|
||||
{
|
||||
log_assert(irp);
|
||||
log_assert(irp->op == HOOK_D3D9_IRP_OP_DEV_PRESENT);
|
||||
@@ -433,14 +512,18 @@ static void iidxhook_util_d3d9_framerate_limiter(struct hook_d3d9_irp* irp)
|
||||
if (iidxhook_util_d3d9_present_current_time == 0) {
|
||||
iidxhook_util_d3d9_present_current_time = time_get_counter();
|
||||
} else {
|
||||
uint64_t frame_time = 1000000 / iidxhook_util_d3d9_config.framerate_limit;
|
||||
uint64_t frame_time =
|
||||
1000000 / iidxhook_util_d3d9_config.framerate_limit;
|
||||
|
||||
uint64_t dt = time_get_elapsed_us(time_get_counter() - iidxhook_util_d3d9_present_current_time);
|
||||
uint64_t dt = time_get_elapsed_us(
|
||||
time_get_counter() - iidxhook_util_d3d9_present_current_time);
|
||||
|
||||
while (dt < frame_time) {
|
||||
/* waste some cpu time by polling
|
||||
because we can't sleep for X us */
|
||||
dt = time_get_elapsed_us(time_get_counter() - iidxhook_util_d3d9_present_current_time);
|
||||
dt = time_get_elapsed_us(
|
||||
time_get_counter() -
|
||||
iidxhook_util_d3d9_present_current_time);
|
||||
}
|
||||
|
||||
iidxhook_util_d3d9_present_current_time = time_get_counter();
|
||||
@@ -448,7 +531,8 @@ static void iidxhook_util_d3d9_framerate_limiter(struct hook_d3d9_irp* irp)
|
||||
}
|
||||
}
|
||||
|
||||
static void iidxhook_util_d3d9_iidx12_fix_song_select_bg(struct hook_d3d9_irp* irp)
|
||||
static void
|
||||
iidxhook_util_d3d9_iidx12_fix_song_select_bg(struct hook_d3d9_irp *irp)
|
||||
{
|
||||
log_assert(irp);
|
||||
log_assert(irp->op == HOOK_D3D9_IRP_OP_DEV_SET_RENDER_STATE);
|
||||
@@ -460,7 +544,8 @@ static void iidxhook_util_d3d9_iidx12_fix_song_select_bg(struct hook_d3d9_irp* i
|
||||
}
|
||||
}
|
||||
|
||||
static void iidxhook_util_d3d9_iidx13_fix_song_select_bg(struct hook_d3d9_irp* irp)
|
||||
static void
|
||||
iidxhook_util_d3d9_iidx13_fix_song_select_bg(struct hook_d3d9_irp *irp)
|
||||
{
|
||||
log_assert(irp);
|
||||
log_assert(irp->op == HOOK_D3D9_IRP_OP_DEV_SET_RENDER_STATE);
|
||||
@@ -472,18 +557,21 @@ static void iidxhook_util_d3d9_iidx13_fix_song_select_bg(struct hook_d3d9_irp* i
|
||||
}
|
||||
}
|
||||
|
||||
static void iidxhook_util_d3d9_iidx11_to_17_fix_uvs_bg_videos(struct hook_d3d9_irp* irp)
|
||||
static void
|
||||
iidxhook_util_d3d9_iidx11_to_17_fix_uvs_bg_videos(struct hook_d3d9_irp *irp)
|
||||
{
|
||||
log_assert(irp);
|
||||
log_assert(irp->op == HOOK_D3D9_IRP_OP_DEV_DRAW_PRIMITIVE_UP);
|
||||
|
||||
/* same code taken from the d3d8 module. but, this just fixes the quad
|
||||
seam issue as there are no reports of streched bg videos */
|
||||
if (iidxhook_util_d3d9_config.iidx11_to_17_fix_uvs_bg_videos &&
|
||||
irp->args.dev_draw_primitive_up.primitive_type == D3DPT_TRIANGLEFAN &&
|
||||
irp->args.dev_draw_primitive_up.primitive_count == 2 &&
|
||||
irp->args.dev_draw_primitive_up.stride == 28) {
|
||||
struct d3d9_vertex* vertices = (struct d3d9_vertex*) irp->args.dev_draw_primitive_up.data;
|
||||
if (iidxhook_util_d3d9_config.iidx11_to_17_fix_uvs_bg_videos &&
|
||||
irp->args.dev_draw_primitive_up.primitive_type == D3DPT_TRIANGLEFAN &&
|
||||
irp->args.dev_draw_primitive_up.primitive_count == 2 &&
|
||||
irp->args.dev_draw_primitive_up.stride == 28) {
|
||||
|
||||
struct d3d9_vertex *vertices =
|
||||
(struct d3d9_vertex *) irp->args.dev_draw_primitive_up.data;
|
||||
|
||||
/*
|
||||
log_info("Video Tex: %f/%f %f/%f %f/%f %f/%f",
|
||||
@@ -494,14 +582,14 @@ static void iidxhook_util_d3d9_iidx11_to_17_fix_uvs_bg_videos(struct hook_d3d9_i
|
||||
*/
|
||||
|
||||
/* Fix full screen background videos (e.g. DistorteD intro sequence) */
|
||||
if ( vertices[0].x >= 0.0f && vertices[0].x < 1.0f &&
|
||||
vertices[0].y >= 0.0f && vertices[0].y < 1.0f &&
|
||||
vertices[1].x > 639.0f && vertices[1].x < 641.0f &&
|
||||
vertices[1].y >= 0.0f && vertices[1].y < 1.0f &&
|
||||
vertices[2].x > 639.0f && vertices[2].x < 641.0f &&
|
||||
vertices[2].y > 479.0f && vertices[2].y < 481.0f &&
|
||||
vertices[3].x >= 0.0f && vertices[3].x < 1.0f &&
|
||||
vertices[3].y > 479.0f && vertices[3].y < 481.0f) {
|
||||
if (vertices[0].x >= 0.0f && vertices[0].x < 1.0f &&
|
||||
vertices[0].y >= 0.0f && vertices[0].y < 1.0f &&
|
||||
vertices[1].x > 639.0f && vertices[1].x < 641.0f &&
|
||||
vertices[1].y >= 0.0f && vertices[1].y < 1.0f &&
|
||||
vertices[2].x > 639.0f && vertices[2].x < 641.0f &&
|
||||
vertices[2].y > 479.0f && vertices[2].y < 481.0f &&
|
||||
vertices[3].x >= 0.0f && vertices[3].x < 1.0f &&
|
||||
vertices[3].y > 479.0f && vertices[3].y < 481.0f) {
|
||||
/* fix UVs
|
||||
1.0f / 640 or 480 fixes the diagonal seam connecting the two
|
||||
triangles which is visible on some GPUs (why? idk)
|
||||
@@ -516,56 +604,58 @@ static void iidxhook_util_d3d9_iidx11_to_17_fix_uvs_bg_videos(struct hook_d3d9_i
|
||||
vertices[3].tv = 0.0f + 1.0f / 480;
|
||||
} else
|
||||
|
||||
/* another identifier, because there are other textures with 512x512 size
|
||||
make sure we got the bg video only to not mess up anything else */
|
||||
/* different versions have different themes and position the bg video
|
||||
on slightly different positions (good job...) */
|
||||
if ( /* single */
|
||||
/* another identifier, because there are other textures with
|
||||
512x512 size make sure we got the bg video only to not mess
|
||||
up anything else */
|
||||
/* different versions have different themes and position the bg
|
||||
video on slightly different positions (good job...) */
|
||||
if (/* single */
|
||||
((vertices[0].x >= 164.0f && vertices[0].x <= 168.0f &&
|
||||
iidxhook_util_d3d9_float_equal(vertices[0].y, 0.0f, 0.1f)) &&
|
||||
(vertices[1].x >= 472.0f && vertices[1].x <= 476.0f &&
|
||||
iidxhook_util_d3d9_float_equal(vertices[1].y, 0.0f, 0.1f)) &&
|
||||
(vertices[2].x >= 472.0f && vertices[2].x <= 476.0f &&
|
||||
iidxhook_util_d3d9_float_equal(vertices[2].y, 416.0f, 0.1f)) &&
|
||||
(vertices[3].x >= 164.0f && vertices[3].x <= 168.0f &&
|
||||
iidxhook_util_d3d9_float_equal(vertices[3].y, 416.0f, 0.1f))) ||
|
||||
iidxhook_util_d3d9_float_equal(vertices[0].y, 0.0f, 0.1f)) &&
|
||||
(vertices[1].x >= 472.0f && vertices[1].x <= 476.0f &&
|
||||
iidxhook_util_d3d9_float_equal(vertices[1].y, 0.0f, 0.1f)) &&
|
||||
(vertices[2].x >= 472.0f && vertices[2].x <= 476.0f &&
|
||||
iidxhook_util_d3d9_float_equal(
|
||||
vertices[2].y, 416.0f, 0.1f)) &&
|
||||
(vertices[3].x >= 164.0f && vertices[3].x <= 168.0f &&
|
||||
iidxhook_util_d3d9_float_equal(
|
||||
vertices[3].y, 416.0f, 0.1f))) ||
|
||||
/* double top left */
|
||||
((iidxhook_util_d3d9_float_equal(vertices[0].x, 6.0f, 0.1f) &&
|
||||
vertices[0].y >= 24.0f && vertices[0].y <= 28.0f) &&
|
||||
(iidxhook_util_d3d9_float_equal(vertices[1].x, 147.0f, 0.1f) &&
|
||||
vertices[1].y >= 24.0f && vertices[1].y <= 28.0f) &&
|
||||
(iidxhook_util_d3d9_float_equal(vertices[2].x, 147.0f, 0.1f) &&
|
||||
vertices[2].y >= 212.0f && vertices[2].y <= 216.0f) &&
|
||||
(iidxhook_util_d3d9_float_equal(vertices[3].x, 6.0f, 0.1f) &&
|
||||
vertices[3].y >= 212.0f && vertices[3].y <= 216.0f)) ||
|
||||
vertices[0].y >= 24.0f && vertices[0].y <= 28.0f) &&
|
||||
(iidxhook_util_d3d9_float_equal(vertices[1].x, 147.0f, 0.1f) &&
|
||||
vertices[1].y >= 24.0f && vertices[1].y <= 28.0f) &&
|
||||
(iidxhook_util_d3d9_float_equal(vertices[2].x, 147.0f, 0.1f) &&
|
||||
vertices[2].y >= 212.0f && vertices[2].y <= 216.0f) &&
|
||||
(iidxhook_util_d3d9_float_equal(vertices[3].x, 6.0f, 0.1f) &&
|
||||
vertices[3].y >= 212.0f && vertices[3].y <= 216.0f)) ||
|
||||
/* double bottom left */
|
||||
((iidxhook_util_d3d9_float_equal(vertices[0].x, 6.0f, 0.1f) &&
|
||||
vertices[0].y >= 216.0f && vertices[0].y <= 220.0f) &&
|
||||
(iidxhook_util_d3d9_float_equal(vertices[1].x, 147.0f, 0.1f) &&
|
||||
vertices[1].y >= 216.0f && vertices[1].y <= 220.0f) &&
|
||||
(iidxhook_util_d3d9_float_equal(vertices[2].x, 147.0f, 0.1) &&
|
||||
vertices[2].y >= 404.0f && vertices[2].y <= 408.0f) &&
|
||||
(iidxhook_util_d3d9_float_equal(vertices[3].x, 6.0f, 0.1f) &&
|
||||
vertices[3].y >= 404.0f && vertices[3].y <= 408.0f)) ||
|
||||
vertices[0].y >= 216.0f && vertices[0].y <= 220.0f) &&
|
||||
(iidxhook_util_d3d9_float_equal(vertices[1].x, 147.0f, 0.1f) &&
|
||||
vertices[1].y >= 216.0f && vertices[1].y <= 220.0f) &&
|
||||
(iidxhook_util_d3d9_float_equal(vertices[2].x, 147.0f, 0.1) &&
|
||||
vertices[2].y >= 404.0f && vertices[2].y <= 408.0f) &&
|
||||
(iidxhook_util_d3d9_float_equal(vertices[3].x, 6.0f, 0.1f) &&
|
||||
vertices[3].y >= 404.0f && vertices[3].y <= 408.0f)) ||
|
||||
/* double top right */
|
||||
((vertices[0].x >= 493.0f && vertices[0].x <= 494.0f &&
|
||||
vertices[0].y >= 24.0f && vertices[0].y <= 28.0f) &&
|
||||
(vertices[1].x >= 634.0f && vertices[1].x <= 635.0f &&
|
||||
vertices[1].y >= 24.0f && vertices[1].y <= 28.0f) &&
|
||||
(vertices[2].x >= 634.0f && vertices[2].x <= 635.0f &&
|
||||
vertices[2].y >= 212.0f && vertices[2].y <= 216.0f) &&
|
||||
(vertices[3].x >= 493.0f && vertices[3].x <= 494.0f &&
|
||||
vertices[3].y >= 212.0f && vertices[3].y <= 216.0f)) ||
|
||||
vertices[0].y >= 24.0f && vertices[0].y <= 28.0f) &&
|
||||
(vertices[1].x >= 634.0f && vertices[1].x <= 635.0f &&
|
||||
vertices[1].y >= 24.0f && vertices[1].y <= 28.0f) &&
|
||||
(vertices[2].x >= 634.0f && vertices[2].x <= 635.0f &&
|
||||
vertices[2].y >= 212.0f && vertices[2].y <= 216.0f) &&
|
||||
(vertices[3].x >= 493.0f && vertices[3].x <= 494.0f &&
|
||||
vertices[3].y >= 212.0f && vertices[3].y <= 216.0f)) ||
|
||||
/* double bottom right */
|
||||
((vertices[0].x >= 493.0f && vertices[0].x <= 494.0f &&
|
||||
vertices[0].y >= 216.0f && vertices[0].y <= 220.0f) &&
|
||||
(vertices[1].x >= 634.0f && vertices[1].x <= 635.0f &&
|
||||
vertices[1].y >= 216.0f && vertices[1].y <= 220.0f) &&
|
||||
(vertices[2].x >= 634.0f && vertices[2].x <= 635.0f &&
|
||||
vertices[2].y >= 404.0f && vertices[2].y <= 408.0f) &&
|
||||
(vertices[3].x >= 493.0f && vertices[3].x <= 494.0f &&
|
||||
vertices[3].y >= 404.0f && vertices[3].y <= 408.0f)))
|
||||
{
|
||||
vertices[0].y >= 216.0f && vertices[0].y <= 220.0f) &&
|
||||
(vertices[1].x >= 634.0f && vertices[1].x <= 635.0f &&
|
||||
vertices[1].y >= 216.0f && vertices[1].y <= 220.0f) &&
|
||||
(vertices[2].x >= 634.0f && vertices[2].x <= 635.0f &&
|
||||
vertices[2].y >= 404.0f && vertices[2].y <= 408.0f) &&
|
||||
(vertices[3].x >= 493.0f && vertices[3].x <= 494.0f &&
|
||||
vertices[3].y >= 404.0f && vertices[3].y <= 408.0f))) {
|
||||
/* fix UVs
|
||||
1.0f / 512 fixes the diagonal seam connecting the two triangles
|
||||
which is visible on some GPUs (why? idk)
|
||||
@@ -582,32 +672,39 @@ static void iidxhook_util_d3d9_iidx11_to_17_fix_uvs_bg_videos(struct hook_d3d9_i
|
||||
}
|
||||
}
|
||||
|
||||
static void iidxhook_uti_d3d9_fix_iidx9_to_13_viewport_size(struct hook_d3d9_irp* irp)
|
||||
static void
|
||||
iidxhook_uti_d3d9_fix_iidx9_to_13_viewport_size(struct hook_d3d9_irp *irp)
|
||||
{
|
||||
log_assert(irp);
|
||||
log_assert(irp->op == HOOK_D3D9_IRP_OP_GET_CLIENT_RECT);
|
||||
|
||||
/* IIDX 9-13 (at least) use this call to get the size of rectangle for setting the viewport size... */
|
||||
/* IIDX 9-13 (at least) use this call to get the size of rectangle for
|
||||
* setting the viewport size... */
|
||||
|
||||
/* Always use the original requested back buffer size. If scaling is active, using the scaled
|
||||
values leads to (3D) scenes getting render to a viewport with incorrect sized. */
|
||||
/* Always use the original requested back buffer size. If scaling is active,
|
||||
using the scaled
|
||||
values leads to (3D) scenes getting render to a viewport with incorrect
|
||||
sized. */
|
||||
irp->args.get_client_rect.rect->left = 0;
|
||||
irp->args.get_client_rect.rect->top = 0;
|
||||
irp->args.get_client_rect.rect->right = iidxhook_util_d3d9_back_buffer_scaling.original_back_buffer_width;
|
||||
irp->args.get_client_rect.rect->bottom = iidxhook_util_d3d9_back_buffer_scaling.original_back_buffer_height;
|
||||
irp->args.get_client_rect.rect->right =
|
||||
iidxhook_util_d3d9_back_buffer_scaling.original_back_buffer_width;
|
||||
irp->args.get_client_rect.rect->bottom =
|
||||
iidxhook_util_d3d9_back_buffer_scaling.original_back_buffer_height;
|
||||
}
|
||||
|
||||
static void iidxhook_util_d3d9_setup_back_buffer_scaling_pre(struct hook_d3d9_irp* irp)
|
||||
static void
|
||||
iidxhook_util_d3d9_setup_back_buffer_scaling_pre(struct hook_d3d9_irp *irp)
|
||||
{
|
||||
log_assert(irp);
|
||||
log_assert(irp->op == HOOK_D3D9_IRP_OP_CTX_CREATE_DEVICE);
|
||||
|
||||
/* Store these so we can apply scaling further down */
|
||||
iidxhook_util_d3d9_back_buffer_scaling.original_back_buffer_width =
|
||||
iidxhook_util_d3d9_back_buffer_scaling.original_back_buffer_width =
|
||||
irp->args.ctx_create_device.pp->BackBufferWidth;
|
||||
iidxhook_util_d3d9_back_buffer_scaling.original_back_buffer_height =
|
||||
iidxhook_util_d3d9_back_buffer_scaling.original_back_buffer_height =
|
||||
irp->args.ctx_create_device.pp->BackBufferHeight;
|
||||
|
||||
|
||||
switch (iidxhook_util_d3d9_config.scale_back_buffer_filter) {
|
||||
case IIDXHOOK_UTIL_D3D9_BACK_BUFFER_SCALE_FILTER_NONE:
|
||||
iidxhook_util_d3d9_back_buffer_scaling.filter = D3DTEXF_NONE;
|
||||
@@ -622,40 +719,47 @@ static void iidxhook_util_d3d9_setup_back_buffer_scaling_pre(struct hook_d3d9_ir
|
||||
break;
|
||||
|
||||
default:
|
||||
log_fatal("Unhandled case, illegal state: %d", iidxhook_util_d3d9_config.scale_back_buffer_filter);
|
||||
log_fatal(
|
||||
"Unhandled case, illegal state: %d",
|
||||
iidxhook_util_d3d9_config.scale_back_buffer_filter);
|
||||
break;
|
||||
}
|
||||
|
||||
if (iidxhook_util_d3d9_config.scale_back_buffer_width > 0 &&
|
||||
iidxhook_util_d3d9_config.scale_back_buffer_height > 0) {
|
||||
log_misc("Scale back buffer from %dx%d -> %dx%d",
|
||||
if (iidxhook_util_d3d9_config.scale_back_buffer_width > 0 &&
|
||||
iidxhook_util_d3d9_config.scale_back_buffer_height > 0) {
|
||||
|
||||
log_misc(
|
||||
"Scale back buffer from %dx%d -> %dx%d",
|
||||
iidxhook_util_d3d9_back_buffer_scaling.original_back_buffer_width,
|
||||
iidxhook_util_d3d9_back_buffer_scaling.original_back_buffer_height,
|
||||
iidxhook_util_d3d9_config.scale_back_buffer_width,
|
||||
iidxhook_util_d3d9_config.scale_back_buffer_height);
|
||||
|
||||
irp->args.ctx_create_device.pp->BackBufferWidth =
|
||||
|
||||
irp->args.ctx_create_device.pp->BackBufferWidth =
|
||||
iidxhook_util_d3d9_config.scale_back_buffer_width;
|
||||
irp->args.ctx_create_device.pp->BackBufferHeight =
|
||||
irp->args.ctx_create_device.pp->BackBufferHeight =
|
||||
iidxhook_util_d3d9_config.scale_back_buffer_height;
|
||||
}
|
||||
}
|
||||
|
||||
static void iidxhook_util_d3d9_setup_back_buffer_scaling_post(struct hook_d3d9_irp* irp)
|
||||
static void
|
||||
iidxhook_util_d3d9_setup_back_buffer_scaling_post(struct hook_d3d9_irp *irp)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
log_assert(irp);
|
||||
log_assert(irp->op == HOOK_D3D9_IRP_OP_CTX_CREATE_DEVICE);
|
||||
|
||||
if (iidxhook_util_d3d9_config.scale_back_buffer_width > 0 &&
|
||||
iidxhook_util_d3d9_config.scale_back_buffer_height > 0) {
|
||||
if (iidxhook_util_d3d9_config.scale_back_buffer_width > 0 &&
|
||||
iidxhook_util_d3d9_config.scale_back_buffer_height > 0) {
|
||||
|
||||
log_misc("Creating intermediate render target texture: %dx%d",
|
||||
log_misc(
|
||||
"Creating intermediate render target texture: %dx%d",
|
||||
iidxhook_util_d3d9_back_buffer_scaling.original_back_buffer_width,
|
||||
iidxhook_util_d3d9_back_buffer_scaling.original_back_buffer_height);
|
||||
|
||||
/* This is our new render target. Let the game render to this in its native res instead of the back buffer */
|
||||
/* This is our new render target. Let the game render to this in its
|
||||
* native res instead of the back buffer */
|
||||
hr = IDirect3DDevice9_CreateTexture(
|
||||
*irp->args.ctx_create_device.pdev,
|
||||
iidxhook_util_d3d9_back_buffer_scaling.original_back_buffer_width,
|
||||
@@ -677,41 +781,42 @@ static void iidxhook_util_d3d9_setup_back_buffer_scaling_post(struct hook_d3d9_i
|
||||
&iidxhook_util_d3d9_back_buffer_scaling.rt_surface);
|
||||
|
||||
if (hr != S_OK) {
|
||||
log_fatal("Getting surface of render target texture failed: %lX", hr);
|
||||
log_fatal(
|
||||
"Getting surface of render target texture failed: %lX", hr);
|
||||
}
|
||||
|
||||
/* Save surface of original render target */
|
||||
hr = IDirect3DDevice9_GetRenderTarget(
|
||||
*irp->args.ctx_create_device.pdev,
|
||||
0,
|
||||
*irp->args.ctx_create_device.pdev,
|
||||
0,
|
||||
&iidxhook_util_d3d9_back_buffer_scaling.rt_orig_surface);
|
||||
|
||||
if (hr != S_OK) {
|
||||
log_fatal("Getting original render target failed: %lX", hr);
|
||||
}
|
||||
|
||||
/* Avoid returning our scaled values because the application might use them, e.g. calculate
|
||||
sprite positions. */
|
||||
irp->args.ctx_create_device.pp->BackBufferWidth =
|
||||
/* Avoid returning our scaled values because the application might use
|
||||
them, e.g. calculate sprite positions. */
|
||||
irp->args.ctx_create_device.pp->BackBufferWidth =
|
||||
iidxhook_util_d3d9_back_buffer_scaling.original_back_buffer_width;
|
||||
irp->args.ctx_create_device.pp->BackBufferHeight =
|
||||
irp->args.ctx_create_device.pp->BackBufferHeight =
|
||||
iidxhook_util_d3d9_back_buffer_scaling.original_back_buffer_height;
|
||||
}
|
||||
}
|
||||
|
||||
static void iidxhook_util_d3d9_set_intermediate_rt(struct hook_d3d9_irp* irp)
|
||||
static void iidxhook_util_d3d9_set_intermediate_rt(struct hook_d3d9_irp *irp)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
log_assert(irp);
|
||||
log_assert(irp->op == HOOK_D3D9_IRP_OP_DEV_BEGIN_SCENE);
|
||||
|
||||
if (iidxhook_util_d3d9_config.scale_back_buffer_width > 0 &&
|
||||
iidxhook_util_d3d9_config.scale_back_buffer_height > 0) {
|
||||
if (iidxhook_util_d3d9_config.scale_back_buffer_width > 0 &&
|
||||
iidxhook_util_d3d9_config.scale_back_buffer_height > 0) {
|
||||
/* Set our intermediate render texture as render target */
|
||||
hr = IDirect3DDevice9_SetRenderTarget(
|
||||
irp->args.dev_begin_scene.self,
|
||||
0,
|
||||
irp->args.dev_begin_scene.self,
|
||||
0,
|
||||
iidxhook_util_d3d9_back_buffer_scaling.rt_surface);
|
||||
|
||||
if (hr != S_OK) {
|
||||
@@ -720,19 +825,19 @@ static void iidxhook_util_d3d9_set_intermediate_rt(struct hook_d3d9_irp* irp)
|
||||
}
|
||||
}
|
||||
|
||||
static void iidxhook_util_d3d9_set_back_buffer_rt(struct hook_d3d9_irp* irp)
|
||||
static void iidxhook_util_d3d9_set_back_buffer_rt(struct hook_d3d9_irp *irp)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
log_assert(irp);
|
||||
log_assert(irp->op == HOOK_D3D9_IRP_OP_DEV_PRESENT);
|
||||
|
||||
if (iidxhook_util_d3d9_config.scale_back_buffer_width > 0 &&
|
||||
iidxhook_util_d3d9_config.scale_back_buffer_height > 0) {
|
||||
if (iidxhook_util_d3d9_config.scale_back_buffer_width > 0 &&
|
||||
iidxhook_util_d3d9_config.scale_back_buffer_height > 0) {
|
||||
/* Set our original surface/back buffer as rt */
|
||||
hr = IDirect3DDevice9_SetRenderTarget(
|
||||
irp->args.dev_present.self,
|
||||
0,
|
||||
irp->args.dev_present.self,
|
||||
0,
|
||||
iidxhook_util_d3d9_back_buffer_scaling.rt_orig_surface);
|
||||
|
||||
if (hr != S_OK) {
|
||||
@@ -741,7 +846,8 @@ static void iidxhook_util_d3d9_set_back_buffer_rt(struct hook_d3d9_irp* irp)
|
||||
}
|
||||
}
|
||||
|
||||
static void iidxhook_util_d3d9_scale_render_target_to_back_buffer(struct hook_d3d9_irp* irp)
|
||||
static void
|
||||
iidxhook_util_d3d9_scale_render_target_to_back_buffer(struct hook_d3d9_irp *irp)
|
||||
{
|
||||
HRESULT hr;
|
||||
RECT src_rect;
|
||||
@@ -749,12 +855,15 @@ static void iidxhook_util_d3d9_scale_render_target_to_back_buffer(struct hook_d3
|
||||
log_assert(irp);
|
||||
log_assert(irp->op == HOOK_D3D9_IRP_OP_DEV_PRESENT);
|
||||
|
||||
if (iidxhook_util_d3d9_config.scale_back_buffer_width > 0 &&
|
||||
iidxhook_util_d3d9_config.scale_back_buffer_height > 0) {
|
||||
if (iidxhook_util_d3d9_config.scale_back_buffer_width > 0 &&
|
||||
iidxhook_util_d3d9_config.scale_back_buffer_height > 0) {
|
||||
|
||||
src_rect.left = 0;
|
||||
src_rect.top = 0;
|
||||
src_rect.right = iidxhook_util_d3d9_back_buffer_scaling.original_back_buffer_width;
|
||||
src_rect.bottom = iidxhook_util_d3d9_back_buffer_scaling.original_back_buffer_height;
|
||||
src_rect.right =
|
||||
iidxhook_util_d3d9_back_buffer_scaling.original_back_buffer_width;
|
||||
src_rect.bottom =
|
||||
iidxhook_util_d3d9_back_buffer_scaling.original_back_buffer_height;
|
||||
|
||||
hr = IDirect3DDevice9_StretchRect(
|
||||
irp->args.dev_present.self,
|
||||
@@ -765,14 +874,19 @@ static void iidxhook_util_d3d9_scale_render_target_to_back_buffer(struct hook_d3
|
||||
iidxhook_util_d3d9_back_buffer_scaling.filter);
|
||||
|
||||
if (hr != S_OK) {
|
||||
log_fatal("Scaling intermediate render target to back buffer failed: %lX", hr);
|
||||
log_fatal(
|
||||
"Scaling intermediate render target to back buffer failed: "
|
||||
"%lX",
|
||||
hr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static void iidxhook_util_d3d9_log_config(const struct iidxhook_util_d3d9_config* config)
|
||||
static void
|
||||
iidxhook_util_d3d9_log_config(const struct iidxhook_util_d3d9_config *config)
|
||||
{
|
||||
log_misc(
|
||||
"iidxhook_util_d3d9_config\n"
|
||||
@@ -808,31 +922,41 @@ static void iidxhook_util_d3d9_log_config(const struct iidxhook_util_d3d9_config
|
||||
config->scale_back_buffer_filter);
|
||||
}
|
||||
|
||||
static void iidxhook_util_d3d9_validate_config(const struct iidxhook_util_d3d9_config* config)
|
||||
static void iidxhook_util_d3d9_validate_config(
|
||||
const struct iidxhook_util_d3d9_config *config)
|
||||
{
|
||||
if (!config->windowed && config->framed) {
|
||||
log_warning("Option framed does not have an effect without windowed");
|
||||
}
|
||||
|
||||
if (config->override_window_width == -1) {
|
||||
log_fatal("Invalid value for override_window_width: %d", config->override_window_width);
|
||||
log_fatal(
|
||||
"Invalid value for override_window_width: %d",
|
||||
config->override_window_width);
|
||||
}
|
||||
|
||||
if (config->override_window_height == -1) {
|
||||
log_fatal("Invalid value for override_window_height: %d", config->override_window_height);
|
||||
log_fatal(
|
||||
"Invalid value for override_window_height: %d",
|
||||
config->override_window_height);
|
||||
}
|
||||
|
||||
if (!config->windowed &&
|
||||
(config->override_window_width > 0 || config->override_window_height > 0)) {
|
||||
log_warning("Overriding window size does not have an effect without windowed");
|
||||
if (!config->windowed &&
|
||||
(config->override_window_width > 0 ||
|
||||
config->override_window_height > 0)) {
|
||||
log_warning(
|
||||
"Overriding window size does not have an effect without "
|
||||
"windowed");
|
||||
}
|
||||
|
||||
if (config->framerate_limit < 0.0f) {
|
||||
log_fatal("Invalid value for framerate_limit: %f", config->framerate_limit);
|
||||
log_fatal(
|
||||
"Invalid value for framerate_limit: %f", config->framerate_limit);
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void iidxhook_util_d3d9_hook_init(void)
|
||||
{
|
||||
@@ -841,7 +965,7 @@ void iidxhook_util_d3d9_hook_init(void)
|
||||
log_info("Initialized");
|
||||
}
|
||||
|
||||
void iidxhook_util_d3d9_init_config(struct iidxhook_util_d3d9_config* config)
|
||||
void iidxhook_util_d3d9_init_config(struct iidxhook_util_d3d9_config *config)
|
||||
{
|
||||
config->windowed = false;
|
||||
config->framed = false;
|
||||
@@ -857,20 +981,26 @@ void iidxhook_util_d3d9_init_config(struct iidxhook_util_d3d9_config* config)
|
||||
config->iidx14_to_19_nvidia_fix = false;
|
||||
config->scale_back_buffer_width = 0;
|
||||
config->scale_back_buffer_height = 0;
|
||||
config->scale_back_buffer_filter = IIDXHOOK_UTIL_D3D9_BACK_BUFFER_SCALE_FILTER_NONE;
|
||||
config->scale_back_buffer_filter =
|
||||
IIDXHOOK_UTIL_D3D9_BACK_BUFFER_SCALE_FILTER_NONE;
|
||||
}
|
||||
|
||||
void iidxhook_util_d3d9_configure(const struct iidxhook_util_d3d9_config* config)
|
||||
void iidxhook_util_d3d9_configure(
|
||||
const struct iidxhook_util_d3d9_config *config)
|
||||
{
|
||||
log_assert(config);
|
||||
|
||||
iidxhook_util_d3d9_log_config(config);
|
||||
iidxhook_util_d3d9_validate_config(config);
|
||||
|
||||
memcpy(&iidxhook_util_d3d9_config, config, sizeof(struct iidxhook_util_d3d9_config));
|
||||
memcpy(
|
||||
&iidxhook_util_d3d9_config,
|
||||
config,
|
||||
sizeof(struct iidxhook_util_d3d9_config));
|
||||
}
|
||||
|
||||
HRESULT iidxhook_util_d3d9_irp_handler(struct hook_d3d9_irp* irp)
|
||||
HRESULT
|
||||
iidxhook_util_d3d9_irp_handler(struct hook_d3d9_irp *irp)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
@@ -912,7 +1042,7 @@ HRESULT iidxhook_util_d3d9_irp_handler(struct hook_d3d9_irp* irp)
|
||||
iidxhook_util_d3d9_fix_create_device_apply_window_mode(irp);
|
||||
iidxhook_util_d3d9_fix_back_buffer_format(irp);
|
||||
iidxhook_util_d3d9_setup_back_buffer_scaling_pre(irp);
|
||||
|
||||
|
||||
hr = hook_d3d9_irp_invoke_next(irp);
|
||||
|
||||
if (hr == S_OK) {
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
#define IIDXHOOK_D3D9_H
|
||||
|
||||
/**
|
||||
* This module hooks into various D3D9 calls implementing a large set of features for IIDX games such as:
|
||||
* window mode, frame buffer up-/downscaling, software rate limiting, software monitor check,...
|
||||
*
|
||||
* This module hooks into various D3D9 calls implementing a large set of
|
||||
* features for IIDX games such as: window mode, frame buffer up-/downscaling,
|
||||
* software rate limiting, software monitor check,...
|
||||
*
|
||||
* @author icex2
|
||||
*/
|
||||
|
||||
@@ -14,7 +15,8 @@
|
||||
#include "hook/d3d9.h"
|
||||
|
||||
/**
|
||||
* Filter types for scaling back buffer, e.g. upscaling for higher resolution monitors.
|
||||
* Filter types for scaling back buffer, e.g. upscaling for higher resolution
|
||||
* monitors.
|
||||
*/
|
||||
enum iidxhook_util_d3d9_back_buffer_scale_filter {
|
||||
IIDXHOOK_UTIL_D3D9_BACK_BUFFER_SCALE_FILTER_NONE = 0,
|
||||
@@ -25,7 +27,8 @@ enum iidxhook_util_d3d9_back_buffer_scale_filter {
|
||||
/**
|
||||
* Callback function to receive resulting refresh rate of monitor check.
|
||||
*/
|
||||
typedef void (*iidxhook_util_d3d9_monitor_check_result_callback_t)(double refresh_rate);
|
||||
typedef void (*iidxhook_util_d3d9_monitor_check_result_callback_t)(
|
||||
double refresh_rate);
|
||||
|
||||
/**
|
||||
* Config structure for this module. Enable/disable supported features.
|
||||
@@ -35,35 +38,36 @@ struct iidxhook_util_d3d9_config {
|
||||
* Enable/disable window mode. Consider combining with framed.
|
||||
*/
|
||||
bool windowed;
|
||||
|
||||
|
||||
/**
|
||||
* Enable a window frame and make the window movable, resizable, minizable.
|
||||
*/
|
||||
bool framed;
|
||||
|
||||
/**
|
||||
* Override the default window height which is determined by the frame buffer size.
|
||||
* Set this to 0 to disable the override.
|
||||
* Override the default window height which is determined by the frame
|
||||
* buffer size. Set this to 0 to disable the override.
|
||||
*/
|
||||
uint16_t override_window_width;
|
||||
|
||||
/**
|
||||
* Override the default window width which is determined by the frame buffer size.
|
||||
* Set this to 0 to disable the override.
|
||||
* Override the default window width which is determined by the frame buffer
|
||||
* size. Set this to 0 to disable the override.
|
||||
*/
|
||||
uint16_t override_window_height;
|
||||
|
||||
/**
|
||||
* Set a software driven framerate limit for the rendering loop and lock to the specified refresh rate, e.g. 59.94.
|
||||
* Use this if the game won't sync up properly with vsync enabled.
|
||||
* Set a software driven framerate limit for the rendering loop and lock to
|
||||
* the specified refresh rate, e.g. 59.94. Use this if the game won't sync
|
||||
* up properly with vsync enabled.
|
||||
*/
|
||||
float framerate_limit;
|
||||
|
||||
/**
|
||||
* Override the GPU vendor ID identifier on display device enumeration.
|
||||
* Override the GPU vendor ID identifier on display device enumeration.
|
||||
* Use this to disable locking to specific GPU cards.
|
||||
* Combine with the pci_pid parameter.
|
||||
*
|
||||
* Combine with the pci_pid parameter.
|
||||
*
|
||||
* Vendor ATI: 1002
|
||||
*/
|
||||
uint16_t pci_vid;
|
||||
@@ -72,34 +76,37 @@ struct iidxhook_util_d3d9_config {
|
||||
* Override the GPU product ID identifier on display device enumeration.
|
||||
* Use this to disable locking to specific GPU cards.
|
||||
* Combine with the pci_pid parameter.
|
||||
*
|
||||
*
|
||||
* PIDs:
|
||||
* 7146: RV515 [Radeon X1300]
|
||||
* 95C5: RV620 LE [Radeon HD 3450]
|
||||
* 95C5: RV620 LE [Radeon HD 3450]
|
||||
*/
|
||||
uint16_t pci_pid;
|
||||
|
||||
/**
|
||||
* Enable a software "monitor check" which determines the (avg.) refresh rate
|
||||
* of the game. Ensure that your GPU is outputting a stable refresh rate to
|
||||
* your monitor. Otherwise, the resulting values fluctuate a lot.
|
||||
*
|
||||
* Callback to a function that receives the result of the monitor check once it completed.
|
||||
* Enable a software "monitor check" which determines the (avg.) refresh
|
||||
* rate of the game. Ensure that your GPU is outputting a stable refresh
|
||||
* rate to your monitor. Otherwise, the resulting values fluctuate a lot.
|
||||
*
|
||||
* Callback to a function that receives the result of the monitor check once
|
||||
* it completed.
|
||||
*/
|
||||
iidxhook_util_d3d9_monitor_check_result_callback_t iidx09_to_19_monitor_check_cb;
|
||||
iidxhook_util_d3d9_monitor_check_result_callback_t
|
||||
iidx09_to_19_monitor_check_cb;
|
||||
|
||||
/**
|
||||
* Ported from d3d8 module to enable this when using d3d8to9.
|
||||
*
|
||||
* Fixes UV coordinates for background videos on IIDX Red to DD and a quad seam issue for 14 to 17.
|
||||
* Use this if you experience the game stretching the background videos or seeing a quad seam
|
||||
* (see implementation for further details).
|
||||
*
|
||||
* Fixes UV coordinates for background videos on IIDX Red to DD and a quad
|
||||
* seam issue for 14 to 17. Use this if you experience the game stretching
|
||||
* the background videos or seeing a quad seam (see implementation for
|
||||
* further details).
|
||||
*/
|
||||
bool iidx11_to_17_fix_uvs_bg_videos;
|
||||
|
||||
/**
|
||||
* Ported from d3d8 module to enable this when using d3d8to9.
|
||||
*
|
||||
*
|
||||
* Fixes the 3D background displayed during song select by disabling fog.
|
||||
* On some machines/GPUs the background is rendered completely white which
|
||||
* is caused by buggy fog rendering. Fog is used to hide the rings appearing
|
||||
@@ -109,11 +116,12 @@ struct iidxhook_util_d3d9_config {
|
||||
|
||||
/**
|
||||
* Ported from d3d8 module to enable this when using d3d8to9.
|
||||
*
|
||||
* Fixes the 3D background displayed during song select by disabling lighting.
|
||||
* On some machines/GPUs the background is rendered completely black which
|
||||
* is caused by buggy lighting. Disabling (dynamic) lighting sets the whole
|
||||
* scene to ambient lighting which displays everything properly.
|
||||
*
|
||||
* Fixes the 3D background displayed during song select by disabling
|
||||
* lighting. On some machines/GPUs the background is rendered completely
|
||||
* black which is caused by buggy lighting. Disabling (dynamic) lighting
|
||||
* sets the whole scene to ambient lighting which displays everything
|
||||
* properly.
|
||||
*/
|
||||
bool iidx13_fix_song_select_bg;
|
||||
|
||||
@@ -124,57 +132,67 @@ struct iidxhook_util_d3d9_config {
|
||||
bool iidx14_to_19_nvidia_fix;
|
||||
|
||||
/**
|
||||
* Scale the back buffer after a frame got rendered. This allows you to up-/downscale the final frame to display
|
||||
* arbitrary resolutions, e.g. 640x480 -> 1920x1080 to allow displaying the game in the monitor's native resolution.
|
||||
* This avoids over-/underscan (yes, that's still a thing with todays TVs) or leaving the upscaling to monitors/TVs
|
||||
* that are doing a terrible job regarding picture quality or latency wise.
|
||||
*
|
||||
* @param width Target width to scale the frame to. 0 disables scaling entirely.
|
||||
* @param height Target height to scale the frame to. 0 disables scaling entirely.
|
||||
* @param filter Filtering method to use for scaling. Depending on how you scale, this can have an impact on the
|
||||
* final image quality.
|
||||
* Scale the back buffer after a frame got rendered. This allows you to
|
||||
* up-/downscale the final frame to display arbitrary resolutions, e.g.
|
||||
* 640x480 -> 1920x1080 to allow displaying the game in the monitor's native
|
||||
* resolution. This avoids over-/underscan (yes, that's still a thing with
|
||||
* todays TVs) or leaving the upscaling to monitors/TVs that are doing a
|
||||
* terrible job regarding picture quality or latency wise.
|
||||
*
|
||||
* @param width Target width to scale the frame to. 0 disables scaling
|
||||
* entirely.
|
||||
* @param height Target height to scale the frame to. 0 disables scaling
|
||||
* entirely.
|
||||
* @param filter Filtering method to use for scaling. Depending on how you
|
||||
* scale, this can have an impact on the final image quality.
|
||||
*/
|
||||
uint16_t scale_back_buffer_width;
|
||||
|
||||
/**
|
||||
* Back buffer scale height, see parameter scale_back_buffer_width for full doc.
|
||||
* Back buffer scale height, see parameter scale_back_buffer_width for full
|
||||
* doc.
|
||||
*/
|
||||
uint16_t scale_back_buffer_height;
|
||||
|
||||
/**
|
||||
* Back buffer scale filter to apply, see parameter scale_back_buffer_width for full doc.
|
||||
* Back buffer scale filter to apply, see parameter scale_back_buffer_width
|
||||
* for full doc.
|
||||
*/
|
||||
enum iidxhook_util_d3d9_back_buffer_scale_filter scale_back_buffer_filter;
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize this hook module. Must be called before any other function of this module.
|
||||
*
|
||||
* Initialize this hook module. Must be called before any other function of this
|
||||
* module.
|
||||
*
|
||||
* Games using d3d9: IIDX 14 (Gold) to IIDX 27 (Rootage)
|
||||
* For d3d8 based games (IIDX 9 to 13): use d3d8to9 wrapper to allow usage of this module.
|
||||
* For d3d8 based games (IIDX 9 to 13): use d3d8to9 wrapper to allow usage of
|
||||
* this module.
|
||||
*/
|
||||
void iidxhook_util_d3d9_hook_init(void);
|
||||
|
||||
/**
|
||||
* Initialize the provided config struct with default values.
|
||||
*
|
||||
*
|
||||
* @param config Pointer to an initialized struct to write default values to.
|
||||
*/
|
||||
void iidxhook_util_d3d9_init_config(struct iidxhook_util_d3d9_config* config);
|
||||
void iidxhook_util_d3d9_init_config(struct iidxhook_util_d3d9_config *config);
|
||||
|
||||
/**
|
||||
* Configure this module by applying the provided config.
|
||||
*
|
||||
*
|
||||
* @param config Config to apply.
|
||||
*/
|
||||
void iidxhook_util_d3d9_configure(const struct iidxhook_util_d3d9_config* config);
|
||||
void iidxhook_util_d3d9_configure(
|
||||
const struct iidxhook_util_d3d9_config *config);
|
||||
|
||||
/**
|
||||
* Main IRP handler call for this module. Must be set up with the hook/d3d9 module to receive calls from d3d9.
|
||||
*
|
||||
* Main IRP handler call for this module. Must be set up with the hook/d3d9
|
||||
* module to receive calls from d3d9.
|
||||
*
|
||||
* @param irp Pointer to a valid IRP.
|
||||
* @return S_OK on success, error otherwise (depending on the irp op).
|
||||
*/
|
||||
HRESULT iidxhook_util_d3d9_irp_handler(struct hook_d3d9_irp* irp);
|
||||
HRESULT iidxhook_util_d3d9_irp_handler(struct hook_d3d9_irp *irp);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -19,38 +19,32 @@
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static unsigned long STDCALL my_inet_addr(const char *cp);
|
||||
static int STDCALL my_connect(SOCKET s, const struct sockaddr* addr,
|
||||
int addrlen);
|
||||
static struct hostent FAR* STDCALL my_gethostbyname(const char *nameB);
|
||||
static int STDCALL
|
||||
my_connect(SOCKET s, const struct sockaddr *addr, int addrlen);
|
||||
static struct hostent FAR *STDCALL my_gethostbyname(const char *nameB);
|
||||
|
||||
static unsigned long (STDCALL *real_inet_addr)(const char *cp);
|
||||
static int (STDCALL *real_connect)(SOCKET s, const struct sockaddr* addr,
|
||||
int addrlen);
|
||||
static struct hostent FAR* (STDCALL *real_gethostbyname)(const char *nameB);
|
||||
static unsigned long(STDCALL *real_inet_addr)(const char *cp);
|
||||
static int(STDCALL *real_connect)(
|
||||
SOCKET s, const struct sockaddr *addr, int addrlen);
|
||||
static struct hostent FAR *(STDCALL *real_gethostbyname)(const char *nameB);
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static const struct hook_symbol eamuse_hook_syms[] = {
|
||||
/* WS2_32.DLL's SDK import lib generates ordinal imports, so these ordinals
|
||||
are a frozen aspect of the Win32 ABI. */
|
||||
/* WS2_32.DLL's SDK import lib generates ordinal imports, so these
|
||||
ordinals are a frozen aspect of the Win32 ABI. */
|
||||
|
||||
{
|
||||
.name = "inet_addr",
|
||||
.ordinal = 11,
|
||||
.patch = my_inet_addr,
|
||||
.link = (void **) &real_inet_addr
|
||||
},
|
||||
{
|
||||
.name = "connect",
|
||||
.ordinal = 4,
|
||||
.patch = my_connect,
|
||||
.link = (void **) &real_connect
|
||||
},
|
||||
{
|
||||
.name = "gethostbyname",
|
||||
.ordinal = 52,
|
||||
.patch = my_gethostbyname,
|
||||
.link = (void **) &real_gethostbyname
|
||||
},
|
||||
{.name = "inet_addr",
|
||||
.ordinal = 11,
|
||||
.patch = my_inet_addr,
|
||||
.link = (void **) &real_inet_addr},
|
||||
{.name = "connect",
|
||||
.ordinal = 4,
|
||||
.patch = my_connect,
|
||||
.link = (void **) &real_connect},
|
||||
{.name = "gethostbyname",
|
||||
.ordinal = 52,
|
||||
.patch = my_gethostbyname,
|
||||
.link = (void **) &real_gethostbyname},
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@@ -62,7 +56,7 @@ static struct net_addr eamuse_server_addr_resolved;
|
||||
|
||||
static unsigned long STDCALL my_inet_addr(const char *cp)
|
||||
{
|
||||
char* tmp;
|
||||
char *tmp;
|
||||
|
||||
/* for a stock machine connected to the eamuse router,
|
||||
the game wants to connect to the standard domain
|
||||
@@ -80,19 +74,23 @@ static unsigned long STDCALL my_inet_addr(const char *cp)
|
||||
return eamuse_server_addr_resolved.ipv4.addr;
|
||||
}
|
||||
|
||||
static int STDCALL my_connect(SOCKET s, const struct sockaddr* addr, int addrlen)
|
||||
static int STDCALL
|
||||
my_connect(SOCKET s, const struct sockaddr *addr, int addrlen)
|
||||
{
|
||||
char* tmp;
|
||||
char *tmp;
|
||||
|
||||
if (addr->sa_family == AF_INET) {
|
||||
/* check if we got our server's address */
|
||||
struct sockaddr_in* addr_in = (struct sockaddr_in*) addr;
|
||||
struct sockaddr_in *addr_in = (struct sockaddr_in *) addr;
|
||||
|
||||
if (addr_in->sin_addr.S_un.S_addr ==
|
||||
eamuse_server_addr_resolved.ipv4.addr) {
|
||||
if (addr_in->sin_addr.S_un.S_addr ==
|
||||
eamuse_server_addr_resolved.ipv4.addr) {
|
||||
tmp = net_addr_to_str(&eamuse_server_addr_resolved);
|
||||
log_misc("Patching port '%d' of %s to %d", ntohs(addr_in->sin_port),
|
||||
tmp, eamuse_server_addr_resolved.ipv4.port);
|
||||
log_misc(
|
||||
"Patching port '%d' of %s to %d",
|
||||
ntohs(addr_in->sin_port),
|
||||
tmp,
|
||||
eamuse_server_addr_resolved.ipv4.port);
|
||||
free(tmp);
|
||||
|
||||
addr_in->sin_port = htons(eamuse_server_addr_resolved.ipv4.port);
|
||||
@@ -102,9 +100,9 @@ static int STDCALL my_connect(SOCKET s, const struct sockaddr* addr, int addrlen
|
||||
return real_connect(s, addr, addrlen);
|
||||
}
|
||||
|
||||
static struct hostent FAR* STDCALL my_gethostbyname(const char* name)
|
||||
static struct hostent FAR *STDCALL my_gethostbyname(const char *name)
|
||||
{
|
||||
char* tmp;
|
||||
char *tmp;
|
||||
|
||||
/* for doc, checkout the other detour of inetaddr above
|
||||
this call is used starting GOLD (not used on pre GOLD) */
|
||||
@@ -121,13 +119,13 @@ static struct hostent FAR* STDCALL my_gethostbyname(const char* name)
|
||||
just populate what's touched by the game */
|
||||
static struct hostent ret;
|
||||
static uint32_t addr;
|
||||
static char* arr[2];
|
||||
static char *arr[2];
|
||||
static bool first = true;
|
||||
|
||||
if (first) {
|
||||
ret.h_length = 4;
|
||||
ret.h_addr_list = (char**) &arr;
|
||||
ret.h_addr_list[0] = (char*) &addr;
|
||||
ret.h_addr_list = (char **) &arr;
|
||||
ret.h_addr_list[0] = (char *) &addr;
|
||||
ret.h_addr_list[1] = NULL;
|
||||
ret.h_aliases = NULL;
|
||||
ret.h_name = NULL;
|
||||
@@ -143,29 +141,26 @@ static struct hostent FAR* STDCALL my_gethostbyname(const char* name)
|
||||
void eamuse_hook_init(void)
|
||||
{
|
||||
hook_table_apply(
|
||||
NULL,
|
||||
"ws2_32.dll",
|
||||
eamuse_hook_syms,
|
||||
lengthof(eamuse_hook_syms));
|
||||
NULL, "ws2_32.dll", eamuse_hook_syms, lengthof(eamuse_hook_syms));
|
||||
|
||||
log_info("Inserted eamuse hooks");
|
||||
}
|
||||
|
||||
void eamuse_set_addr(const struct net_addr* addr)
|
||||
void eamuse_set_addr(const struct net_addr *addr)
|
||||
{
|
||||
char* tmp_str;
|
||||
char* tmp_str2;
|
||||
char *tmp_str;
|
||||
char *tmp_str2;
|
||||
|
||||
log_assert(addr);
|
||||
|
||||
memcpy(&eamuse_server_addr, addr, sizeof(struct net_addr));
|
||||
|
||||
tmp_str = net_addr_to_str(&eamuse_server_addr);
|
||||
|
||||
|
||||
eamuse_server_addr_resolved.type = NET_ADDR_TYPE_IPV4;
|
||||
|
||||
if (!net_resolve_hostname_net_addr(&eamuse_server_addr,
|
||||
&eamuse_server_addr_resolved.ipv4)) {
|
||||
if (!net_resolve_hostname_net_addr(
|
||||
&eamuse_server_addr, &eamuse_server_addr_resolved.ipv4)) {
|
||||
log_fatal("Failed to resolve eamuse server address: %s", tmp_str);
|
||||
free(tmp_str);
|
||||
return;
|
||||
@@ -184,7 +179,8 @@ void eamuse_check_connection()
|
||||
if (!net_check_remote_connection(&eamuse_server_addr_resolved, 5000)) {
|
||||
log_info("Target eamuse server reachable.");
|
||||
} else {
|
||||
log_warning("Target eamuse server is not reachable. Game might throw "
|
||||
log_warning(
|
||||
"Target eamuse server is not reachable. Game might throw "
|
||||
"network errors/warnings if eamuse is enabled.");
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ void eamuse_hook_init(void);
|
||||
*
|
||||
* @param addr net_addr struct with address to the server.
|
||||
*/
|
||||
void eamuse_set_addr(const struct net_addr* addr);
|
||||
void eamuse_set_addr(const struct net_addr *addr);
|
||||
|
||||
/**
|
||||
* Check if the target eamuse server is reachable. Reports success/error using
|
||||
|
||||
@@ -17,24 +17,24 @@ static BOOL my_SetSpeakerMode(int direct_sound_struct, int a2);
|
||||
|
||||
static const struct hook_symbol effector_hook_syms[] = {
|
||||
{
|
||||
.name = "EnableEqualizer",
|
||||
.patch = my_EnableEqualizer,
|
||||
.name = "EnableEqualizer",
|
||||
.patch = my_EnableEqualizer,
|
||||
},
|
||||
{
|
||||
.name = "GetEqualizerStatus",
|
||||
.patch = my_GetEqualizerStatus,
|
||||
.name = "GetEqualizerStatus",
|
||||
.patch = my_GetEqualizerStatus,
|
||||
},
|
||||
{
|
||||
.name = "SetEqualizerGain",
|
||||
.patch = my_SetEqualizerGain,
|
||||
.name = "SetEqualizerGain",
|
||||
.patch = my_SetEqualizerGain,
|
||||
},
|
||||
{
|
||||
.name = "SetGlobalEnvironment",
|
||||
.patch = my_SetGlobalEnvironment,
|
||||
.name = "SetGlobalEnvironment",
|
||||
.patch = my_SetGlobalEnvironment,
|
||||
},
|
||||
{
|
||||
.name = "SetSpeakerMode",
|
||||
.patch = my_SetSpeakerMode,
|
||||
.name = "SetSpeakerMode",
|
||||
.patch = my_SetSpeakerMode,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -76,10 +76,7 @@ static BOOL my_SetSpeakerMode(int direct_sound_struct, int a2)
|
||||
void effector_hook_init(void)
|
||||
{
|
||||
hook_table_apply(
|
||||
NULL,
|
||||
"rteffect.dll",
|
||||
effector_hook_syms,
|
||||
lengthof(effector_hook_syms));
|
||||
NULL, "rteffect.dll", effector_hook_syms, lengthof(effector_hook_syms));
|
||||
|
||||
log_info("Inserted rteffect hooks");
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
#include "util/thread.h"
|
||||
|
||||
static int log_thread_proc(void *ctx);
|
||||
static void log_post(char level, const char *module, const char *fmt,
|
||||
va_list ap);
|
||||
static void
|
||||
log_post(char level, const char *module, const char *fmt, va_list ap);
|
||||
static void log_post_misc(const char *module, const char *fmt, ...);
|
||||
static void log_post_info(const char *module, const char *fmt, ...);
|
||||
static void log_post_warning(const char *module, const char *fmt, ...);
|
||||
@@ -39,17 +39,20 @@ void log_server_init(void)
|
||||
log_rv_consumer = CreateSemaphore(NULL, 0, 1, NULL);
|
||||
ready = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
|
||||
log_to_external(log_post_misc, log_post_info, log_post_warning,
|
||||
log_post_fatal);
|
||||
log_to_external(
|
||||
log_post_misc, log_post_info, log_post_warning, log_post_fatal);
|
||||
|
||||
log_thread_id = avs_thread_create(log_thread_proc, ready, 16384, 0);
|
||||
|
||||
if (WaitForSingleObject(ready, INFINITE)) {
|
||||
// can't do any logging here, yet.
|
||||
fprintf(stderr, "ERROR log_server_init: WaitForSingleObject failed: %08x", (unsigned int) GetLastError());
|
||||
fprintf(
|
||||
stderr,
|
||||
"ERROR log_server_init: WaitForSingleObject failed: %08x",
|
||||
(unsigned int) GetLastError());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
CloseHandle(ready);
|
||||
|
||||
log_misc("Started log server thread");
|
||||
@@ -66,10 +69,10 @@ static int log_thread_proc(void *ctx)
|
||||
log_body_misc(LOG_MODULE, "Log server thread is running");
|
||||
|
||||
while (run) {
|
||||
|
||||
if (WaitForSingleObject(log_rv_consumer, INFINITE)) {
|
||||
log_fatal("WaitForSingleObject failed: %08x",
|
||||
(unsigned int) GetLastError());
|
||||
log_fatal(
|
||||
"WaitForSingleObject failed: %08x",
|
||||
(unsigned int) GetLastError());
|
||||
}
|
||||
|
||||
switch (log_rv_level) {
|
||||
@@ -100,8 +103,8 @@ static int log_thread_proc(void *ctx)
|
||||
}
|
||||
|
||||
if (!ReleaseSemaphore(log_rv_producer, 1, NULL)) {
|
||||
log_fatal("ReleaseSemaphore failed: %08x",
|
||||
(unsigned int) GetLastError());
|
||||
log_fatal(
|
||||
"ReleaseSemaphore failed: %08x", (unsigned int) GetLastError());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,8 +113,8 @@ static int log_thread_proc(void *ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void log_post(char level, const char *module, const char *fmt,
|
||||
va_list ap)
|
||||
static void
|
||||
log_post(char level, const char *module, const char *fmt, va_list ap)
|
||||
{
|
||||
if (WaitForSingleObject(log_rv_producer, INFINITE)) {
|
||||
return;
|
||||
@@ -124,14 +127,14 @@ static void log_post(char level, const char *module, const char *fmt,
|
||||
ReleaseSemaphore(log_rv_consumer, 1, NULL);
|
||||
}
|
||||
|
||||
#define LOG_POST_IMPL(name, level) \
|
||||
#define LOG_POST_IMPL(name, level) \
|
||||
static void name(const char *module, const char *fmt, ...) \
|
||||
{ \
|
||||
va_list ap; \
|
||||
\
|
||||
va_start(ap, fmt); \
|
||||
log_post(level, module, fmt, ap); \
|
||||
va_end(ap); \
|
||||
{ \
|
||||
va_list ap; \
|
||||
\
|
||||
va_start(ap, fmt); \
|
||||
log_post(level, module, fmt, ap); \
|
||||
va_end(ap); \
|
||||
}
|
||||
|
||||
LOG_POST_IMPL(log_post_misc, 'M')
|
||||
@@ -158,4 +161,3 @@ void log_server_fini(void)
|
||||
log_rv_producer = NULL;
|
||||
log_rv_consumer = NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,12 +2,14 @@
|
||||
#define IIDXHOOK_LOG_SERVER_H
|
||||
|
||||
/**
|
||||
* Initialize the log server which creates a dedicated thread and a log message queue.
|
||||
*
|
||||
* Log messages are posted to the queue by the application and the background thread writes them to the target output.
|
||||
* Required for newer iidx and pop'n games using the avs log api (e.g. iidxhook4 to 7) due to a quirk of the ezusb
|
||||
* driver. For a full breakdown about the logging on avs (and non avs) based konami games,
|
||||
* see doc/logging-breadkdown-avs.md.
|
||||
* Initialize the log server which creates a dedicated thread and a log message
|
||||
* queue.
|
||||
*
|
||||
* Log messages are posted to the queue by the application and the background
|
||||
* thread writes them to the target output. Required for newer iidx and pop'n
|
||||
* games using the avs log api (e.g. iidxhook4 to 7) due to a quirk of the ezusb
|
||||
* driver. For a full breakdown about the logging on avs (and non avs) based
|
||||
* konami games, see doc/logging-breadkdown-avs.md.
|
||||
*/
|
||||
void log_server_init(void);
|
||||
|
||||
|
||||
@@ -17,32 +17,31 @@
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static BOOL WINAPI my_CreateDirectoryA(LPCSTR lpPathName,
|
||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes);
|
||||
static BOOL WINAPI my_CreateDirectoryA(
|
||||
LPCSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes);
|
||||
|
||||
static BOOL (WINAPI *real_CreateDirectoryA)(LPCSTR lpPathName,
|
||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes);
|
||||
static BOOL(WINAPI *real_CreateDirectoryA)(
|
||||
LPCSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes);
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static const struct hook_symbol settings_hook_syms[] = {
|
||||
{
|
||||
.name = "CreateDirectoryA",
|
||||
.patch = my_CreateDirectoryA,
|
||||
.link = (void **) &real_CreateDirectoryA
|
||||
},
|
||||
{.name = "CreateDirectoryA",
|
||||
.patch = my_CreateDirectoryA,
|
||||
.link = (void **) &real_CreateDirectoryA},
|
||||
};
|
||||
|
||||
static bool settings_folders_checked;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
BOOL WINAPI my_CreateDirectoryA(LPCSTR lpPathName,
|
||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes)
|
||||
BOOL WINAPI my_CreateDirectoryA(
|
||||
LPCSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
|
||||
{
|
||||
if ( lpPathName != NULL &&
|
||||
(lpPathName[0] == 'd' || lpPathName[0] == 'e' || lpPathName[0] == 'f') &&
|
||||
lpPathName[1] == ':') {
|
||||
if (lpPathName != NULL &&
|
||||
(lpPathName[0] == 'd' || lpPathName[0] == 'e' ||
|
||||
lpPathName[0] == 'f') &&
|
||||
lpPathName[1] == ':') {
|
||||
char new_path[MAX_PATH];
|
||||
|
||||
strcpy(new_path, lpPathName);
|
||||
@@ -55,28 +54,26 @@ BOOL WINAPI my_CreateDirectoryA(LPCSTR lpPathName,
|
||||
return real_CreateDirectoryA(lpPathName, lpSecurityAttributes);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
void settings_hook_init(void)
|
||||
{
|
||||
hook_table_apply(
|
||||
NULL,
|
||||
"kernel32.dll",
|
||||
settings_hook_syms,
|
||||
lengthof(settings_hook_syms));
|
||||
NULL, "kernel32.dll", settings_hook_syms, lengthof(settings_hook_syms));
|
||||
|
||||
log_info("Inserted settings hooks");
|
||||
}
|
||||
|
||||
HRESULT settings_hook_dispatch_irp(struct irp *irp)
|
||||
HRESULT
|
||||
settings_hook_dispatch_irp(struct irp *irp)
|
||||
{
|
||||
if (irp->op == IRP_OP_OPEN &&
|
||||
(irp->open_filename[0] == L'd' || irp->open_filename[0] == L'e' ||
|
||||
irp->open_filename[0] == L'f') && irp->open_filename[1] == L':') {
|
||||
char* log_str;
|
||||
if (irp->op == IRP_OP_OPEN &&
|
||||
(irp->open_filename[0] == L'd' || irp->open_filename[0] == L'e' ||
|
||||
irp->open_filename[0] == L'f') &&
|
||||
irp->open_filename[1] == L':') {
|
||||
char *log_str;
|
||||
|
||||
((wchar_t*) irp->open_filename)[1] = L'\\';
|
||||
((wchar_t *) irp->open_filename)[1] = L'\\';
|
||||
|
||||
wstr_narrow(irp->open_filename, &log_str);
|
||||
log_misc("Remapped settings path %s", log_str);
|
||||
|
||||
Reference in New Issue
Block a user