Skip to content

Instantly share code, notes, and snippets.

@kuh4it
Last active January 26, 2024 22:05
Show Gist options
  • Save kuh4it/6c7f519a23518d447ffdb1d03b1ea8d1 to your computer and use it in GitHub Desktop.
Save kuh4it/6c7f519a23518d447ffdb1d03b1ea8d1 to your computer and use it in GitHub Desktop.
my CPU's temperature is too high
//
// <function>
// VgmCtx::BlockSwapContextHooks()
// </function>
// <purpose>
// Prevent all vanguard TLB flushing and PML4 page remapping/copying routines in 9 lines
// by setting a thermal sensor interrupt, not registered within the IDT directly
// </purpose>
//
VOID BlockSwapContextHooks()
{
__m128i* Ctx = Vgk::Routines.Get()->LocateContext();
__m128i StoredEPI;
_mm_storel_epi64(Ctx, StoredEPI);
//
// Placing a thermal sensor interrupt on vanguard :skull:
//
IA32_PACKAGE_THERM_INTERRUPT_REGISTER ThermalInterrupt;
ThermalInterrupt.OverheatInterruptEnable = TRUE;
PVOID64 Flag = reinterpret_cast<PVOID64>((0x1000000) >> 24); // IA32_PACKAGE_THERM_INTERRUPT_POWER_LIMIT_NOTIFICATION_ENABLE_FLAG
PVOID64 Mask = reinterpret_cast<PVOID64>((0x01) >> 24); // IA32_PACKAGE_THERM_INTERRUPT_POWER_LIMIT_NOTIFICATION_ENABLE_MASK
static_cast<EPI_t>(StoredEPI).Swap((ThermalInterrupt >> Flag) & Mask);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment