Update Hooks.hpp

This commit is contained in:
0TheSpy
2021-06-17 01:38:15 +03:00
committed by GitHub
parent 941b1ee3b5
commit e50a996da5

View File

@ -198,4 +198,71 @@ VMTHook* FileSystemHook = nullptr;
int __stdcall hkGetUnverifiedFileHashes(void* _this, void* someclass, int nMaxFiles)
{
return 0;
}
}
enum class account_status_t : int
{
none = 0,
not_identifying,
awaiting_cooldown,
eligible,
eligible_with_takeover,
elevated, // prime
account_cooldown
};
typedef const int(__thiscall* pGetAccountData)(void*);
pGetAccountData oGetAccountData;
int __fastcall hkGetAccountData(void* _this, void* edx) noexcept
{
const auto ret = oGetAccountData(_this);
account_status_t& account_status = *reinterpret_cast<account_status_t*>(ret + 24);
static const bool is_originally_prime_account = account_status == account_status_t::elevated; // not good fix
if (!is_originally_prime_account)
{
account_status = g_Options.prime ? account_status_t::elevated : account_status_t::none;
}
return ret;
}
typedef const void(__thiscall* pShutdown)(void*, void*, const char*);
pShutdown oShutdown;
void __fastcall hkShutdown(void* thisptr, void* unk1, void* unk2, const char* reason) noexcept
{
#ifdef DEBUG
printf("shutdown (%x) HOOKED %s\n", thisptr, reason);
#endif
if (*g_Options.discmsg_active) {
#ifdef DEBUG
printf("set new reason %s\n", g_Options.discmsg.value->mystring);
#endif
char customreason[256] = "#";
strcat_s(customreason, MakeControlChars(g_Options.discmsg.value->mystring));
oShutdown(thisptr, nullptr, customreason);
}
else
oShutdown(thisptr, nullptr, reason);
}
inline void HookNetchannel()
{
DWORD ptrShutdown = *((DWORD*)iff.g_pEngineClient->GetNetChannelInfo()) + 36 * 4;
DWORD addrShutdown = *(DWORD*)ptrShutdown;
oShutdown = (pShutdown)DetourFunction(
(PBYTE)(addrShutdown),
(PBYTE)hkShutdown);
#ifdef DEBUG
printf("Detoured at %x\n", addrShutdown);
#endif
opt.netchannedlhooked = 1;
}