@@ -19,7 +19,7 @@ mod _winapi {
1919 Win32 :: Foundation :: { HANDLE , HINSTANCE , MAX_PATH } ,
2020 core:: PCWSTR ,
2121 } ;
22- use windows_sys:: Win32 :: Foundation :: { BOOL , HANDLE as RAW_HANDLE } ;
22+ use windows_sys:: Win32 :: Foundation :: { BOOL , INVALID_HANDLE_VALUE } ;
2323
2424 #[ pyattr]
2525 use windows_sys:: Win32 :: {
@@ -87,8 +87,18 @@ mod _winapi {
8787 #[ pyfunction]
8888 fn GetStdHandle (
8989 std_handle : windows_sys:: Win32 :: System :: Console :: STD_HANDLE ,
90- ) -> WindowsSysResult < RAW_HANDLE > {
91- WindowsSysResult ( unsafe { windows_sys:: Win32 :: System :: Console :: GetStdHandle ( std_handle) } )
90+ vm : & VirtualMachine ,
91+ ) -> PyResult < Option < HANDLE > > {
92+ let handle = unsafe { windows_sys:: Win32 :: System :: Console :: GetStdHandle ( std_handle) } ;
93+ if handle == INVALID_HANDLE_VALUE {
94+ return Err ( errno_err ( vm) ) ;
95+ }
96+ Ok ( if handle. is_null ( ) {
97+ // NULL handle - return None
98+ None
99+ } else {
100+ Some ( HANDLE ( handle as isize ) )
101+ } )
92102 }
93103
94104 #[ pyfunction]
@@ -114,7 +124,8 @@ mod _winapi {
114124
115125 #[ pyfunction]
116126 fn DuplicateHandle (
117- ( src_process, src) : ( HANDLE , HANDLE ) ,
127+ src_process : HANDLE ,
128+ src : HANDLE ,
118129 target_process : HANDLE ,
119130 access : u32 ,
120131 inherit : BOOL ,
@@ -294,6 +305,11 @@ mod _winapi {
294305 }
295306 }
296307
308+ #[ pyfunction]
309+ fn ExitProcess ( exit_code : u32 ) {
310+ unsafe { windows_sys:: Win32 :: System :: Threading :: ExitProcess ( exit_code) }
311+ }
312+
297313 #[ pyfunction]
298314 fn NeedCurrentDirectoryForExePath ( exe_name : PyStrRef ) -> bool {
299315 let exe_name = exe_name. as_str ( ) . to_wide_with_nul ( ) ;
0 commit comments