1
1
use rustc_middle:: mir;
2
- use rustc_target:: abi:: Size ;
3
2
use rustc_target:: spec:: abi:: Abi ;
4
3
5
4
use log:: trace;
@@ -11,7 +10,6 @@ use crate::*;
11
10
12
11
#[ derive( Debug , Copy , Clone ) ]
13
12
pub enum Dlsym {
14
- NtWriteFile ,
15
13
SetThreadDescription ,
16
14
WaitOnAddress ,
17
15
WakeByAddressSingle ,
@@ -23,7 +21,6 @@ impl Dlsym {
23
21
pub fn from_str < ' tcx > ( name : & str ) -> InterpResult < ' tcx , Option < Dlsym > > {
24
22
Ok ( match name {
25
23
"GetSystemTimePreciseAsFileTime" => None ,
26
- "NtWriteFile" => Some ( Dlsym :: NtWriteFile ) ,
27
24
"SetThreadDescription" => Some ( Dlsym :: SetThreadDescription ) ,
28
25
"WaitOnAddress" => Some ( Dlsym :: WaitOnAddress ) ,
29
26
"WakeByAddressSingle" => Some ( Dlsym :: WakeByAddressSingle ) ,
@@ -49,72 +46,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
49
46
this. check_abi ( abi, Abi :: System { unwind : false } ) ?;
50
47
51
48
match dlsym {
52
- Dlsym :: NtWriteFile => {
53
- if !this. frame_in_std ( ) {
54
- throw_unsup_format ! (
55
- "`NtWriteFile` support is crude and just enough for stdout to work"
56
- ) ;
57
- }
58
-
59
- let [
60
- handle,
61
- _event,
62
- _apc_routine,
63
- _apc_context,
64
- io_status_block,
65
- buf,
66
- n,
67
- byte_offset,
68
- _key,
69
- ] = check_arg_count ( args) ?;
70
- let handle = this. read_target_isize ( handle) ?;
71
- let buf = this. read_pointer ( buf) ?;
72
- let n = this. read_scalar ( n) ?. to_u32 ( ) ?;
73
- let byte_offset = this. read_target_usize ( byte_offset) ?; // is actually a pointer
74
- let io_status_block = this. deref_operand ( io_status_block) ?;
75
-
76
- if byte_offset != 0 {
77
- throw_unsup_format ! (
78
- "`NtWriteFile` `ByteOffset` paremeter is non-null, which is unsupported"
79
- ) ;
80
- }
81
-
82
- let written = if handle == -11 || handle == -12 {
83
- // stdout/stderr
84
- use std:: io:: { self , Write } ;
85
-
86
- let buf_cont =
87
- this. read_bytes_ptr_strip_provenance ( buf, Size :: from_bytes ( u64:: from ( n) ) ) ?;
88
- let res = if this. machine . mute_stdout_stderr {
89
- Ok ( buf_cont. len ( ) )
90
- } else if handle == -11 {
91
- io:: stdout ( ) . write ( buf_cont)
92
- } else {
93
- io:: stderr ( ) . write ( buf_cont)
94
- } ;
95
- // We write at most `n` bytes, which is a `u32`, so we cannot have written more than that.
96
- res. ok ( ) . map ( |n| u32:: try_from ( n) . unwrap ( ) )
97
- } else {
98
- throw_unsup_format ! (
99
- "on Windows, writing to anything except stdout/stderr is not supported"
100
- )
101
- } ;
102
- // We have to put the result into io_status_block.
103
- if let Some ( n) = written {
104
- let io_status_information =
105
- this. mplace_field_named ( & io_status_block, "Information" ) ?;
106
- this. write_scalar (
107
- Scalar :: from_target_usize ( n. into ( ) , this) ,
108
- & io_status_information. into ( ) ,
109
- ) ?;
110
- }
111
- // Return whether this was a success. >= 0 is success.
112
- // For the error code we arbitrarily pick 0xC0000185, STATUS_IO_DEVICE_ERROR.
113
- this. write_scalar (
114
- Scalar :: from_u32 ( if written. is_some ( ) { 0 } else { 0xC0000185u32 } ) ,
115
- dest,
116
- ) ?;
117
- }
118
49
Dlsym :: SetThreadDescription => {
119
50
let [ handle, name] = check_arg_count ( args) ?;
120
51
0 commit comments