I'm trying to create a MemoryMappedFile and ensure that only certain processes have access to the shared memory. This blog post on MSDN says:
The memory mapped file security allows you to customize who or which process can have access to the resource, this can be quite important when you want to protect sensitive information and you don’t want other processes changing the file map.
However, I cannot figure out how to reference a process, only the built-in SIDs which reference users and user groups. This works, but is not what I'm looking for:
MemoryMappedFileSecurity mmfs = new MemoryMappedFileSecurity();
SecurityIdentifier si = new SecurityIdentifier(WellKnownSidType.LocalServiceSid, null);
AccessRule<MemoryMappedFileRights> ar = new AccessRule<MemoryMappedFileRights>(si, MemoryMappedFileRights.ReadWrite, AccessControlType.Allow);
mmfs.AddAccessRule(ar);
MemoryMappedFile mmf = MemoryMappedFile.CreateNew("testmmf", 134217728, MemoryMappedFileAccess.ReadWrite, MemoryMappedFileOptions.None, mmfs, System.IO.HandleInheritability.None);
How do I reference my processes? Does my process have an SID? What concept am I completely missing?