@@ -28,10 +28,20 @@ mod _winapi {
2828 ERROR_PIPE_CONNECTED , ERROR_SEM_TIMEOUT , GENERIC_READ , GENERIC_WRITE , STILL_ACTIVE ,
2929 WAIT_ABANDONED , WAIT_ABANDONED_0 , WAIT_OBJECT_0 , WAIT_TIMEOUT ,
3030 } ,
31+ Globalization :: {
32+ LCMAP_FULLWIDTH , LCMAP_HALFWIDTH , LCMAP_HIRAGANA , LCMAP_KATAKANA ,
33+ LCMAP_LINGUISTIC_CASING , LCMAP_LOWERCASE , LCMAP_SIMPLIFIED_CHINESE , LCMAP_TITLECASE ,
34+ LCMAP_TRADITIONAL_CHINESE , LCMAP_UPPERCASE ,
35+ } ,
3136 Storage :: FileSystem :: {
32- FILE_FLAG_FIRST_PIPE_INSTANCE , FILE_FLAG_OVERLAPPED , FILE_GENERIC_READ ,
33- FILE_GENERIC_WRITE , FILE_TYPE_CHAR , FILE_TYPE_DISK , FILE_TYPE_PIPE , FILE_TYPE_REMOTE ,
34- FILE_TYPE_UNKNOWN , OPEN_EXISTING , PIPE_ACCESS_DUPLEX , PIPE_ACCESS_INBOUND , SYNCHRONIZE ,
37+ COPYFILE2_CALLBACK_CHUNK_FINISHED , COPYFILE2_CALLBACK_CHUNK_STARTED ,
38+ COPYFILE2_CALLBACK_ERROR , COPYFILE2_CALLBACK_POLL_CONTINUE ,
39+ COPYFILE2_CALLBACK_STREAM_FINISHED , COPYFILE2_CALLBACK_STREAM_STARTED ,
40+ COPYFILE2_PROGRESS_CANCEL , COPYFILE2_PROGRESS_CONTINUE , COPYFILE2_PROGRESS_PAUSE ,
41+ COPYFILE2_PROGRESS_QUIET , COPYFILE2_PROGRESS_STOP , FILE_FLAG_FIRST_PIPE_INSTANCE ,
42+ FILE_FLAG_OVERLAPPED , FILE_GENERIC_READ , FILE_GENERIC_WRITE , FILE_TYPE_CHAR ,
43+ FILE_TYPE_DISK , FILE_TYPE_PIPE , FILE_TYPE_REMOTE , FILE_TYPE_UNKNOWN , OPEN_EXISTING ,
44+ PIPE_ACCESS_DUPLEX , PIPE_ACCESS_INBOUND , SYNCHRONIZE ,
3545 } ,
3646 System :: {
3747 Console :: { STD_ERROR_HANDLE , STD_INPUT_HANDLE , STD_OUTPUT_HANDLE } ,
@@ -53,6 +63,13 @@ mod _winapi {
5363 IDLE_PRIORITY_CLASS , INFINITE , NORMAL_PRIORITY_CLASS , PROCESS_DUP_HANDLE ,
5464 REALTIME_PRIORITY_CLASS , STARTF_USESHOWWINDOW , STARTF_USESTDHANDLES ,
5565 } ,
66+ WindowsProgramming :: {
67+ COPY_FILE_ALLOW_DECRYPTED_DESTINATION , COPY_FILE_COPY_SYMLINK ,
68+ COPY_FILE_FAIL_IF_EXISTS , COPY_FILE_NO_BUFFERING , COPY_FILE_NO_OFFLOAD ,
69+ COPY_FILE_OPEN_SOURCE_FOR_WRITE , COPY_FILE_REQUEST_COMPRESSED_TRAFFIC ,
70+ COPY_FILE_REQUEST_SECURITY_PRIVILEGES , COPY_FILE_RESTARTABLE ,
71+ COPY_FILE_RESUME_FROM_PAUSE ,
72+ } ,
5673 } ,
5774 UI :: WindowsAndMessaging :: SW_HIDE ,
5875 } ;
@@ -142,6 +159,16 @@ mod _winapi {
142159 }
143160 }
144161
162+ #[ pyfunction]
163+ fn GetLastError ( ) -> u32 {
164+ unsafe { windows_sys:: Win32 :: Foundation :: GetLastError ( ) }
165+ }
166+
167+ #[ pyfunction]
168+ fn GetVersion ( ) -> u32 {
169+ unsafe { windows_sys:: Win32 :: System :: SystemInformation :: GetVersion ( ) }
170+ }
171+
145172 #[ derive( FromArgs ) ]
146173 struct CreateProcessArgs {
147174 #[ pyarg( positional) ]
@@ -254,6 +281,21 @@ mod _winapi {
254281 ) )
255282 }
256283
284+ #[ pyfunction]
285+ fn OpenProcess (
286+ desired_access : u32 ,
287+ inherit_handle : bool ,
288+ process_id : u32 ,
289+ ) -> windows_sys:: Win32 :: Foundation :: HANDLE {
290+ unsafe {
291+ windows_sys:: Win32 :: System :: Threading :: OpenProcess (
292+ desired_access,
293+ BOOL :: from ( inherit_handle) ,
294+ process_id,
295+ )
296+ }
297+ }
298+
257299 #[ pyfunction]
258300 fn NeedCurrentDirectoryForExePath ( exe_name : PyStrRef ) -> bool {
259301 let exe_name = exe_name. as_str ( ) . to_wide_with_nul ( ) ;
@@ -452,4 +494,24 @@ mod _winapi {
452494 let ( path, _) = path. split_at ( length as usize ) ;
453495 Ok ( String :: from_utf16 ( path) . unwrap ( ) )
454496 }
497+
498+ #[ pyfunction]
499+ fn OpenMutexW ( desired_access : u32 , inherit_handle : bool , name : u16 ) -> PyResult < isize > {
500+ let handle = unsafe {
501+ windows_sys:: Win32 :: System :: Threading :: OpenMutexW (
502+ desired_access,
503+ BOOL :: from ( inherit_handle) ,
504+ windows_sys:: core:: PCWSTR :: from ( name as _ ) ,
505+ )
506+ } ;
507+ // if handle.is_invalid() {
508+ // return Err(errno_err(vm));
509+ // }
510+ Ok ( handle)
511+ }
512+
513+ #[ pyfunction]
514+ fn ReleaseMutex ( handle : isize ) -> WindowsSysResult < BOOL > {
515+ WindowsSysResult ( unsafe { windows_sys:: Win32 :: System :: Threading :: ReleaseMutex ( handle) } )
516+ }
455517}
0 commit comments