Sharing of Global In-memory Memory Mapped File
Asked Answered
H

0

6

We are trying to port the following code from .Net Framework to .Net Core. The code creates an in-memory memory mapped file that is accessible by applications running under different logged in accounts (without admin privilege). MemoryMappedFileSecurity class does not exist in .Net Core, how can I set up the shared memory mapped file?

var security = new MemoryMappedFileSecurity();<br/>
security.AddAccessRule(new AccessRule<MemoryMappedFileRights>(
                                    "everyone",
                                    MemoryMappedFileRights.FullControl,
                                    AccessControlType.Allow));

var memoryMappedFile = MemoryMappedFile.CreateNew(
                            "global\\SharedMap",
                            size,
                            MemoryMappedFileAccess.ReadWrite,
                            MemoryMappedFileOptions.DelayAllocatePages,
                            security,
                            HandleInheritability.Inheritable);

This is code which has been working for many years in .Net framework.

Memory is created (without a backing file) by a Windows service. Memory is then accessed by desktop client apps, which are not admins.

The security is needed, so that we can see the “admin” service memory from the desktop clients.

We are trying to convert our system, piece by piece, to .Net core 3.0. This system includes 100s of components made in several of our factories, in various countries around the world. So, We cannot just “replace all code” at once. We cannot change the protocol used by the server.

We have many years of experience with memory maps, but need to know what technology in .Net core is supposed to be equivalent to MemoryMappedFileSecurity?

Hadik answered 17/7, 2019 at 23:59 Comment(4)
google.com/amp/s/www.red-gate.com/simple-talk/dotnet/… Here’s a whole article about memory mapped files in.net core. It might not specifically address your question, but it will probably help you sort through it.Bolduc
I found a comment on the .NET Core github that suggests these access rights are simply no longer necessary. Any process that maps to the same name/memory location can have access to that data.Anile
We tested and as you said, as long as the processes are running under one login credential, they don't have any problem accessing the shared MMF. However, our problem is to allow processes running under a different credential to access the same MMF. That's why we need to set the Security. As the .Net Core interface does not have the MemoryMappedFileSecurity object, we want to find out what can we do to support the sharing across different processes running under different login credentialsHadik
@AnthonyCheung did you ever figure this out? We're running into the same problem.Excerpta

© 2022 - 2024 — McMap. All rights reserved.