Steam proxy
This commit is contained in:
parent
2ea490382b
commit
245cd533d1
2
deps/fmt
vendored
2
deps/fmt
vendored
@ -1 +1 @@
|
||||
Subproject commit 4133e501f3277aeef530b75de2e7bfceca93e5d2
|
||||
Subproject commit 0d5ef5c2a66026409b0cfbafa1d2f46cdc5aa4d0
|
2
deps/mongoose
vendored
2
deps/mongoose
vendored
@ -1 +1 @@
|
||||
Subproject commit 6f7f774080f0c2ec291bfa0a908bc31a923051a1
|
||||
Subproject commit 36a1927915f966f20486a80070f0428f2606a53a
|
2
deps/protobuf
vendored
2
deps/protobuf
vendored
@ -1 +1 @@
|
||||
Subproject commit 790e6afb72ed4ad952d9c74e73ae53a01443fe97
|
||||
Subproject commit 70c1ac756d3cd8fa04725f82f0ad1a30404c3bb3
|
@ -109,7 +109,7 @@ namespace Components
|
||||
Game::CL_GetClientName(localClientNum, index, buf, size);
|
||||
|
||||
// Remove the colors
|
||||
strncpy(buf, Colors::Strip(buf).data(), size);
|
||||
strncpy_s(buf, size, Colors::Strip(buf).data(), size);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
@ -163,8 +163,8 @@ namespace Components
|
||||
|
||||
if (Console::LineBufferIndex)
|
||||
{
|
||||
strcpy(Console::LineBuffer2, Console::LineBuffer);
|
||||
strcat(Console::LineBuffer, "\n");
|
||||
strcpy_s(Console::LineBuffer2, Console::LineBuffer);
|
||||
strcat_s(Console::LineBuffer, "\n");
|
||||
Console::LineBufferIndex = 0;
|
||||
return Console::LineBuffer;
|
||||
}
|
||||
@ -215,7 +215,7 @@ namespace Components
|
||||
wprintw(Console::InputWindow, "%s", Console::LineBuffer2);
|
||||
wrefresh(Console::InputWindow);
|
||||
|
||||
strcpy(Console::LineBuffer, Console::LineBuffer2);
|
||||
strcpy_s(Console::LineBuffer, Console::LineBuffer2);
|
||||
Console::LineBufferIndex = strlen(Console::LineBuffer);
|
||||
break;
|
||||
}
|
||||
@ -310,7 +310,7 @@ namespace Components
|
||||
|
||||
va_list va;
|
||||
va_start(va, format);
|
||||
_vsnprintf(buffer, sizeof(buffer), format, va);
|
||||
_vsnprintf_s(buffer, sizeof(buffer), format, va);
|
||||
va_end(va);
|
||||
|
||||
Game::Com_Printf(0, "ERROR:\n");
|
||||
@ -424,7 +424,7 @@ namespace Components
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
_vsnprintf(buffer, sizeof(buffer), format, ap);
|
||||
_vsnprintf_s(buffer, sizeof(buffer), format, ap);
|
||||
va_end(ap);
|
||||
|
||||
perror(buffer);
|
||||
|
@ -13,11 +13,11 @@ namespace Components
|
||||
{
|
||||
char filename[MAX_PATH];
|
||||
__time64_t time;
|
||||
tm* ltime;
|
||||
tm ltime;
|
||||
|
||||
_time64(&time);
|
||||
ltime = _localtime64(&time);
|
||||
strftime(filename, sizeof(filename) - 1, "iw4x-" VERSION_STR "-%Y%m%d%H%M%S.dmp", ltime);
|
||||
_localtime64_s(<ime, &time);
|
||||
strftime(filename, sizeof(filename) - 1, "iw4x-" VERSION_STR "-%Y%m%d%H%M%S.dmp", <ime);
|
||||
|
||||
HANDLE hFile = CreateFileA(filename, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
|
||||
|
@ -71,7 +71,7 @@ namespace Components
|
||||
|
||||
va_list ap = reinterpret_cast<char*>(const_cast<char**>(&message[1]));
|
||||
//va_start(ap, *message);
|
||||
_vsnprintf(buffer, sizeof(buffer), *message, ap);
|
||||
_vsnprintf_s(buffer, sizeof(buffer), *message, ap);
|
||||
va_end(ap);
|
||||
|
||||
return buffer;
|
||||
|
@ -118,7 +118,7 @@ namespace Components
|
||||
|
||||
AntiCheat::EmptyHash();
|
||||
|
||||
_snprintf(buffer, size, format, mapname);
|
||||
_snprintf_s(buffer, size, size, format, mapname);
|
||||
}
|
||||
|
||||
void Maps::AddDependency(std::string expression, std::string zone)
|
||||
|
@ -45,7 +45,7 @@ namespace Components
|
||||
Game::Script_SetupTokens(script, reinterpret_cast<char*>(0x797F80));
|
||||
script->punctuations = reinterpret_cast<Game::punctuation_t*>(0x797F80);
|
||||
|
||||
strcpy(script->buffer, buffer.data());
|
||||
memcpy(script->buffer, buffer.data(), script->length + 1);
|
||||
|
||||
script->length = Game::Script_CleanString(script->buffer);
|
||||
|
||||
@ -75,7 +75,7 @@ namespace Components
|
||||
return 0;
|
||||
}
|
||||
|
||||
strncpy(source->filename, "string", 64);
|
||||
strncpy_s(source->filename, 64, "string", 64);
|
||||
source->scriptstack = script;
|
||||
source->tokens = NULL;
|
||||
source->defines = NULL;
|
||||
|
@ -305,6 +305,7 @@ namespace Components
|
||||
Utils::Hook::Nop(0x6830B1, 20);
|
||||
Utils::Hook(0x682EBF, QuickPatch::GetStatsID, HOOK_CALL).Install()->Quick();
|
||||
Utils::Hook(0x6830B1, QuickPatch::GetStatsID, HOOK_CALL).Install()->Quick();
|
||||
//Utils::Hook::Set<BYTE>(0x68323A, 0xEB);
|
||||
|
||||
// Exploit fixes
|
||||
Utils::Hook(0x414D92, QuickPatch::MsgReadBitsCompressCheckSV, HOOK_CALL).Install()->Quick();
|
||||
|
@ -144,7 +144,7 @@ namespace Components
|
||||
char msgbuf[1024] = { 0 };
|
||||
va_list v;
|
||||
va_start(v, message);
|
||||
_vsnprintf(msgbuf, sizeof(msgbuf), message, v);
|
||||
_vsnprintf_s(msgbuf, sizeof(msgbuf), message, v);
|
||||
va_end(v);
|
||||
|
||||
Game::Scr_ShutdownAllocNode();
|
||||
|
@ -271,12 +271,17 @@ namespace Components
|
||||
Theatre::DemoContainer.CurrentSelection = index;
|
||||
Theatre::Container::DemoInfo info = Theatre::DemoContainer.Demos[index];
|
||||
|
||||
tm time;
|
||||
char buffer[1000] = { 0 };
|
||||
localtime_s(&time, &info.TimeStamp);
|
||||
asctime_s(buffer, sizeof buffer, &time);
|
||||
|
||||
Dvar::Var("ui_demo_mapname").Set(info.Mapname);
|
||||
Dvar::Var("ui_demo_mapname_localized").Set(Game::UI_LocalizeMapName(info.Mapname.data()));
|
||||
Dvar::Var("ui_demo_gametype").Set(Game::UI_LocalizeGameType(info.Gametype.data()));
|
||||
Dvar::Var("ui_demo_length").Set(Utils::String::FormatTimeSpan(info.Length));
|
||||
Dvar::Var("ui_demo_author").Set(info.Author);
|
||||
Dvar::Var("ui_demo_date").Set(std::asctime(std::localtime(&info.TimeStamp)));
|
||||
Dvar::Var("ui_demo_date").Set(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
// Disable irrelevant warnings
|
||||
#pragma warning(disable: 4100) // Unreferenced parameter (steam has to have them and other stubs as well, due to their calling convention)
|
||||
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define VC_EXTRALEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
||||
#include <windows.h>
|
||||
|
@ -54,15 +54,7 @@ namespace Steam
|
||||
|
||||
void Utils::SetOverlayNotificationPosition(int eNotificationPosition)
|
||||
{
|
||||
if (Steam::Overlay)
|
||||
{
|
||||
FARPROC setPosition = GetProcAddress(Steam::Overlay, "SetNotificationPosition");
|
||||
|
||||
if (setPosition)
|
||||
{
|
||||
::Utils::Hook::Call<void(int)>(setPosition)(eNotificationPosition);
|
||||
}
|
||||
}
|
||||
Proxy::SetOverlayNotificationPosition(eNotificationPosition);
|
||||
}
|
||||
|
||||
bool Utils::IsAPICallCompleted(unsigned __int64 hSteamAPICall, bool *pbFailed)
|
||||
|
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()
|
||||
|
@ -24,6 +24,8 @@ typedef union
|
||||
#include "Interfaces\SteamRemoteStorage.hpp"
|
||||
#include "Interfaces\SteamMasterServerUpdater.hpp"
|
||||
|
||||
#include "Proxy.hpp"
|
||||
|
||||
namespace Steam
|
||||
{
|
||||
class Callbacks
|
||||
@ -88,6 +90,4 @@ namespace Steam
|
||||
STEAM_EXPORT Steam::RemoteStorage* SteamRemoteStorage();
|
||||
STEAM_EXPORT Steam::User* SteamUser();
|
||||
STEAM_EXPORT Steam::Utils* SteamUtils();
|
||||
|
||||
extern HMODULE Overlay;
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ namespace Utils
|
||||
DWORD oldProtect;
|
||||
VirtualProtect(place, length + 1, PAGE_EXECUTE_READWRITE, &oldProtect);
|
||||
|
||||
strncpy(static_cast<char*>(place), string, length);
|
||||
strncpy_s(static_cast<char*>(place), length, string, length);
|
||||
|
||||
VirtualProtect(place, length + 1, oldProtect, &oldProtect);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user