WaitForWarrock()
Just a simple function some of you would probably find useful. Loops until the WarRock window is found, and returns the process ID when it finds the Window. I use a threaded version, but it's more specific than this code, but this should be an easy starting point for your trainer and/or injector.
Simple example usage:
Enjoy. Thinking about posting my simple DLL injection code, if anybody doesn't know how to to do it (tons of resources around the web) let me know, and I'll post it.
Code:
DWORD WaitForWarrock()
{
DWORD dwPID = -1; // Return value, intialized to -1 for error checking.
HWND hWarrockWnd = NULL; // Warrock window handle, initialized to NULL for error checking.
bool bFound = false; // Boolean toggle, pretty self explanatory.
while (!bFound)
{
if ((hWarrockWnd = FindWindow("WarRock", "WarRock")) != NULL)
{
// We've found Warrock's main window, now let's try to get the PID.
if (GetWindowThreadProcessId(hWarrockWnd, &dwPID))
{
// Check the dwPID value, just to be sure.
if (dwPID > 0)
{
// Yep, we found it, let's break out of this loop.
bFound = true;
}
}
}
Sleep(50); // To avoid being a complete CPU whore, I know this is dirty, but it works just fine.
}
return dwPID; // Return the process ID to the caller.
}
Code:
DWORD dwWarrockPID = WaitForWarrock();


