[Steam] Only handle overlay related operations in the client

This commit is contained in:
momo5502 2017-01-27 22:04:11 +01:00
parent 4e84c297e4
commit d79493d6d7
3 changed files with 32 additions and 84 deletions

View File

@ -5,17 +5,17 @@ namespace Steam
::Utils::Library Proxy::Client; ::Utils::Library Proxy::Client;
::Utils::Library Proxy::Overlay; ::Utils::Library Proxy::Overlay;
ISteamClient008* Proxy::SteamClient; ISteamClient008* Proxy::SteamClient = nullptr;
IClientEngine* Proxy::ClientEngine; IClientEngine* Proxy::ClientEngine = nullptr;
IClientUser* Proxy::ClientUser; IClientUser* Proxy::ClientUser = nullptr;
void* Proxy::SteamPipe; void* Proxy::SteamPipe = nullptr;
void* Proxy::SteamUser; void* Proxy::SteamUser = nullptr;
Friends15* Proxy::SteamFriends; Friends15* Proxy::SteamFriends = nullptr;
Utils* Proxy::SteamUtils; Utils* Proxy::SteamUtils = nullptr;
uint32_t Proxy::AppId; uint32_t Proxy::AppId = 0;
std::recursive_mutex Proxy::CallMutex; std::recursive_mutex Proxy::CallMutex;
std::vector<Proxy::CallContainer> Proxy::Calls; std::vector<Proxy::CallContainer> Proxy::Calls;
@ -29,54 +29,15 @@ namespace Steam
{ {
Proxy::AppId = appId; Proxy::AppId = appId;
SetEnvironmentVariableA("SteamAppId", ::Utils::String::VA("%lu", appId)); // if (!Components::Flags::HasFlag("nosteam"))
SetEnvironmentVariableA("SteamGameId", ::Utils::String::VA("%llu", appId & 0xFFFFFF)); // {
// SetEnvironmentVariableA("SteamAppId", ::Utils::String::VA("%lu", appId));
// SetEnvironmentVariableA("SteamGameId", ::Utils::String::VA("%llu", appId & 0xFFFFFF));
//
// ::Utils::IO::WriteFile("steam_appid.txt", ::Utils::String::VA("%lu", appId), false);
// }
::Utils::IO::WriteFile("steam_appid.txt", ::Utils::String::VA("%lu", appId), false); remove("steam_appid.txt");
}
void Proxy::SetMod(std::string mod)
{
#if 0
if (!Proxy::ClientUser) return;
GameID_t gameID;
gameID.m_nType = 1; // k_EGameIDTypeGameMod
gameID.m_nAppID = Proxy::AppId & 0xFFFFFF;
gameID.m_nModID = 0x01010101;
char ourPath[MAX_PATH] = { 0 };
GetModuleFileNameA(GetModuleHandle(nullptr), ourPath, sizeof(ourPath));
char ourDirectory[MAX_PATH] = { 0 };
GetCurrentDirectoryA(sizeof(ourDirectory), ourDirectory);
char blob[1] = { 0 };
std::string cmdline = ::Utils::String::VA("\"%s\" -parentProc %d", ourPath, GetCurrentProcessId());
Proxy::ClientUser->SpawnProcess(blob, 0, ourPath, cmdline.data(), 0, ourDirectory, gameID, Proxy::AppId, mod.data(), 0);
#endif
}
void Proxy::RunMod()
{
char* command = "-parentProc ";
char* parentProc = strstr(GetCommandLineA(), command);
if (parentProc)
{
parentProc += strlen(command);
int pid = atoi(parentProc);
HANDLE processHandle = OpenProcess(SYNCHRONIZE, FALSE, pid);
if (processHandle && processHandle != INVALID_HANDLE_VALUE)
{
WaitForSingleObject(processHandle, INFINITE);
CloseHandle(processHandle);
}
TerminateProcess(GetCurrentProcess(), 0);
}
} }
void Proxy::RegisterCall(int32_t callId, uint32_t size, uint64_t call) void Proxy::RegisterCall(int32_t callId, uint32_t size, uint64_t call)
@ -142,13 +103,13 @@ namespace Steam
} }
Proxy::CallbackMsg message; Proxy::CallbackMsg message;
while (Proxy::SteamBGetCallback(Proxy::SteamPipe, &message)) while (Proxy::SteamBGetCallback && Proxy::SteamFreeLastCallback && Proxy::SteamBGetCallback(Proxy::SteamPipe, &message))
{ {
#ifdef DEBUG #ifdef DEBUG
Components::Logger::Print("Steam::Proxy: Callback dispatched: %d\n", message.m_iCallback); printf("Callback dispatched: %d\n", message.m_iCallback);
#endif #endif
Steam::Callbacks::RunCallback(message.m_iCallback, message.m_pubParam); //Steam::Callbacks::RunCallback(message.m_iCallback, message.m_pubParam);
Proxy::RunCallback(message.m_iCallback, message.m_pubParam); Proxy::RunCallback(message.m_iCallback, message.m_pubParam);
Proxy::SteamFreeLastCallback(Proxy::SteamPipe); Proxy::SteamFreeLastCallback(Proxy::SteamPipe);
} }
@ -163,7 +124,7 @@ namespace Steam
::Utils::Memory::Allocator allocator; ::Utils::Memory::Allocator allocator;
#ifdef DEBUG #ifdef DEBUG
Components::Logger::Print("Steam::Proxy: Handling call: %d\n", call.callId); printf("Handling call: %d\n", call.callId);
#endif #endif
call.handled = true; call.handled = true;
@ -172,7 +133,7 @@ namespace Steam
{ {
#ifdef DEBUG #ifdef DEBUG
auto error = Proxy::SteamUtils->GetAPICallFailureReason(call.call); auto error = Proxy::SteamUtils->GetAPICallFailureReason(call.call);
Components::Logger::Print("Steam::Proxy: API call failed: %X Handle: %llX\n", error, call.call); printf("API call failed: %X Handle: %llX\n", error, call.call);
#endif #endif
continue; continue;
} }
@ -185,7 +146,7 @@ namespace Steam
{ {
#ifdef DEBUG #ifdef DEBUG
auto error = Proxy::SteamUtils->GetAPICallFailureReason(call.call); auto error = Proxy::SteamUtils->GetAPICallFailureReason(call.call);
Components::Logger::Print("Steam::Proxy: GetAPICallResult failed: %X Handle: %llX\n", error, call.call); printf("GetAPICallResult failed: %X Handle: %llX\n", error, call.call);
#endif #endif
continue; continue;
} }
@ -198,16 +159,19 @@ namespace Steam
Proxy::UnregisterCalls(); Proxy::UnregisterCalls();
} }
bool Proxy::Inititalize() bool Proxy::Inititalize(bool overlayOnly)
{ {
std::string directoy = Proxy::GetSteamDirectory(); std::string directoy = Proxy::GetSteamDirectory();
if (directoy.empty()) return false; if (directoy.empty()) return false;
SetDllDirectoryA(Proxy::GetSteamDirectory().data()); SetDllDirectoryA(Proxy::GetSteamDirectory().data());
Proxy::Client = ::Utils::Library(STEAMCLIENT_LIB, false);
Proxy::Overlay = ::Utils::Library(GAMEOVERLAY_LIB, false); Proxy::Overlay = ::Utils::Library(GAMEOVERLAY_LIB, false);
if (!Proxy::Client.valid() || !Proxy::Overlay.valid()) return false; if (!Proxy::Overlay.valid()) return false;
if (overlayOnly) return true;
Proxy::Client = ::Utils::Library(STEAMCLIENT_LIB, false);
if (!Proxy::Client.valid()) return false;
Proxy::SteamClient = Proxy::Client.get<ISteamClient008*(const char*, int*)>("CreateInterface")("SteamClient008", nullptr); Proxy::SteamClient = Proxy::Client.get<ISteamClient008*(const char*, int*)>("CreateInterface")("SteamClient008", nullptr);
if(!Proxy::SteamClient) return false; if(!Proxy::SteamClient) return false;

View File

@ -334,12 +334,10 @@ namespace Steam
class Proxy class Proxy
{ {
public: public:
static bool Inititalize(); static bool Inititalize(bool overlayOnly = false);
static void Uninititalize(); static void Uninititalize();
static void SetGame(uint32_t appId); static void SetGame(uint32_t appId);
static void SetMod(std::string mod);
static void RunMod();
//Overlay related proxies //Overlay related proxies
static void SetOverlayNotificationPosition(uint32_t eNotificationPosition); static void SetOverlayNotificationPosition(uint32_t eNotificationPosition);

View File

@ -106,26 +106,12 @@ namespace Steam
{ {
bool SteamAPI_Init() bool SteamAPI_Init()
{ {
#ifndef DISABLE_STEAM_GAME Proxy::SetGame(10190);
if (!Components::Flags::HasFlag("nosteam"))
{
//Proxy::SetGame(10190);
}
#endif
if (!Proxy::Inititalize()) if (!Proxy::Inititalize(true))
{ {
OutputDebugStringA("Steamproxy not initialized properly"); OutputDebugStringA("Steamproxy not initialized properly");
} }
else
{
#ifndef DISABLE_STEAM_GAME
if (!Components::Flags::HasFlag("nosteam"))
{
//Proxy::SetMod("IW4x - Modern Warfare 2");
}
#endif
}
return true; return true;
} }
@ -143,7 +129,7 @@ namespace Steam
void SteamAPI_RunCallbacks() void SteamAPI_RunCallbacks()
{ {
Callbacks::RunCallbacks(); Callbacks::RunCallbacks();
Proxy::RunFrame(); //Proxy::RunFrame();
} }
void SteamAPI_Shutdown() void SteamAPI_Shutdown()