Merge branch 'develop' into refactor-scripts-stuff
This commit is contained in:
@ -19,15 +19,9 @@ namespace Utils
|
||||
return Library(handle);
|
||||
}
|
||||
|
||||
Library::Library(const std::string& buffer, bool _freeOnDestroy) : _module(nullptr), freeOnDestroy(_freeOnDestroy)
|
||||
Library::Library(const std::string& name, 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;
|
||||
this->_module = LoadLibraryExA(name.data(), nullptr, 0);
|
||||
}
|
||||
|
||||
Library::Library(const HMODULE handle)
|
||||
@ -49,7 +43,7 @@ namespace Utils
|
||||
return this->_module != nullptr;
|
||||
}
|
||||
|
||||
HMODULE Library::getModule()
|
||||
HMODULE Library::getModule() const
|
||||
{
|
||||
return this->_module;
|
||||
}
|
||||
|
@ -10,13 +10,13 @@ namespace Utils
|
||||
static Library GetByAddress(void* address);
|
||||
|
||||
Library() : _module(nullptr), freeOnDestroy(false) {};
|
||||
Library(const std::string& buffer, bool freeOnDestroy);
|
||||
explicit Library(const std::string& name);
|
||||
Library(const std::string& name, bool freeOnDestroy);
|
||||
explicit Library(const std::string& name) : _module(GetModuleHandleA(name.data())), freeOnDestroy(true) {};
|
||||
explicit Library(HMODULE handle);
|
||||
~Library();
|
||||
|
||||
bool isValid() const;
|
||||
HMODULE getModule();
|
||||
HMODULE getModule() const;
|
||||
|
||||
template <typename T>
|
||||
T getProc(const std::string& process) const
|
||||
|
@ -81,10 +81,12 @@ namespace Utils
|
||||
this->pool.push_back(data);
|
||||
return data;
|
||||
}
|
||||
|
||||
template <typename T> inline T* allocate()
|
||||
{
|
||||
return this->allocateArray<T>(1);
|
||||
}
|
||||
|
||||
template <typename T> inline T* allocateArray(size_t count = 1)
|
||||
{
|
||||
return static_cast<T*>(this->allocate(count * sizeof(T)));
|
||||
|
@ -107,10 +107,9 @@ namespace Utils
|
||||
void SetEnvironment()
|
||||
{
|
||||
wchar_t exeName[512];
|
||||
GetModuleFileNameW(GetModuleHandle(nullptr), exeName, sizeof(exeName) / sizeof(wchar_t));
|
||||
|
||||
GetModuleFileNameW(GetModuleHandleW(nullptr), exeName, sizeof(exeName) / sizeof(wchar_t));
|
||||
|
||||
wchar_t* exeBaseName = wcsrchr(exeName, L'\\');
|
||||
auto* exeBaseName = wcsrchr(exeName, L'\\');
|
||||
exeBaseName[0] = L'\0';
|
||||
|
||||
SetCurrentDirectoryW(exeName);
|
||||
|
Reference in New Issue
Block a user