Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shared Memory and ACLs

Status
Not open for further replies.

xwb

Programmer
Jul 11, 2002
6,828
GB
I have a client process that uses shared memory created by a service. The problem is that the service is created as "Local User" so the clients are unable to access the shared memory. Even with adding a "Global\" prefix, I can't access the memory. I'm creating the shared memory as
Code:
      mHandle = CreateFileMapping (
         (HANDLE) 0xFFFFFFFF,           // Use system buffering
         (LPSECURITY_ATTRIBUTES) 0,
         PAGE_READWRITE,                // Protection
         0,                             // filesize high dword
         mFileSize,                      // filesize low dword
         name);                         // Name
What it boils down to is I have to fill in the LPSECURITY_ATTRIBUTES for the "Everyone" user. I've been playing with all sorts of combinations for the last 3 hours and getting nowhere. This is the basic framework I'm using
Code:
      SECURITY_DESCRIPTOR* sd = new SECURITY_DESCRIPTOR();
      InitializeSecurityDescriptor (sd, SECURITY_DESCRIPTOR_REVISION);
      // Have tried all sorts of permutations on the contents of sd

      SECURITY_ATTRIBUTES* sa = new SECURITY_ATTRIBUTES;
      sa->nLength = sizeof (*sa);
      sa->bInheritHandle = FALSE;
      sa->lpSecurityDescriptor = sd;
      std::string name = "Global\\";
      name += (in_name == 0? SMBaseName: in_name);
      mHandle = CreateFileMapping (
         (HANDLE) 0xFFFFFFFF,           // Use system buffering
         sa,
         PAGE_READWRITE,           // Protection
         0,                             // filesize high dword
         mFileSize,                     // filesize low dword
         name.c_str());                 // Name
Any simple examples on what to put into sd to represent the "Everyone" user would be great.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top