Consider I create semaphore in user app that way:
semaphorNotificationHandle = CreateSemaphore(
NULL, // default security attributes
0, // initial count
1, // maximum count
L"Global" L"mysemaphore");
My question is if it is possible for kernel mode driver to check if this semaphore exists?
In user mode it would be easy however is it doable in kernel mode driver? My first approach was this (on the kernel site):
HANDLE ghSemaphore = CreateSemaphore(
NULL, // default security attributes
0, // initial count
1, // maximum count
L"Global" L"mysemaphore");
if (GetLastError() == ERROR_ALREADY_EXISTS)
{
printf("semaphore already exists");
//should return fail here
return TRUE;
}
However I can not do it when in kernel mode, any suggestions? I'm ready to change anything about the design, it does not have to necessery be semaphore, It could be pipe or even some event object.