| 1586 | |
| 1587 | #[pyfunction] |
| 1588 | fn ConnectPipe(address: String, vm: &VirtualMachine) -> PyResult<isize> { |
| 1589 | use windows_sys::Win32::Foundation::{GENERIC_READ, GENERIC_WRITE}; |
| 1590 | use windows_sys::Win32::Storage::FileSystem::{ |
| 1591 | CreateFileW, FILE_FLAG_OVERLAPPED, OPEN_EXISTING, |
| 1592 | }; |
| 1593 | |
| 1594 | let address_wide: Vec<u16> = address.encode_utf16().chain(core::iter::once(0)).collect(); |
| 1595 | |
| 1596 | let handle = unsafe { |
| 1597 | CreateFileW( |
| 1598 | address_wide.as_ptr(), |
| 1599 | GENERIC_READ | GENERIC_WRITE, |
| 1600 | 0, |
| 1601 | core::ptr::null(), |
| 1602 | OPEN_EXISTING, |
| 1603 | FILE_FLAG_OVERLAPPED, |
| 1604 | core::ptr::null_mut(), |
| 1605 | ) |
| 1606 | }; |
| 1607 | |
| 1608 | if handle == windows_sys::Win32::Foundation::INVALID_HANDLE_VALUE { |
| 1609 | return Err(set_from_windows_err(0, vm)); |
| 1610 | } |
| 1611 | |
| 1612 | Ok(handle as isize) |
| 1613 | } |
| 1614 | |
| 1615 | #[pyfunction] |
| 1616 | fn CreateIoCompletionPort( |