| 3 | using namespace LIEF::logging; |
| 4 | |
| 5 | int main(int argc, const char** argv) { |
| 6 | if (!LIEF::is_extended()) { |
| 7 | err("This example requires the extended version of LIEF"); |
| 8 | return EXIT_FAILURE; |
| 9 | } |
| 10 | |
| 11 | if (argc != 3) { |
| 12 | err("Usage: {} <binary> <address>", argv[0]); |
| 13 | return EXIT_FAILURE; |
| 14 | } |
| 15 | |
| 16 | std::unique_ptr<LIEF::Binary> target = LIEF::Parser::parse(argv[1]); |
| 17 | |
| 18 | if (target == nullptr) { |
| 19 | err("Can't parse: {}", argv[1]); |
| 20 | return EXIT_FAILURE; |
| 21 | } |
| 22 | |
| 23 | std::string add_str = argv[2]; |
| 24 | uint64_t addr = 0; |
| 25 | |
| 26 | if (add_str.size() > 2 && add_str[0] == '0' && add_str[1] == 'x') { |
| 27 | addr = std::strtoull(add_str.c_str() + 2, /*__endptr=*/nullptr, 16); |
| 28 | } else { |
| 29 | addr = std::strtoull(add_str.c_str(), /*__endptr=*/nullptr, 10); |
| 30 | } |
| 31 | |
| 32 | for (std::unique_ptr<LIEF::assembly::Instruction> inst : target->disassemble(addr)) { |
| 33 | info("{}", inst->to_string()); |
| 34 | } |
| 35 | |
| 36 | return EXIT_SUCCESS; |
| 37 | } |
nothing calls this directly
no test coverage detected