Context when communicating with WDM

(Forgive me, This is an ntdev(ish) related topic)

We have a WDM for a USB device.
I need to communicate with this device from both Windows 98+ and Windows
2000 drivers.
(Windows 2000 is fine, there are no problems there).

When talking to the WDM from the vxd there are two documented methods.

  1. Export a function and use PELDR APIs to find the entry point.
    Using this method we discovered that the driver isn’t always called at

  2. Use NtKernCreateFile / NtKernDeviceIoControl / NtKernCloseFile

Using this method the driver is always called at PASSIVE_LEVEL.

But, as this intermediate ‘interface driver’ will be called from absolutely
any context there
are issues with the handle returned from NtKernCreateFile.

This is fine in most cases, and could be remedied by associated this handle
with one returned
from the ‘interface driver’ which uses a handle based open/close/comm

  1. Sometimes the calling context isn’t always the same as when the initial
    handle was obtained.
    (VWIN32_GetCurrentProcessHandle() returns 0, due to calling context being
    another driver)

  2. The USB driver calls back into the interface driver to let it know that
    the device is being removed.
    The ‘interface driver’ would need to be in the correct to context close the
    open handles.

Under Windows NT/2000 the solution would be to use ObReferenceObjectByHandle
and ObOpenObjectByPointer.

Is it possible to do an equivalent of these from a vxd?

Rob Linegar
Software Engineer
Data Encryption Systems Limited

You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)