Remove runner
This commit is contained in:
parent
4ab61d8242
commit
841c26762a
32
premake5.lua
32
premake5.lua
@ -280,20 +280,6 @@ resincludedirs {"$(ProjectDir)src"}
|
||||
|
||||
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"
|
||||
kind "ConsoleApp"
|
||||
language "C++"
|
||||
@ -311,7 +297,7 @@ includedirs {"./src/client", "./src/common", "%{prj.location}/src"}
|
||||
|
||||
resincludedirs {"$(ProjectDir)src"}
|
||||
|
||||
dependson {"tlsdll", "runner"}
|
||||
dependson {"tlsdll"}
|
||||
|
||||
links {"common"}
|
||||
|
||||
@ -335,22 +321,6 @@ links {"common"}
|
||||
|
||||
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"
|
||||
dependencies.projects()
|
||||
|
||||
|
@ -17,9 +17,8 @@
|
||||
#define MENU_MAIN 310
|
||||
|
||||
#define TLS_DLL 311
|
||||
#define RUNNER 312
|
||||
|
||||
#define ICON_IMAGE 313
|
||||
#define ICON_IMAGE 312
|
||||
|
||||
#define LUA_JSON_SCRIPT 315
|
||||
#define LUI_UPDATER_MENU 316
|
||||
#define LUA_JSON_SCRIPT 313
|
||||
#define LUI_UPDATER_MENU 314
|
||||
|
@ -106,12 +106,6 @@ TLS_DLL RCDATA "../../build/bin/x64/Debug/tlsdll.dll"
|
||||
TLS_DLL RCDATA "../../build/bin/x64/Release/tlsdll.dll"
|
||||
#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"
|
||||
|
||||
#endif // English (United States) resources
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
};
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user