| 22 | LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); |
| 23 | |
| 24 | int WINAPI wWinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPWSTR /*lpCmdLine*/, int /*nCmdShow*/) |
| 25 | { |
| 26 | LPWSTR* szArgList; |
| 27 | int argCount; |
| 28 | szArgList = CommandLineToArgvW(GetCommandLineW(), &argCount); |
| 29 | std::wstring programPath = szArgList[0]; |
| 30 | std::wstring programName = programPath.substr(programPath.find_last_of(L"/\\") + 1); |
| 31 | if (argCount > 1) |
| 32 | { |
| 33 | std::string applicationName = Utils::WstringToString(szArgList[1]); // league |
| 34 | std::string cmdLine; |
| 35 | for (int i = 2; i < argCount; i++) |
| 36 | { |
| 37 | cmdLine += "\"" + Utils::WstringToString(szArgList[i]) + "\" "; |
| 38 | } |
| 39 | |
| 40 | cmdLine.replace(cmdLine.find("\"--no-proxy-server\""), strlen("\"--no-proxy-server\""), ""); |
| 41 | |
| 42 | AllocConsole(); |
| 43 | FILE* f; |
| 44 | freopen_s(&f, "CONOUT$", "w", stdout); |
| 45 | |
| 46 | STARTUPINFOA startupInfo = {}; |
| 47 | startupInfo.cb = sizeof(startupInfo); |
| 48 | PROCESS_INFORMATION processInformation = {}; |
| 49 | |
| 50 | static HMODULE kernel32 = GetModuleHandleA("kernel32"); |
| 51 | static auto pCreateProcessA = (decltype(&CreateProcessA))GetProcAddress(kernel32, "CreateProcessA"); |
| 52 | if (!pCreateProcessA(applicationName.c_str(), const_cast<char*>(cmdLine.c_str()), nullptr, nullptr, false, 2U, nullptr, nullptr, &startupInfo, |
| 53 | &processInformation)) |
| 54 | return 0; |
| 55 | |
| 56 | std::cout << "App: " << applicationName << std::endl; |
| 57 | std::cout << "PID: " << processInformation.dwProcessId << std::endl; |
| 58 | std::cout << "Args: " << cmdLine << std::endl; |
| 59 | |
| 60 | static auto pDebugActiveProcessStop = (decltype(&DebugActiveProcessStop))GetProcAddress(kernel32, "DebugActiveProcessStop"); |
| 61 | if (!pDebugActiveProcessStop(processInformation.dwProcessId)) |
| 62 | { |
| 63 | CloseHandle(processInformation.hProcess); |
| 64 | CloseHandle(processInformation.hThread); |
| 65 | fclose(f); |
| 66 | FreeConsole(); |
| 67 | return 0; |
| 68 | } |
| 69 | |
| 70 | static auto pWaitForSingleObject = (decltype(&WaitForSingleObject))GetProcAddress(kernel32, "WaitForSingleObject"); |
| 71 | pWaitForSingleObject(processInformation.hProcess, INFINITE); |
| 72 | |
| 73 | std::cout << "Exited" << std::endl; |
| 74 | |
| 75 | CloseHandle(processInformation.hProcess); |
| 76 | CloseHandle(processInformation.hThread); |
| 77 | std::this_thread::sleep_for(std::chrono::milliseconds(1000)); |
| 78 | fclose(f); |
| 79 | FreeConsole(); |
| 80 | } |
| 81 | else |
nothing calls this directly
no test coverage detected