DriverEntry

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

DriverEntry是驱动加载后第一个执行的例程,它负责初始化驱动程序。

语法:

DRIVER_INITIALIZE DriverEntry;

NTSTATUS DriverEntry(
_In_ struct _DRIVER_OBJECT *DriverObject,
_In_ PUNICODE_STRING RegistryPath
)
{ ... }

参数:
DriverObject [in]
A pointer to a DRIVER_OBJECT structure. This is the driver's driver object.
一个DRIVER_OBJECT结构体的指针,是驱动程序的驱动对象。
RegistryPath [in]
A pointer to a counted Unicode string specifying the path to the driver's registry key.
一个UNICODE字符串,指定驱动程序在注册表中对应的键值。
返回值:

If the routine succeeds, it must return STATUS_SUCCESS. Otherwise, it must return one of the error status values defined in Ntstatus.h.
如果执行成功,必须返回STATUS_SUCCESS, 其它情况下,返回ntstatus.h定义的错误码。

其它说明:

The DriverObject parameter supplies the DriverEntry routine with a pointer to the driver's driver object, which is allocated by the I/O manager.
DriverEntry程的DriverObject参数是一个由IO管理器分配的指向驱动程序的驱动对象指针。
The DriverEntry routine must fill in the driver object with entry points for the driver's standard routines.
DriverEntry必须指定驱动程序的标准例程的入口点。
The DriverObject pointer gives the driver access to DriverObject->HardwareDatabase,
驱动程序通过DriverObject->HardwareDatabase(一个UNICODE字符串)访问\Registry\Machine\Hardware子树。
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.
RegistryPath是一个指向\Registry\Machine\System\CurrentControlSet\Services\DriverName注册表路径的UNICODE字符串,

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.
DriverEntry应该保存一个UNICODE字符串(如果以后会用到),而不是指针,因为I/O管理器在它返回后会释放RegisterPath。

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.
DDK提供的build工具默认使用DriverEntry这个入口函数进行链接,所以,使用其它的入口函数名称,需要你修改build工具的参数。

posted @ 2013-05-29 17:40  bqrm_521(小奎)  阅读(783)  评论(0编辑  收藏  举报