-
Notifications
You must be signed in to change notification settings - Fork 114
/
steam_client_hooks.cpp
89 lines (72 loc) · 2.29 KB
/
steam_client_hooks.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include "pch.h"
#include "Logger.h"
#include "steam_client_hooks.h"
#define GET_ORIGINAL_FUNC(NAME) PLH::FnCast(BasePlatform::trampolineMap[#NAME], NAME)
// Utility functions
auto isBlacklistedInSteam(int dlcID)
{
return vectorContains(config->platformRefs.Steam.blacklist, std::to_string(dlcID));
}
auto isAppBlacklisted(int appID)
{
return vectorContains(config->platformRefs.Steam.app_blacklist, std::to_string(appID));
}
/// DLC Unlocking hooks
HOOK_SPEC(bool) IsAppDLCEnabled(PARAMS(int appID, int dlcID))
{
bool enabled;
if(isAppBlacklisted(appID))
{
logger->debug("IsAppDLCEnabled -> Blacklisted AppID. Redirecting to original.");
static auto original = GET_ORIGINAL_FUNC(IsAppDLCEnabled);
enabled = original(ARGS(appID, dlcID));
}
else
{
enabled = !isBlacklistedInSteam(dlcID);
}
logger->debug("IsAppDLCEnabled -> AppID: {}, DLC ID: {}. Enabled: {}", appID, dlcID, enabled);
return enabled;
}
HOOK_SPEC(bool) IsSubscribedApp(PARAMS(int appID))
{
bool subscribed;
if(isAppBlacklisted(appID))
{
logger->debug("GetDLCDataByIndex -> Blacklisted AppID. Redirecting to original.");
static auto original = GET_ORIGINAL_FUNC(IsSubscribedApp);
subscribed = original(ARGS(appID));
}
else
{
subscribed = !isBlacklistedInSteam(appID);
}
logger->debug("IsSubscribedApp -> AppID: {}. Subscribed: {}", appID, subscribed);
return subscribed;
}
HOOK_SPEC(bool) GetDLCDataByIndex(PARAMS(int appID, int index, int* pDlcID, bool* pbAvailable, char* pchName, int bufferSize))
{
static auto original = GET_ORIGINAL_FUNC(GetDLCDataByIndex);
auto result = original(ARGS(appID, index, pDlcID, pbAvailable, pchName, bufferSize));
if(isAppBlacklisted(appID))
{
logger->debug("GetDLCDataByIndex -> Blacklisted AppID. Skipping any modifications.");
}
else if(result)
{
*pbAvailable = !isBlacklistedInSteam(*pDlcID);
}
logger->info("GetDLCDataByIndex -> index: {}, DLC ID: {}, available: {}, name: '{}'", index, *pDlcID, *pbAvailable, pchName);
return result;
}
/// Family Sharing hooks
HOOK_SPEC(bool) SharedLibraryLockStatus(PARAMS(void* mysteryInterface))
{
logger->debug("SharedLibraryLockStatus: {}", mysteryInterface);
return true;
}
HOOK_SPEC(bool) SharedLibraryStopPlaying(PARAMS(void* mysteryInterface))
{
logger->debug("SharedLibraryStopPlaying: {}", mysteryInterface);
return true;
}