Is it possible you didn't specify an appropriate security descriptor for the file being mapped.  When creating the mapped file memory  I'd made the mistake of passing NULL for the security attribute which worked fine for most Win32 versions until we got to XP running as a service.  At this point I realized I needed to generate a valid, but promiscuous security descriptor to ensure anyone could access the shared memory.  I'd done this:

            // attempt to create (or gain access to) named shared memory
            SECURITY_ATTRIBUTES sa;
            sa.nLength = sizeof(sa);
            SECURITY_DESCRIPTOR sd;
            InitializeSecurityDescriptor(&sd,SECURITY_DESCRIPTOR_REVISION);
            SetSecurityDescriptorDacl(&sd,TRUE,NULL,FALSE);
            sa.lpSecurityDescriptor = &sd;
            sa.bInheritHandle = TRUE;

Perhaps this is why your app isn't behaving like you'd thought.  Also, you will need to be careful to allow users sharing the memory to know when it has become invalid and should be released so you can recreate a new version (e.g., restarting the process that creates it) and have the accessors reattach to the new version.

HTH, Nat

Thursday, May 01, 2003 4:42 PM
To: <[EMAIL PROTECTED]>
cc:
From: "Neil Devlin" <[EMAIL PROTECTED]>
Subject: [MSVC] OpenFileMapping query..


Hi,
I have an application thats has its on DLL that uses system wide hooks. I
share some memory between the two by using OpenFileMapping.. The application
creates the mapped file, and the DLL opened the map file. Things work fine,
I create the mapped file in the application once, then close it at the end.
But within the DLL I have to open it and close it everytime I use it. I have
one Global class within the DLL that deals with the memory reading, opening
etc. Is this normal for a DLL memory mapped? I have tried opening the memory
map whenthe system wide hooks gets started (within the DLL), and close it
when the system wide hook gets closed (within the DLL). I dont get any
errors opening it, but the application doesnt work properly.

Any ideas?

neil


Reply via email to