| 124 | |
| 125 | |
| 126 | void DisasmDisplay(DbgRef<DebuggerController> debugger, const std::uint32_t count) |
| 127 | { |
| 128 | using namespace BinaryNinja; |
| 129 | |
| 130 | std::vector<std::string> disasm_strings {}; |
| 131 | std::vector<std::string> llil_strings {}; |
| 132 | std::vector<std::string> mlil_strings {}; |
| 133 | std::vector<std::string> hlil_strings {}; |
| 134 | |
| 135 | std::uintptr_t instruction_increment {}; |
| 136 | for (std::uint32_t steps {}; steps < count; steps++) |
| 137 | { |
| 138 | const auto instruction_offset = debugger->IP() + instruction_increment; |
| 139 | if (!instruction_offset) |
| 140 | return; |
| 141 | |
| 142 | const auto architecture = debugger->GetRemoteArchitecture(); |
| 143 | if (!architecture) |
| 144 | return; |
| 145 | |
| 146 | const auto data = debugger->ReadMemory(instruction_offset, 16); |
| 147 | if (data.GetLength() == 0) |
| 148 | return; |
| 149 | |
| 150 | size_t size = data.GetLength(); |
| 151 | std::vector<InstructionTextToken> instruction_tokens {}; |
| 152 | if (!architecture->GetInstructionText( |
| 153 | (const uint8_t*)data.GetData(), instruction_offset, size, instruction_tokens)) |
| 154 | { |
| 155 | printf("failed to disassemble\n"); |
| 156 | return; |
| 157 | } |
| 158 | |
| 159 | instruction_increment += size; |
| 160 | |
| 161 | auto data_buffer = DataBuffer(data.GetData(), size); |
| 162 | Ref<BinaryData> bd = new BinaryData(new FileMetadata(), data_buffer); |
| 163 | Ref<BinaryView> bv; |
| 164 | for (const auto& type : BinaryViewType::GetViewTypes()) |
| 165 | if (type->IsTypeValidForData(bd) && type->GetName() == "Raw") |
| 166 | { |
| 167 | bv = type->Create(bd); |
| 168 | break; |
| 169 | } |
| 170 | |
| 171 | bv->UpdateAnalysisAndWait(); |
| 172 | |
| 173 | Ref<Platform> plat = nullptr; |
| 174 | auto arch_list = Platform::GetList(); |
| 175 | for (const auto& arch : arch_list) |
| 176 | { |
| 177 | constexpr auto os = |
| 178 | #ifdef WIN32 |
| 179 | "windows"; |
| 180 | #else |
| 181 | "linux"; |
| 182 | #endif |
| 183 |
no test coverage detected