From 2cf374aed77522474715fbd390e22146dc42f85f Mon Sep 17 00:00:00 2001 From: AMJ <69196954+ThisAMJ@users.noreply.github.com> Date: Tue, 24 Sep 2024 17:22:36 +1000 Subject: [PATCH] fix: windows scan method --- src/Modules/SteamAPI.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Modules/SteamAPI.cpp b/src/Modules/SteamAPI.cpp index 936d250ff..1c3b5cc0c 100644 --- a/src/Modules/SteamAPI.cpp +++ b/src/Modules/SteamAPI.cpp @@ -1,5 +1,7 @@ #include "SteamAPI.hpp" +#include "SAR.hpp" + bool SteamAPI::Init() { const auto steam_api = Memory::GetModuleHandleByName(this->Name()); if (!steam_api) @@ -19,15 +21,18 @@ bool SteamAPI::Init() { return false; #ifdef _WIN32 - void ***scanResult = reinterpret_cast(Memory::Scan(this->Name(), "89 0D ? ? ? ? 85 C9 0F", 2)); - if (!scanResult || !*scanResult || !**scanResult) { + void ***scanResult; + if (sar.game->Is(SourceGame_Portal2) || sar.game->Is(SourceGame_PortalReloaded) || sar.game->Is(SourceGame_PortalStoriesMel)) { + scanResult = reinterpret_cast(Memory::Scan(this->Name(), "89 0D ? ? ? ? 85 C9 0F", 2)); + } else { scanResult = reinterpret_cast(Memory::Scan(this->Name(), "A3 ? ? ? ? 3B C3 0F 84", 1)); - if (!scanResult || !*scanResult || !**scanResult) - return false; } - void *interfaceMgr = **scanResult; - const auto fn = *(ISteamTimeline * (__rescall **)(void *, void *, void *, const char *))(*(uintptr_t *)interfaceMgr + 48); - g_timeline = fn(interfaceMgr, GetHSteamUser(), GetHSteamPipe(), "STEAMTIMELINE_INTERFACE_V001"); + + if (scanResult && *scanResult && **scanResult) { + void *interfaceMgr = **scanResult; + const auto fn = *(ISteamTimeline * (__rescall **)(void *, void *, void *, const char *))(*(uintptr_t *)interfaceMgr + 48); + g_timeline = fn(interfaceMgr, GetHSteamUser(), GetHSteamPipe(), "STEAMTIMELINE_INTERFACE_V001"); + } #else // TODO: Linux mods support return false;