<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Security Descriptor]]></title><description><![CDATA[<p>Hallo!</p>
<p>Bräuchte Hilfe von 'nem C++ Guru, der sich mit der Windowsprogrammierung auskennt. Meine Kenntnisse sind, was dieses ganze Security und Access Rights betrifft, recht beschränkt.</p>
<p>Es geht um Folgendes:</p>
<p>Ich öffne einen seriellen Port so:</p>
<pre><code class="language-cpp">m_hCom = CreateFile(m_sComPort,    
        GENERIC_READ | GENERIC_WRITE,
        0, // Exclusive access
        0, // security
        OPEN_EXISTING,
        FILE_FLAG_OVERLAPPED, // Non-Overlapped I/O 
        NULL); // Null template
</code></pre>
<p>später versuche ich darauf zu schreiben:</p>
<pre><code class="language-cpp">bWriteRC = WriteFile(m_hCom, sSend,iFrameLength,&amp;iBytesWritten,&amp;ola);
</code></pre>
<p>die overlapped Struktur ola sieht folgendermaßen aus:</p>
<pre><code class="language-cpp">SECURITY_DESCRIPTOR * pSd;
    SECURITY_DESCRIPTOR  sd;
    pSd = &amp;sd;

InitializeSecurityDescriptor( pSd, SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl( pSd, TRUE, NULL, FALSE);

PSID sid = NULL;
SID_IDENTIFIER_AUTHORITY sid_auth = {SECURITY_WORLD_SID_AUTHORITY };

AllocateAndInitializeSid( &amp;sid_auth, 1, 0, 0, 0, 0, 0, 0, 0, 0, &amp;sid);
SetSecurityDescriptorOwner(pSd, &amp;sid, FALSE);

SECURITY_ATTRIBUTES * pSa;
SECURITY_ATTRIBUTES sa; 
sa.nLength = sizeof(sa);
sa.bInheritHandle = 1;
sa.lpSecurityDescriptor = pSd;
pSa = &amp;sa;

ola.hEvent = CreateEvent(
    pSa,   // security attributes ALL ACCESS
    TRUE,  // manual reset event 
    FALSE,  // not signaled 
    NULL    // no name 
    ;
</code></pre>
<p>Jetzt bekomme ich aber beim WriteFile einen Error 1337 - Invalid SID<br />
und weiß nicht warum. Wenn ich die Initialisierung des SID weglasse, bekomme ich später bei einem WaitCommEvent()</p>
<pre><code class="language-cpp">bReadRC = WaitCommEvent (m_hCom, &amp;dwCommModemStatus, &amp;ola);
</code></pre>
<p>einen Error 5 - Access Denied</p>
<p>Hat irgendjemand eine Ahnung, was ich da falsch mache? Wie gesagt, C++ unter Windows ist neu für mich. Danke</p>
<p>Markus</p>
<p>P.S.: WaitCommEvent ohne Overlapped geht, aber das brauch ich für die Applikation leider nicht (kein Rücksprung vor Eventvorkommen)</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/77417/security-descriptor</link><generator>RSS for Node</generator><lastBuildDate>Fri, 24 Apr 2026 10:58:19 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/77417.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 21 Jun 2004 08:02:33 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Security Descriptor on Mon, 21 Jun 2004 08:02:33 GMT]]></title><description><![CDATA[<p>Hallo!</p>
<p>Bräuchte Hilfe von 'nem C++ Guru, der sich mit der Windowsprogrammierung auskennt. Meine Kenntnisse sind, was dieses ganze Security und Access Rights betrifft, recht beschränkt.</p>
<p>Es geht um Folgendes:</p>
<p>Ich öffne einen seriellen Port so:</p>
<pre><code class="language-cpp">m_hCom = CreateFile(m_sComPort,    
        GENERIC_READ | GENERIC_WRITE,
        0, // Exclusive access
        0, // security
        OPEN_EXISTING,
        FILE_FLAG_OVERLAPPED, // Non-Overlapped I/O 
        NULL); // Null template
</code></pre>
<p>später versuche ich darauf zu schreiben:</p>
<pre><code class="language-cpp">bWriteRC = WriteFile(m_hCom, sSend,iFrameLength,&amp;iBytesWritten,&amp;ola);
</code></pre>
<p>die overlapped Struktur ola sieht folgendermaßen aus:</p>
<pre><code class="language-cpp">SECURITY_DESCRIPTOR * pSd;
    SECURITY_DESCRIPTOR  sd;
    pSd = &amp;sd;

InitializeSecurityDescriptor( pSd, SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl( pSd, TRUE, NULL, FALSE);

PSID sid = NULL;
SID_IDENTIFIER_AUTHORITY sid_auth = {SECURITY_WORLD_SID_AUTHORITY };

AllocateAndInitializeSid( &amp;sid_auth, 1, 0, 0, 0, 0, 0, 0, 0, 0, &amp;sid);
SetSecurityDescriptorOwner(pSd, &amp;sid, FALSE);

SECURITY_ATTRIBUTES * pSa;
SECURITY_ATTRIBUTES sa; 
sa.nLength = sizeof(sa);
sa.bInheritHandle = 1;
sa.lpSecurityDescriptor = pSd;
pSa = &amp;sa;

ola.hEvent = CreateEvent(
    pSa,   // security attributes ALL ACCESS
    TRUE,  // manual reset event 
    FALSE,  // not signaled 
    NULL    // no name 
    ;
</code></pre>
<p>Jetzt bekomme ich aber beim WriteFile einen Error 1337 - Invalid SID<br />
und weiß nicht warum. Wenn ich die Initialisierung des SID weglasse, bekomme ich später bei einem WaitCommEvent()</p>
<pre><code class="language-cpp">bReadRC = WaitCommEvent (m_hCom, &amp;dwCommModemStatus, &amp;ola);
</code></pre>
<p>einen Error 5 - Access Denied</p>
<p>Hat irgendjemand eine Ahnung, was ich da falsch mache? Wie gesagt, C++ unter Windows ist neu für mich. Danke</p>
<p>Markus</p>
<p>P.S.: WaitCommEvent ohne Overlapped geht, aber das brauch ich für die Applikation leider nicht (kein Rücksprung vor Eventvorkommen)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/544674</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/544674</guid><dc:creator><![CDATA[Bokon Taylay]]></dc:creator><pubDate>Mon, 21 Jun 2004 08:02:33 GMT</pubDate></item></channel></rss>