|
|
@ -37,11 +37,14 @@ X86BA_TEMPLATE void X86BinaryApplication<BitSize>::loadFromFile(std::string_view
|
|
|
|
|
|
|
|
|
|
|
|
_originalRelocs.clear();
|
|
|
|
_originalRelocs.clear();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_peFile.getRelocDir().isPresent())
|
|
|
|
|
|
|
|
{
|
|
|
|
_peFile.getRelocDir().forEachEntry(
|
|
|
|
_peFile.getRelocDir().forEachEntry(
|
|
|
|
[this](pe::BlockEntry const& entry)
|
|
|
|
[this](pe::BlockEntry const& entry)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_originalRelocs.insert(entry.getRva());
|
|
|
|
_originalRelocs.insert(entry.getRva());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// printf("* - Number of relocations: 0x%x\n", _originalRelocs.size());
|
|
|
|
// printf("* - Number of relocations: 0x%x\n", _originalRelocs.size());
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -714,7 +717,10 @@ X86BA_TEMPLATE bool X86BinaryApplication<BitSize>::transformRoutines()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Guesstimate.. Fix this..
|
|
|
|
// Guesstimate.. Fix this..
|
|
|
|
|
|
|
|
if (_peFile.getRelocDir().isPresent())
|
|
|
|
|
|
|
|
{
|
|
|
|
_peFile.getRelocDir().extend(((_routines.size() + 0x3) & ~0x3) * 0x100);
|
|
|
|
_peFile.getRelocDir().extend(((_routines.size() + 0x3) & ~0x3) * 0x100);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (auto& rtn : _routines)
|
|
|
|
for (auto& rtn : _routines)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -856,10 +862,12 @@ X86BA_TEMPLATE void X86BinaryApplication<BitSize>::compile()
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Append all relocations
|
|
|
|
// Append all relocations
|
|
|
|
|
|
|
|
if (_peFile.getRelocDir().isPresent())
|
|
|
|
|
|
|
|
{
|
|
|
|
for (auto it = _relocBlocks.begin(); it != _relocBlocks.end(); ++it)
|
|
|
|
for (auto it = _relocBlocks.begin(); it != _relocBlocks.end(); ++it)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
u32 rva = it->first;
|
|
|
|
u32 rva = it->first;
|
|
|
|
std::vector<RelocationEntry> const &entries = it->second;
|
|
|
|
std::vector<RelocationEntry> const& entries = it->second;
|
|
|
|
|
|
|
|
|
|
|
|
if (entries.empty())
|
|
|
|
if (entries.empty())
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
@ -888,6 +896,7 @@ X86BA_TEMPLATE void X86BinaryApplication<BitSize>::compile()
|
|
|
|
bs.append(pe::RelocationType::REL_BASED_ABSOLUTE, 0);
|
|
|
|
bs.append(pe::RelocationType::REL_BASED_ABSOLUTE, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pe::SectionHeader& reloc = _peFile.getSectionHdr(".reloc");
|
|
|
|
pe::SectionHeader& reloc = _peFile.getSectionHdr(".reloc");
|
|
|
|
std::uint32_t fileAlignment = _peFile.getPEHdr().getOptionalHdr().getFileAlignment();
|
|
|
|
std::uint32_t fileAlignment = _peFile.getPEHdr().getOptionalHdr().getFileAlignment();
|
|
|
|