Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
shanepowell committed Feb 21, 2025
2 parents 5ec95d6 + eb7854c commit 7a380c4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions DbgHelpUtils/symbol_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,12 @@ namespace dlg_help_utils::dbg_help
if (pdb.is_valid())
{
auto const debug_module_info_size = sizeof(IMAGE_DEBUG_DIRECTORY) + cv_record_size;
auto const debug_module_info = std::make_unique<uint8_t[]>(debug_module_info_size);

// Most recent DbgHelp.dll now requires sizeof(IMAGE_DEBUG_DIRECTORY) + cv_record_size to be 8bytes-aligned
auto const mandatoryAlignment = 8;
auto const debug_module_info_size_aligned = (debug_module_info_size + mandatoryAlignment) & (~uint64_t(mandatoryAlignment - 1));

auto const debug_module_info = std::make_unique<uint8_t[]>(debug_module_info_size_aligned);
auto* info = reinterpret_cast<IMAGE_DEBUG_DIRECTORY*>(debug_module_info.get());

info->TimeDateStamp = module_time_stamp;
Expand All @@ -1090,14 +1095,15 @@ namespace dlg_help_utils::dbg_help
info->Type = IMAGE_DEBUG_TYPE_CODEVIEW;
info->AddressOfRawData = 0;
info->PointerToRawData = sizeof(IMAGE_DEBUG_DIRECTORY);
info->SizeOfData = cv_record_size;

memcpy(debug_module_info.get() + info->PointerToRawData, cv_record, cv_record_size);

MODLOAD_DATA module_load_info;
module_load_info.ssize = sizeof(module_load_info);
module_load_info.ssig = DBHHEADER_DEBUGDIRS;
module_load_info.data = debug_module_info.get();
module_load_info.size = static_cast<DWORD>(debug_module_info_size);
module_load_info.size = static_cast<DWORD>(debug_module_info_size_aligned);
module_load_info.flags = 0;

if (callback().symbol_load_debug())
Expand Down

0 comments on commit 7a380c4

Please sign in to comment.