[Proxy] Correctly set app config
This commit is contained in:
parent
4ff7b8f105
commit
495a55e135
@ -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<bool>("SpawnProcess", ourPath, cmdline.data(), 0, ourDirectory, gameID.Bits, Proxy::AppId, mod.data(), 0, 0);
|
||||
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 };
|
||||
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<bool>("SpawnProcess", ourPath, cmdline.data(), 0, ourDirectory, gameID.bits, Proxy::AppId, mod.data(), 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void Proxy::RunMod()
|
||||
|
@ -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<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
|
||||
{
|
||||
public:
|
||||
|
@ -31,7 +31,7 @@ typedef union
|
||||
unsigned int m_nModID : 32;
|
||||
};
|
||||
|
||||
unsigned long long Bits;
|
||||
unsigned long long bits;
|
||||
} GameID_t;
|
||||
#pragma pack( pop )
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user