Skip to content

Commit 0a72112

Browse files
committed
remove explicitly generating shm name
1 parent 0926314 commit 0a72112

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

  • crates/fspy_shared/src/ipc/channel

crates/fspy_shared/src/ipc/channel/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@ pub fn channel(capacity: usize) -> io::Result<(ChannelConf, Receiver)> {
2626
// Initialize the lock file with a unique name.
2727
let lock_file_path = temp_dir().join(format!("fspy_ipc_{}.lock", Uuid::new_v4()));
2828

29-
// Initialize the shared memory with a unique id.
30-
// Use a named shared memory so it can be opened from other processes.
31-
let shm_id = format!("fspy_shm_{}", Uuid::new_v4());
32-
let shm = ShmemConf::new()
33-
.size(capacity)
34-
.os_id(&shm_id)
35-
.create()
36-
.map_err(|err| io::Error::new(io::ErrorKind::Other, err))?;
29+
let mut conf = ShmemConf::new().size(capacity);
30+
// On Windows, allow opening raw shared memory (without backing file) for DLL injection scenarios
31+
#[cfg(target_os = "windows")]
32+
{
33+
conf = conf.allow_raw(true);
34+
}
35+
36+
let shm = conf.create().map_err(|err| io::Error::new(io::ErrorKind::Other, err))?;
3737

3838
let conf = ChannelConf {
3939
lock_file_path: lock_file_path.as_os_str().into(),
40-
shm_id: shm_id.into(),
40+
shm_id: shm.get_os_id().into(),
4141
shm_size: capacity,
4242
};
4343

0 commit comments

Comments
 (0)