NTSTATUS DriverEntry(PDRIVER_OBJECT pDriverObject, PUNICODE_STRING pRegistryPath) { KdPrint(("DriverEntry")); EnumDrivers(pDriverObject); pDriverObject->DriverUnload = DriverUnLoad; return STATUS_SUCCESS; }
NTSTATUS DispatchControl(PDEVICE_OBJECT DeviceObject,PIRP Irp) { NTSTATUS Status = STATUS_SUCCESS; PIO_STACK_LOCATION IrpSp; PVOID InputBuffer = NULL; PVOID OutputBuffer = NULL; ULONG_PTR InputSize = 0; ULONG_PTR OutputSize = 0; ULONG_PTR IoControlCode = 0; IrpSp = IoGetCurrentIrpStackLocation(Irp); InputBuffer = IrpSp->Parameters.DeviceIoControl.Type3InputBuffer; OutputBuffer = Irp->UserBuffer; InputSize = IrpSp->Parameters.DeviceIoControl.InputBufferLength; OutputSize = IrpSp->Parameters.DeviceIoControl.OutputBufferLength; IoControlCode = IrpSp->Parameters.DeviceIoControl.IoControlCode; switch(IoControlCode) { case CTL_GET_DPCTIMER: { EnumDpcTimer(OutputBuffer); Irp->IoStatus.Information = 0; Status = Irp->IoStatus.Status = Status; break; } case CTL_REMOVEDPCTIMER: { Status = RemoveDPCTimer(InputBuffer); Irp->IoStatus.Information = 0; Status = Irp->IoStatus.Status = Status; break; } case CTL_GET_DRIVER: { GetKernelLdrDataTableEntry(g_DriverObject); Status = EnumDrivers(OutputBuffer,OutputSize); Irp->IoStatus.Information = 0; Status = Irp->IoStatus.Status = Status; break; } default: { Irp->IoStatus.Status = STATUS_UNSUCCESSFUL; Irp->IoStatus.Information = 0; break; } } IoCompleteRequest(Irp,IO_NO_INCREMENT); return Status; }
BOOLEAN DiskHook(VOID) { if(UnloadInProgress) { DbPrint(DC_DISK,DL_WARNING, ("DiskHook when UnloadInProgress!\n")); return FALSE; } if(!DiskHooked) { DbPrint(DC_DISK,DL_NOTIFY, ("DiskHook!\n")); ExInitializeFastMutex(&DiskDevListMutex); if(NT_SUCCESS(EnumDrivers(FindDiskDev, NULL))) { DiskHooked=TRUE; } else { ExDestroyFastMutex(&DiskDevListMutex); return FALSE; } } return TRUE; }