diff --git a/mai2hook/touch.c b/mai2hook/touch.c index 3241655..e34fb89 100644 --- a/mai2hook/touch.c +++ b/mai2hook/touch.c @@ -229,7 +229,6 @@ static HRESULT touch_cmd_dispatch(char* cmd, struct iobuf *dest, uint8_t side) else if (!strcmp(cmd, CMD_HALT)) { dprintf("Mai2 touch%d: Halt\n", side); - Sleep(1001); // ? return S_OK; } diff --git a/platform/misc.c b/platform/misc.c index 040a249..4c36c9d 100644 --- a/platform/misc.c +++ b/platform/misc.c @@ -14,6 +14,8 @@ #include "util/dprintf.h" static BOOL WINAPI misc_ExitWindowsEx(unsigned int flags, uint32_t reason); +static int my_vsprintf(char *const buffer, const char *const format, va_list args); +static int (*next_vsprintf)(char *const buffer, const char *const format, va_list args); static HRESULT misc_read_os_version(void *bytes, uint32_t *nbytes); static HRESULT misc_read_app_loader_count(void *bytes, uint32_t *nbytes); @@ -29,6 +31,14 @@ static const struct hook_symbol misc_syms[] = { } }; +static const struct hook_symbol logging_sym[] = { + { + .name = "vsprintf", + .patch = my_vsprintf, + .link = (void **) &next_vsprintf, + } +}; + static const struct reg_hook_val misc_root_keys[] = { { .name = L"OSVersion", @@ -130,6 +140,7 @@ HRESULT misc_hook_init(const struct misc_config *cfg, const char *platform_id) /* Apply function hooks */ hook_table_apply(NULL, "user32.dll", misc_syms, _countof(misc_syms)); + hook_table_apply(NULL, "msvcr110.dll", logging_sym, _countof(logging_sym)); return S_OK; } @@ -170,3 +181,10 @@ static HRESULT misc_read_platform_name(void *bytes, uint32_t *nbytes) { return reg_hook_read_wstr(bytes, nbytes, L"ALLS MX2.1"); // TODO: Dynamic } + +static int my_vsprintf(char *const buffer, const char *const format, va_list args) +{ + int ret = next_vsprintf(buffer, format, args); + dprintf("%s\n", buffer); + return ret; +}