@@ -408,6 +408,20 @@ static uint32_t hkClientUser_GetSubscribedApps(void* pClientUser, uint32_t* pApp
408408 return count;
409409}
410410
411+ static bool hkClientUser_RequiresLegacyCDKey (void * pClientUser, uint32_t appId, uint32_t * a2)
412+ {
413+ const bool requiresKey = Hooks::IClientUser_RequiresLegacyCDKey.tramp .fn (pClientUser, appId, a2);
414+ g_pLog->once (" IClientUser::RequiresLegacyCDKey(%p, %u, %u) -> %i\n " , pClientUser, appId, a2, requiresKey);
415+
416+ if (requiresKey && g_config.isAddedAppId (appId))
417+ {
418+ g_pLog->once (" Disable CD Key for %u\n " , appId);
419+ return false ;
420+ }
421+
422+ return requiresKey;
423+ }
424+
411425static void patchRetn (lm_address_t address)
412426{
413427 constexpr lm_byte_t retn = 0xC3 ;
@@ -504,6 +518,7 @@ namespace Hooks
504518 DetourHook<IClientApps_PipeLoop_t> IClientApps_PipeLoop (" IClientApps::PipeLoop" );
505519 DetourHook<IClientUser_BIsSubscribedApp_t> IClientUser_BIsSubscribedApp (" IClientUser::BIsSubscribedApp" );
506520 DetourHook<IClientUser_GetSubscribedApps_t> IClientUser_GetSubscribedApps (" IClientUser::GetSubscribedApps" );
521+ DetourHook<IClientUser_RequiresLegacyCDKey_t> IClientUser_RequiresLegacyCDKey (" IClientUser::RequiresLegacyCDKey" );
507522
508523 VFTHook<IClientAppManager_BIsDlcEnabled_t> IClientAppManager_BIsDlcEnabled (" IClientAppManager::BIsDlcEnabled" );
509524 VFTHook<IClientAppManager_LaunchApp_t> IClientAppManager_LaunchApp (" IClientAppManager::LaunchApp" );
@@ -535,6 +550,18 @@ bool Hooks::setup()
535550 prologue.size ()
536551 );
537552
553+ // TODO: Make this shit less verbose in case I fail my reversing & refactor for all this crap
554+ prologue = std::vector<lm_byte_t >({
555+ 0x53 , 0x56 , 0x57 , 0x55
556+ });
557+ bool requiresLegacyCDKey = IClientUser_RequiresLegacyCDKey.setup
558+ (
559+ Patterns::RequiresLegacyCDKey,
560+ MemHlp::SigFollowMode::PrologueUpwards,
561+ &prologue[0 ],
562+ prologue.size (),
563+ &hkClientUser_RequiresLegacyCDKey
564+ );
538565
539566 bool succeeded =
540567 CheckAppOwnership.setup (Patterns::CheckAppOwnership, MemHlp::SigFollowMode::Relative, &hkCheckAppOwnership)
@@ -546,7 +573,9 @@ bool Hooks::setup()
546573
547574 && runningApp != LM_ADDRESS_BAD
548575 && stopPlayingBorrowedApp != LM_ADDRESS_BAD
549- && IClientUser_GetSteamId != LM_ADDRESS_BAD;
576+ && IClientUser_GetSteamId != LM_ADDRESS_BAD
577+
578+ && requiresLegacyCDKey;
550579
551580 if (!succeeded)
552581 {
@@ -575,6 +604,7 @@ void Hooks::place()
575604 IClientAppManager_PipeLoop.place ();
576605 IClientUser_BIsSubscribedApp.place ();
577606 IClientUser_GetSubscribedApps.place ();
607+ IClientUser_RequiresLegacyCDKey.place ();
578608
579609 createAndPlaceSteamIdHook ();
580610}
@@ -588,6 +618,7 @@ void Hooks::remove()
588618 IClientAppManager_PipeLoop.remove ();
589619 IClientUser_BIsSubscribedApp.remove ();
590620 IClientUser_GetSubscribedApps.remove ();
621+ IClientUser_RequiresLegacyCDKey.remove ();
591622
592623 // VFT Hooks
593624 IClientAppManager_BIsDlcEnabled.remove ();
0 commit comments