Steam proxy
This commit is contained in:
@ -1,105 +1,97 @@
|
||||
#include "STDInclude.hpp"
|
||||
|
||||
namespace Steam
|
||||
{
|
||||
unsigned int Utils::GetSecondsSinceAppActive()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int Utils::GetSecondsSinceComputerActive()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Utils::GetConnectedUniverse()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned int Utils::GetServerRealTime()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char* Utils::GetIPCountry()
|
||||
{
|
||||
return "US";
|
||||
}
|
||||
|
||||
bool Utils::GetImageSize(int iImage, unsigned int *pnWidth, unsigned int *pnHeight)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Utils::GetImageRGBA(int iImage, unsigned char *pubDest, int nDestBufferSize)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Utils::GetCSERIPPort(unsigned int *unIP, unsigned short *usPort)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned char Utils::GetCurrentBatteryPower()
|
||||
{
|
||||
return 255;
|
||||
}
|
||||
|
||||
unsigned int Utils::GetAppID()
|
||||
{
|
||||
return 10190;
|
||||
}
|
||||
|
||||
void Utils::SetOverlayNotificationPosition(int eNotificationPosition)
|
||||
{
|
||||
if (Steam::Overlay)
|
||||
{
|
||||
FARPROC setPosition = GetProcAddress(Steam::Overlay, "SetNotificationPosition");
|
||||
|
||||
if (setPosition)
|
||||
{
|
||||
::Utils::Hook::Call<void(int)>(setPosition)(eNotificationPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Utils::IsAPICallCompleted(unsigned __int64 hSteamAPICall, bool *pbFailed)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int Utils::GetAPICallFailureReason(unsigned __int64 hSteamAPICall)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool Utils::GetAPICallResult(unsigned __int64 hSteamAPICall, void *pCallback, int cubCallback, int iCallbackExpected, bool *pbFailed)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void Utils::RunFrame()
|
||||
{
|
||||
}
|
||||
|
||||
unsigned int Utils::GetIPCCallCount()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Utils::SetWarningMessageHook(void(*pFunction)(int hpipe, const char *message))
|
||||
{
|
||||
}
|
||||
|
||||
bool Utils::IsOverlayEnabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Utils::BOverlayNeedsPresent()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#include "STDInclude.hpp"
|
||||
|
||||
namespace Steam
|
||||
{
|
||||
unsigned int Utils::GetSecondsSinceAppActive()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int Utils::GetSecondsSinceComputerActive()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Utils::GetConnectedUniverse()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned int Utils::GetServerRealTime()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char* Utils::GetIPCountry()
|
||||
{
|
||||
return "US";
|
||||
}
|
||||
|
||||
bool Utils::GetImageSize(int iImage, unsigned int *pnWidth, unsigned int *pnHeight)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Utils::GetImageRGBA(int iImage, unsigned char *pubDest, int nDestBufferSize)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Utils::GetCSERIPPort(unsigned int *unIP, unsigned short *usPort)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned char Utils::GetCurrentBatteryPower()
|
||||
{
|
||||
return 255;
|
||||
}
|
||||
|
||||
unsigned int Utils::GetAppID()
|
||||
{
|
||||
return 10190;
|
||||
}
|
||||
|
||||
void Utils::SetOverlayNotificationPosition(int eNotificationPosition)
|
||||
{
|
||||
Proxy::SetOverlayNotificationPosition(eNotificationPosition);
|
||||
}
|
||||
|
||||
bool Utils::IsAPICallCompleted(unsigned __int64 hSteamAPICall, bool *pbFailed)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int Utils::GetAPICallFailureReason(unsigned __int64 hSteamAPICall)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool Utils::GetAPICallResult(unsigned __int64 hSteamAPICall, void *pCallback, int cubCallback, int iCallbackExpected, bool *pbFailed)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void Utils::RunFrame()
|
||||
{
|
||||
}
|
||||
|
||||
unsigned int Utils::GetIPCCallCount()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Utils::SetWarningMessageHook(void(*pFunction)(int hpipe, const char *message))
|
||||
{
|
||||
}
|
||||
|
||||
bool Utils::IsOverlayEnabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Utils::BOverlayNeedsPresent()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
88
src/Steam/Proxy.cpp
Normal file
88
src/Steam/Proxy.cpp
Normal file
@ -0,0 +1,88 @@
|
||||
#include "STDInclude.hpp"
|
||||
|
||||
namespace Steam
|
||||
{
|
||||
HMODULE Proxy::Client = nullptr;
|
||||
HMODULE Proxy::Overlay = nullptr;
|
||||
|
||||
bool Proxy::Inititalize()
|
||||
{
|
||||
std::string directoy = Proxy::GetSteamDirectory();
|
||||
if (directoy.empty()) return false;
|
||||
|
||||
SetDllDirectoryA(Proxy::GetSteamDirectory().data());
|
||||
|
||||
Proxy::Client = LoadLibraryA(STEAMCLIENT_LIB);
|
||||
Proxy::Overlay = LoadLibraryA(GAMEOVERLAY_LIB);
|
||||
|
||||
return (Proxy::Client && Proxy::Overlay);
|
||||
}
|
||||
|
||||
void Proxy::Uninititalize()
|
||||
{
|
||||
if (Proxy::Client) FreeLibrary(Proxy::Client);
|
||||
Proxy::Client = nullptr;
|
||||
|
||||
if (Proxy::Overlay) FreeLibrary(Proxy::Overlay);
|
||||
Proxy::Overlay = nullptr;
|
||||
}
|
||||
|
||||
std::string Proxy::GetSteamDirectory()
|
||||
{
|
||||
HKEY hRegKey;
|
||||
char SteamPath[MAX_PATH];
|
||||
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, STEAM_REGISTRY_PATH, 0, KEY_QUERY_VALUE, &hRegKey) == ERROR_SUCCESS)
|
||||
{
|
||||
DWORD dwLength = sizeof(SteamPath);
|
||||
RegQueryValueExA(hRegKey, "InstallPath", NULL, NULL, reinterpret_cast<BYTE*>(SteamPath), &dwLength);
|
||||
RegCloseKey(hRegKey);
|
||||
|
||||
return SteamPath;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
void Proxy::SetOverlayNotificationPosition(uint32_t eNotificationPosition)
|
||||
{
|
||||
if (Proxy::Overlay)
|
||||
{
|
||||
FARPROC SetNotificationPositionFn = GetProcAddress(Proxy::Overlay, "SetNotificationPosition");
|
||||
|
||||
if (SetNotificationPositionFn)
|
||||
{
|
||||
::Utils::Hook::Call<void(uint32_t)>(SetNotificationPositionFn)(eNotificationPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Proxy::IsOverlayEnabled()
|
||||
{
|
||||
if (Proxy::Overlay)
|
||||
{
|
||||
FARPROC IsOverlayEnabledFn = GetProcAddress(Proxy::Overlay, "IsOverlayEnabled");
|
||||
|
||||
if (IsOverlayEnabledFn)
|
||||
{
|
||||
return ::Utils::Hook::Call<bool()>(IsOverlayEnabledFn)();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Proxy::BOverlayNeedsPresent()
|
||||
{
|
||||
if (Proxy::Overlay)
|
||||
{
|
||||
FARPROC BOverlayNeedsPresentFn = GetProcAddress(Proxy::Overlay, "BOverlayNeedsPresent");
|
||||
|
||||
if (BOverlayNeedsPresentFn)
|
||||
{
|
||||
return ::Utils::Hook::Call<bool()>(BOverlayNeedsPresentFn)();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
30
src/Steam/Proxy.hpp
Normal file
30
src/Steam/Proxy.hpp
Normal file
@ -0,0 +1,30 @@
|
||||
#ifdef _WIN64
|
||||
#define GAMEOVERLAY_LIB "gameoverlayrenderer64.dll"
|
||||
#define STEAMCLIENT_LIB "steamclient64.dll"
|
||||
#define STEAM_REGISTRY_PATH "Software\\Wow6432Node\\Valve\\Steam"
|
||||
#else
|
||||
#define GAMEOVERLAY_LIB "gameoverlayrenderer.dll"
|
||||
#define STEAMCLIENT_LIB "steamclient.dll"
|
||||
#define STEAM_REGISTRY_PATH "Software\\Valve\\Steam"
|
||||
#endif
|
||||
|
||||
namespace Steam
|
||||
{
|
||||
class Proxy
|
||||
{
|
||||
public:
|
||||
static bool Inititalize();
|
||||
static void Uninititalize();
|
||||
|
||||
//Overlay related proxies
|
||||
static void SetOverlayNotificationPosition(uint32_t eNotificationPosition);
|
||||
static bool IsOverlayEnabled();
|
||||
static bool BOverlayNeedsPresent();
|
||||
|
||||
private:
|
||||
static HMODULE Client;
|
||||
static HMODULE Overlay;
|
||||
|
||||
static std::string GetSteamDirectory();
|
||||
};
|
||||
}
|
@ -2,8 +2,6 @@
|
||||
|
||||
namespace Steam
|
||||
{
|
||||
HMODULE Overlay = 0;
|
||||
|
||||
uint64_t Callbacks::CallID = 0;
|
||||
std::map<uint64_t, bool> Callbacks::Calls;
|
||||
std::map<uint64_t, Callbacks::Base*> Callbacks::ResultHandlers;
|
||||
@ -71,22 +69,9 @@ namespace Steam
|
||||
{
|
||||
bool SteamAPI_Init()
|
||||
{
|
||||
Overlay = GetModuleHandleA("gameoverlayrenderer.dll");
|
||||
|
||||
if (!Overlay)
|
||||
if (!Proxy::Inititalize())
|
||||
{
|
||||
HKEY hRegKey;
|
||||
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Valve\\Steam", 0, KEY_QUERY_VALUE, &hRegKey) == ERROR_SUCCESS)
|
||||
{
|
||||
char steamPath[MAX_PATH] = { 0 };
|
||||
DWORD dwLength = sizeof(steamPath);
|
||||
RegQueryValueExA(hRegKey, "InstallPath", NULL, NULL, reinterpret_cast<BYTE*>(steamPath), &dwLength);
|
||||
RegCloseKey(hRegKey);
|
||||
|
||||
SetDllDirectoryA(steamPath);
|
||||
|
||||
Overlay = LoadLibraryA(::Utils::String::VA("%s\\%s", steamPath, "gameoverlayrenderer.dll"));
|
||||
}
|
||||
OutputDebugStringA("Steamproxy not initialized properly");
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -109,6 +94,7 @@ namespace Steam
|
||||
|
||||
void SteamAPI_Shutdown()
|
||||
{
|
||||
Proxy::Uninititalize();
|
||||
}
|
||||
|
||||
void SteamAPI_UnregisterCallResult()
|
||||
|
@ -1,93 +1,93 @@
|
||||
#pragma once
|
||||
|
||||
#define STEAM_EXPORT extern "C" __declspec(dllexport)
|
||||
|
||||
typedef union
|
||||
{
|
||||
struct
|
||||
{
|
||||
unsigned int AccountID : 32;
|
||||
unsigned int AccountInstance : 20;
|
||||
unsigned int AccountType : 4;
|
||||
int Universe : 8;
|
||||
};
|
||||
|
||||
unsigned long long Bits;
|
||||
} SteamID;
|
||||
|
||||
#include "Interfaces\SteamUser.hpp"
|
||||
#include "Interfaces\SteamUtils.hpp"
|
||||
#include "Interfaces\SteamFriends.hpp"
|
||||
#include "Interfaces\SteamGameServer.hpp"
|
||||
#include "Interfaces\SteamNetworking.hpp"
|
||||
#include "Interfaces\SteamMatchmaking.hpp"
|
||||
#include "Interfaces\SteamRemoteStorage.hpp"
|
||||
#include "Interfaces\SteamMasterServerUpdater.hpp"
|
||||
|
||||
namespace Steam
|
||||
{
|
||||
class Callbacks
|
||||
{
|
||||
public:
|
||||
class Base
|
||||
{
|
||||
public:
|
||||
Base() : Flags(0), Callback(0) {};
|
||||
|
||||
virtual void Run(void *pvParam) = 0;
|
||||
virtual void Run(void *pvParam, bool bIOFailure, uint64_t hSteamAPICall) = 0;
|
||||
virtual int GetCallbackSizeBytes() = 0;
|
||||
|
||||
int GetICallback() { return Callback; }
|
||||
void SetICallback(int iCallback) { Callback = iCallback; }
|
||||
|
||||
protected:
|
||||
unsigned char Flags;
|
||||
int Callback;
|
||||
};
|
||||
|
||||
struct Result
|
||||
{
|
||||
void* data;
|
||||
int size;
|
||||
int type;
|
||||
uint64_t call;
|
||||
};
|
||||
|
||||
static uint64_t RegisterCall();
|
||||
static void RegisterCallback(Base* handler, int callback);
|
||||
static void RegisterCallResult(uint64_t call, Base* result);
|
||||
static void ReturnCall(void* data, int size, int type, uint64_t call);
|
||||
static void RunCallbacks();
|
||||
|
||||
private:
|
||||
static uint64_t CallID;
|
||||
static std::map<uint64_t, bool> Calls;
|
||||
static std::map<uint64_t, Base*> ResultHandlers;
|
||||
static std::vector<Result> Results;
|
||||
static std::vector<Base*> CallbackList;
|
||||
};
|
||||
|
||||
STEAM_EXPORT bool SteamAPI_Init();
|
||||
STEAM_EXPORT void SteamAPI_RegisterCallResult(Callbacks::Base* result, uint64_t call);
|
||||
STEAM_EXPORT void SteamAPI_RegisterCallback(Callbacks::Base* handler, int callback);
|
||||
STEAM_EXPORT void SteamAPI_RunCallbacks();
|
||||
STEAM_EXPORT void SteamAPI_Shutdown();
|
||||
STEAM_EXPORT void SteamAPI_UnregisterCallResult();
|
||||
STEAM_EXPORT void SteamAPI_UnregisterCallback();
|
||||
|
||||
STEAM_EXPORT bool SteamGameServer_Init();
|
||||
STEAM_EXPORT void SteamGameServer_RunCallbacks();
|
||||
STEAM_EXPORT void SteamGameServer_Shutdown();
|
||||
|
||||
STEAM_EXPORT Steam::Friends* SteamFriends();
|
||||
STEAM_EXPORT Steam::Matchmaking* SteamMatchmaking();
|
||||
STEAM_EXPORT Steam::GameServer* SteamGameServer();
|
||||
STEAM_EXPORT Steam::MasterServerUpdater* SteamMasterServerUpdater();
|
||||
STEAM_EXPORT Steam::Networking* SteamNetworking();
|
||||
STEAM_EXPORT Steam::RemoteStorage* SteamRemoteStorage();
|
||||
STEAM_EXPORT Steam::User* SteamUser();
|
||||
STEAM_EXPORT Steam::Utils* SteamUtils();
|
||||
|
||||
extern HMODULE Overlay;
|
||||
}
|
||||
#pragma once
|
||||
|
||||
#define STEAM_EXPORT extern "C" __declspec(dllexport)
|
||||
|
||||
typedef union
|
||||
{
|
||||
struct
|
||||
{
|
||||
unsigned int AccountID : 32;
|
||||
unsigned int AccountInstance : 20;
|
||||
unsigned int AccountType : 4;
|
||||
int Universe : 8;
|
||||
};
|
||||
|
||||
unsigned long long Bits;
|
||||
} SteamID;
|
||||
|
||||
#include "Interfaces\SteamUser.hpp"
|
||||
#include "Interfaces\SteamUtils.hpp"
|
||||
#include "Interfaces\SteamFriends.hpp"
|
||||
#include "Interfaces\SteamGameServer.hpp"
|
||||
#include "Interfaces\SteamNetworking.hpp"
|
||||
#include "Interfaces\SteamMatchmaking.hpp"
|
||||
#include "Interfaces\SteamRemoteStorage.hpp"
|
||||
#include "Interfaces\SteamMasterServerUpdater.hpp"
|
||||
|
||||
#include "Proxy.hpp"
|
||||
|
||||
namespace Steam
|
||||
{
|
||||
class Callbacks
|
||||
{
|
||||
public:
|
||||
class Base
|
||||
{
|
||||
public:
|
||||
Base() : Flags(0), Callback(0) {};
|
||||
|
||||
virtual void Run(void *pvParam) = 0;
|
||||
virtual void Run(void *pvParam, bool bIOFailure, uint64_t hSteamAPICall) = 0;
|
||||
virtual int GetCallbackSizeBytes() = 0;
|
||||
|
||||
int GetICallback() { return Callback; }
|
||||
void SetICallback(int iCallback) { Callback = iCallback; }
|
||||
|
||||
protected:
|
||||
unsigned char Flags;
|
||||
int Callback;
|
||||
};
|
||||
|
||||
struct Result
|
||||
{
|
||||
void* data;
|
||||
int size;
|
||||
int type;
|
||||
uint64_t call;
|
||||
};
|
||||
|
||||
static uint64_t RegisterCall();
|
||||
static void RegisterCallback(Base* handler, int callback);
|
||||
static void RegisterCallResult(uint64_t call, Base* result);
|
||||
static void ReturnCall(void* data, int size, int type, uint64_t call);
|
||||
static void RunCallbacks();
|
||||
|
||||
private:
|
||||
static uint64_t CallID;
|
||||
static std::map<uint64_t, bool> Calls;
|
||||
static std::map<uint64_t, Base*> ResultHandlers;
|
||||
static std::vector<Result> Results;
|
||||
static std::vector<Base*> CallbackList;
|
||||
};
|
||||
|
||||
STEAM_EXPORT bool SteamAPI_Init();
|
||||
STEAM_EXPORT void SteamAPI_RegisterCallResult(Callbacks::Base* result, uint64_t call);
|
||||
STEAM_EXPORT void SteamAPI_RegisterCallback(Callbacks::Base* handler, int callback);
|
||||
STEAM_EXPORT void SteamAPI_RunCallbacks();
|
||||
STEAM_EXPORT void SteamAPI_Shutdown();
|
||||
STEAM_EXPORT void SteamAPI_UnregisterCallResult();
|
||||
STEAM_EXPORT void SteamAPI_UnregisterCallback();
|
||||
|
||||
STEAM_EXPORT bool SteamGameServer_Init();
|
||||
STEAM_EXPORT void SteamGameServer_RunCallbacks();
|
||||
STEAM_EXPORT void SteamGameServer_Shutdown();
|
||||
|
||||
STEAM_EXPORT Steam::Friends* SteamFriends();
|
||||
STEAM_EXPORT Steam::Matchmaking* SteamMatchmaking();
|
||||
STEAM_EXPORT Steam::GameServer* SteamGameServer();
|
||||
STEAM_EXPORT Steam::MasterServerUpdater* SteamMasterServerUpdater();
|
||||
STEAM_EXPORT Steam::Networking* SteamNetworking();
|
||||
STEAM_EXPORT Steam::RemoteStorage* SteamRemoteStorage();
|
||||
STEAM_EXPORT Steam::User* SteamUser();
|
||||
STEAM_EXPORT Steam::Utils* SteamUtils();
|
||||
}
|
||||
|
Reference in New Issue
Block a user