Merge branch 'develop' of https://github.com/auroramod/iw7-mod
This commit is contained in:
commit
e4a915c565
32
premake5.lua
32
premake5.lua
@ -296,20 +296,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++"
|
||||
@ -327,7 +313,7 @@ includedirs {"./src/client", "./src/common", "%{prj.location}/src"}
|
||||
|
||||
resincludedirs {"$(ProjectDir)src"}
|
||||
|
||||
dependson {"tlsdll", "runner"}
|
||||
dependson {"tlsdll"}
|
||||
|
||||
links {"common"}
|
||||
|
||||
@ -370,22 +356,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()
|
||||
|
||||
|
@ -18,8 +18,6 @@ namespace steam_proxy
|
||||
{
|
||||
namespace
|
||||
{
|
||||
utils::binary_resource runner_file(RUNNER, "runner.exe");
|
||||
|
||||
utils::nt::library steam_client_module_{};
|
||||
#ifdef LOAD_STEAM_OVERLAY
|
||||
utils::nt::library steam_overlay_module_{};
|
||||
@ -84,8 +82,7 @@ namespace steam_proxy
|
||||
steam_pipe_ = steam_client_module_.invoke<steam::HSteamPipe>("Steam_CreateSteamPipe");
|
||||
global_user_ = steam_client_module_.invoke<steam::HSteamUser>(
|
||||
"Steam_ConnectToGlobalUser", steam_pipe_);
|
||||
client_user_ = client_engine_.invoke<void*>(8, steam_pipe_, global_user_);
|
||||
// GetIClientUser
|
||||
client_user_ = client_engine_.invoke<void*>(8, steam_pipe_, global_user_); // GetIClientUser
|
||||
client_utils_ = client_engine_.invoke<void*>(14, steam_pipe_); // GetIClientUtils
|
||||
}
|
||||
|
||||
@ -147,36 +144,23 @@ namespace steam_proxy
|
||||
|
||||
client_utils_.invoke<void>("SetAppIDForCurrentPipe", app_id, false);
|
||||
|
||||
char our_directory[MAX_PATH] = { 0 };
|
||||
GetCurrentDirectoryA(sizeof(our_directory), our_directory);
|
||||
|
||||
const auto path = runner_file.get_extracted_file();
|
||||
const std::string cmdline = utils::string::va("\"%s\" -proc %d", path.data(), GetCurrentProcessId());
|
||||
|
||||
steam::game_id game_id;
|
||||
game_id.raw.type = 1; // k_EGameIDTypeGameMod
|
||||
game_id.raw.app_id = app_id & 0xFFFFFF;
|
||||
|
||||
const auto* mod_id = "iw7";
|
||||
game_id.raw.mod_id = *reinterpret_cast<const unsigned int*>(mod_id) | 0x80000000;
|
||||
|
||||
client_user_.invoke<bool>("SpawnProcess", path.data(), cmdline.data(), our_directory,
|
||||
&game_id.bits, title.data(), 0, 0, 0);
|
||||
|
||||
return ownership_state::success;
|
||||
}
|
||||
|
||||
ownership_state start_mod(const std::string& title, const size_t app_id)
|
||||
{
|
||||
__try
|
||||
try
|
||||
{
|
||||
return start_mod_unsafe(title, app_id);
|
||||
}
|
||||
__except (EXCEPTION_EXECUTE_HANDLER)
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
do_cleanup();
|
||||
return ownership_state::error;
|
||||
printf("Steam: %s\n", e.what());
|
||||
MessageBoxA(GetForegroundWindow(), e.what(), "Error", MB_ICONERROR);
|
||||
TerminateProcess(GetCurrentProcess(), 1234);
|
||||
}
|
||||
return ownership_state::error;
|
||||
}
|
||||
}
|
||||
|
||||
@ -218,8 +202,9 @@ namespace steam_proxy
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (std::exception& e)
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
do_cleanup();
|
||||
printf("Steam: %s\n", e.what());
|
||||
MessageBoxA(GetForegroundWindow(), e.what(), "Error", MB_ICONERROR);
|
||||
TerminateProcess(GetCurrentProcess(), 1234);
|
||||
|
@ -9,7 +9,6 @@
|
||||
#define DW_PLAYLISTS 303
|
||||
|
||||
#define TLS_DLL 304
|
||||
#define RUNNER 305
|
||||
|
||||
#define ICON_IMAGE 306
|
||||
|
||||
|
@ -107,12 +107,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…
x
Reference in New Issue
Block a user