Windows attach dll

pull/337/head^2
FlightlessMango 4 years ago
parent b7aa6a997b
commit 3ffa1bed7a

@ -30,7 +30,7 @@ vklayer_files = []
opengl_files = []
if ['windows', 'mingw'].contains(host_machine.system())
vklayer_files += files(
'win/main.cpp'
)
endif

@ -0,0 +1,32 @@
#include "windows.h"
#include <cstdio>
void ConsoleSetup()
{
// With this trick we'll be able to print content to the console, and if we have luck we could get information printed by the game.
AllocConsole();
SetConsoleTitle("MangoHud");
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
freopen("CONIN$", "r", stdin);
}
int MainThread(){
ConsoleSetup();
return 0;
}
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD fdwReason, LPVOID)
{
DisableThreadLibraryCalls(hInstance);
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)MainThread, NULL, 0, NULL);
break;
}
return TRUE;
}
Loading…
Cancel
Save