Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions crates/xcl/src/hle/kernelx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1957,8 +1957,13 @@ mod tests {

#[test]
fn xmem_virtual_query_marks_cpu_readable_memory() {
// VirtualQueryEx writes a MEMORY_BASIC_INFORMATION at the start of the buffer.
#[repr(align(8))]
struct QueryBuffer([u8; 64]);

unsafe {
let mut info = [0u8; 64];
let mut storage = QueryBuffer([0; 64]);
let info = &mut storage.0;
let x = 5u32;
let proc_ = thr::GetCurrentProcess();
assert_eq!(XMemVirtualQuery(proc_, &x as *const u32 as _, info.as_mut_ptr() as _), 1);
Expand All @@ -1967,7 +1972,7 @@ mod tests {
assert_eq!(u32::from_le_bytes(info[48..52].try_into().unwrap()) & 3, 1);
// reserved, not committed: not CPU-readable
let r = mem::VirtualAlloc(std::ptr::null(), 0x10000, mem::MEM_RESERVE, mem::PAGE_NOACCESS);
let mut info = [0u8; 64];
info.fill(0);
assert_eq!(XMemVirtualQuery(proc_, r, info.as_mut_ptr() as _), 1);
assert_eq!(info[48] & 3, 0);
mem::VirtualFree(r, 0, mem::MEM_RELEASE);
Expand Down
Loading