The GetLastError() function return value corresponds to this Windows System error code:
ERROR_ACCESS_DENIED
5 (0x5)
Access is denied.
I don’t think it’s a privilege issue on my part. I am in an administrator account.
When I try to step through the MapnamedSharedMemoryRegion() function, the visual studio debugger steps through all if statements as if they don’t exist.
The funny thing is that if I implement shared memory in my game using the Windows API everything works fine. Something tricky is happening with the Unreal Engine code.
Finally… a breakthrough of sorts! Here is what I did…
I changed from the default 64 bit debug game build to a 32 bit windows build. This then exposed the normal project properties I was used to seeing, rather that the very abbreviated version. I turned off all optiizations with /Od. It seems that once you have altered the default settings of project settings, you can go back to a 64 bit build, and you still can see all options.
Are you using the Unreal Engine API or are you directly going through Windows API for shared memory? I’ve implemented a shared memory class that will take care of using Windows Shared memory for you, mind you that this class only works on Windows, so you’d have to implement your own stuff for Linux:
Hi jgcoded, from the nature of this latest comment it seems that you were able to solve your issue. Is this the case? If I am mistaken please let me know and I’ll try to assist you with this problem.
Hi , unfortunately I only found a work-around to my problem, and not a solution. My work-around was to not use the Unreal Engine C++ API for shared memory. Instead, I rolled out my own class that accesses the Windows API directly. This work-around forces me to provide my own implementations for shared memory on all platforms I must support.
The real solution would be to be able to use Unreal’s FPlatformMemory::MapNamedSharedMemoryRegion() function to create my shared memory object. This function is still failing, but my own equivalent function (see my link to the github gist above) actually works. It’s completely bizarre and this has left some of my coworkers baffled.
If you want to reproduce what I’m seeing, step through the MapNamedSharedMemoryRegion() function on a Windows computer using the Visual Studio 2013 debugger.
I think the cause of the problem comes from the ‘Global’ prefix the Unreal Engine code applies to all shared memory names. According to msdn, creating a global shared memory object requires some kind of special permission if you’re not in session zero. I have no idea what “session zero” means, but it must be causing security=NULL, like you pointed out.
Maybe the fix is to remove the ‘Global’ prefix in the Unreal Engine code? I think this is the fix because my code does not prefix the shared memory name with Global and it ends up working in my game.
I apologize for the time since my last post, unfortunately this isn’t a feature that the engine was designed to support and thus I am not quite able provide more information as to how to integrate this feature. If you believe that removing the Global prefix in the source code would fix this issue, I would suggest making a Pull Request on our GitHub page (.com/EpicGames/UnrealEngine) so that it can be reviewed and possibly integrated into a future build.