I make a sample of Event object to show this issue:
How to create a no security level kernel object?
Code
SECURITY_DESCRIPTOR sd;
InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(&sd, TRUE, (PACL)NULL, FALSE);
SECURITY_ATTRIBUTES sa;
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.bInheritHandle = FALSE;
sa.lpSecurityDescriptor = &sd;
HANDLE MonitorEvent = CreateEventA(&sa, FALSE, FALSE, "Global\\{A7DF02C8-0F89-4a3b-A6E8-E3E08C167C58}");
You can do the following operation to set the event in another process
Code
HANDLE hMonitor = OpenEventA(EVENT_ALL_ACCESS, FALSE, "Global\\{A7DF02C8-0F89-4a3b-A6E8-E3E08C167C58}");
if ( NULL == hMonitor )
{
cout << "Open event failed, last error:" << GetLastError() << endl;
return 0;
}
SetEvent(hMonitor);
Why I make this sample?
Because I want to operate a windows kernel object in the different process, and these process own the different security level. e.g. service and user process. So if you don't set the security descriptor , you will always get the NULL when you invoke OpenEvent API and get the error number is 5.