Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The first argument to <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms684326%28v=vs.85%29.aspx" rel="noreferrer"><code>OpenSemaphore()</code></a> is documented as:</p> <blockquote> <p>dwDesiredAccess [in]</p> <p>The access to the semaphore object. The function fails if the security descriptor of the specified object does not permit the requested access for the calling process. For a list of access rights, see Synchronization Object Security and Access Rights.</p> </blockquote> <p>In the posted code <code>NULL</code> is specified: which is not documented as having a special meaning. Change to one of the access rights documented at <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms686670%28v=vs.85%29.aspx" rel="noreferrer">Synchronization Object Security and Access Rights</a>:</p> <pre><code>bitmapSem = OpenSemaphore(SYNCHRONIZE, TRUE, "Global\\bitmap"); </code></pre> <p>EDIT:</p> <p>To create a security descriptor that would grant access to <code>Everyone</code> try the following (untested) code:</p> <pre><code>/* Create a security descriptor that has an an empty DACL, to grant access to 'Everyone'. */ SECURITY_DESCRIPTOR sd; if (0 == InitializeSecurityDescriptor(&amp;sd, SECURITY_DESCRIPTOR_REVISION) || 0 == SetSecurityDescriptorDacl(&amp;sd, TRUE, (PACL)0, FALSE)) { /* Failed to create security descriptor. */ } else { SECURITY_ATTRIBUTES sa; sa.nLength = sizeof(sa); sa.lpSecurityDescriptor = &amp;sd; sa.bInheritHandle = FALSE; HANDLE sh = CreateSemaphore(&amp;sa, 1, 1, "Global\\bitmap"); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload