Click to See Complete Forum and Search --> : OpenFileMapping fails when process runs under different account


pankaj.talk
July 12th, 2007, 05:16 AM
Hi,

I am using CreateFileMapping & OpenFileMapping function to simulate name based shared memory in windows.

I am specifying lpAttributes as NULL in the call to CreateFileMapping. Now if the process A that executes CreateFileMapping runs under a different account than process B that executes OpenFileMapping, the Process B fails, giving an access denied error. That is Process B fails to attach to the file segment.

How do I fix this? I found that we can specify a security descriptor (second argument to CreateFileMapping) for a file mapping object when you call the CreateFileMapping function. But not sure how to do this

LoveCPlusplus
July 18th, 2007, 01:03 AM
You can find the sample codes in MSND Platform SDK->Authorization->Creating a Security Descriptor for a New Object in C++