uhh oohh i guess it works
This commit is contained in:
parent
1263941560
commit
86df8ddc64
|
@ -64,8 +64,25 @@ impl Memory {
|
|||
}
|
||||
|
||||
let mut value = MaybeUninit::<Value>::zeroed();
|
||||
let overflow = (lookup.offset + S::BYTES).saturating_sub(lookup.size - 1);
|
||||
let normal = S::BYTES - overflow;
|
||||
|
||||
unsafe {
|
||||
core::ptr::copy_nonoverlapping::<u8>(lookup.ptr, value.as_mut_ptr().cast(), 1);
|
||||
core::ptr::copy_nonoverlapping::<u8>(lookup.ptr, value.as_mut_ptr().cast(), normal);
|
||||
if overflow != 0 {
|
||||
let lookup = self.page_lookup(lookup.ptr as u64 + lookup.size as u64)?;
|
||||
match lookup.perm {
|
||||
Permission::Empty | Permission::Node => return None,
|
||||
Permission::Readonly | Permission::Write | Permission::Exec => (),
|
||||
}
|
||||
|
||||
core::ptr::copy_nonoverlapping::<u8>(
|
||||
lookup.ptr,
|
||||
value.as_mut_ptr().cast::<u8>().add(normal),
|
||||
overflow,
|
||||
);
|
||||
}
|
||||
|
||||
Some(value.assume_init())
|
||||
}
|
||||
}
|
||||
|
@ -77,8 +94,26 @@ impl Memory {
|
|||
return Err(());
|
||||
}
|
||||
|
||||
let overflow = (lookup.offset + S::BYTES).saturating_sub(lookup.size - 1);
|
||||
let normal = S::BYTES - overflow;
|
||||
unsafe {
|
||||
core::ptr::copy_nonoverlapping::<u8>((&value as *const Value).cast(), lookup.ptr, 1)
|
||||
core::ptr::copy_nonoverlapping::<u8>(
|
||||
(&value as *const Value).cast(),
|
||||
lookup.ptr,
|
||||
normal,
|
||||
);
|
||||
|
||||
if overflow != 0 {
|
||||
let lookup = self
|
||||
.page_lookup(lookup.ptr as u64 + lookup.size as u64)
|
||||
.ok_or(())?;
|
||||
|
||||
core::ptr::copy_nonoverlapping::<u8>(
|
||||
(&value as *const Value).cast::<u8>().add(normal),
|
||||
lookup.ptr,
|
||||
overflow,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
Ok(())
|
||||
|
|
Loading…
Reference in a new issue