Click to Rate and Give Feedback
MSDN
MSDN Library
Windows Driver Kit
Reference
 DriverEntry
Windows Driver Kit: Kernel-Mode Driver Architecture
DriverEntry

DriverEntry is the first routine called after a driver is loaded, and is responsible for initializing the driver.

NTSTATUS 
  DriverEntry( 
    IN PDRIVER_OBJECT  DriverObject
    IN PUNICODE_STRING  RegistryPath 
    ); 

Parameters

DriverObject
Caller-supplied pointer to a DRIVER_OBJECT structure. This is the driver's driver object.
RegistryPath
Pointer to a counted Unicode string specifying the path to the driver's registry key.

Return Value

If the routine succeeds, it must return STATUS_SUCCESS. Otherwise, it must return one of the error status values defined in ntstatus.h.

Comments

The DriverObject parameter supplies the DriverEntry routine with a pointer to the driver's driver object, which is allocated by the I/O manager. The DriverEntry routine must fill in the driver object with entry points for the driver's standard routines.

The DriverObject pointer gives the driver access to DriverObject->HardwareDatabase, which points to a counted Unicode string that specifies a path to the registry's \Registry\Machine\Hardware tree.

The registry path string pointed to by RegistryPath is of the form \Registry\Machine\System\CurrentControlSet\Services\DriverName. A driver can use this path to store driver-specific information; see Registry Keys for Drivers. The DriverEntry routine should save a copy of the Unicode string, not the pointer, since the I/O manager frees the RegistryPath buffer after DriverEntry returns.

For more information about implementing a DriverEntry routine, see Writing a DriverEntry Routine.

While it is possible to name this routine something other than DriverEntry, doing so is not recommended. The DDK-supplied build tools automatically inform the linker that the driver's entry point is called DriverEntry, so giving the routine another name requires you to modify the build tools. For more information about build tools, see Building Drivers.

Requirements

IRQL: PASSIVE_LEVEL

Headers: Declared in wdm.h. Include wdm.h, ntddk.h, or ntifs.h.

APIScan Requirements

Header: wdm.h, ntddk.h, or ntifs.h
Function: DriverEntry
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker