diff --git a/src/Steam/Proxy.cpp b/src/Steam/Proxy.cpp index 45fcf5cf..cc647509 100644 --- a/src/Steam/Proxy.cpp +++ b/src/Steam/Proxy.cpp @@ -98,14 +98,31 @@ namespace Steam gameID.m_nAppID = Proxy::AppId & 0xFFFFFF; gameID.m_nModID = 0xBAADF00D; - char ourPath[MAX_PATH] = { 0 }; - GetModuleFileNameA(GetModuleHandle(nullptr), ourPath, sizeof(ourPath)); + Interface clientApps(Proxy::ClientEngine->GetIClientApps(Proxy::SteamUser, Proxy::SteamPipe, "CLIENTAPPS_INTERFACE_VERSION001")); + Interface clientShortcuts(Proxy::ClientEngine->GetIClientShortcuts(Proxy::SteamUser, Proxy::SteamPipe, "CLIENTSHORTCUTS_INTERFACE_VERSION001")); + if (!clientApps || clientShortcuts) return; - char ourDirectory[MAX_PATH] = { 0 }; - GetCurrentDirectoryA(sizeof(ourDirectory), ourDirectory); + KeyValuesBuilder builder; + builder.packString("name", mod.data()); + builder.packUint64("gameid", gameID.bits); + builder.packString("installed", "1"); + builder.packString("gamedir", "IW4x"); + builder.packString("serverbrowsername", "IW4x"); + builder.packEnd(); - std::string cmdline = ::Utils::String::VA("\"%s\" -proc %d", ourPath, GetCurrentProcessId()); - Proxy::ClientUser.invoke("SpawnProcess", ourPath, cmdline.data(), 0, ourDirectory, gameID.Bits, Proxy::AppId, mod.data(), 0, 0); + std::string str = builder.getString(); + uint32_t uniqueId = clientShortcuts.invoke("GetUniqueLocalAppId"); + if (clientApps.invoke("SetLocalAppConfig", uniqueId, str.data(), static_cast(str.size()))) + { + char ourPath[MAX_PATH] = { 0 }; + GetModuleFileNameA(GetModuleHandle(nullptr), ourPath, sizeof(ourPath)); + + char ourDirectory[MAX_PATH] = { 0 }; + GetCurrentDirectoryA(sizeof(ourDirectory), ourDirectory); + + std::string cmdline = ::Utils::String::VA("\"%s\" -proc %d", ourPath, GetCurrentProcessId()); + Proxy::ClientUser.invoke("SpawnProcess", ourPath, cmdline.data(), 0, ourDirectory, gameID.bits, Proxy::AppId, mod.data(), 0, 0); + } } void Proxy::RunMod() diff --git a/src/Steam/Proxy.hpp b/src/Steam/Proxy.hpp index 603fee08..229571be 100644 --- a/src/Steam/Proxy.hpp +++ b/src/Steam/Proxy.hpp @@ -131,6 +131,53 @@ namespace Steam std::string getMethodName(unsigned char* methodPtr); }; + class KeyValuesBuilder + { + private: + std::stringstream m_buffer; + + inline void packBytes(const void* bytes, size_t size) + { + m_buffer << std::string(reinterpret_cast(bytes), size); + } + + inline void packDataType(uint8_t type) + { + packBytes(&type, 1); + } + + inline void packNullTerminated(const char* string) + { + packBytes(string, strlen(string) + 1); + } + + public: + inline void packString(const char* key, const char* value) + { + packDataType(1); + packNullTerminated(key); + packNullTerminated(value); + } + + inline void packUint64(const char* key, uint64_t value) + { + packDataType(7); + packNullTerminated(key); + packBytes(&value, sizeof(value)); + } + + inline void packEnd() + { + packDataType(8); + } + + inline std::string getString() + { + return m_buffer.str(); + } + }; + + class Proxy { public: diff --git a/src/Steam/Steam.hpp b/src/Steam/Steam.hpp index 657aa0c7..082a5d9e 100644 --- a/src/Steam/Steam.hpp +++ b/src/Steam/Steam.hpp @@ -31,7 +31,7 @@ typedef union unsigned int m_nModID : 32; }; - unsigned long long Bits; + unsigned long long bits; } GameID_t; #pragma pack( pop )