diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index d4ae5ce2..9d8fc37d 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -248,6 +248,14 @@ namespace Components } } + template std::function < T > ImportFunction(const std::string& dll, const std::string& function) + { + auto dllHandle = GetModuleHandleA(&dll[0]); + auto procAddr = GetProcAddress(dllHandle, &function[0]); + + return std::function < T >(reinterpret_cast(procAddr)); + } + QuickPatch::QuickPatch() { QuickPatch::FrameTime = 0; @@ -256,6 +264,41 @@ namespace Components QuickPatch::FrameTime = Game::Sys_Milliseconds(); }); + // quit_hard + Command::Add("quit_hard", [](Command::Params*) + { + typedef enum _HARDERROR_RESPONSE_OPTION { + OptionAbortRetryIgnore, + OptionOk, + OptionOkCancel, + OptionRetryCancel, + OptionYesNo, + OptionYesNoCancel, + OptionShutdownSystem + } HARDERROR_RESPONSE_OPTION, *PHARDERROR_RESPONSE_OPTION; + + typedef enum _HARDERROR_RESPONSE { + ResponseReturnToCaller, + ResponseNotHandled, + ResponseAbort, + ResponseCancel, + ResponseIgnore, + ResponseNo, + ResponseOk, + ResponseRetry, + ResponseYes + } HARDERROR_RESPONSE, *PHARDERROR_RESPONSE; + + BOOLEAN hasPerms; + HARDERROR_RESPONSE response; + + auto result = ImportFunction("ntdll.dll", "RtlAdjustPrivilege") + (19, true, false, &hasPerms); + + result = ImportFunction("ntdll.dll", "NtRaiseHardError") + (0xC000007B /*0x0000000A*/, 0, nullptr, nullptr, OptionShutdownSystem, &response); + }); + // bounce dvar sv_enableBounces = Game::Dvar_RegisterBool("sv_enableBounces", false, Game::DVAR_FLAG_REPLICATED, "Enables bouncing on the server"); Utils::Hook(0x4B1B2D, QuickPatch::BounceStub, HOOK_JUMP).install()->quick();