Changing the style to PascalCase
This commit is contained in:
@ -2,17 +2,17 @@
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
Library Library::load(const std::string& name)
|
||||
Library Library::Load(const std::string& name)
|
||||
{
|
||||
return Library(LoadLibraryA(name.data()));
|
||||
}
|
||||
|
||||
Library Library::load(const std::filesystem::path& path)
|
||||
Library Library::Load(const std::filesystem::path& path)
|
||||
{
|
||||
return Library::load(path.generic_string());
|
||||
return Library::Load(path.generic_string());
|
||||
}
|
||||
|
||||
Library Library::get_by_address(void* address)
|
||||
Library Library::GetByAddress(void* address)
|
||||
{
|
||||
HMODULE handle = nullptr;
|
||||
GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, static_cast<LPCSTR>(address), &handle);
|
||||
@ -40,23 +40,23 @@ namespace Utils
|
||||
{
|
||||
if (this->freeOnDestroy)
|
||||
{
|
||||
this->free();
|
||||
this->Free();
|
||||
}
|
||||
}
|
||||
|
||||
bool Library::is_valid() const
|
||||
bool Library::IsValid() const
|
||||
{
|
||||
return this->_module != nullptr;
|
||||
}
|
||||
|
||||
HMODULE Library::getModule()
|
||||
HMODULE Library::GetModule()
|
||||
{
|
||||
return this->_module;
|
||||
}
|
||||
|
||||
void Library::free()
|
||||
void Library::Free()
|
||||
{
|
||||
if (this->is_valid())
|
||||
if (this->IsValid())
|
||||
{
|
||||
FreeLibrary(this->_module);
|
||||
}
|
||||
|
@ -5,9 +5,9 @@ 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);
|
||||
static Library Load(const std::string& name);
|
||||
static Library Load(const std::filesystem::path& path);
|
||||
static Library GetByAddress(void* address);
|
||||
|
||||
Library() : _module(nullptr), freeOnDestroy(false) {};
|
||||
Library(const std::string& buffer, bool freeOnDestroy);
|
||||
@ -15,48 +15,48 @@ namespace Utils
|
||||
explicit Library(HMODULE handle);
|
||||
~Library();
|
||||
|
||||
bool is_valid() const;
|
||||
HMODULE getModule();
|
||||
bool IsValid() const;
|
||||
HMODULE GetModule();
|
||||
|
||||
template <typename T>
|
||||
T get_proc(const std::string& process) const
|
||||
T GetProc(const std::string& process) const
|
||||
{
|
||||
if (!this->is_valid()) T{};
|
||||
if (!this->IsValid()) T{};
|
||||
return reinterpret_cast<T>(GetProcAddress(this->_module, process.data()));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::function<T> get(const std::string& process) const
|
||||
std::function<T> Get(const std::string& process) const
|
||||
{
|
||||
if (!this->is_valid()) return std::function<T>();
|
||||
return static_cast<T*>(this->get_proc<void*>(process));
|
||||
if (!this->IsValid()) return std::function<T>();
|
||||
return static_cast<T*>(this->GetProc<void*>(process));
|
||||
}
|
||||
|
||||
template <typename T, typename... Args>
|
||||
T invoke(const std::string& process, Args ... args) const
|
||||
T Invoke(const std::string& process, Args ... args) const
|
||||
{
|
||||
auto method = this->get<T(__cdecl)(Args ...)>(process);
|
||||
auto method = this->Get<T(__cdecl)(Args ...)>(process);
|
||||
if (method) return method(args...);
|
||||
return T();
|
||||
}
|
||||
|
||||
template <typename T, typename... Args>
|
||||
T invoke_pascal(const std::string& process, Args ... args) const
|
||||
T InvokePascal(const std::string& process, Args ... args) const
|
||||
{
|
||||
auto method = this->get<T(__stdcall)(Args ...)>(process);
|
||||
auto method = this->Get<T(__stdcall)(Args ...)>(process);
|
||||
if (method) return method(args...);
|
||||
return T();
|
||||
}
|
||||
|
||||
template <typename T, typename... Args>
|
||||
T invoke_this(const std::string& process, void* this_ptr, Args ... args) const
|
||||
T InvokeThis(const std::string& process, void* this_ptr, Args ... args) const
|
||||
{
|
||||
auto method = this->get<T(__thiscall)(void*, Args ...)>(this_ptr, process);
|
||||
auto method = this->Get<T(__thiscall)(void*, Args ...)>(this_ptr, process);
|
||||
if (method) return method(args...);
|
||||
return T();
|
||||
}
|
||||
|
||||
void free();
|
||||
void Free();
|
||||
|
||||
private:
|
||||
HMODULE _module;
|
||||
|
Reference in New Issue
Block a user