Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.

Commit 93982f4

Browse files
committed
handle winapis
1 parent d8a010e commit 93982f4

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

Cargo.lock

Lines changed: 0 additions & 2 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
@@ -10,7 +10,7 @@ crate-type = ["cdylib"]
1010

1111
[dependencies]
1212
pyo3 = "0.18.1"
13-
libscemu = "0.18.2"
13+
libscemu = "0.18.3"
1414
#libscemu = { path = "/home/sha0/src/libscemu/" }
1515
#libscemu = { path = "/Users/sha0coder/src/libscemu/" }
1616
#libscemu = { path = "/Users/jesus/src/libscemu/" }

DOCUMENTATION.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,24 @@ libscemu provide multipe hooks, but not pyscemu.
445445
one opion is synchronous way:
446446

447447
```python
448+
def GetUserNameA():
449+
retaddr = emu.stack_pop64()
450+
print('GetUserNameA')
451+
emu.write_string(emu.get_reg('rcx'), 'baremetal\x00')
452+
emu.write_qword(emu.get_reg('rdx'), 9)
453+
emu.set_reg('rax', emu.get_reg('rcx'))
454+
455+
def recv():
456+
retaddr = emu.stack_pop64()
457+
rip = emu.get_reg('rip')
458+
rcx = emu.get_reg('rcx')
459+
rdx = emu.get_reg('rdx')
460+
r8 = emu.get_reg('r8')
461+
print(f'{rip:x}: recv({rcx}, {rdx:x}, {r8})')
462+
emu.write_dword(rdx, 3)
463+
emu.set_reg('rax', 4)
464+
465+
448466
emu.set_reg('rip', comm_protocol)
449467
while True:
450468
addr, name = emu.run_until_apicall()
@@ -453,6 +471,6 @@ while True:
453471
elif name =='recv':
454472
recv()
455473
else:
456-
print(f'unhandled call {name}')
474+
emu.handle_winapi(addr)
457475
```
458476

src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,11 @@ impl Emu {
800800
return Ok(self.emu.bp.get_mem_write());
801801
}
802802

803+
/// handle winapi address
804+
pub fn handle_winapi(&mut self, addr: u64) {
805+
self.emu.handle_winapi(addr);
806+
}
807+
803808
/// emulate until next winapi call
804809
pub fn run_until_apicall(&mut self) -> PyResult<(u64,String)> {
805810
self.emu.skip_apicall = true;

0 commit comments

Comments
 (0)