busenum.c - #include\"busenum.h GLOBALS Globals NPAGED_LOOKASIDE_LIST g_LookAside#ifdef ALLOC_PRAGMA#pragma alloc_text(INIT DriverEntry#pragma

busenum.c - #include"busenum.h GLOBALS Globals...

This preview shows page 1 - 4 out of 18 pages.

#include "busenum.h"GLOBALS Globals;NPAGED_LOOKASIDE_LIST g_LookAside;#ifdef ALLOC_PRAGMA#pragma alloc_text(INIT, DriverEntry)#pragma alloc_text(PAGE, Bus_DriverUnload)#pragma alloc_text(PAGE, Bus_CreateClose)#endifNTSTATUS DriverEntry(__in PDRIVER_OBJECT DriverObject, __in PUNICODE_STRING RegistryPath){Bus_KdPrint(("Driver Entry\n"));ExInitializeNPagedLookasideList(&g_LookAside, NULL, NULL, 0, sizeof(PENDING_IRP), BUSENUM_POOL_TAG, 0);Globals.RegistryPath.MaximumLength = RegistryPath->Length + sizeof(UNICODE_NULL);Globals.RegistryPath.Length = RegistryPath->Length;Globals.RegistryPath.Buffer = ExAllocatePoolWithTag(PagedPool, Globals.RegistryPath.MaximumLength, BUSENUM_POOL_TAG);if (!Globals.RegistryPath.Buffer){return STATUS_INSUFFICIENT_RESOURCES;}RtlCopyUnicodeString(&Globals.RegistryPath, RegistryPath);DriverObject->MajorFunction [IRP_MJ_CREATE ] =DriverObject->MajorFunction [IRP_MJ_CLOSE ] = Bus_CreateClose;DriverObject->MajorFunction [IRP_MJ_PNP ] = Bus_PnP;DriverObject->MajorFunction [IRP_MJ_POWER ] = Bus_Power;DriverObject->MajorFunction [IRP_MJ_DEVICE_CONTROL ] = Bus_IoCtl;DriverObject->MajorFunction [IRP_MJ_INTERNAL_DEVICE_CONTROL] = Bus_Internal_IoCtl;DriverObject->DriverUnload = Bus_DriverUnload;DriverObject->DriverExtension->AddDevice = Bus_AddDevice;return STATUS_SUCCESS;}VOID Bus_DriverUnload(__in PDRIVER_OBJECT DriverObject){UNREFERENCED_PARAMETER(DriverObject);PAGED_CODE();Bus_KdPrint(("Driver Unload\n"));ASSERT(NULL == DriverObject->DeviceObject);ExDeleteNPagedLookasideList(&g_LookAside);if (Globals.RegistryPath.Buffer) ExFreePool(Globals.RegistryPath.Buffer);return;}
Background image
NTSTATUS Bus_CreateClose(PDEVICE_OBJECT DeviceObject, PIRP Irp){PIO_STACK_LOCATION irpStack;NTSTATUS status;PFDO_DEVICE_DATA fdoData;PCOMMON_DEVICE_DATA commonData;PAGED_CODE();commonData = (PCOMMON_DEVICE_DATA) DeviceObject->DeviceExtension;if (!commonData->IsFDO){Irp->IoStatus.Status = status = STATUS_INVALID_DEVICE_REQUEST;IoCompleteRequest(Irp, IO_NO_INCREMENT);return status;}fdoData = (PFDO_DEVICE_DATA) DeviceObject->DeviceExtension;if (fdoData->DevicePnPState == Deleted){Irp->IoStatus.Status = status = STATUS_NO_SUCH_DEVICE;IoCompleteRequest(Irp, IO_NO_INCREMENT);return status;}Bus_IncIoCount(fdoData);irpStack = IoGetCurrentIrpStackLocation(Irp);switch (irpStack->MajorFunction){case IRP_MJ_CREATE:Bus_KdPrint(("Create \n"));status = STATUS_SUCCESS;break;case IRP_MJ_CLOSE:Bus_KdPrint(("Close \n"));status = STATUS_SUCCESS;break;default:status = STATUS_INVALID_DEVICE_REQUEST;break;}Irp->IoStatus.Information = 0;Irp->IoStatus.Status = status;IoCompleteRequest(Irp, IO_NO_INCREMENT);Bus_DecIoCount(fdoData);return status;}NTSTATUS Bus_IoCtl(PDEVICE_OBJECT DeviceObject, PIRP Irp){PIO_STACK_LOCATION irpStack;
Background image
NTSTATUS status;ULONG inlen;PFDO_DEVICE_DATA fdoData;PVOID buffer;PCOMMON_DEVICE_DATA commonData;commonData = (PCOMMON_DEVICE_DATA) DeviceObject->DeviceExtension;if (!commonData->IsFDO){Irp->IoStatus.Status = status = STATUS_INVALID_DEVICE_REQUEST;IoCompleteRequest(Irp, IO_NO_INCREMENT);return status;}fdoData = (PFDO_DEVICE_DATA) DeviceObject->DeviceExtension;if (fdoData->DevicePnPState == Deleted){Irp->IoStatus.Status = status = STATUS_NO_SUCH_DEVICE;
Background image
Image of page 4

You've reached the end of your free preview.

Want to read all 18 pages?

  • Fall '15
  • NormanBest

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors