Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void RedirectIOToConsole()
- {
- AllocConsole();
- handle_out = GetStdHandle(STD_OUTPUT_HANDLE);
- int hCrt = _open_osfhandle((long)handle_out, _O_TEXT);
- FILE* hf_out = _fdopen(hCrt, "w");
- setvbuf(hf_out, NULL, _IONBF, 0);
- *stdout = *hf_out;
- DWORD written = 0;
- LPCWSTR message = L"Hooked successfully\n";
- WriteConsoleW(handle_out, message, lstrlenW(message), &written, nullptr);
- }
- void HookedLogf(FOutputDevice *self, const TCHAR *msg, ...)
- {
- DWORD written = 0;
- WriteConsoleW(handle_out, msg, lstrlenW(msg), &written, nullptr);
- WriteConsoleW(handle_out, "\n", 1, &written, nullptr);
- }
- bool SetHooks(void)
- {
- // ?Logf@FOutputDevice@@QAAXPB_WZZ
- PVOID Logf;
- Logf = (PVOID)GetProcAddress(LoadLibraryA("core.dll"), "?Logf@FOutputDevice@@QAAXPB_WZZ");
- DWORD protect;
- if (!VirtualProtect(Logf, 5, PAGE_EXECUTE_READWRITE, &protect))
- {
- DWORD written = 0;
- const TCHAR * msg = L"PEZDA RULYU\n";
- WriteConsoleW(handle_out, msg, lstrlenW(msg), &written, nullptr);
- return false;
- }
- *(PBYTE)Logf = 0xE9;
- *(PINT)((size_t)Logf + 1) = (INT)((size_t)&HookedLogf - ((size_t)Logf + 5));
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement