about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2022-10-21 12:19:59 +0200
committerRalf Jung <post@ralfj.de>2022-10-21 12:20:25 +0200
commitbb911ce32aeef2d691af993d0a1696d8402998a9 (patch)
tree295eb20dddee89560f4e67c9fc14937611688207 /src
parent76c554eac22112968da92699c64c260700bcd663 (diff)
downloadrust-bb911ce32aeef2d691af993d0a1696d8402998a9.tar.gz
rust-bb911ce32aeef2d691af993d0a1696d8402998a9.zip
add always-failing GetFileInformationByHandleEx stub
Diffstat (limited to 'src')
-rw-r--r--src/tools/miri/src/shims/windows/foreign_items.rs35
1 files changed, 20 insertions, 15 deletions
diff --git a/src/tools/miri/src/shims/windows/foreign_items.rs b/src/tools/miri/src/shims/windows/foreign_items.rs
index d998bdf420f..fa8eaaed58c 100644
--- a/src/tools/miri/src/shims/windows/foreign_items.rs
+++ b/src/tools/miri/src/shims/windows/foreign_items.rs
@@ -343,16 +343,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
                 // FIXME: we should set last_error, but to what?
                 this.write_null(dest)?;
             }
-            "GetConsoleMode" => {
-                // Windows "isatty" (in libtest) needs this, so we fake it.
-                let [console, mode] =
-                    this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
-                this.read_scalar(console)?.to_machine_isize(this)?;
-                this.deref_operand(mode)?;
-                // Indicate an error.
-                // FIXME: we should set last_error, but to what?
-                this.write_null(dest)?;
-            }
             "GetStdHandle" => {
                 let [which] =
                     this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
@@ -404,14 +394,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
                 let [] = this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
                 // Just fake a HANDLE
                 // It's fine to not use the Handle type here because its a stub
-                this.write_scalar(Scalar::from_machine_isize(1, this), dest)?;
+                this.write_int(1, dest)?;
             }
             "GetModuleHandleA" if this.frame_in_std() => {
                 #[allow(non_snake_case)]
                 let [_lpModuleName] =
                     this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
                 // We need to return something non-null here to make `compat_fn!` work.
-                this.write_scalar(Scalar::from_machine_isize(1, this), dest)?;
+                this.write_int(1, dest)?;
             }
             "SetConsoleTextAttribute" if this.frame_in_std() => {
                 #[allow(non_snake_case)]
@@ -420,24 +410,39 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
                 // Pretend these does not exist / nothing happened, by returning zero.
                 this.write_null(dest)?;
             }
+            "GetConsoleMode" if this.frame_in_std() => {
+                let [console, mode] =
+                    this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
+                this.read_scalar(console)?.to_machine_isize(this)?;
+                this.deref_operand(mode)?;
+                // Indicate an error.
+                this.write_null(dest)?;
+            }
+            "GetFileInformationByHandleEx" if this.frame_in_std() => {
+                #[allow(non_snake_case)]
+                let [_hFile, _FileInformationClass, _lpFileInformation, _dwBufferSize] =
+                    this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
+                // Just make it fail.
+                this.write_null(dest)?;
+            }
             "AddVectoredExceptionHandler" if this.frame_in_std() => {
                 #[allow(non_snake_case)]
                 let [_First, _Handler] =
                     this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
                 // Any non zero value works for the stdlib. This is just used for stack overflows anyway.
-                this.write_scalar(Scalar::from_machine_usize(1, this), dest)?;
+                this.write_int(1, dest)?;
             }
             "SetThreadStackGuarantee" if this.frame_in_std() => {
                 #[allow(non_snake_case)]
                 let [_StackSizeInBytes] =
                     this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
                 // Any non zero value works for the stdlib. This is just used for stack overflows anyway.
-                this.write_scalar(Scalar::from_u32(1), dest)?;
+                this.write_int(1, dest)?;
             }
             "GetCurrentProcessId" if this.frame_in_std() => {
                 let [] = this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
                 let result = this.GetCurrentProcessId()?;
-                this.write_scalar(Scalar::from_u32(result), dest)?;
+                this.write_int(result, dest)?;
             }
             // this is only callable from std because we know that std ignores the return value
             "SwitchToThread" if this.frame_in_std() => {