Skip to content

Commit

Permalink
SysAllocStringLen
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonros committed Jan 4, 2025
1 parent 93cbb3d commit 0496014
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions libmwemu/src/winapi64/oleaut32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ fn SysAllocStringLen(emu: &mut emu::Emu) {
let mut size = emu.regs.rdx;

log::info!(
"{}** {} oleaut32!SysAllocStringLen str_ptr: 0x{:x} size: {}",
"{}** {}:{:x} oleaut32!SysAllocStringLen str_ptr: 0x{:x} size: {}",
emu.colors.light_red,
emu.pos,
emu.regs.rip,
str_ptr,
size
);
Expand All @@ -48,12 +49,17 @@ fn SysAllocStringLen(emu: &mut emu::Emu) {
let base = emu.maps.alloc(size + 100).expect("oleaut32!SysAllocStringLen out of memory");
let name = format!("alloc_{:x}", base);
emu.maps.create_map(&name, base, size + 100);
emu.maps.memcpy(base + 8, str_ptr, size as usize - 1);

// watch out for null?
if str_ptr != 0 {
emu.maps.memcpy(base + 8, str_ptr, size as usize - 1);
}

log::info!(
"{}** {} oleaut32!SysAllocStringLen ={} {} {}",
"{}** {}:{:x} oleaut32!SysAllocStringLen ={} {} {}",
emu.colors.light_red,
emu.pos,
emu.regs.rip,
name,
size - 8,
emu.colors.nc
Expand Down

0 comments on commit 0496014

Please sign in to comment.