I got NtReadVirtualMemory to work
pub fn NtReadVirtualMemory(
process_handle: Win.HANDLE,
base_address: ?*anyopaque,
buffer: *anyopaque,
number_of_bytes_to_read: usize,
number_of_bytes_read: ?*Win.SIZE_T,
) callconv(.winapi) u32 {
return asm volatile (
\\ sub $0x38, %%rsp // Allocate 56 bytes (shadow + args + alignment)
\\ mov %[a5], %%rax // Load pointer into rax
\\ mov %%rax, 0x28(%%rsp) // Store at correct offset (shadow + 8)
\\ mov %%rcx, %%r10
\\ mov $0x3f, %%eax
\\ syscall
\\ add $0x38, %%rsp
: [ret] "={rax}" (-> u32),
: [a1] "{rcx}" (process_handle),
[a2] "{rdx}" (base_address),
[a3] "{r8}" (buffer),
[a4] "{r9}" (number_of_bytes_to_read),
[a5] "r" (number_of_bytes_read),
: .{.r10 = true, .r11 = true, .memory = true}
);
}
but I have to do stack allocation in assembly which I dont like
is there a way to let the compiler do the dirty work for more than 4 params?