From - Tue Sep 16 14:13:53 1997 Path: news.mitre.org!blanket.mitre.org!news.tufts.edu!cam-news-feed5.bbnplanet.com!cam-news-hub1.bbnplanet.com!cpk-news-hub1.bbnplanet.com!news.bbnplanet.com!news-peer.sprintlink.net!news-sea-19.sprintlink.net!news-in-west.sprintlink.net!news.sprintlink.net!Sprint!159.56.2.2!thetimes.pixel.kodak.com!news.kodak.com!newsserver.rdcs.Kodak.COM!not-for-mail From: TVLE Newsgroups: comp.os.ms-windows.programmer.nt.kernel-mode Subject: Re: Help: OpenEvent fails with an ERROR_ACCESS_DENIED?? Date: Tue, 16 Sep 1997 11:16:57 -0500 Organization: Eastman Kodak Company Lines: 48 Message-ID: <341EB0F9.40E7@KODAK.COM> References: <341DB0ED.4D78@KODAK.COM> Reply-To: TVLE NNTP-Posting-Host: hypercube.hidal.kodak.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 2.01Gold (WinNT; I) TVLE wrote: > > Hi everyone-- > > I use IoCreateNotificationEvent() in my driver > to signal when my PCI board has data available > to be read. In my user app, after I CreateFile() > to open a handle to my driver, I OpenEvent() to > get the handle to the event. Why does OpenEvent()fail > with a GetLastError of ERROR_ACCESS_DENIED? > Please help me to understand what it is that I'm > doing wrong. Thanks in advance.. > > // open driver > if ((m_driverHandle = CreateFile(driverName, > GENERIC_WRITE | GENERIC_READ, > 0, // no file sharing > 0, // no security descriptor > OPEN_EXISTING, > FILE_ATTRIBUTE_NORMAL|FILE_FLAG_OVERLAPPED, > 0 // no template file > )) != INVALID_HANDLE_VALUE) > { > // driver opened successfully > // open a handle to the board data available event > m_boardDataAvailableEventHandle = ::OpenEvent(SYNCHRONIZE, FALSE, DATA_AVAILABLE_EVENT_NAME0); > if (m_boardDataAvailableEventHandle == NULL) > { > CString error; > error.Format("OpenEvent failed! Error = 0x%.8x",GetLastError()); > AfxMessageBox((LPCTSTR)error); > return STATUS_OPEN_DATA_AVAIL_EVENT_FAILED; > } > > // create a thread to wait on the event and read data from the > // board into the circular buffer > // ... > // ... > } I've resorted to creating the event in my user app and sending the handle down to the driver via an IOCTL and using ObReferenceObjectByHandle() (and subsequent ObDereferenceObject()). This appears to work just fine...Hopefully there's not any gotchas in this method especially with the need to ObDereferenceObject(). Thanks in advance of any comments from those who have used this sort of event notification...