Search code examples
c#memory-mapped-files

C# MemoryMappedFile, how to set rights to communicate betweend processes?


I use memorymappedfile and it works when I communicate between 2 processes. However, I set up a windows service that runs with the LOCAL SYSTEM account and I would like to communicate with processes that runs in the current domain account logged in.

I found accessrule and tried :

security.AddAccessRule(new AccessRule<MemoryMappedFileRights>(string.Concat(Environment.MachineName, "\\Administrator"), MemoryMappedFileRights.FullControl, AccessControlType.Allow));

and also :

security.AddAccessRule(new AccessRule<MemoryMappedFileRights>("Everyone"), MemoryMappedFileRights.FullControl, AccessControlType.Allow));

But did not work, how can I grant FULL ACCESS TO EVERYONE AND/OR ANONYMOUS LOGON whatever?


Solution

  • I found it!

    Just put "Global\" in the segment name :

    "Global\SegmentMemoryName" and put AccessRule to Everyone and you're done!