From 6b86d4a80791569549f4c948fe7baf74acb0da85 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sat, 10 Dec 2016 13:07:18 +0100 Subject: [PATCH] [Proxy] Basic steam proxy --- src/Steam/Proxy.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++- src/Steam/Proxy.hpp | 34 ++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 1 deletion(-) diff --git a/src/Steam/Proxy.cpp b/src/Steam/Proxy.cpp index f2967a40..86b33a57 100644 --- a/src/Steam/Proxy.cpp +++ b/src/Steam/Proxy.cpp @@ -5,6 +5,14 @@ namespace Steam ::Utils::Library Proxy::Client; ::Utils::Library Proxy::Overlay; + ISteamClient008* Proxy::SteamClient; + + void* Proxy::SteamPipe; + void* Proxy::SteamUser; + + Friends* Proxy::SteamFriends; + Utils* Proxy::SteamUtils; + bool Proxy::Inititalize() { std::string directoy = Proxy::GetSteamDirectory(); @@ -14,12 +22,50 @@ namespace Steam Proxy::Client = ::Utils::Library(STEAMCLIENT_LIB, false); Proxy::Overlay = ::Utils::Library(GAMEOVERLAY_LIB, false); + if (!Proxy::Client.valid() || !Proxy::Overlay.valid()) return false; - return (Proxy::Client.valid() && Proxy::Overlay.valid()); + Proxy::SteamClient = Proxy::Client.get("CreateInterface")("SteamClient008", nullptr); + Proxy::SteamPipe = Proxy::SteamClient->CreateSteamPipe(); + if (!Proxy::SteamPipe) return false; + + Proxy::SteamUser = Proxy::SteamClient->ConnectToGlobalUser(Proxy::SteamPipe); + if (!Proxy::SteamUser) + { + Proxy::SteamClient->ReleaseSteamPipe(Proxy::SteamPipe); + return false; + } + + Proxy::SteamFriends = reinterpret_cast(Proxy::SteamClient->GetISteamFriends(Proxy::SteamUser, Proxy::SteamPipe, "SteamFriends005")); + if (!Proxy::SteamFriends) + { + Proxy::SteamClient->ReleaseUser(Proxy::SteamPipe, Proxy::SteamUser); + Proxy::SteamClient->ReleaseSteamPipe(Proxy::SteamPipe); + return false; + } + + Proxy::SteamUtils = reinterpret_cast(Proxy::SteamClient->GetISteamFriends(Proxy::SteamUser, Proxy::SteamPipe, "SteamUtils005")); + if (!Proxy::SteamUtils) + { + Proxy::SteamClient->ReleaseUser(Proxy::SteamPipe, Proxy::SteamUser); + Proxy::SteamClient->ReleaseSteamPipe(Proxy::SteamPipe); + return false; + } + + return true; } void Proxy::Uninititalize() { + if (Proxy::SteamClient && Proxy::SteamPipe) + { + if (Proxy::SteamUser) + { + Proxy::SteamClient->ReleaseUser(Proxy::SteamPipe, Proxy::SteamUser); + } + + Proxy::SteamClient->ReleaseSteamPipe(Proxy::SteamPipe); + } + Proxy::Client = ::Utils::Library(); Proxy::Overlay = ::Utils::Library(); } diff --git a/src/Steam/Proxy.hpp b/src/Steam/Proxy.hpp index f2b551c8..6737ffd7 100644 --- a/src/Steam/Proxy.hpp +++ b/src/Steam/Proxy.hpp @@ -10,6 +10,32 @@ namespace Steam { + class ISteamClient008 + { + public: + virtual void* CreateSteamPipe() = 0; + virtual bool ReleaseSteamPipe(void* hSteamPipe) = 0; + virtual void* ConnectToGlobalUser(void* hSteamPipe) = 0; + virtual void* CreateLocalUser(void* *phSteamPipe, int eAccountType) = 0; + virtual void ReleaseUser(void* hSteamPipe, void* hUser) = 0; + virtual void *GetISteamUser(void* hSteamUser, void* hSteamPipe, const char *pchVersion) = 0; + virtual void *GetISteamGameServer(void* hSteamUser, void* hSteamPipe, const char *pchVersion) = 0; + virtual void SetLocalIPBinding(uint32_t unIP, uint16_t usPort) = 0; + virtual void *GetISteamFriends(void* hSteamUser, void* hSteamPipe, const char *pchVersion) = 0; + virtual void *GetISteamUtils(void* hSteamPipe, const char *pchVersion) = 0; + virtual void *GetISteamMatchmaking(void* hSteamUser, void* hSteamPipe, const char *pchVersion) = 0; + virtual void *GetISteamMasterServerUpdater(void* hSteamUser, void* hSteamPipe, const char *pchVersion) = 0; + virtual void *GetISteamMatchmakingServers(void* hSteamUser, void* hSteamPipe, const char *pchVersion) = 0; + virtual void *GetISteamGenericInterface(void* hSteamUser, void* hSteamPipe, const char *pchVersion) = 0; + virtual void *GetISteamUserStats(void* hSteamUser, void* hSteamPipe, const char *pchVersion) = 0; + virtual void *GetISteamApps(void* hSteamUser, void* hSteamPipe, const char *pchVersion) = 0; + virtual void *GetISteamNetworking(void* hSteamUser, void* hSteamPipe, const char *pchVersion) = 0; + virtual void*GetISteamRemoteStorage(void* hSteamuser, void* hSteamPipe, const char *pchVersion) = 0; + virtual void RunFrame() = 0; + virtual uint32_t GetIPCCallCount() = 0; + virtual void SetWarningMessageHook(void* pFunction) = 0; + }; + class Proxy { public: @@ -21,10 +47,18 @@ namespace Steam static bool IsOverlayEnabled(); static bool BOverlayNeedsPresent(); + static Friends* SteamFriends; + static Utils* SteamUtils; + private: static ::Utils::Library Client; static ::Utils::Library Overlay; + static ISteamClient008* SteamClient; + + static void* SteamPipe; + static void* SteamUser; + static std::string GetSteamDirectory(); }; }