Add ProcessPrng shim to Miri

This is essentially the same as SystemFunction036 (aka RtlGenRandom) except that the given length is a usize instead of a u32
This commit is contained in:
Chris Denton 2024-02-20 08:51:24 -03:00
parent 08caefbb10
commit 8f89cbd796
No known key found for this signature in database
GPG Key ID: 713472F2F45627DE

View File

@ -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)?;