Skip to content

Commit

Permalink
fix: windows scan method
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisAMJ committed Sep 24, 2024
1 parent 8df750b commit 2cf374a
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/Modules/SteamAPI.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "SteamAPI.hpp"

#include "SAR.hpp"

bool SteamAPI::Init() {
const auto steam_api = Memory::GetModuleHandleByName(this->Name());
if (!steam_api)
Expand All @@ -19,15 +21,18 @@ bool SteamAPI::Init() {
return false;

#ifdef _WIN32
void ***scanResult = reinterpret_cast<void ***>(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<void ***>(Memory::Scan(this->Name(), "89 0D ? ? ? ? 85 C9 0F", 2));
} else {
scanResult = reinterpret_cast<void ***>(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;
Expand Down

0 comments on commit 2cf374a

Please sign in to comment.