- Failed to open a named "Event Object" created by another process
- Posted by Kenji Chan on October 8th, 2003
I failed to open a named "Event Object" created by another process (also my
program)
, and it returned error #5 (Access is denied.). Why is that?
I tried to supply SECURITY_ATTRIBUTES with CreateEvent() like:
SECURITY_ATTRIBUTES s_att;
s_att.nLength = sizeof(SECURITY_ATTRIBUTES);
s_att.lpSecurityDescriptor = 0;
s_att.bInheritHandle = 1;
wait_obj = CreateEvent( &s_att, 0, 0, name );
But still failed.
Can somebody help me?
--------------
Kenji Chan
- Posted by Scott McPhillips [MVP] on October 8th, 2003
Kenji Chan wrote:
If the other process is a service then it must supply a
SECURITY_ATTRIBUTES when it creates the event, and it must be a valid
SECURITY_ATTRIBUTES, not just a NULL descriptor. I also suspect that
you can't get away with allocating these SECURITY_ATTRIBUTES on the
stack: Make them exist for the lifetime of the app(s).
--
Scott McPhillips [VC++ MVP]
- Posted by Kenji Chan on October 9th, 2003
Yes, my another program is a service run as "Local System"
If two programs run as the same account, everything is fine
I'm really not sure how to open a named event object that created by a
"System" process, can somebody give me some hints.
Anyway I tried something like:
SID sid;
SECURITY_DESCRIPTOR sd;
SECURITY_ATTRIBUTES s_att;
SID_NAME_USE sid_name;
void somefunc( char *name ){
DWORD dwsid = sizeof(SID);
char domainname[1024];
DWORD dwname = sizeof( domainname );
InitializeSecurityDescriptor( &sd, SECURITY_DESCRIPTOR_REVISION );
if ( !LookupAccountName( 0, "System", &sid, &dwsid, domainname, &dwname,
&sid_name ) ) printf("LookupAccountName error\n");
if ( !SetSecurityDescriptorOwner( &sd, &sid, 1 ) )
printf("SetSecurityDescriptorOwner error#%u\n", GetLastError());
printf("%s %d\n", domainname, sid_name);
s_att.nLength = sizeof(SECURITY_ATTRIBUTES);
s_att.lpSecurityDescriptor = &sd;
s_att.bInheritHandle = 1;
wait_obj = CreateEvent( &s_att, 0, 0, name );
.....
}
But still failed with #5 (Access is denied)
Why?
- Get "Open", not "Search", if click drive on "My Computer" screen (Microsoft Windows) by djloekee27@gmail.com
- Re: SuSe 9.3 - "patch process failed" (Computers & Technology) by Kutloze Scheefgepoepte
- Re: SuSe 9.3 - "patch process failed" (Computers & Technology) by Kutloze Scheefgepoepte
- in Word, Photo Editor not on "object type" list in Insert|Object (Home and office) by magda
- New virus with a process named "Netlink32.exe" (Virus & Worms) by DickW

