diff --git a/src/Inject.h b/src/Inject.h index 6bb0649..08d147a 100644 --- a/src/Inject.h +++ b/src/Inject.h @@ -3,7 +3,7 @@ #include const DWORD EXIT_TIME = 50000; -const DWORD WAIT_TIME = 50000; +const DWORD WAIT_TIME = 1000; DWORD GetPidByWindowName(LPCSTR windowName); HANDLE GetGameProcess(LPCSTR windowName); diff --git a/src/Main.cpp b/src/Main.cpp index 417c75a..f4a2d03 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -85,8 +85,20 @@ int main(int argc, char *argv[]) } std::cout << "Trying to get game process of " << windowName << std::endl; - std::cout << "Current error code: " << GetLastErrorString() << std::endl; - HANDLE ph = GetGameProcess(windowName.c_str()); + + HANDLE ph = NULL; + for (int i = 0; i < 20; i++) + { + std::cout << "Attempt " << i + 1 << std::endl; + ph = GetGameProcess(windowName.c_str()); + if (ph != NULL) + { + std::cout << "Found game process" << std::endl; + break; + } + Sleep(1000); + } + if (ph == NULL) { std::cout << "Failed to get game process, error: " << GetLastErrorString() << std::endl;