Okay so basically I am injecting my dll into a game and then creating a thread within the game so I may have access, now my code is like 38 lines long and it's as BASIC as it can get, yet, whenever I inject it crashes. I have determined the reason for crashing is the CreateThread call, but I can't see what I've done wrong with it. Can someone look at my code because I've been at this for hours.
Code:
#include <windows.h>
#define game "League of Legends (TM) Client"
#define game2 "PVP.net Client"
HWND hWnd;
HANDLE HndThread;
int Thread()
{
hWnd = FindWindow(NULL,game);
while(1)
{
if(GetAsyncKeyState(VK_F12)&1)
{
ShowWindow(hWnd,SW_MINIMIZE);
}
if(GetAsyncKeyState(VK_F10)&1)
{
return 0;
}
Sleep(1);
}
}
BOOL APIENTRY DllMain( HMODULE hModule,DWORD reason,LPVOID lpReserved)
{
if(reason == DLL_PROCESS_ATTACH)
{
hWnd = FindWindow(NULL,game);
if(hWnd == NULL)
{
MessageBox(hWnd,"Could not find window.","Not Found",0);
return 0;
}
else
{
HndThread = CreateThread(0,0,(LPTHREAD_START_ROUTINE)&Thread,NULL,0,NULL);
}
}
return 0;
}
Now I realize the only purpose of this code is to minimize the game, but that's not my issue. Yes the game is a bitch to minimize because it is set to always on top etc. But my real problem is the fact I can't even inject it. Whenever I inject it crashes, and it's for sure the line
Code:
HndThread = CreateThread(0,0,(LPTHREAD_START_ROUTINE)&Thread,NULL,0,NULL);
Because when I comment it out the game doesn't crash, but it still crashes even if I call nothing in CreateThread, or if I comment everything inside Thread()
Any help is appreciated.
Edit: It's also not the injector, I've been using it for years.
~lilneo