mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2025-01-04 10:13:02 +05:00
Updated ModuleList.hpp
This commit is contained in:
parent
a76b06a400
commit
614354ec8a
1 changed files with 34 additions and 11 deletions
|
@ -107,12 +107,32 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void EnumerateInternal( HMODULE* modules, size_t numModules )
|
void EnumerateInternal( HMODULE* modules, size_t numModules )
|
||||||
|
{
|
||||||
|
size_t moduleNameLength = MAX_PATH;
|
||||||
|
wchar_t* moduleName = static_cast<wchar_t*>( malloc( moduleNameLength * sizeof(moduleName[0]) ) );
|
||||||
|
if ( moduleName != nullptr )
|
||||||
{
|
{
|
||||||
m_moduleList.reserve( numModules );
|
m_moduleList.reserve( numModules );
|
||||||
for ( size_t i = 0; i < numModules; i++ )
|
for ( size_t i = 0; i < numModules; i++ )
|
||||||
{
|
{
|
||||||
wchar_t moduleName[MAX_PATH];
|
// Obtain module name, with resizing if necessary
|
||||||
if ( GetModuleFileNameW( *modules, moduleName, MAX_PATH ) != 0 )
|
DWORD size;
|
||||||
|
while ( size = GetModuleFileNameW( *modules, moduleName, moduleNameLength ), size == moduleNameLength )
|
||||||
|
{
|
||||||
|
wchar_t* newName = static_cast<wchar_t*>( realloc( moduleName, 2 * moduleNameLength * sizeof(moduleName[0]) ) );
|
||||||
|
if ( newName != nullptr )
|
||||||
|
{
|
||||||
|
moduleName = newName;
|
||||||
|
moduleNameLength *= 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
size = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( size != 0 )
|
||||||
{
|
{
|
||||||
const wchar_t* nameBegin = wcsrchr( moduleName, '\\' ) + 1;
|
const wchar_t* nameBegin = wcsrchr( moduleName, '\\' ) + 1;
|
||||||
const wchar_t* dotPos = wcsrchr( nameBegin, '.' );
|
const wchar_t* dotPos = wcsrchr( nameBegin, '.' );
|
||||||
|
@ -127,6 +147,9 @@ private:
|
||||||
}
|
}
|
||||||
modules++;
|
modules++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free( moduleName );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector< std::pair<HMODULE, std::wstring> > m_moduleList;
|
std::vector< std::pair<HMODULE, std::wstring> > m_moduleList;
|
||||||
|
|
Loading…
Reference in a new issue