⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 initiate.c

📁 此驱动程序是SATA功能的PCI卡为例
💻 C
字号:
/******************************************************************************
 * * File Name:
 * *      Initiate.c
 * * Description:
 * *      This file initializes the necessary system resources for the Silicon Image 3124A Pci card device.
 * * Revision History:
 * *      10-11-07 : Sil3124 1.00
 ******************************************************************************/

#include "Sil3124.h"
UNICODE_STRING ServiceRegistryPath; //save registry information

/******************************************************************************
 *
 * Function   :  DriverEntry
 *
 * Description:  Entry point for the driver.
 *
 ******************************************************************************/
#pragma code_seg("INIT") // start INIT section
//extern "C"			
NTSTATUS DriverEntry( IN PDRIVER_OBJECT pDriverObject,
					  IN PUNICODE_STRING pRegistryPath)
{												//DriverEntry
    NTSTATUS status = STATUS_SUCCESS;

	#if DBG
	DebugPrintInit("Sil3124 checked");	//DebugPrint init
    #else
	DebugPrintInit("Sil3124 free");
    #endif
	DebugPrint("DriverEntry Start..");

	DebugPrint("RegistryPath is %T",pRegistryPath);

 // Save the name of the service key
	ServiceRegistryPath.Buffer = (PWSTR) ExAllocatePool(PagedPool, pRegistryPath->Length + sizeof(WCHAR));
	if (!ServiceRegistryPath.Buffer)
	{
		DebugPrint("Sil3124 - Unable to allocate %d bytes for copy of service key name.", pRegistryPath->Length + sizeof(WCHAR));
		return STATUS_INSUFFICIENT_RESOURCES;
	}

	ServiceRegistryPath.MaximumLength = pRegistryPath->Length + sizeof(WCHAR);
	RtlCopyUnicodeString(&ServiceRegistryPath, pRegistryPath);

    // Fill in the appropriate dispatch handlers
	pDriverObject->DriverExtension->AddDevice           = AddDevice;
    pDriverObject->DriverUnload                         = DriverUnload;

    pDriverObject->MajorFunction[IRP_MJ_CREATE]         = DispatchCreate;
    pDriverObject->MajorFunction[IRP_MJ_CLOSE]          = DispatchClose;

    pDriverObject->MajorFunction[IRP_MJ_READ]           = DispatchRead;
	pDriverObject->MajorFunction[IRP_MJ_PNP]            = DispatchPnp; 
	pDriverObject->MajorFunction[IRP_MJ_WRITE]          = DispatchWrite;
    pDriverObject->MajorFunction[IRP_MJ_POWER]          = DispatchPower;
	pDriverObject->DriverStartIo						= StartIo;
    pDriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = DispatchIoControl;

    return(status);
}												//DriverEntry
#pragma code_seg()	// end INIT section

/******************************************************************************
 *
 * Function   :  DriverUnload
 *
 * Description:  Unload the driver.
 *
 ******************************************************************************/
#pragma code_seg("PAGE") // start PAGE section
VOID DriverUnload( IN PDRIVER_OBJECT pDriverObject)
{	
											// DriverUnload
	PAGED_CODE();
	DebugPrint("DriverUnload Start.");
	RtlFreeUnicodeString(&ServiceRegistryPath);
	DebugPrint("DriverUnload End.");

	//Close DebugPrint.
      DebugPrintClose();                         //close connection to DebugPrint Driver
}												// DriverUnload
#pragma code_seg()	// end PAGE section

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -