Merge branch 'develop' into fix-dedi

This commit is contained in:
Edo
2022-04-06 21:38:36 +02:00
committed by GitHub
95 changed files with 414 additions and 592 deletions

View File

@ -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;
}

View File

@ -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)));

View File

@ -107,9 +107,9 @@ namespace Utils
void SetEnvironment()
{
wchar_t exeName[512];
GetModuleFileNameW(GetModuleHandle(nullptr), exeName, sizeof(exeName) / 2);
GetModuleFileNameW(GetModuleHandle(nullptr), exeName, sizeof(exeName) / sizeof(wchar_t));
wchar_t* exeBaseName = wcsrchr(exeName, L'\\');
auto* exeBaseName = wcsrchr(exeName, L'\\');
exeBaseName[0] = L'\0';
SetCurrentDirectoryW(exeName);