//------------------------------------------------------------------------------ int hooked_fwrite(const void* data, int size, int count, void* unused) { wchar_t buf[2048]; size_t characters; DWORD written; size *= count; characters = MultiByteToWideChar( CP_UTF8, 0, (const char*)data, size, buf, sizeof_array(buf) ); characters = characters ? characters : sizeof_array(buf) - 1; buf[characters] = L'\0'; if (g_alt_fwrite_hook) { g_alt_fwrite_hook(buf); } else { HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE); WriteConsoleW(handle, buf, (DWORD)wcslen(buf), &written, NULL); } return size; }
//------------------------------------------------------------------------------ int hooked_fwrite(const void* data, int size, int count, void* unused) { wchar_t buf[2048]; size_t characters; DWORD written; size *= count; #if 0 if (*(char*)data == '\n') { static int i = 0; static const char b[] = "!@#$%^&*()_+|"; hooked_fwrite(b + (i % sizeof_array(b)), 1, 1, 0); ++i; } #endif characters = MultiByteToWideChar( CP_UTF8, 0, (const char*)data, size, buf, sizeof_array(buf) ); characters = characters ? characters : sizeof_array(buf) - 1; buf[characters] = L'\0'; if (g_alt_fwrite_hook) { g_alt_fwrite_hook(buf); } else { WriteConsoleW( GetStdHandle(STD_OUTPUT_HANDLE), buf, (DWORD)wcslen(buf), &written, NULL ); } return size; }