From 8f89cbd796fe54b3454175193d6c2be245376161 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Tue, 20 Feb 2024 08:51:24 -0300 Subject: [PATCH] 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 --- src/tools/miri/src/shims/windows/foreign_items.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/tools/miri/src/shims/windows/foreign_items.rs b/src/tools/miri/src/shims/windows/foreign_items.rs index bddc30b8379..fdd7fc5fad4 100644 --- a/src/tools/miri/src/shims/windows/foreign_items.rs +++ b/src/tools/miri/src/shims/windows/foreign_items.rs @@ -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)?;