<?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[Event unter anderem Benutzer aufrufen]]></title><description><![CDATA[<p>Hallo zusammen<br />
ich hoffe das gehört hier rein. soweit ich weiss, gehört das zur API, also bitte nicht hauen, wenns hier falsch ist <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>ich muss in einem programm ein event basteln, dass ich unter einem anderen benutzer (mit anderem Programm, das durch runas gestartet wird) brauchen kann.. eigentlich wollte ich das so machen:</p>
<p>programm 1:</p>
<pre><code>HANDLE event = CreateEvent(0, FALSE, FALSE, &quot;MeinEvent&quot;);
[...]
WaitForSingleObject(event, INFINITE);
</code></pre>
<p>programm 2 (unter anderem benutzer gestartet)</p>
<pre><code>HANDLE event = OpenEvent(EVENT_MODIFY_STATE, FALSE, &quot;MeinEvent&quot;);
PulseEvent(event);
</code></pre>
<p>(ich muss in programm 1 warten, bis programm 2 durchgelaufen ist)</p>
<p>blöderweise funktioniert OpenEvent nicht. durch einiges ausprobieren und nachforschen habe ich rausgefunden, dass das default-SECURITY_ATTRIBUTE anderen benutzern nur lese-zugriff auf events gibt, OpenEvent also nur mit &quot;SYNCHRONIZE&quot; anstatt &quot;EVENT_MODIFY_STATE&quot; funzen würde, was mir nichts bringt (SYNCHRONIZE erlaubt das pulsen oder das normale losschicken eines events nicht)<br />
um das zu ändern, müsste ich den ersten parameter von CreateEvent (das Security-Attribute, 0 = default) ändern. ein solches sieht so aus:</p>
<pre><code>typedef struct _SECURITY_ATTRIBUTES { // sa 
    DWORD  nLength; 
    LPVOID lpSecurityDescriptor; 
    BOOL   bInheritHandle; 
} SECURITY_ATTRIBUTES;
</code></pre>
<p>nLength und bInheritHandle sind mir klar, aber um dem anderen user zugriff zu gewähren, muss ich lpSecurityDescriptor ändern.. der ist auch ein struct, dessen parameter man laut <a href="http://windowssdk.msdn.microsoft.com/en-us/library/ms723272.aspx" rel="nofollow">MSDN</a> nur per funktionen setzen soll.. die, die ich wohl benötige, ist InitializeSecurityDescriptor()</p>
<p>die sieht ihrerseits so aus:</p>
<pre><code>BOOL InitializeSecurityDescriptor(
  PSECURITY_DESCRIPTOR pSecurityDescriptor,
  DWORD dwRevision
);
</code></pre>
<p>dwRevision ist &quot;[in] The revision level to assign to the security descriptor. This parameter must be SECURITY_DESCRIPTOR_REVISION. &quot;<br />
nur wird mir leider nirgends gesagt, was eine SECURITY_DESCRIPTOR_REVISION ist..</p>
<p>ausserdem wäre da noch die funktion &quot;SetSecurityDescriptorGroup&quot;.<br />
diese will einen pointer zu einer SID.<br />
um eine solche zu basteln, bräuchte ich wohl die funktion &quot;AllocateAndIntializeSid&quot;</p>
<pre><code>BOOL AllocateAndInitializeSid(
  PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
  BYTE nSubAuthorityCount,
  DWORD dwSubAuthority0,
  DWORD dwSubAuthority1,
  DWORD dwSubAuthority2,
  DWORD dwSubAuthority3,
  DWORD dwSubAuthority4,
  DWORD dwSubAuthority5,
  DWORD dwSubAuthority6,
  DWORD dwSubAuthority7,
  PSID* pSid
);
</code></pre>
<p>pIdentifierAuthority<br />
[in] Pointer to a SID_IDENTIFIER_AUTHORITY structure. This structure provides the top-level identifier authority value to set in the SID.<br />
nSubAuthorityCount<br />
[in] Specifies the number of subauthorities to place in the SID. This parameter also identifies how many of the subauthority parameters have meaningful values. This parameter must contain a value from 1 to 8.<br />
For example, a value of 3 indicates that the subauthority values specified by the dwSubAuthority0, dwSubAuthority1, and dwSubAuthority2 parameters have meaningful values and to ignore the remainder.</p>
<p>dwSubAuthority0<br />
[in] Subauthority value to place in the SID.<br />
[...]<br />
dwSubAuthority7<br />
[in] Subauthority value to place in the SID.<br />
pSid<br />
[out] Pointer to a variable that receives the pointer to the allocated and initialized SID structure.</p>
<p>nun gibts aber keinen link auf der <a href="http://windowssdk.msdn.microsoft.com/en-us/library/ms717989.aspx" rel="nofollow">msdn-seite</a>, der mir sagen würde, wie ich diese subauthorities mache..</p>
<p>ich hätte auch noch <a href="http://windowssdk.msdn.microsoft.com/en-us/library/ms707085.aspx" rel="nofollow">ein beispiel gefunden</a> (weiter unten bei &quot;To retreive the SID for a user account&quot;) , werd aber daraus nicht wirklich schlau.</p>
<p>kann mir jemand da aushelfen? (eventuell sogar mit einem code, wie man ein event bastelt, das man von anderen usern aus auch benutzen kann? :D)</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/159695/event-unter-anderem-benutzer-aufrufen</link><generator>RSS for Node</generator><lastBuildDate>Sun, 19 Jul 2026 06:04:45 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/159695.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 18 Sep 2006 08:24:51 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Event unter anderem Benutzer aufrufen on Mon, 18 Sep 2006 08:29:23 GMT]]></title><description><![CDATA[<p>Hallo zusammen<br />
ich hoffe das gehört hier rein. soweit ich weiss, gehört das zur API, also bitte nicht hauen, wenns hier falsch ist <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>ich muss in einem programm ein event basteln, dass ich unter einem anderen benutzer (mit anderem Programm, das durch runas gestartet wird) brauchen kann.. eigentlich wollte ich das so machen:</p>
<p>programm 1:</p>
<pre><code>HANDLE event = CreateEvent(0, FALSE, FALSE, &quot;MeinEvent&quot;);
[...]
WaitForSingleObject(event, INFINITE);
</code></pre>
<p>programm 2 (unter anderem benutzer gestartet)</p>
<pre><code>HANDLE event = OpenEvent(EVENT_MODIFY_STATE, FALSE, &quot;MeinEvent&quot;);
PulseEvent(event);
</code></pre>
<p>(ich muss in programm 1 warten, bis programm 2 durchgelaufen ist)</p>
<p>blöderweise funktioniert OpenEvent nicht. durch einiges ausprobieren und nachforschen habe ich rausgefunden, dass das default-SECURITY_ATTRIBUTE anderen benutzern nur lese-zugriff auf events gibt, OpenEvent also nur mit &quot;SYNCHRONIZE&quot; anstatt &quot;EVENT_MODIFY_STATE&quot; funzen würde, was mir nichts bringt (SYNCHRONIZE erlaubt das pulsen oder das normale losschicken eines events nicht)<br />
um das zu ändern, müsste ich den ersten parameter von CreateEvent (das Security-Attribute, 0 = default) ändern. ein solches sieht so aus:</p>
<pre><code>typedef struct _SECURITY_ATTRIBUTES { // sa 
    DWORD  nLength; 
    LPVOID lpSecurityDescriptor; 
    BOOL   bInheritHandle; 
} SECURITY_ATTRIBUTES;
</code></pre>
<p>nLength und bInheritHandle sind mir klar, aber um dem anderen user zugriff zu gewähren, muss ich lpSecurityDescriptor ändern.. der ist auch ein struct, dessen parameter man laut <a href="http://windowssdk.msdn.microsoft.com/en-us/library/ms723272.aspx" rel="nofollow">MSDN</a> nur per funktionen setzen soll.. die, die ich wohl benötige, ist InitializeSecurityDescriptor()</p>
<p>die sieht ihrerseits so aus:</p>
<pre><code>BOOL InitializeSecurityDescriptor(
  PSECURITY_DESCRIPTOR pSecurityDescriptor,
  DWORD dwRevision
);
</code></pre>
<p>dwRevision ist &quot;[in] The revision level to assign to the security descriptor. This parameter must be SECURITY_DESCRIPTOR_REVISION. &quot;<br />
nur wird mir leider nirgends gesagt, was eine SECURITY_DESCRIPTOR_REVISION ist..</p>
<p>ausserdem wäre da noch die funktion &quot;SetSecurityDescriptorGroup&quot;.<br />
diese will einen pointer zu einer SID.<br />
um eine solche zu basteln, bräuchte ich wohl die funktion &quot;AllocateAndIntializeSid&quot;</p>
<pre><code>BOOL AllocateAndInitializeSid(
  PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
  BYTE nSubAuthorityCount,
  DWORD dwSubAuthority0,
  DWORD dwSubAuthority1,
  DWORD dwSubAuthority2,
  DWORD dwSubAuthority3,
  DWORD dwSubAuthority4,
  DWORD dwSubAuthority5,
  DWORD dwSubAuthority6,
  DWORD dwSubAuthority7,
  PSID* pSid
);
</code></pre>
<p>pIdentifierAuthority<br />
[in] Pointer to a SID_IDENTIFIER_AUTHORITY structure. This structure provides the top-level identifier authority value to set in the SID.<br />
nSubAuthorityCount<br />
[in] Specifies the number of subauthorities to place in the SID. This parameter also identifies how many of the subauthority parameters have meaningful values. This parameter must contain a value from 1 to 8.<br />
For example, a value of 3 indicates that the subauthority values specified by the dwSubAuthority0, dwSubAuthority1, and dwSubAuthority2 parameters have meaningful values and to ignore the remainder.</p>
<p>dwSubAuthority0<br />
[in] Subauthority value to place in the SID.<br />
[...]<br />
dwSubAuthority7<br />
[in] Subauthority value to place in the SID.<br />
pSid<br />
[out] Pointer to a variable that receives the pointer to the allocated and initialized SID structure.</p>
<p>nun gibts aber keinen link auf der <a href="http://windowssdk.msdn.microsoft.com/en-us/library/ms717989.aspx" rel="nofollow">msdn-seite</a>, der mir sagen würde, wie ich diese subauthorities mache..</p>
<p>ich hätte auch noch <a href="http://windowssdk.msdn.microsoft.com/en-us/library/ms707085.aspx" rel="nofollow">ein beispiel gefunden</a> (weiter unten bei &quot;To retreive the SID for a user account&quot;) , werd aber daraus nicht wirklich schlau.</p>
<p>kann mir jemand da aushelfen? (eventuell sogar mit einem code, wie man ein event bastelt, das man von anderen usern aus auch benutzen kann? :D)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1139390</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1139390</guid><dc:creator><![CDATA[Klaue]]></dc:creator><pubDate>Mon, 18 Sep 2006 08:29:23 GMT</pubDate></item><item><title><![CDATA[Reply to Event unter anderem Benutzer aufrufen on Tue, 19 Sep 2006 09:27:03 GMT]]></title><description><![CDATA[<p>danke für die rege beteiligung <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61b.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_tongue"
      title=":P"
      alt="😛"
    /></p>
<p>ich hab's nun gelöst (für's archiv, falls irgendwann mal jemand ein ähnliches problem haben sollte)<br />
erst hatte ich sowas (in Programm 1):</p>
<pre><code>SECURITY_ATTRIBUTES* secAttr = new SECURITY_ATTRIBUTES;
secAttr-&gt;bInheritHandle = FALSE; // keine vererbung
SECURITY_DESCRIPTOR *pSecDesc = new SECURITY_DESCRIPTOR;
PSID sid= NULL; // plöde securityid

// Retrieve the SID of the Everyone group.
SID_IDENTIFIER_AUTHORITY WorldAuth = SECURITY_WORLD_SID_AUTHORITY;
if (AllocateAndInitializeSid(&amp;WorldAuth, 1, SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0, &amp;sid) == FALSE) {
	ErrorHandler(&quot;AllocateAndInitializeSid failed&quot;, GetLastError());
}

if (InitializeSecurityDescriptor(pSecDesc, SECURITY_DESCRIPTOR_REVISION) == FALSE) {
	ErrorHandler(&quot;InitializeSecurityDescriptor failed&quot;, GetLastError());
}

//SetSecurityDescriptorGroup(pSecDesc, sid, FALSE);
secAttr-&gt;lpSecurityDescriptor = pSecDesc; // da mussich machen
secAttr-&gt;nLength = sizeof(*secAttr); // die grösse in bytes

HANDLE event = CreateEvent(secAttr, FALSE, FALSE, &quot;TTPRIETEVENT&quot;);
</code></pre>
<p>(ErrorHandler ist ne eigene funktion, die den Fehler ins logfile schreibt und das programm falls nötig beendet)</p>
<p>durch ein usenetposting von Rob Beckers in borland.public.cppbuilder.vcl.components.using (&quot;How to intercept another running instance of the same program?&quot;) hatte ich eine funktionierende lösung, die, wie könnte es auch anders sein, um einiges einfacher war. danke, rob</p>
<pre><code>SECURITY_ATTRIBUTES SecAttr; 
SECURITY_DESCRIPTOR SecDesc; 

InitializeSecurityDescriptor(&amp;SecDesc,SECURITY_DESCRIPTOR_REVISION); 
SetSecurityDescriptorDacl(&amp;SecDesc,TRUE,NULL,FALSE); 
SecAttr.nLength=sizeof(SECURITY_ATTRIBUTES); 
SecAttr.bInheritHandle=FALSE;

//descriptor for event so all processes have full access 
SecAttr.lpSecurityDescriptor=&amp;SecDesc; 
HANDLE event = CreateEvent(&amp;SecAttr, TRUE, FALSE, &quot;TTPRIETEVENT&quot;);
if (event == NULL) ErrorHandler(&quot;Fehler bei CreateEvent&quot;, GetLastError(), true);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1140188</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1140188</guid><dc:creator><![CDATA[Klaue]]></dc:creator><pubDate>Tue, 19 Sep 2006 09:27:03 GMT</pubDate></item><item><title><![CDATA[Reply to Event unter anderem Benutzer aufrufen on Tue, 19 Sep 2006 10:22:08 GMT]]></title><description><![CDATA[<p>hi,<br />
du kannst auch 'nen security descriptor mit 'ner NULL DACL nehmen. da kann dann jeder beliebig drauf zugreifen:</p>
<pre><code>SECURITY_DESCRIPTOR SD;
InitializeSecurityDescriptor (&amp;SD, SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl (&amp;SD TRUE, (PACL)NULL, FALSE);
</code></pre>
<p>...und wenn du mit mehreren benutzern hantierst, dann ist es besser den event im globalen session namespace anzulegen:</p>
<pre><code>HANDLE event = CreateEvent(secAttr, FALSE, FALSE, &quot;Global\\TTPRIETEVENT&quot;);
</code></pre>
<p>dann isser z.b. auch in allen terminal sessions sichtbar...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1140224</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1140224</guid><dc:creator><![CDATA[net 0]]></dc:creator><pubDate>Tue, 19 Sep 2006 10:22:08 GMT</pubDate></item><item><title><![CDATA[Reply to Event unter anderem Benutzer aufrufen on Thu, 21 Sep 2006 06:57:01 GMT]]></title><description><![CDATA[<blockquote>
<p>hi,<br />
du kannst auch 'nen security descriptor mit 'ner NULL DACL nehmen. da kann dann jeder beliebig drauf zugreifen:</p>
<pre><code>SECURITY_DESCRIPTOR SD;
InitializeSecurityDescriptor (&amp;SD, SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl (&amp;SD TRUE, (PACL)NULL, FALSE);
</code></pre>
</blockquote>
<p>hab ich ja nun auch gemacht:</p>
<pre><code>SECURITY_DESCRIPTOR SecDesc; 

InitializeSecurityDescriptor(&amp;SecDesc,SECURITY_DESCRIPTOR_REVISION); 
SetSecurityDescriptorDacl(&amp;SecDesc,TRUE,NULL,FALSE);
</code></pre>
<blockquote>
<p>...und wenn du mit mehreren benutzern hantierst, dann ist es besser den event im globalen session namespace anzulegen:</p>
<pre><code>HANDLE event = CreateEvent(secAttr, FALSE, FALSE, &quot;Global\\TTPRIETEVENT&quot;);
</code></pre>
<p>dann isser z.b. auch in allen terminal sessions sichtbar...</p>
</blockquote>
<p>mach ich eventuell noch, aber ist bei meinem fall eher unnötig</p>
<p>danke trotzdem <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1141561</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1141561</guid><dc:creator><![CDATA[Klaue]]></dc:creator><pubDate>Thu, 21 Sep 2006 06:57:01 GMT</pubDate></item></channel></rss>