2023-03-20 10:26:43 +01:00
|
|
|
//=============================================================================//
|
|
|
|
//
|
|
|
|
// Purpose: SDK launcher implementation.
|
|
|
|
//
|
|
|
|
//=============================================================================//
|
2021-12-25 22:36:38 +01:00
|
|
|
#include "core/stdafx.h"
|
2022-05-23 19:14:12 +02:00
|
|
|
#include "basepanel.h"
|
2022-05-24 02:23:37 +02:00
|
|
|
#include "sdklauncher_const.h"
|
|
|
|
#include "sdklauncher.h"
|
2023-03-20 10:26:43 +01:00
|
|
|
#include "public/utility/binstream.h"
|
2022-05-23 19:14:12 +02:00
|
|
|
|
2022-05-26 22:04:50 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2023-03-20 10:26:43 +01:00
|
|
|
// Purpose: initializes and runs the user interface
|
2022-05-26 22:04:50 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2023-03-20 10:26:43 +01:00
|
|
|
void CLauncher::RunSurface()
|
2022-05-26 22:04:50 +02:00
|
|
|
{
|
|
|
|
Forms::Application::EnableVisualStyles();
|
|
|
|
UIX::UIXTheme::InitializeRenderer(new Themes::KoreTheme());
|
|
|
|
|
2023-03-20 10:26:43 +01:00
|
|
|
m_pSurface = new CUIBaseSurface();
|
2022-05-26 22:04:50 +02:00
|
|
|
Forms::Application::Run(g_pLauncher->m_pSurface);
|
|
|
|
UIX::UIXTheme::ShutdownRenderer();
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2022-09-21 20:40:34 +02:00
|
|
|
// Purpose: initializes the console (development only)
|
2022-05-26 22:04:50 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
void CLauncher::InitConsole()
|
|
|
|
{
|
|
|
|
AllocConsole();
|
|
|
|
freopen("conin$", "r", stdin);
|
|
|
|
freopen("conout$", "w", stdout);
|
|
|
|
freopen("conout$", "w", stderr);
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Purpose: initializes the logger
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
void CLauncher::InitLogger()
|
|
|
|
{
|
2023-03-19 11:20:04 +01:00
|
|
|
m_pLogger->set_pattern("[%^%l%$] %v");
|
|
|
|
m_pLogger->set_level(spdlog::level::trace);
|
|
|
|
spdlog::set_default_logger(m_pLogger); // Set as default.
|
2022-05-26 22:04:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Purpose: handles user input pre-init
|
|
|
|
// Input : argc -
|
|
|
|
// *argv -
|
2022-09-21 20:40:34 +02:00
|
|
|
// Output : exit_code (-1 if EntryPoint should continue to HandleInput)
|
2022-05-26 22:04:50 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2023-03-20 10:26:43 +01:00
|
|
|
int CLauncher::HandleCommandLine(int argc, char* argv[])
|
2022-05-26 22:04:50 +02:00
|
|
|
{
|
|
|
|
for (int i = 1; i < __argc; ++i)
|
|
|
|
{
|
|
|
|
std::string arg = __argv[i];
|
2023-03-20 10:26:43 +01:00
|
|
|
eLaunchMode mode = eLaunchMode::LM_HOST;
|
|
|
|
|
2022-09-21 20:40:34 +02:00
|
|
|
if ((arg == "-developer") || (arg == "-dev"))
|
2022-05-26 22:04:50 +02:00
|
|
|
{
|
2023-03-20 10:26:43 +01:00
|
|
|
mode = eLaunchMode::LM_HOST_DEV;
|
2022-05-26 22:04:50 +02:00
|
|
|
}
|
2023-03-20 10:26:43 +01:00
|
|
|
else if ((arg == "-retail") || (arg == "-prod"))
|
2022-05-26 22:04:50 +02:00
|
|
|
{
|
2023-03-20 10:26:43 +01:00
|
|
|
mode = eLaunchMode::LM_HOST;
|
2022-05-26 22:04:50 +02:00
|
|
|
}
|
2023-03-20 10:26:43 +01:00
|
|
|
else if ((arg == "-dedicated_dev") || (arg == "-dedid"))
|
2022-05-26 22:04:50 +02:00
|
|
|
{
|
2023-03-20 10:26:43 +01:00
|
|
|
mode = eLaunchMode::LM_SERVER_DEV;
|
2022-05-26 22:04:50 +02:00
|
|
|
}
|
2023-03-20 10:26:43 +01:00
|
|
|
else if ((arg == "-dedicated") || (arg == "-dedi"))
|
2022-05-26 22:04:50 +02:00
|
|
|
{
|
2023-03-20 10:26:43 +01:00
|
|
|
mode = eLaunchMode::LM_SERVER;
|
2022-05-26 22:04:50 +02:00
|
|
|
}
|
2023-03-20 10:26:43 +01:00
|
|
|
else if ((arg == "-client_dev") || (arg == "-cld"))
|
2022-05-26 22:04:50 +02:00
|
|
|
{
|
2023-03-20 10:26:43 +01:00
|
|
|
mode = eLaunchMode::LM_CLIENT_DEV;
|
2022-05-26 22:04:50 +02:00
|
|
|
}
|
2023-03-20 10:26:43 +01:00
|
|
|
else if ((arg == "-client") || (arg == "-cl"))
|
2022-05-26 22:04:50 +02:00
|
|
|
{
|
2023-03-20 10:26:43 +01:00
|
|
|
mode = eLaunchMode::LM_CLIENT;
|
|
|
|
}
|
2022-05-26 22:04:50 +02:00
|
|
|
|
2023-03-20 10:26:43 +01:00
|
|
|
if (CreateLaunchContext(mode) && LaunchProcess())
|
|
|
|
{
|
2022-05-26 22:04:50 +02:00
|
|
|
Sleep(2000);
|
2023-03-20 10:26:43 +01:00
|
|
|
return EXIT_SUCCESS;
|
2022-05-26 22:04:50 +02:00
|
|
|
}
|
2023-03-20 10:26:43 +01:00
|
|
|
|
|
|
|
Sleep(2000);
|
|
|
|
return EXIT_FAILURE;
|
2022-05-26 22:04:50 +02:00
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Purpose: handles user input post-init
|
|
|
|
// Output : exit_code
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
int CLauncher::HandleInput()
|
|
|
|
{
|
|
|
|
std::cout << "----------------------------------------------------------------------------------------------------------------------" << std::endl;
|
2023-03-20 10:26:43 +01:00
|
|
|
AddLog(spdlog::level::level_enum::warn, "If a DEV option has been chosen as launch parameter, do not broadcast servers to the Server Browser!\n");
|
|
|
|
AddLog(spdlog::level::level_enum::warn, "All FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY ConVar's/ConCommand's will be enabled.\n");
|
|
|
|
AddLog(spdlog::level::level_enum::warn, "Connected clients will be able to set and execute anything marked FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY.\n");
|
2022-05-26 22:04:50 +02:00
|
|
|
std::cout << "----------------------------------------------------------------------------------------------------------------------" << std::endl;
|
2023-03-20 10:26:43 +01:00
|
|
|
AddLog(spdlog::level::level_enum::warn, "Use DEV HOST [0] for research and development purposes.\n");
|
|
|
|
AddLog(spdlog::level::level_enum::warn, "Use RETAIL HOST [1] for playing the game and creating servers.\n");
|
|
|
|
AddLog(spdlog::level::level_enum::warn, "Use DEV SERVER [2] for research and development purposes.\n");
|
|
|
|
AddLog(spdlog::level::level_enum::warn, "Use RETAIL SERVER [3] for running and hosting dedicated servers.\n");
|
|
|
|
AddLog(spdlog::level::level_enum::warn, "Use DEV CLIENT [4] for research and development purposes.\n");
|
|
|
|
AddLog(spdlog::level::level_enum::warn, "Use RETAIL CLIENT [5] for running the client only game.\n");
|
2022-05-26 22:04:50 +02:00
|
|
|
std::cout << "----------------------------------------------------------------------------------------------------------------------" << std::endl;
|
2023-03-20 10:26:43 +01:00
|
|
|
AddLog(spdlog::level::level_enum::info, "Enter '0' for 'DEV HOST'.\n");
|
|
|
|
AddLog(spdlog::level::level_enum::info, "Enter '1' for 'RETAIL HOST'.\n");
|
|
|
|
AddLog(spdlog::level::level_enum::info, "Enter '2' for 'DEV SERVER'.\n");
|
|
|
|
AddLog(spdlog::level::level_enum::info, "Enter '3' for 'RETAIL SERVER'.\n");
|
|
|
|
AddLog(spdlog::level::level_enum::info, "Enter '4' for 'DEV CLIENT'.\n");
|
|
|
|
AddLog(spdlog::level::level_enum::info, "Enter '5' for 'RETAIL CLIENT'.\n");
|
2022-05-26 22:04:50 +02:00
|
|
|
std::cout << "----------------------------------------------------------------------------------------------------------------------" << std::endl;
|
|
|
|
std::cout << "User input: ";
|
|
|
|
|
2023-03-20 10:26:43 +01:00
|
|
|
std::string input;
|
2022-05-26 22:04:50 +02:00
|
|
|
if (std::cin >> input)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
eLaunchMode mode = static_cast<eLaunchMode>(std::stoi(input));
|
|
|
|
|
2023-03-20 10:26:43 +01:00
|
|
|
if (CreateLaunchContext(mode) && LaunchProcess())
|
2022-05-26 22:04:50 +02:00
|
|
|
{
|
|
|
|
Sleep(2000);
|
2023-03-20 10:26:43 +01:00
|
|
|
return EXIT_SUCCESS;
|
2022-05-26 22:04:50 +02:00
|
|
|
}
|
2023-03-20 10:26:43 +01:00
|
|
|
else
|
2022-05-26 22:04:50 +02:00
|
|
|
{
|
2023-03-20 10:26:43 +01:00
|
|
|
AddLog(spdlog::level::level_enum::err, "Invalid mode (range 0-5).\n");
|
2022-05-26 22:04:50 +02:00
|
|
|
Sleep(2000);
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
2023-03-20 10:26:43 +01:00
|
|
|
catch (const std::exception& e)
|
2022-05-26 22:04:50 +02:00
|
|
|
{
|
2023-03-20 10:26:43 +01:00
|
|
|
AddLog(spdlog::level::level_enum::err, "SDK Launcher only takes numerical input; error: {:s}.\n", e.what());
|
2022-05-26 22:04:50 +02:00
|
|
|
Sleep(2000);
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
2023-03-20 10:26:43 +01:00
|
|
|
AddLog(spdlog::level::level_enum::err, "SDK Launcher requires numerical input.\n");
|
2021-08-01 02:25:29 -07:00
|
|
|
|
2022-05-26 22:04:50 +02:00
|
|
|
Sleep(2000);
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
2022-05-24 02:23:37 +02:00
|
|
|
|
2022-05-26 22:04:50 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2023-03-20 10:26:43 +01:00
|
|
|
// Purpose: create launch context.
|
2022-05-26 22:04:50 +02:00
|
|
|
// Input : lMode -
|
|
|
|
// lState -
|
2023-03-20 10:26:43 +01:00
|
|
|
// *szCommandLine -
|
|
|
|
// Output : true on success, false otherwise.
|
2022-05-26 22:04:50 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2023-03-20 10:26:43 +01:00
|
|
|
bool CLauncher::CreateLaunchContext(eLaunchMode lMode, const char* szCommandLine /*= nullptr*/, const char* szConfig /*= nullptr*/)
|
2021-04-13 04:45:22 -07:00
|
|
|
{
|
2021-08-30 16:39:56 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
2021-08-01 02:25:29 -07:00
|
|
|
switch (lMode)
|
2021-04-13 05:05:29 -07:00
|
|
|
{
|
2022-09-21 20:40:34 +02:00
|
|
|
case eLaunchMode::LM_HOST_DEV:
|
2022-05-23 19:14:12 +02:00
|
|
|
{
|
2023-03-20 10:26:43 +01:00
|
|
|
if (!szConfig) { szConfig = "startup_dev.cfg"; }
|
2021-08-30 16:39:56 +02:00
|
|
|
|
2023-03-20 10:26:43 +01:00
|
|
|
SetupLaunchContext(szConfig, MAIN_WORKER_DLL, MAIN_GAME_DLL, szCommandLine);
|
2022-09-21 20:40:34 +02:00
|
|
|
AddLog(spdlog::level::level_enum::info, "*** LAUNCHING GAME [DEV] ***\n");
|
2022-05-23 19:14:12 +02:00
|
|
|
break;
|
|
|
|
}
|
2022-05-24 02:23:37 +02:00
|
|
|
case eLaunchMode::LM_HOST:
|
2022-05-23 19:14:12 +02:00
|
|
|
{
|
2023-03-20 10:26:43 +01:00
|
|
|
if (!szConfig) { szConfig = "startup_retail.cfg"; }
|
2021-08-30 16:39:56 +02:00
|
|
|
|
2023-03-20 10:26:43 +01:00
|
|
|
SetupLaunchContext(szConfig, MAIN_WORKER_DLL, MAIN_GAME_DLL, szCommandLine);
|
2022-09-21 20:40:34 +02:00
|
|
|
AddLog(spdlog::level::level_enum::info, "*** LAUNCHING GAME [RETAIL] ***\n");
|
2022-05-23 19:14:12 +02:00
|
|
|
break;
|
|
|
|
}
|
2022-09-21 20:40:34 +02:00
|
|
|
case eLaunchMode::LM_SERVER_DEV:
|
2022-05-23 19:14:12 +02:00
|
|
|
{
|
2023-03-20 10:26:43 +01:00
|
|
|
if (!szConfig) { szConfig = "startup_dedi_dev.cfg"; }
|
2022-01-16 12:48:56 +01:00
|
|
|
|
2023-03-20 10:26:43 +01:00
|
|
|
SetupLaunchContext(szConfig, SERVER_WORKER_DLL, SERVER_GAME_DLL, szCommandLine);
|
2022-09-21 20:40:34 +02:00
|
|
|
AddLog(spdlog::level::level_enum::info, "*** LAUNCHING DEDICATED [DEV] ***\n");
|
2022-05-23 19:14:12 +02:00
|
|
|
break;
|
|
|
|
}
|
2022-05-24 02:23:37 +02:00
|
|
|
case eLaunchMode::LM_SERVER:
|
2022-05-23 19:14:12 +02:00
|
|
|
{
|
2023-03-20 10:26:43 +01:00
|
|
|
if (!szConfig) { szConfig = "startup_dedi_retail.cfg"; }
|
2022-05-23 19:14:12 +02:00
|
|
|
|
2023-03-20 10:26:43 +01:00
|
|
|
SetupLaunchContext(szConfig, SERVER_WORKER_DLL, SERVER_GAME_DLL, szCommandLine);
|
2022-09-21 20:40:34 +02:00
|
|
|
AddLog(spdlog::level::level_enum::info, "*** LAUNCHING DEDICATED [RETAIL] ***\n");
|
2022-05-26 22:04:50 +02:00
|
|
|
break;
|
|
|
|
}
|
2022-09-21 20:40:34 +02:00
|
|
|
case eLaunchMode::LM_CLIENT_DEV:
|
2022-05-26 22:04:50 +02:00
|
|
|
{
|
2023-03-20 10:26:43 +01:00
|
|
|
if (!szConfig) { szConfig = "startup_client_dev.cfg"; }
|
2022-05-26 22:04:50 +02:00
|
|
|
|
2023-03-20 10:26:43 +01:00
|
|
|
SetupLaunchContext(szConfig, CLIENT_WORKER_DLL, MAIN_GAME_DLL, szCommandLine);
|
2022-09-21 20:40:34 +02:00
|
|
|
AddLog(spdlog::level::level_enum::info, "*** LAUNCHING CLIENT [DEV] ***\n");
|
2022-05-26 22:04:50 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case eLaunchMode::LM_CLIENT:
|
|
|
|
{
|
2023-03-20 10:26:43 +01:00
|
|
|
if (!szConfig) { szConfig = "startup_client_retail.cfg"; }
|
2022-05-26 22:04:50 +02:00
|
|
|
|
2023-03-20 10:26:43 +01:00
|
|
|
SetupLaunchContext(szConfig, CLIENT_WORKER_DLL, MAIN_GAME_DLL, szCommandLine);
|
2022-09-21 20:40:34 +02:00
|
|
|
AddLog(spdlog::level::level_enum::info, "*** LAUNCHING CLIENT [RETAIL] ***\n");
|
2022-05-23 19:14:12 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
2022-05-26 22:04:50 +02:00
|
|
|
AddLog(spdlog::level::level_enum::err, "*** NO LAUNCH MODE SPECIFIED ***\n");
|
2022-05-23 19:14:12 +02:00
|
|
|
return false;
|
|
|
|
}
|
2021-04-13 05:05:29 -07:00
|
|
|
}
|
|
|
|
|
2022-05-23 19:14:12 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-05-26 22:04:50 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2023-03-20 10:26:43 +01:00
|
|
|
// Purpose: setup launch context.
|
|
|
|
// Input : *szConfig -
|
|
|
|
// *szWorkerDll -
|
|
|
|
// *szGameDll -
|
|
|
|
// *szCommandLine -
|
2022-05-26 22:04:50 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2023-03-20 10:26:43 +01:00
|
|
|
void CLauncher::SetupLaunchContext(const char* szConfig, const char* szWorkerDll, const char* szGameDll, const char* szCommandLine)
|
2022-05-24 02:23:37 +02:00
|
|
|
{
|
2023-03-20 10:26:43 +01:00
|
|
|
CIOStream cfgFile;
|
|
|
|
string commandLine;
|
2022-05-24 02:23:37 +02:00
|
|
|
|
2023-03-20 10:26:43 +01:00
|
|
|
if (szConfig && szConfig[0])
|
2022-05-24 02:23:37 +02:00
|
|
|
{
|
2023-03-20 10:26:43 +01:00
|
|
|
if (cfgFile.Open(Format(GAME_CFG_PATH"%s", szConfig), CIOStream::READ))
|
|
|
|
{
|
|
|
|
if (!cfgFile.ReadString(commandLine))
|
|
|
|
{
|
|
|
|
AddLog(spdlog::level::level_enum::err, Format("Failed to read file '%s'!\n", szConfig));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // Failed to open config file.
|
|
|
|
{
|
|
|
|
AddLog(spdlog::level::level_enum::err, Format("Failed to open file '%s'!\n", szConfig));
|
|
|
|
}
|
2022-05-24 02:23:37 +02:00
|
|
|
}
|
|
|
|
|
2023-03-20 10:26:43 +01:00
|
|
|
if (szCommandLine && szCommandLine[0])
|
2022-05-24 02:23:37 +02:00
|
|
|
{
|
2023-03-20 10:26:43 +01:00
|
|
|
commandLine.append(szCommandLine);
|
2022-05-26 22:04:50 +02:00
|
|
|
}
|
|
|
|
|
2023-03-20 10:26:43 +01:00
|
|
|
m_svWorkerDll = Format("%s\\%s", m_svCurrentDir.c_str(), szWorkerDll);
|
|
|
|
m_svGameExe = Format("%s\\%s", m_svCurrentDir.c_str(), szGameDll);
|
|
|
|
m_svCmdLine = Format("%s\\%s %s", m_svCurrentDir.c_str(), szGameDll, commandLine.c_str());
|
2022-05-24 02:23:37 +02:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// Print the file paths and arguments.
|
|
|
|
std::cout << "----------------------------------------------------------------------------------------------------------------------" << std::endl;
|
2023-03-20 10:26:43 +01:00
|
|
|
AddLog(spdlog::level::level_enum::debug, "- CWD: {:s}\n", m_svCurrentDir);
|
|
|
|
AddLog(spdlog::level::level_enum::debug, "- EXE: {:s}\n", m_svGameExe);
|
|
|
|
AddLog(spdlog::level::level_enum::debug, "- DLL: {:s}\n", m_svWorkerDll);
|
|
|
|
AddLog(spdlog::level::level_enum::debug, "- CLI: {:s}\n", commandLine);
|
2022-05-24 02:23:37 +02:00
|
|
|
std::cout << "----------------------------------------------------------------------------------------------------------------------" << std::endl;
|
|
|
|
}
|
|
|
|
|
2022-05-26 22:04:50 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2022-05-28 16:12:56 +02:00
|
|
|
// Purpose: launches the game with results from the setup
|
2022-05-26 22:04:50 +02:00
|
|
|
// Output : true on success, false otherwise
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2023-03-20 10:26:43 +01:00
|
|
|
bool CLauncher::LaunchProcess() const
|
2022-05-23 19:14:12 +02:00
|
|
|
{
|
2021-06-17 17:07:26 -07:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
2021-04-13 04:45:22 -07:00
|
|
|
// Build our list of dlls to inject.
|
|
|
|
LPCSTR DllsToInject[1] =
|
|
|
|
{
|
2022-05-23 19:14:12 +02:00
|
|
|
m_svWorkerDll.c_str()
|
2021-04-13 04:45:22 -07:00
|
|
|
};
|
|
|
|
|
2022-03-04 16:06:36 +01:00
|
|
|
STARTUPINFOA StartupInfo = { 0 };
|
2021-08-30 16:39:56 +02:00
|
|
|
PROCESS_INFORMATION ProcInfo = { 0 };
|
|
|
|
|
|
|
|
// Initialize startup info struct.
|
2022-03-04 16:06:36 +01:00
|
|
|
StartupInfo.cb = sizeof(STARTUPINFOA);
|
2021-08-30 16:39:56 +02:00
|
|
|
|
2021-06-17 17:07:26 -07:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
2021-04-13 04:45:22 -07:00
|
|
|
// Create the game process in a suspended state with our dll.
|
2021-08-30 16:39:56 +02:00
|
|
|
BOOL result = DetourCreateProcessWithDllsA
|
|
|
|
(
|
2022-05-23 19:14:12 +02:00
|
|
|
m_svGameExe.c_str(), // lpApplicationName
|
|
|
|
(LPSTR)m_svCmdLine.c_str(), // lpCommandLine
|
2021-08-30 16:39:56 +02:00
|
|
|
NULL, // lpProcessAttributes
|
|
|
|
NULL, // lpThreadAttributes
|
|
|
|
FALSE, // bInheritHandles
|
|
|
|
CREATE_SUSPENDED, // dwCreationFlags
|
|
|
|
NULL, // lpEnvironment
|
2022-05-23 19:14:12 +02:00
|
|
|
m_svCurrentDir.c_str(), // lpCurrentDirectory
|
2021-08-30 16:39:56 +02:00
|
|
|
&StartupInfo, // lpStartupInfo
|
|
|
|
&ProcInfo, // lpProcessInformation
|
|
|
|
sizeof(DllsToInject) / sizeof(LPCSTR), // nDlls
|
|
|
|
DllsToInject, // rlpDlls
|
|
|
|
NULL // pfCreateProcessA
|
2021-04-13 04:45:22 -07:00
|
|
|
);
|
|
|
|
|
2021-06-17 17:07:26 -07:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// Failed to create the process.
|
2021-04-13 04:45:22 -07:00
|
|
|
if (!result)
|
|
|
|
{
|
|
|
|
PrintLastError();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-06-17 17:07:26 -07:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
2021-04-13 04:45:22 -07:00
|
|
|
// Resume the process.
|
|
|
|
ResumeThread(ProcInfo.hThread);
|
|
|
|
|
2021-06-17 17:07:26 -07:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
2021-04-13 04:45:22 -07:00
|
|
|
// Close the process and thread handles.
|
|
|
|
CloseHandle(ProcInfo.hProcess);
|
|
|
|
CloseHandle(ProcInfo.hThread);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-06-17 17:07:26 -07:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2022-09-21 20:40:34 +02:00
|
|
|
// EntryPoint.
|
2021-07-12 08:47:54 -07:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2021-04-13 04:45:22 -07:00
|
|
|
int main(int argc, char* argv[], char* envp[])
|
|
|
|
{
|
2022-05-26 22:04:50 +02:00
|
|
|
g_pLauncher->InitLogger();
|
|
|
|
if (__argc < 2)
|
2021-08-01 02:25:29 -07:00
|
|
|
{
|
2022-05-26 22:04:50 +02:00
|
|
|
FreeConsole();
|
2023-03-20 10:26:43 +01:00
|
|
|
g_pLauncher->RunSurface();
|
2022-05-23 19:14:12 +02:00
|
|
|
}
|
|
|
|
else
|
2021-08-19 15:26:44 +02:00
|
|
|
{
|
2023-03-20 10:26:43 +01:00
|
|
|
int results = g_pLauncher->HandleCommandLine(__argc, __argv);
|
2022-05-26 22:04:50 +02:00
|
|
|
if (results != -1)
|
|
|
|
return results;
|
2021-08-19 15:26:44 +02:00
|
|
|
|
2022-05-26 22:04:50 +02:00
|
|
|
return g_pLauncher->HandleInput();
|
2022-05-23 19:14:12 +02:00
|
|
|
}
|
|
|
|
return EXIT_SUCCESS;
|
2021-12-25 22:36:38 +01:00
|
|
|
}
|
2023-03-19 11:20:04 +01:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Singleton Launcher.
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
CLauncher* g_pLauncher(new CLauncher("win_console"));
|