Fix Quit Hard
This commit is contained in:
parent
a6b17cf64d
commit
5f7cefa5c9
@ -149,6 +149,7 @@ template <size_t S> class Sizer { };
|
||||
#pragma comment(lib, "Advapi32.lib")
|
||||
#pragma comment(lib, "rpcrt4.lib")
|
||||
#pragma comment(lib, "dbghelp.lib")
|
||||
#pragma comment(lib, "ntdll.lib")
|
||||
|
||||
// Enable additional literals
|
||||
using namespace std::literals;
|
||||
|
@ -2,11 +2,40 @@
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
Library Library::load(const std::string& name)
|
||||
{
|
||||
return Library(LoadLibraryA(name.data()));
|
||||
}
|
||||
|
||||
Library Library::load(const std::filesystem::path& path)
|
||||
{
|
||||
return Library::load(path.generic_string());
|
||||
}
|
||||
|
||||
Library Library::get_by_address(void* address)
|
||||
{
|
||||
HMODULE handle = nullptr;
|
||||
GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, static_cast<LPCSTR>(address), &handle);
|
||||
return Library(handle);
|
||||
}
|
||||
|
||||
Library::Library(const std::string& buffer, bool _freeOnDestroy) : _module(nullptr), freeOnDestroy(_freeOnDestroy)
|
||||
{
|
||||
this->_module = LoadLibraryExA(buffer.data(), nullptr, 0);
|
||||
}
|
||||
|
||||
Library::Library(const std::string& buffer)
|
||||
{
|
||||
this->_module = GetModuleHandleA(buffer.data());
|
||||
this->freeOnDestroy = true;
|
||||
}
|
||||
|
||||
Library::Library(const HMODULE handle)
|
||||
{
|
||||
this->_module = handle;
|
||||
this->freeOnDestroy = true;
|
||||
}
|
||||
|
||||
Library::~Library()
|
||||
{
|
||||
if (this->freeOnDestroy)
|
||||
|
@ -5,8 +5,14 @@ namespace Utils
|
||||
class Library
|
||||
{
|
||||
public:
|
||||
static Library load(const std::string& name);
|
||||
static Library load(const std::filesystem::path& path);
|
||||
static Library get_by_address(void* address);
|
||||
|
||||
Library() : _module(nullptr), freeOnDestroy(false) {};
|
||||
Library(const std::string& buffer, bool freeOnDestroy = true);
|
||||
Library(const std::string& buffer, bool freeOnDestroy);
|
||||
explicit Library(const std::string& name);
|
||||
explicit Library(HMODULE handle);
|
||||
~Library();
|
||||
|
||||
bool is_valid() const;
|
||||
|
Loading…
Reference in New Issue
Block a user