vmp does, except each reloc will decrypt the ptr... polymorphic stuff..3.0
parent
22504906d4
commit
79db6d538c
@ -0,0 +1,40 @@
|
|||||||
|
#include <decomp/routine.hpp>
|
||||||
|
|
||||||
|
namespace theo::decomp {
|
||||||
|
routine_t::routine_t(coff::section_header_t* scn, std::vector<std::uint8_t>& fn)
|
||||||
|
: m_scn(scn), m_data(fn) {}
|
||||||
|
|
||||||
|
std::vector<decomp::symbol_t> routine_t::decompose() {
|
||||||
|
std::uint32_t offset = 0u;
|
||||||
|
xed_error_enum_t err;
|
||||||
|
|
||||||
|
xed_decoded_inst_t instr;
|
||||||
|
std::vector<xed_decoded_inst_t> instrs;
|
||||||
|
xed_state_t istate{XED_MACHINE_MODE_LONG_64, XED_ADDRESS_WIDTH_64b};
|
||||||
|
xed_decoded_inst_zero_set_mode(&instr, &istate);
|
||||||
|
|
||||||
|
// keep looping over the section, lower the number of bytes each time...
|
||||||
|
//
|
||||||
|
while ((err = xed_decode(&instr, m_data.data() + offset,
|
||||||
|
m_data.size() - offset)) == XED_ERROR_NONE) {
|
||||||
|
char buff[255];
|
||||||
|
offset += xed_decoded_inst_get_length(&instr);
|
||||||
|
xed_format_context(XED_SYNTAX_INTEL, &instr, buff, sizeof buff, 0, 0, 0);
|
||||||
|
spdlog::info("{}", buff);
|
||||||
|
instrs.push_back(instr);
|
||||||
|
|
||||||
|
// need to set this so that instr can be used to decode again...
|
||||||
|
xed_decoded_inst_zero_set_mode(&instr, &istate);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
coff::section_header_t* routine_t::scn() {
|
||||||
|
return m_scn;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::uint8_t> routine_t::data() {
|
||||||
|
return m_data;
|
||||||
|
}
|
||||||
|
} // namespace theo::decomp
|
Loading…
Reference in new issue