-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdllmain.cpp
More file actions
59 lines (45 loc) · 1.29 KB
/
dllmain.cpp
File metadata and controls
59 lines (45 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <Windows.h>
#include <iostream>
#include <io.h>
#include <fcntl.h>
#include "renderhook.h"
void SetupConsole() {
AllocConsole();
FILE* pCout;
freopen_s(&pCout, "CONOUT$", "w", stdout);
FILE* pCerr;
freopen_s(&pCerr, "CONOUT$", "w", stderr);
FILE* pCin;
freopen_s(&pCin, "CONIN$", "r", stdin);
SetConsoleTitleA("Hook Console");
std::cout << "[+] Console allocated successfully" << std::endl;
}
void CleanupConsole() {
fclose(stdout);
fclose(stderr);
fclose(stdin);
FreeConsole();
}
DWORD WINAPI MainThread(LPVOID lpParam) {
SetupConsole();
std::cout << "[+] DLL Injected successfully" << std::endl;
// Set the rendering backend
RenderHook::SetRenderingBackend(DIRECTX11);
std::cout << "[*] Press END to unload" << std::endl;
while (!GetAsyncKeyState(VK_END)) {
Sleep(100);
}
std::cout << "[*] Unloading..." << std::endl;
RenderHook::Unhook();
Sleep(1000);
CleanupConsole();
FreeLibraryAndExitThread((HMODULE)lpParam, 0);
return 0;
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved) {
if (dwReason == DLL_PROCESS_ATTACH) {
DisableThreadLibraryCalls(hModule);
CreateThread(nullptr, 0, MainThread, hModule, 0, nullptr);
}
return TRUE;
}