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

📄 init.cpp

📁 使用DDK编写的PCI9054芯片的驱动程序
💻 CPP
字号:
/******************************************************************************
 * * File Name:
 * *      Init.cpp
 * * Description:
 * *      This file initializes the necessary system resources for the Can Pci card device.
 * * Revision History:
 * *      02-28-02 : PDC4000 1.00
 ******************************************************************************/

#include "PDC4000.h"

UNICODE_STRING ServiceRegistryPath;		//The 


/******************************************************************************
 *
 * 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;

	KdPrint((DBG_NAME "DriverEntry Start."));

	KdPrint((DBG_NAME "RegistryPath is %T",pRegistryPath));

    // Determine OS version through WDM version information
    if (IoIsWdmVersionAvailable(0x01, 0x10) == FALSE)
    {				//Determine OS version
        if (IoIsWdmVersionAvailable(0x01, 0x00) == TRUE)
        {			//
            KdPrint((DBG_NAME "OS supports WDM 1.0 (Windows 98)\n"));
        }
        else
		{
            KdPrint((DBG_NAME "WARNING - OS does not support WDM 1.0\n"));
		}
	}
    else
	{
        KdPrint((DBG_NAME "OS supports WDM 1.10 (Windows 2000 or above)\n"));
	}				//Determine OS version

    // Save the name of the service key
	ServiceRegistryPath.Buffer = (PWSTR) ExAllocatePool(PagedPool, pRegistryPath->Length + sizeof(WCHAR));
	if (!ServiceRegistryPath.Buffer)
	{
		KdPrint((DBG_NAME "PDC4000 - 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_WRITE]          = DispatchWrite;
	pDriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = DispatchIoControl;

	pDriverObject->DriverStartIo						= StartIo;
	pDriverObject->MajorFunction[IRP_MJ_CLEANUP]        = DispatchCleanup;
    
    pDriverObject->MajorFunction[IRP_MJ_PNP]            = DispatchPnp;
    pDriverObject->MajorFunction[IRP_MJ_POWER]          = DispatchPower;

    pDriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = DispatchSystemControl;
    

	KdPrint((DBG_NAME "DriverEntry End.\n"));

    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();
	KdPrint((DBG_NAME "DriverUnload Start.\n"));
	RtlFreeUnicodeString(&ServiceRegistryPath);
	KdPrint((DBG_NAME "DriverUnload End.\n"));
}												// DriverUnload
#pragma code_seg()	// end PAGE section

⌨️ 快捷键说明

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