Remove runner

This commit is contained in:
Federico Cecchetto 2022-02-17 20:01:56 +01:00
parent 4ab61d8242
commit 841c26762a
7 changed files with 4 additions and 277 deletions

View File

@ -280,20 +280,6 @@ resincludedirs {"$(ProjectDir)src"}
dependencies.imports() dependencies.imports()
project "runner"
kind "WindowedApp"
language "C++"
files {"./src/runner/**.rc", "./src/runner/**.hpp", "./src/runner/**.cpp", "./src/runner/resources/**.*"}
includedirs {"./src/runner", "./src/common", "%{prj.location}/src"}
resincludedirs {"$(ProjectDir)src"}
links {"common"}
dependencies.imports()
project "client" project "client"
kind "ConsoleApp" kind "ConsoleApp"
language "C++" language "C++"
@ -311,7 +297,7 @@ includedirs {"./src/client", "./src/common", "%{prj.location}/src"}
resincludedirs {"$(ProjectDir)src"} resincludedirs {"$(ProjectDir)src"}
dependson {"tlsdll", "runner"} dependson {"tlsdll"}
links {"common"} links {"common"}
@ -335,22 +321,6 @@ links {"common"}
resincludedirs {"$(ProjectDir)src"} resincludedirs {"$(ProjectDir)src"}
project "runner"
kind "WindowedApp"
language "C++"
files {"./src/runner/**.rc", "./src/runner/**.hpp", "./src/runner/**.cpp", "./src/runner/resources/**.*"}
includedirs {"./src/runner", "./src/common", "%{prj.location}/src"}
links {"common"}
resincludedirs {"$(ProjectDir)src"}
links {"common"}
dependencies.imports()
group "Dependencies" group "Dependencies"
dependencies.projects() dependencies.projects()

View File

@ -17,9 +17,8 @@
#define MENU_MAIN 310 #define MENU_MAIN 310
#define TLS_DLL 311 #define TLS_DLL 311
#define RUNNER 312
#define ICON_IMAGE 313 #define ICON_IMAGE 312
#define LUA_JSON_SCRIPT 315 #define LUA_JSON_SCRIPT 313
#define LUI_UPDATER_MENU 316 #define LUI_UPDATER_MENU 314

View File

@ -106,12 +106,6 @@ TLS_DLL RCDATA "../../build/bin/x64/Debug/tlsdll.dll"
TLS_DLL RCDATA "../../build/bin/x64/Release/tlsdll.dll" TLS_DLL RCDATA "../../build/bin/x64/Release/tlsdll.dll"
#endif #endif
#ifdef _DEBUG
RUNNER RCDATA "../../build/bin/x64/Debug/runner.exe"
#else
RUNNER RCDATA "../../build/bin/x64/Release/runner.exe"
#endif
ICON_IMAGE RCDATA "resources/icon.png" ICON_IMAGE RCDATA "resources/icon.png"
#endif // English (United States) resources #endif // English (United States) resources

View File

@ -1,95 +0,0 @@
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include "debugger.hpp"
namespace
{
bool acquire_debug_privilege()
{
TOKEN_PRIVILEGES token_privileges;
ZeroMemory(&token_privileges, sizeof(token_privileges));
token_privileges.PrivilegeCount = 1;
HANDLE token;
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &token))
{
return false;
}
if (!LookupPrivilegeValue(nullptr, SE_DEBUG_NAME, &token_privileges.Privileges[0].Luid))
{
CloseHandle(token);
return false;
}
token_privileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
DWORD size;
if (!AdjustTokenPrivileges(token, FALSE, &token_privileges, 0, nullptr, &size))
{
CloseHandle(token);
return false;
}
return CloseHandle(token) != FALSE;
}
}
debugger::debugger(const unsigned long process_id, const bool start)
{
if (!start)
{
return;
}
this->runner_ = std::thread([this, process_id]()
{
this->terminate_ = false;
this->run(process_id);
});
}
debugger::~debugger()
{
this->terminate_ = true;
if (this->runner_.joinable())
{
this->runner_.join();
}
}
void debugger::run(const unsigned long process_id) const
{
acquire_debug_privilege();
if (!DebugActiveProcess(process_id))
{
return;
}
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
DEBUG_EVENT event;
while (!this->terminate_ && WaitForDebugEvent(&event,INFINITE))
{
if (event.dwDebugEventCode == EXCEPTION_DEBUG_EVENT)
{
ContinueDebugEvent(event.dwProcessId, event.dwThreadId, DBG_EXCEPTION_NOT_HANDLED);
continue;
}
if (event.dwDebugEventCode == EXIT_PROCESS_DEBUG_EVENT)
{
ContinueDebugEvent(event.dwProcessId, event.dwThreadId, DBG_CONTINUE);
break;
}
#ifdef DEV_BUILD
if (event.dwDebugEventCode == CREATE_PROCESS_DEBUG_EVENT)
{
OutputDebugStringA("Debugger attached!\n");
}
#endif
ContinueDebugEvent(event.dwProcessId, event.dwThreadId, DBG_CONTINUE);
}
}

View File

@ -1,15 +0,0 @@
#pragma once
#include <thread>
class debugger
{
public:
debugger(unsigned long process_id, bool start);
~debugger();
private:
volatile bool terminate_ = false;
std::thread runner_;
void run(unsigned long process_id) const;
};

View File

@ -1,100 +0,0 @@
// Microsoft Visual C++ generated resource script.
//
#pragma code_page(65001)
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "windows.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (United States) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"#include ""windows.h""\r\n"
"\0"
END
2 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,0
PRODUCTVERSION 1,0,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE VFT_DLL
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "X Labs"
VALUE "FileDescription", "Steam mod runner"
VALUE "FileVersion", "1.0.0.0"
VALUE "InternalName", "Runner"
VALUE "LegalCopyright", "All rights reserved."
VALUE "OriginalFilename", "runner.exe"
VALUE "ProductName", "runner"
VALUE "ProductVersion", "1.0.0.0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
/////////////////////////////////////////////////////////////////////////////
//
// Binary Data
//
102 ICON "../client/resources/icon.ico"
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -1,26 +0,0 @@
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <cstdlib>
#include "debugger.hpp"
int __stdcall WinMain(HINSTANCE, HINSTANCE, PSTR, int)
{
const auto* const command = "-proc ";
const char* parent_proc = strstr(GetCommandLineA(), command);
if (parent_proc)
{
const auto pid = DWORD(atoi(parent_proc + strlen(command)));
auto* const process_handle = OpenProcess(SYNCHRONIZE, FALSE, pid);
if (process_handle)
{
//debugger _(pid, strstr(GetCommandLineA(), "-debug ") != nullptr);
WaitForSingleObject(process_handle, INFINITE);
CloseHandle(process_handle);
return 0;
}
}
return 1;
}