@@ -17,7 +17,6 @@ pub mod security;
17
17
pub mod tp;
18
18
19
19
use self :: security:: SecurityDescriptor ;
20
- use handleapi:: INVALID_HANDLE_VALUE ;
21
20
use ntapi:: ntioapi:: FILE_COMPLETION_INFORMATION ;
22
21
use ntapi:: ntioapi:: FileReplaceCompletionInformation ;
23
22
use ntapi:: ntioapi:: IO_STATUS_BLOCK ;
@@ -34,7 +33,6 @@ use ntrtl::RtlAllocateHeap;
34
33
use ntrtl:: RtlDosPathNameToNtPathName_U_WithStatus ;
35
34
use ntrtl:: RtlFreeUnicodeString ;
36
35
use ntrtl:: RtlNtStatusToDosErrorNoTeb ;
37
- use processthreadsapi:: GetExitCodeProcess ;
38
36
use std:: cell:: UnsafeCell ;
39
37
use std:: ffi:: OsStr ;
40
38
use std:: ffi:: c_void;
@@ -55,32 +53,33 @@ use std::sync::atomic::Ordering;
55
53
use std:: time:: Duration ;
56
54
use widestring:: U16CString ;
57
55
use widestring:: Utf16Str ;
58
- use winapi:: shared:: ntdef;
59
- use winapi:: shared:: ntdef:: NTSTATUS ;
60
- use winapi:: shared:: ntstatus;
61
- use winapi:: shared:: ntstatus:: STATUS_PENDING ;
62
- use winapi:: shared:: winerror:: ERROR_BAD_PATHNAME ;
63
- use winapi:: shared:: ws2def;
64
- use winapi:: um:: errhandlingapi:: GetErrorMode ;
65
- use winapi:: um:: errhandlingapi:: SetErrorMode ;
66
- use winapi:: um:: handleapi;
67
- use winapi:: um:: handleapi:: CloseHandle ;
68
- use winapi:: um:: heapapi:: GetProcessHeap ;
69
- use winapi:: um:: ioapiset:: CreateIoCompletionPort ;
70
- use winapi:: um:: ioapiset:: GetQueuedCompletionStatusEx ;
71
- use winapi:: um:: ioapiset:: PostQueuedCompletionStatus ;
72
- use winapi:: um:: minwinbase:: OVERLAPPED ;
73
- use winapi:: um:: minwinbase:: OVERLAPPED_ENTRY ;
74
- use winapi:: um:: processenv:: SetStdHandle ;
75
- use winapi:: um:: processthreadsapi;
76
- use winapi:: um:: processthreadsapi:: TerminateProcess ;
77
- use winapi:: um:: synchapi;
78
- use winapi:: um:: winbase:: INFINITE ;
79
- use winapi:: um:: winbase:: SEM_FAILCRITICALERRORS ;
80
- use winapi:: um:: winbase:: STD_OUTPUT_HANDLE ;
81
- use winapi:: um:: winbase:: SetFileCompletionNotificationModes ;
82
- use winapi:: um:: winnt;
83
- use winapi:: um:: winsock2;
56
+ use windows:: Win32 :: Foundation :: CloseHandle ;
57
+ use windows:: Win32 :: Foundation :: DuplicateHandle ;
58
+ use windows:: Win32 :: Foundation :: DUPLICATE_SAME_ACCESS ;
59
+ use windows:: Win32 :: Foundation :: ERROR_BAD_PATHNAME ;
60
+ use windows:: Win32 :: Foundation :: INVALID_HANDLE_VALUE ;
61
+ use windows:: Win32 :: Foundation :: NTSTATUS ;
62
+ use windows:: Win32 :: Foundation :: STATUS_PENDING ;
63
+ use windows:: Win32 :: Foundation :: INFINITE ;
64
+ use windows:: Win32 :: System :: ErrorReporting :: GetErrorMode ;
65
+ use windows:: Win32 :: System :: ErrorReporting :: SetErrorMode ;
66
+ use windows:: Win32 :: System :: ErrorReporting :: SEM_FAILCRITICALERRORS ;
67
+ use windows:: Win32 :: System :: IO :: CreateIoCompletionPort ;
68
+ use windows:: Win32 :: System :: IO :: GetQueuedCompletionStatusEx ;
69
+ use windows:: Win32 :: System :: IO :: PostQueuedCompletionStatus ;
70
+ use windows:: Win32 :: System :: IO :: OVERLAPPED ;
71
+ use windows:: Win32 :: System :: IO :: OVERLAPPED_ENTRY ;
72
+ use windows:: Win32 :: System :: Memory :: GetProcessHeap ;
73
+ use windows:: Win32 :: System :: Threading :: GetCurrentProcess ;
74
+ use windows:: Win32 :: System :: Threading :: GetExitCodeProcess ;
75
+ use windows:: Win32 :: System :: Threading :: GetProcessId ;
76
+ use windows:: Win32 :: System :: Threading :: SetStdHandle ;
77
+ use windows:: Win32 :: System :: Threading :: TerminateProcess ;
78
+ use windows:: Win32 :: System :: Threading :: STD_OUTPUT_HANDLE ;
79
+ use windows:: Win32 :: System :: Threading :: WaitForSingleObject ;
80
+ use windows:: Win32 :: Storage :: FileSystem :: SetFileCompletionNotificationModes ;
81
+ use windows:: Win32 :: Networking :: WinSock :: IOC_IN ;
82
+ use windows:: Win32 :: Networking :: WinSock :: IOC_VENDOR ;
84
83
85
84
#[ repr( transparent) ]
86
85
#[ derive( Debug , Copy , Clone , PartialEq , Eq ) ]
@@ -99,11 +98,11 @@ impl BorrowedHandleExt for BorrowedHandle<'_> {
99
98
let options = if access. is_some ( ) {
100
99
0
101
100
} else {
102
- winnt :: DUPLICATE_SAME_ACCESS
101
+ DUPLICATE_SAME_ACCESS
103
102
} ;
104
103
unsafe {
105
- let process = processthreadsapi :: GetCurrentProcess ( ) ;
106
- if handleapi :: DuplicateHandle (
104
+ let process = GetCurrentProcess ( ) ;
105
+ if DuplicateHandle (
107
106
process,
108
107
self . as_raw_handle ( ) ,
109
108
process,
@@ -134,8 +133,8 @@ pub trait OwnedSocketExt: Sized {
134
133
fn from_handle ( handle : OwnedHandle ) -> Result < Self > ;
135
134
}
136
135
137
- const SIO_SOCKET_TRANSFER_BEGIN : u32 = ws2def :: IOC_IN | ws2def :: IOC_VENDOR | 301 ;
138
- const SIO_SOCKET_TRANSFER_END : u32 = ws2def :: IOC_IN | ws2def :: IOC_VENDOR | 302 ;
136
+ const SIO_SOCKET_TRANSFER_BEGIN : u32 = IOC_IN | IOC_VENDOR | 301 ;
137
+ const SIO_SOCKET_TRANSFER_END : u32 = IOC_IN | IOC_VENDOR | 302 ;
139
138
140
139
/// Ensures WSAStartup has been called for the process.
141
140
fn init_winsock ( ) {
@@ -209,7 +208,7 @@ struct WaitObject(OwnedHandle);
209
208
210
209
impl WaitObject {
211
210
fn wait ( & self ) {
212
- assert ! ( unsafe { synchapi :: WaitForSingleObject ( self . 0 . as_raw_handle( ) , INFINITE ) } == 0 ) ;
211
+ assert ! ( unsafe { WaitForSingleObject ( self . 0 . as_raw_handle( ) , INFINITE ) } == 0 ) ;
213
212
}
214
213
}
215
214
@@ -233,7 +232,7 @@ impl Process {
233
232
234
233
pub fn id ( & self ) -> u32 {
235
234
unsafe {
236
- let pid = processthreadsapi :: GetProcessId ( self . as_handle ( ) . as_raw_handle ( ) ) ;
235
+ let pid = GetProcessId ( self . as_handle ( ) . as_raw_handle ( ) ) ;
237
236
assert_ne ! ( pid, 0 ) ;
238
237
pid
239
238
}
0 commit comments