1
0
Fork 0
forked from lthn/blockchain

callstack_helper: fixed a potential issue in get_mod_info::operator()

This commit is contained in:
sowle 2025-05-30 14:45:24 +02:00
parent 99bcf712df
commit be0b6ab35e
No known key found for this signature in database
GPG key ID: C07A24B2D89D49FC

View file

@ -43,20 +43,19 @@ namespace
module_data ret{};
try
{
char temp[buffer_length];
MODULEINFO mi;
char temp[buffer_length] = {0};
MODULEINFO mi{};
GetModuleInformation(process, module, &mi, sizeof(mi));
ret.base_address = mi.lpBaseOfDll;
ret.load_size = mi.SizeOfImage;
GetModuleFileNameEx(process, module, temp, sizeof(temp));
ret.image_name = temp;
GetModuleBaseName(process, module, temp, sizeof(temp));
ret.module_name = temp;
std::vector<char> img(ret.image_name.begin(), ret.image_name.end());
std::vector<char> mod(ret.module_name.begin(), ret.module_name.end());
SymLoadModule64(process, 0, &img[0], &mod[0], (DWORD64)ret.base_address, ret.load_size);
if (GetModuleFileNameEx(process, module, temp, sizeof(temp)))
ret.image_name = temp;
if (GetModuleBaseName(process, module, temp, sizeof(temp)))
ret.module_name = temp;
SymLoadModule64(process, 0, ret.image_name.c_str(), ret.module_name.c_str(), (DWORD64)ret.base_address, ret.load_size);
}
catch(std::exception& e)
{