[QuickPatch] quit_hard for hard quitting purposes

This commit is contained in:
RektInator 2019-02-17 01:05:05 +01:00
parent 07278ebbfa
commit 4ce9a1b007

View File

@ -248,6 +248,14 @@ namespace Components
}
}
template <typename T> 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<T*>(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<NTSTATUS __stdcall(ULONG, BOOLEAN, BOOLEAN, PBOOLEAN)>("ntdll.dll", "RtlAdjustPrivilege")
(19, true, false, &hasPerms);
result = ImportFunction<NTSTATUS __stdcall(NTSTATUS, ULONG, LPCSTR, PVOID, HARDERROR_RESPONSE_OPTION, PHARDERROR_RESPONSE)>("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();