parent
bfe69aea09
commit
dd78210335
@ -99,10 +99,10 @@ lock_api = "0.4.3"
|
|||||||
regex = "1.4.5"
|
regex = "1.4.5"
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
windows = { version = "0.29.0", features = ["std", "Win32_Foundation", "Win32_System_Threading", "Win32_System_Diagnostics_Debug", "Win32_System_Kernel", "Win32_System_Memory", "Win32_Security"] }
|
windows = { version = "0.37.0", features = ["Win32_Foundation", "Win32_System_Threading", "Win32_System_Diagnostics_Debug", "Win32_System_Kernel", "Win32_System_Memory", "Win32_Security"] }
|
||||||
|
|
||||||
[target.'cfg(windows)'.build-dependencies]
|
[target.'cfg(windows)'.build-dependencies]
|
||||||
windows = "0.29.0"
|
windows = "0.37.0"
|
||||||
|
|
||||||
#[profile.release]
|
#[profile.release]
|
||||||
#lto = true
|
#lto = true
|
||||||
|
@ -1165,7 +1165,8 @@ pub mod win32_shmem {
|
|||||||
const INVALID_HANDLE_VALUE: isize = -1;
|
const INVALID_HANDLE_VALUE: isize = -1;
|
||||||
|
|
||||||
use windows::{
|
use windows::{
|
||||||
Win32::Foundation::{CloseHandle, BOOL, HANDLE, PSTR},
|
core::PCSTR,
|
||||||
|
Win32::Foundation::{CloseHandle, BOOL, HANDLE},
|
||||||
Win32::System::Memory::{
|
Win32::System::Memory::{
|
||||||
CreateFileMappingA, MapViewOfFile, OpenFileMappingA, UnmapViewOfFile,
|
CreateFileMappingA, MapViewOfFile, OpenFileMappingA, UnmapViewOfFile,
|
||||||
FILE_MAP_ALL_ACCESS, PAGE_READWRITE,
|
FILE_MAP_ALL_ACCESS, PAGE_READWRITE,
|
||||||
@ -1205,14 +1206,9 @@ pub mod win32_shmem {
|
|||||||
PAGE_READWRITE,
|
PAGE_READWRITE,
|
||||||
0,
|
0,
|
||||||
map_size as u32,
|
map_size as u32,
|
||||||
PSTR(map_str_bytes.as_mut_ptr()),
|
PCSTR(map_str_bytes.as_mut_ptr()),
|
||||||
);
|
)?;
|
||||||
if handle == HANDLE(0) {
|
|
||||||
return Err(Error::unknown(format!(
|
|
||||||
"Cannot create shared memory {}",
|
|
||||||
String::from_utf8_lossy(map_str_bytes)
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
let map = MapViewOfFile(handle, FILE_MAP_ALL_ACCESS, 0, 0, map_size) as *mut u8;
|
let map = MapViewOfFile(handle, FILE_MAP_ALL_ACCESS, 0, 0, map_size) as *mut u8;
|
||||||
if map.is_null() {
|
if map.is_null() {
|
||||||
return Err(Error::unknown(format!(
|
return Err(Error::unknown(format!(
|
||||||
@ -1235,16 +1231,11 @@ pub mod win32_shmem {
|
|||||||
let map_str_bytes = id.id;
|
let map_str_bytes = id.id;
|
||||||
// Unlike MapViewOfFile this one needs u32
|
// Unlike MapViewOfFile this one needs u32
|
||||||
let handle = OpenFileMappingA(
|
let handle = OpenFileMappingA(
|
||||||
FILE_MAP_ALL_ACCESS,
|
FILE_MAP_ALL_ACCESS.0,
|
||||||
BOOL(0),
|
BOOL(0),
|
||||||
PSTR(map_str_bytes.as_ptr() as *mut _),
|
PCSTR(map_str_bytes.as_ptr() as *mut _),
|
||||||
);
|
)?;
|
||||||
if handle == HANDLE(0) {
|
|
||||||
return Err(Error::unknown(format!(
|
|
||||||
"Cannot open shared memory {}",
|
|
||||||
String::from_utf8_lossy(&map_str_bytes)
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
let map = MapViewOfFile(handle, FILE_MAP_ALL_ACCESS, 0, 0, map_size) as *mut u8;
|
let map = MapViewOfFile(handle, FILE_MAP_ALL_ACCESS, 0, 0, map_size) as *mut u8;
|
||||||
if map.is_null() {
|
if map.is_null() {
|
||||||
return Err(Error::unknown(format!(
|
return Err(Error::unknown(format!(
|
||||||
|
@ -1096,12 +1096,6 @@ mod windows_exception_handler {
|
|||||||
compiler_fence(Ordering::SeqCst);
|
compiler_fence(Ordering::SeqCst);
|
||||||
|
|
||||||
ExitProcess(1);
|
ExitProcess(1);
|
||||||
|
|
||||||
LeaveCriticalSection(
|
|
||||||
(data.critical as *mut RTL_CRITICAL_SECTION)
|
|
||||||
.as_mut()
|
|
||||||
.unwrap(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
compiler_fence(Ordering::SeqCst);
|
compiler_fence(Ordering::SeqCst);
|
||||||
|
@ -374,6 +374,13 @@ impl From<TryFromSliceError> for Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
impl From<windows::core::Error> for Error {
|
||||||
|
fn from(err: windows::core::Error) -> Self {
|
||||||
|
Self::unknown(format!("Windows API error: {:?}", err))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "python")]
|
#[cfg(feature = "python")]
|
||||||
impl From<pyo3::PyErr> for Error {
|
impl From<pyo3::PyErr> for Error {
|
||||||
fn from(err: pyo3::PyErr) -> Self {
|
fn from(err: pyo3::PyErr) -> Self {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user