resolving relocate function and patching them (successfully done one :D)

This commit is contained in:
georgemoralis 2023-07-11 18:50:29 +03:00
parent 42dc535638
commit 81906c271a
4 changed files with 137 additions and 59 deletions

View file

@ -5,9 +5,26 @@
void SymbolsResolver::AddSymbol(const SymbolRes& s, u64 virtual_addr)
{
SymbolRecord r{};
char str[256];
sprintf(str, "%s (%s)[%s_v%d][%s_v%d.%d]", s.name.c_str(),s.nidName.c_str(), s.library.c_str(), s.library_version, s.module.c_str(),s.module_version_major, s.module_version_minor);
r.name = std::string(str);
r.name = GenerateName(s);
r.virtual_address = virtual_addr;
m_symbols.push_back(r);
}
std::string SymbolsResolver::GenerateName(const SymbolRes& s) {
char str[256];
sprintf(str, "%s lib[%s_v%d]mod[%s_v%d.%d]", s.name.c_str(),s.library.c_str(), s.library_version, s.module.c_str(),
s.module_version_major, s.module_version_minor);
return std::string(str);
}
const SymbolRecord* SymbolsResolver::FindSymbol(const SymbolRes& s) const {
std::string name = GenerateName(s);
int index = 0;
for (auto symbol : m_symbols) {
if (symbol.name.compare(name) == 0) {
return &m_symbols.at(index);
}
index++;
}
return nullptr;
}