Reading a memory-mapped file created by a Service

C

Chris Purdum

Folks,
I've got a problem that only happens on some machines: I've got a
Windows service that creates a memory mapped file of a known name using
the following functions in order like this:

1. InitializeSecurityDescriptor (&sd, SECURITY_DESCRIPTOR_REVISION) - to
get a Security Descriptor sd
2. SetSecurityDescriptorDacl (&sd, TRUE, NULL, FALSE) - to set a NULL
ACL so anyone can access is
3. CreateFileMapping - to create the mapping
4. MapViewOfFile

I then have a command-line program that reads this shared memory segment
and displays its data. It's a quick way to get stats on the service.
It does this with

1. OpenFileMapping
2. MapViewOfFile

On some systems, this works great, but on one of our test systems, the
OpenFileMapping in the command-line program fails with
ERROR_FILE_NOT_FOUND, even though the service created it successfully,
and they both know the correct name of the mapping.

Anyone know why this might be?

Thanks.

Chris Purdum
 
Joined
Nov 27, 2007
Messages
1
Reaction score
0
shared memory access and NT Services

Preface name of your shared memory object with "Global\\" (first slash is for escaping the second).
When you try to access shared memory created in NT service from your console application, bear in mind that console application runs in a different security context and shared memory objects created in the NT service are not visible unless they are created in the global namespace. See for more information MSDN page for CreateEvent Win API or type in Google "Kernel Object Namespaces".
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top