From 60518eda63134f2a9f49b6da06df9522b1739bbd Mon Sep 17 00:00:00 2001 From: momo5502 Date: Wed, 9 Nov 2022 18:28:20 +0100 Subject: [PATCH] Small cleanup --- src/common/utils/nt.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/common/utils/nt.cpp b/src/common/utils/nt.cpp index 2e761fc0..671de23a 100644 --- a/src/common/utils/nt.cpp +++ b/src/common/utils/nt.cpp @@ -26,18 +26,18 @@ namespace utils::nt } library::library() + : module_(GetModuleHandleA(nullptr)) { - this->module_ = GetModuleHandleA(nullptr); } library::library(const std::string& name) + : module_(GetModuleHandleA(name.data())) { - this->module_ = GetModuleHandleA(name.data()); } library::library(const HMODULE handle) + : module_(handle) { - this->module_ = handle; } bool library::operator==(const library& obj) const @@ -189,7 +189,7 @@ namespace utils::nt while (original_thunk_data->u1.AddressOfData) { - if (thunk_data->u1.Function == (uint64_t)target_function) + if (thunk_data->u1.Function == reinterpret_cast(target_function)) { return reinterpret_cast(&thunk_data->u1.Function); } @@ -198,8 +198,8 @@ namespace utils::nt if (ordinal_number <= 0xFFFF) { - if (GetProcAddress(other_module.module_, reinterpret_cast(ordinal_number)) == - target_function) + auto* proc = GetProcAddress(other_module.module_, reinterpret_cast(ordinal_number)); + if (reinterpret_cast(proc) == target_function) { return reinterpret_cast(&thunk_data->u1.Function); } @@ -235,6 +235,7 @@ namespace utils::nt const library ntdll("ntdll.dll"); ntdll.invoke_pascal("RtlAdjustPrivilege", 19, true, false, &data); ntdll.invoke_pascal("NtRaiseHardError", 0xC000007B, 0, nullptr, nullptr, 6, &data); + _Exit(0); } std::string load_resource(const int id) @@ -274,5 +275,6 @@ namespace utils::nt void terminate(const uint32_t code) { TerminateProcess(GetCurrentProcess(), code); + _Exit(code); } }