[python-win32] Handle to a Driver
me at chi-tai.info
Sat Apr 2 21:56:53 CEST 2005
maybe someone can help me. I am writing an application, which uses the
win32event.CreateEvent to create a synchronisation event which handle is
then stored in a PyHANDLE.
This handle is then submitted with DeviceIoControl to a Driver which
calls the Function ObReferenceObjectByHandle to get a valid kernel
handle to the user-mode
And here the problem occours. This function returns with a "invalid
handle" status. The code is as follows:
ReadEvent = CreateEvent ( None, 0, 0, None )
ret = DeviceIoControl (hDevice, IOCTL_SET_READ_EVENT, str(ReadEvent),
Driver code in Dispatch Routine for IOCTL:
ntStatus = ObReferenceObjectByHandle ( handleFromPython,
EVENT_MODIFY_STATE, *ExEventObjectType, Irp->RequestorMode, (PVOID*)
The ReferenceObject has to be done, because each user-mode process has
another context, and windows kernle-mode works in an
it is needed to make a kernel-mode eventhandle to access it later.
Is it possible that the win32 extensions wrapped the functions whithin
it's own handle-table, so that the operating system can't find the
handle-id in the system handle table ?
i know it's not a common problem... but drivers often have to notify
user-mode applications, and this is the way they do it.
More information about the Python-win32