Skip to content

Commit

Permalink
Add ProcessPrng shim to Miri
Browse files Browse the repository at this point in the history
This is essentially the same as SystemFunction036 (aka RtlGenRandom) except that the given length is a usize instead of a u32
  • Loading branch information
ChrisDenton committed Feb 25, 2024
1 parent 08caefb commit 8f89cbd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/tools/miri/src/shims/windows/foreign_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
this.gen_random(ptr, len.into())?;
this.write_scalar(Scalar::from_bool(true), dest)?;
}
"ProcessPrng" => {
let [ptr, len] =
this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
let ptr = this.read_pointer(ptr)?;
let len = this.read_target_usize(len)?;
this.gen_random(ptr, len.into())?;
this.write_scalar(Scalar::from_i32(1), dest)?;
}
"BCryptGenRandom" => {
let [algorithm, ptr, len, flags] =
this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
Expand Down

0 comments on commit 8f89cbd

Please sign in to comment.