fixes for win32
This commit is contained in:
parent
6f1058f8d1
commit
cc0da780ef
@ -1,7 +1,7 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
windows::build!(
|
windows::build!(
|
||||||
windows::win32::system_services::{HANDLE},
|
windows::win32::system_services::{HANDLE, BOOL},
|
||||||
windows::win32::windows_programming::CloseHandle,
|
windows::win32::windows_programming::CloseHandle,
|
||||||
// API needed for the shared memory
|
// API needed for the shared memory
|
||||||
windows::win32::system_services::{CreateFileMappingA, OpenFileMappingA, MapViewOfFile, UnmapViewOfFile},
|
windows::win32::system_services::{CreateFileMappingA, OpenFileMappingA, MapViewOfFile, UnmapViewOfFile},
|
||||||
|
@ -446,7 +446,7 @@ pub mod shmem {
|
|||||||
use super::ShMem;
|
use super::ShMem;
|
||||||
use crate::{
|
use crate::{
|
||||||
bolts::bindings::{
|
bolts::bindings::{
|
||||||
windows::win32::system_services::HANDLE,
|
windows::win32::system_services::{HANDLE, BOOL},
|
||||||
windows::win32::system_services::{
|
windows::win32::system_services::{
|
||||||
CreateFileMappingA, MapViewOfFile, OpenFileMappingA, UnmapViewOfFile,
|
CreateFileMappingA, MapViewOfFile, OpenFileMappingA, UnmapViewOfFile,
|
||||||
},
|
},
|
||||||
@ -509,7 +509,7 @@ pub mod shmem {
|
|||||||
impl Win32ShMem {
|
impl Win32ShMem {
|
||||||
pub fn from_str(map_str_bytes: &[u8; 20], map_size: usize) -> Result<Self, Error> {
|
pub fn from_str(map_str_bytes: &[u8; 20], map_size: usize) -> Result<Self, Error> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let handle = OpenFileMappingA(FILE_MAP_ALL_ACCESS, 0, map_str_bytes as *const u8 as *const i8);
|
let handle = OpenFileMappingA(FILE_MAP_ALL_ACCESS, BOOL(0), map_str_bytes as *const u8 as *const i8);
|
||||||
if handle == HANDLE(0) {
|
if handle == HANDLE(0) {
|
||||||
return Err(Error::Unknown(format!(
|
return Err(Error::Unknown(format!(
|
||||||
"Cannot open shared memory {}",
|
"Cannot open shared memory {}",
|
||||||
@ -562,14 +562,12 @@ pub mod shmem {
|
|||||||
String::from_utf8_lossy(map_str_bytes)
|
String::from_utf8_lossy(map_str_bytes)
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
let mut ret = Self {
|
Ok(Self {
|
||||||
shm_str: [0; 20],
|
shm_str: map_str_bytes[0..20],
|
||||||
handle: handle,
|
handle: handle,
|
||||||
map: map,
|
map: map,
|
||||||
map_size: map_size,
|
map_size: map_size,
|
||||||
};
|
})
|
||||||
ret.shm_str.clone_from_slice(map_str_bytes[0..20]);
|
|
||||||
Ok(ret)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user