(
file_name: PyStrRef,
desired_access: u32,
share_mode: u32,
_security_attributes: PyObjectRef, // Always NULL (0)
creation_disposition: u32,
flags_and_
| 99 | reason = "matches Win32 CreateFile parameter structure" |
| 100 | )] |
| 101 | fn CreateFile( |
| 102 | file_name: PyStrRef, |
| 103 | desired_access: u32, |
| 104 | share_mode: u32, |
| 105 | _security_attributes: PyObjectRef, // Always NULL (0) |
| 106 | creation_disposition: u32, |
| 107 | flags_and_attributes: u32, |
| 108 | _template_file: PyObjectRef, // Always NULL (0) |
| 109 | vm: &VirtualMachine, |
| 110 | ) -> PyResult<WinHandle> { |
| 111 | use windows_sys::Win32::Storage::FileSystem::CreateFileW; |
| 112 | |
| 113 | let file_name_wide = file_name.as_wtf8().to_wide_with_nul(); |
| 114 | |
| 115 | let handle = unsafe { |
| 116 | CreateFileW( |
| 117 | file_name_wide.as_ptr(), |
| 118 | desired_access, |
| 119 | share_mode, |
| 120 | null(), |
| 121 | creation_disposition, |
| 122 | flags_and_attributes, |
| 123 | null_mut(), |
| 124 | ) |
| 125 | }; |
| 126 | |
| 127 | if handle == windows_sys::Win32::Foundation::INVALID_HANDLE_VALUE { |
| 128 | return Err(vm.new_last_os_error()); |
| 129 | } |
| 130 | |
| 131 | Ok(WinHandle(handle)) |
| 132 | } |
| 133 | |
| 134 | #[pyfunction] |
| 135 | fn GetStdHandle( |
nothing calls this directly
no test coverage detected