Skip to content

Commit bb911ce

Browse files
committed
add always-failing GetFileInformationByHandleEx stub
1 parent 76c554e commit bb911ce

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

Diff for: src/tools/miri/src/shims/windows/foreign_items.rs

+20-15
Original file line numberDiff line numberDiff line change
@@ -343,16 +343,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
343343
// FIXME: we should set last_error, but to what?
344344
this.write_null(dest)?;
345345
}
346-
"GetConsoleMode" => {
347-
// Windows "isatty" (in libtest) needs this, so we fake it.
348-
let [console, mode] =
349-
this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
350-
this.read_scalar(console)?.to_machine_isize(this)?;
351-
this.deref_operand(mode)?;
352-
// Indicate an error.
353-
// FIXME: we should set last_error, but to what?
354-
this.write_null(dest)?;
355-
}
356346
"GetStdHandle" => {
357347
let [which] =
358348
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> {
404394
let [] = this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
405395
// Just fake a HANDLE
406396
// It's fine to not use the Handle type here because its a stub
407-
this.write_scalar(Scalar::from_machine_isize(1, this), dest)?;
397+
this.write_int(1, dest)?;
408398
}
409399
"GetModuleHandleA" if this.frame_in_std() => {
410400
#[allow(non_snake_case)]
411401
let [_lpModuleName] =
412402
this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
413403
// We need to return something non-null here to make `compat_fn!` work.
414-
this.write_scalar(Scalar::from_machine_isize(1, this), dest)?;
404+
this.write_int(1, dest)?;
415405
}
416406
"SetConsoleTextAttribute" if this.frame_in_std() => {
417407
#[allow(non_snake_case)]
@@ -420,24 +410,39 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
420410
// Pretend these does not exist / nothing happened, by returning zero.
421411
this.write_null(dest)?;
422412
}
413+
"GetConsoleMode" if this.frame_in_std() => {
414+
let [console, mode] =
415+
this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
416+
this.read_scalar(console)?.to_machine_isize(this)?;
417+
this.deref_operand(mode)?;
418+
// Indicate an error.
419+
this.write_null(dest)?;
420+
}
421+
"GetFileInformationByHandleEx" if this.frame_in_std() => {
422+
#[allow(non_snake_case)]
423+
let [_hFile, _FileInformationClass, _lpFileInformation, _dwBufferSize] =
424+
this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
425+
// Just make it fail.
426+
this.write_null(dest)?;
427+
}
423428
"AddVectoredExceptionHandler" if this.frame_in_std() => {
424429
#[allow(non_snake_case)]
425430
let [_First, _Handler] =
426431
this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
427432
// Any non zero value works for the stdlib. This is just used for stack overflows anyway.
428-
this.write_scalar(Scalar::from_machine_usize(1, this), dest)?;
433+
this.write_int(1, dest)?;
429434
}
430435
"SetThreadStackGuarantee" if this.frame_in_std() => {
431436
#[allow(non_snake_case)]
432437
let [_StackSizeInBytes] =
433438
this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
434439
// Any non zero value works for the stdlib. This is just used for stack overflows anyway.
435-
this.write_scalar(Scalar::from_u32(1), dest)?;
440+
this.write_int(1, dest)?;
436441
}
437442
"GetCurrentProcessId" if this.frame_in_std() => {
438443
let [] = this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
439444
let result = this.GetCurrentProcessId()?;
440-
this.write_scalar(Scalar::from_u32(result), dest)?;
445+
this.write_int(result, dest)?;
441446
}
442447
// this is only callable from std because we know that std ignores the return value
443448
"SwitchToThread" if this.frame_in_std() => {

0 commit comments

Comments
 (0)