[Proxy] Correctly set app config

This commit is contained in:
momo5502 2017-02-17 13:19:48 +01:00
parent 4ff7b8f105
commit 495a55e135
3 changed files with 71 additions and 7 deletions

View File

@ -98,6 +98,22 @@ namespace Steam
gameID.m_nAppID = Proxy::AppId & 0xFFFFFF; gameID.m_nAppID = Proxy::AppId & 0xFFFFFF;
gameID.m_nModID = 0xBAADF00D; gameID.m_nModID = 0xBAADF00D;
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;
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 str = builder.getString();
uint32_t uniqueId = clientShortcuts.invoke<uint32_t>("GetUniqueLocalAppId");
if (clientApps.invoke<bool>("SetLocalAppConfig", uniqueId, str.data(), static_cast<uint32_t>(str.size())))
{
char ourPath[MAX_PATH] = { 0 }; char ourPath[MAX_PATH] = { 0 };
GetModuleFileNameA(GetModuleHandle(nullptr), ourPath, sizeof(ourPath)); GetModuleFileNameA(GetModuleHandle(nullptr), ourPath, sizeof(ourPath));
@ -105,7 +121,8 @@ namespace Steam
GetCurrentDirectoryA(sizeof(ourDirectory), ourDirectory); GetCurrentDirectoryA(sizeof(ourDirectory), ourDirectory);
std::string cmdline = ::Utils::String::VA("\"%s\" -proc %d", ourPath, GetCurrentProcessId()); std::string cmdline = ::Utils::String::VA("\"%s\" -proc %d", ourPath, GetCurrentProcessId());
Proxy::ClientUser.invoke<bool>("SpawnProcess", ourPath, cmdline.data(), 0, ourDirectory, gameID.Bits, Proxy::AppId, mod.data(), 0, 0); Proxy::ClientUser.invoke<bool>("SpawnProcess", ourPath, cmdline.data(), 0, ourDirectory, gameID.bits, Proxy::AppId, mod.data(), 0, 0);
}
} }
void Proxy::RunMod() void Proxy::RunMod()

View File

@ -131,6 +131,53 @@ namespace Steam
std::string getMethodName(unsigned char* methodPtr); 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<const char*>(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 class Proxy
{ {
public: public:

View File

@ -31,7 +31,7 @@ typedef union
unsigned int m_nModID : 32; unsigned int m_nModID : 32;
}; };
unsigned long long Bits; unsigned long long bits;
} GameID_t; } GameID_t;
#pragma pack( pop ) #pragma pack( pop )