misc: add _snprintf hook

This commit is contained in:
Hay1tsme 2024-06-18 00:29:19 -04:00
parent 47196e0ac4
commit 42bdad96a6

View File

@ -18,6 +18,9 @@ static int WINAPI my_ShowCursor(BOOL bShow);
static BOOL WINAPI my_GetCursorInfo(PCURSORINFO pci);
static UINT WINAPI my_GetDriveTypeA(LPCSTR lpRootPathName);
static int my_snprintf(char *const buffer, const size_t buffer_count, const char *const format, ...);
static int (*next_snprintf)(char *const buffer, const size_t buffer_count, const char *const format, ...);
static HRESULT reg_read_sys_ver(void *bytes, uint32_t *nbytes);
static BOOL (WINAPI *next_BlockInput)(BOOL fBlockIt);
@ -52,6 +55,14 @@ static const struct hook_symbol misc_k32_syms[] = {
},
};
static const struct hook_symbol misc_msvcr120_syms[] = {
{
.name = "_snprintf",
.patch = my_snprintf,
.link = (void **) &next_snprintf,
},
};
static const struct reg_hook_val nbgi_reg[] = {
{
.name = L"SystemVersion",
@ -79,6 +90,12 @@ HRESULT misc_hook_init(const struct misc_config *cfg)
"kernel32.dll",
misc_k32_syms,
_countof(misc_k32_syms));
hook_table_apply(
NULL,
"MSVCR120.dll",
misc_msvcr120_syms,
_countof(misc_msvcr120_syms));
reg_hook_push_key(
HKEY_LOCAL_MACHINE,
@ -165,4 +182,15 @@ static UINT WINAPI my_GetDriveTypeA(LPCSTR lpRootPathName)
case 'j': return DRIVE_FIXED;
default: return next_GetDriveTypeA(lpRootPathName);
}
}
}
static int my_snprintf(char *const buffer, const size_t buffer_count, const char *const format, ...)
{
va_list ap;
int ret = 0;
va_start(ap, format);
ret = next_snprintf(buffer, buffer_count, format, ap);
OutputDebugStringA(buffer);
return ret;
}