Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. void RedirectIOToConsole()
  2. {
  3.     AllocConsole();
  4.     handle_out = GetStdHandle(STD_OUTPUT_HANDLE);
  5.     int hCrt = _open_osfhandle((long)handle_out, _O_TEXT);
  6.     FILE* hf_out = _fdopen(hCrt, "w");
  7.     setvbuf(hf_out, NULL, _IONBF, 0);
  8.     *stdout = *hf_out;
  9.  
  10.     DWORD written = 0;
  11.     LPCWSTR message = L"Hooked successfully\n";
  12.     WriteConsoleW(handle_out, message, lstrlenW(message), &written, nullptr);
  13. }
  14.  
  15. void HookedLogf(FOutputDevice *self, const TCHAR *msg, ...)
  16. {
  17.     DWORD written = 0;
  18.     WriteConsoleW(handle_out, msg, lstrlenW(msg), &written, nullptr);
  19.     WriteConsoleW(handle_out, "\n", 1, &written, nullptr);
  20. }
  21.  
  22. bool SetHooks(void)
  23. {
  24.     // ?Logf@FOutputDevice@@QAAXPB_WZZ
  25.    
  26.     PVOID Logf;
  27.     Logf = (PVOID)GetProcAddress(LoadLibraryA("core.dll"), "?Logf@FOutputDevice@@QAAXPB_WZZ");
  28.  
  29.     DWORD protect;
  30.     if (!VirtualProtect(Logf, 5, PAGE_EXECUTE_READWRITE, &protect))
  31.     {
  32.         DWORD written = 0;
  33.         const TCHAR * msg = L"PEZDA RULYU\n";
  34.         WriteConsoleW(handle_out, msg, lstrlenW(msg), &written, nullptr);
  35.         return false;
  36.     }
  37.     *(PBYTE)Logf = 0xE9;
  38.     *(PINT)((size_t)Logf + 1) = (INT)((size_t)&HookedLogf - ((size_t)Logf + 5));
  39.  
  40.     return true;
  41. }