Skip to content

Commit 30f33f9

Browse files
committed
Update to the latest icicle version
1 parent e7da0ae commit 30f33f9

File tree

10 files changed

+458
-372
lines changed

10 files changed

+458
-372
lines changed

.github/workflows/CI.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
runs-on: ubuntu-latest
2424
strategy:
2525
matrix:
26-
target: [x86_64, x86, aarch64, armv7, s390x, ppc64le]
26+
target: [x86_64, aarch64]
2727
steps:
2828
- uses: actions/checkout@v3
2929
with:
@@ -48,7 +48,7 @@ jobs:
4848
runs-on: windows-latest
4949
strategy:
5050
matrix:
51-
target: [x64, x86]
51+
target: [x64]
5252
steps:
5353
- uses: actions/checkout@v3
5454
with:

Cargo.lock

Lines changed: 1 addition & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
22

33
[package]
4-
name = "icicle-unicorn"
4+
name = "icicle-python"
55
version = "0.1.0"
66
edition = "2021"
77

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# icicle-unicorn
1+
# icicle-python
22

3-
This project is an attempt to replace unicorn with a wrapper around [icicle-emu](https://github.com/icicle-emu/icicle-emu).
3+
This project is an easy to use Python wrapper around [icicle-emu](https://github.com/icicle-emu/icicle-emu).
44

55
## Requirements
66

@@ -9,6 +9,10 @@ This project is an attempt to replace unicorn with a wrapper around [icicle-emu]
99

1010
## Building
1111

12+
TODO: talk about the submodule
13+
14+
TODO: clone ghidra and set `GHIDRA_SRC` environment variable
15+
1216
Set up a virtual environment:
1317

1418
```shell

icicle-emu

icicle.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,12 @@ class Icicle:
9898

9999
icount_limit: int
100100

101+
# TODO: API to get memory information?
102+
101103
def mem_map(self, address: int, size: int, protection: MemoryProtection): ...
102104

105+
def mem_unmap(self, address: int, size: int): ...
106+
103107
def mem_protect(self, address: int, size: int, protection: MemoryProtection): ...
104108

105109
def mem_read(self, address: int, size: int) -> bytes: ...

src/lib.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ enum ExceptionCodePy {
122122

123123
ExecViolation = 0x0401,
124124
SelfModifyingCode = 0x0402,
125+
ExecUnaligned = 0x0404,
125126
OutOfMemory = 0x0501,
126127
AddressOverflow = 0x0502,
127128

@@ -166,6 +167,7 @@ impl From<ExceptionCode> for ExceptionCodePy {
166167
ExceptionCode::WriteUnaligned => ExceptionCodePy::WriteUnaligned,
167168
ExceptionCode::ExecViolation => ExceptionCodePy::ExecViolation,
168169
ExceptionCode::SelfModifyingCode => ExceptionCodePy::SelfModifyingCode,
170+
ExceptionCode::ExecUnaligned => ExceptionCodePy::ExecUnaligned,
169171
ExceptionCode::OutOfMemory => ExceptionCodePy::OutOfMemory,
170172
ExceptionCode::AddressOverflow => ExceptionCodePy::AddressOverflow,
171173
ExceptionCode::InvalidInstruction => ExceptionCodePy::InvalidInstruction,
@@ -290,11 +292,13 @@ impl Icicle {
290292
);
291293
}
292294

295+
// TODO: support instantiating this multiple times
293296
if tracing {
294-
tracing_subscriber::fmt()
297+
if tracing_subscriber::fmt()
295298
.with_max_level(tracing::Level::DEBUG)
296299
.with_target(false)
297-
.init();
300+
.try_init().is_err() {
301+
}
298302
}
299303

300304
// Setup the CPU state for the target triple
@@ -362,6 +366,19 @@ impl Icicle {
362366
}
363367
}
364368

369+
fn mem_unmap(&mut self, address: u64, size: u64) -> PyResult<()> {
370+
if self.vm.cpu.mem.unmap_memory_len(address, size) {
371+
Ok(())
372+
} else {
373+
Err(
374+
raise_MemoryError(
375+
format!("Failed to unmap memory {address:X}[{size:X}]"),
376+
MemError::Unknown,
377+
)
378+
)
379+
}
380+
}
381+
365382
fn mem_protect(&mut self, address: u64, size: usize, protection: MemoryProtection) -> PyResult<()> {
366383
self.vm.cpu.mem.update_perm(address, size as u64, convert_protection(protection))
367384
.map_err(|e| {

0 commit comments

Comments
 (0)