This commit is contained in:
Maurice Heumann
2025-03-29 06:50:56 +01:00
committed by momo5502
parent ab144de125
commit dec66f051d
4 changed files with 47 additions and 17 deletions

View File

@@ -76,7 +76,8 @@ namespace icicle
void map_mmio(const uint64_t address, const size_t size, mmio_read_callback read_cb,
mmio_write_callback write_cb) override
{
throw std::runtime_error("Not implemented");
return;
// throw std::runtime_error("Not implemented");
}
void map_memory(const uint64_t address, const size_t size, memory_permission permissions) override
@@ -116,28 +117,33 @@ namespace icicle
emulator_hook* hook_instruction(int instruction_type, instruction_hook_callback callback) override
{
throw std::runtime_error("Not implemented");
return nullptr;
// throw std::runtime_error("Not implemented");
}
emulator_hook* hook_basic_block(basic_block_hook_callback callback) override
{
throw std::runtime_error("Not implemented");
return nullptr;
// throw std::runtime_error("Not implemented");
}
emulator_hook* hook_edge_generation(edge_generation_hook_callback callback) override
{
throw std::runtime_error("Not implemented");
return nullptr;
// throw std::runtime_error("Not implemented");
}
emulator_hook* hook_interrupt(interrupt_hook_callback callback) override
{
throw std::runtime_error("Not implemented");
return nullptr;
// throw std::runtime_error("Not implemented");
}
emulator_hook* hook_memory_violation(uint64_t address, size_t size,
memory_violation_hook_callback callback) override
{
throw std::runtime_error("Not implemented");
return nullptr;
// throw std::runtime_error("Not implemented");
}
emulator_hook* hook_memory_access(const uint64_t address, const size_t size, const memory_operation filter,
@@ -148,32 +154,34 @@ namespace icicle
return nullptr;
}
throw std::runtime_error("Not implemented");
return nullptr;
// throw std::runtime_error("Not implemented");
}
void delete_hook(emulator_hook* hook) override
{
throw std::runtime_error("Not implemented");
// throw std::runtime_error("Not implemented");
}
void serialize_state(utils::buffer_serializer& buffer, const bool is_snapshot) const override
{
throw std::runtime_error("Not implemented");
// throw std::runtime_error("Not implemented");
}
void deserialize_state(utils::buffer_deserializer& buffer, const bool is_snapshot) override
{
throw std::runtime_error("Not implemented");
// throw std::runtime_error("Not implemented");
}
std::vector<std::byte> save_registers() override
{
throw std::runtime_error("Not implemented");
// throw std::runtime_error("Not implemented");
return {};
}
void restore_registers(const std::vector<std::byte>& register_data) override
{
throw std::runtime_error("Not implemented");
// throw std::runtime_error("Not implemented");
}
bool has_violation() const override

View File

@@ -96,7 +96,7 @@ impl IcicleEmulator {
pub fn read_register(&mut self, reg: X64Register, buffer: &mut [u8]) -> usize {
let reg_node = self.reg.get_node(reg);
let res = self.vm.cpu.read_dynamic(pcode::Value::Var(reg_node));
let bytes: [u8; 32] = res.zxt();
@@ -113,7 +113,28 @@ impl IcicleEmulator {
let len = std::cmp::min(data.len(), buffer.len());
buffer[..len].copy_from_slice(&data[..len]);
self.vm.cpu.write_var(reg_node, buffer);
//let value = icicle_cpu::regs::DynamicValue::new(buffer, reg_node.size.into());
//self.vm.cpu.write_trunc(reg_node, value);
match reg_node.size {
1 => self.vm.cpu.write_var::<[u8; 1]>(reg_node, buffer[..1].try_into().expect("")),
2 => self.vm.cpu.write_var::<[u8; 2]>(reg_node, buffer[..2].try_into().expect("")),
3 => self.vm.cpu.write_var::<[u8; 3]>(reg_node, buffer[..3].try_into().expect("")),
4 => self.vm.cpu.write_var::<[u8; 4]>(reg_node, buffer[..4].try_into().expect("")),
5 => self.vm.cpu.write_var::<[u8; 5]>(reg_node, buffer[..5].try_into().expect("")),
6 => self.vm.cpu.write_var::<[u8; 6]>(reg_node, buffer[..6].try_into().expect("")),
7 => self.vm.cpu.write_var::<[u8; 7]>(reg_node, buffer[..7].try_into().expect("")),
8 => self.vm.cpu.write_var::<[u8; 8]>(reg_node, buffer[..8].try_into().expect("")),
9 => self.vm.cpu.write_var::<[u8; 9]>(reg_node, buffer[..9].try_into().expect("")),
10 => self.vm.cpu.write_var::<[u8; 10]>(reg_node, buffer[..10].try_into().expect("")),
11 => self.vm.cpu.write_var::<[u8; 11]>(reg_node, buffer[..11].try_into().expect("")),
12 => self.vm.cpu.write_var::<[u8; 12]>(reg_node, buffer[..12].try_into().expect("")),
13 => self.vm.cpu.write_var::<[u8; 13]>(reg_node, buffer[..13].try_into().expect("")),
14 => self.vm.cpu.write_var::<[u8; 14]>(reg_node, buffer[..14].try_into().expect("")),
15 => self.vm.cpu.write_var::<[u8; 15]>(reg_node, buffer[..15].try_into().expect("")),
16 => self.vm.cpu.write_var::<[u8; 16]>(reg_node, buffer[..16].try_into().expect("")),
_ => panic!("invalid dynamic value size"),
}
return reg_node.size.into();
}
@@ -674,7 +695,7 @@ impl X64RegisterNodes {
fp5: r("ST5"),
fp6: r("ST6"),
fp7: r("ST7"),
/*k0: r("K0"),
/*k0: r("K0"),
k1: r("K1"),
k2: r("K2"),
k3: r("K3"),

View File

@@ -33,7 +33,7 @@ void process_context::setup(x64_emulator& emu, memory_manager& memory, const app
const mapped_module& executable, const mapped_module& ntdll,
const apiset::container& apiset_container)
{
setup_gdt(emu, memory);
// setup_gdt(emu, memory);
this->kusd.setup();

View File

@@ -4,6 +4,7 @@
#include "cpu_context.hpp"
#include <unicorn_x64_emulator.hpp>
#include <icicle_x64_emulator.hpp>
#include <utils/io.hpp>
#include <utils/finally.hpp>
@@ -207,7 +208,7 @@ namespace
std::unique_ptr<x64_emulator> create_default_x64_emulator()
{
return unicorn::create_x64_emulator();
return icicle::create_x64_emulator();
}
windows_emulator::windows_emulator(application_settings app_settings, const emulator_settings& settings,