From: Mathieu on 18 Oct 2009 11:27 Bug in the Windows Kernel. The event DeviceDispatch IRP_MJ_CREATE and IRP_MJ_CLOSE are not invoked why call the API Function CreateFile function of User-Mode. SOURCE INCOMPLETE! Help me please ! #define VDUM_DOS_BASE_NAME "\\\\.\\VDUMInternal_Sivaller" hFile= CreateFile(VDUM_DOS_BASE_NAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); CloseHandle(hFile); IRP_MJ_CREATE not called , why bug in the windows kernel ! I D'ont view the message "IRP_MJ_CREATE" in the utility debugging DebugView or WinDbg. There is a line quoted KdPrint(("IRP_MJ_CREATE")) !! Help me please ! i lost a time to finding a problem solution ! ------------------ ui.h ------------------ #define FILE_DEVICE_IMDISK 0x8373 #define IOCTL_CMD_GETVER CTL_CODE(FILE_DEVICE_VDUMS, 0x801, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) #define IOCTL_CMD_CREATEVIRTUALDISK CTL_CODE(FILE_DEVICE_VDUMS, 0x802, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) #define IOCTL_CMD_DELETEVIRTUALDISK CTL_CODE(FILE_DEVICE_VDUMS, 0x803, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) #define IOCTL_CMD_PARAMETERVIRTUALDISK CTL_CODE(FILE_DEVICE_VDUMS, 0x804, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) #define IOCTL_CMD_DEPARAMETERVIRTUALDISK CTL_CODE(FILE_DEVICE_VDUMS, 0x805, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) #define namedriver L"\\Device\\sivaller_vdum_beta" #define dosdriver L"\\??\\sivaller_vdum_beta" #define FILE_DEVICE_VDUM #ifndef USERMODE #define VDUM_CTL_DOSDEV L"VDUM_Sivaller" #define VDUM_CTL_DOSDEV_NAME L"\\??\\" VDUM_CTL_DOSDEV #define VDUM_CTL_SYMLINK_NAME L"\\DosDevices\\" VDUM_CTL_DOSDEV #else #define VDUM_CTL_DOSDEV "VDUM_Sivaller" #define VDUM_CTL_DOSDEV_NAME "\\\\.\\" VDUM_CTL_DOSDEV #define VDUM_CTL_SYMLINK_NAME "\\DosDevices\\" VDUM_CTL_DOSDEV #endif /// /// The base names for the device objects created in \Device /// //#define VDUM_DEVICE_DIR_NAME _T("\\Device") #ifdef USERMODE #define VDUM_DEVICE_BASE_NAME "\\Device\\VDUMInternal_Sivaller" //#define VDUM_DOS_DIR_NAME _T("\\\\.\\") #define VDUM_DOS_BASE_NAME "\\\\.\\VDUMInternal_Sivaller" #else #define VDUM_DEVICE_BASE_NAME L"\\Device\\VDUMInternal_Sivaller" //#define VDUM_DOS_DIR_NAME _T("\\\\.\\") #define VDUM_DOS_BASE_NAME L"\\\\.\\VDUMInternal_Sivaller" #endif typedef unsigned long DWORD; typedef struct { BOOLEAN create_d; CHAR letter; CHAR iddevice; }TCREATEVD,*PCREATEVD; typedef struct { WCHAR pipe[64]; WCHAR eventrecv[64]; WCHAR eventsend[64]; DWORD sizeko; CHAR letter; DISK_GEOMETRY disk_geometry; UCHAR time_out; }TCONFIGVD,*PCONFIGVD; --------------- ui.c --------------- #include <ntddk.h> #include <ntdddisk.h> #include <stdio.h> #include "sdi.h" #include "ui.h" #include "gvdisk.h" #define maxdevice 8 typedef unsigned short WORD; PDEVICE_OBJECT g_devcontrol = NULL; PDEVICE_OBJECT device_letter[maxdevice]; NTSTATUS GLinkLetter(CHAR letter,UNICODE_STRING device_name,BOOLEAN c_link) { NTSTATUS status=0; WCHAR sym_link_global_wchar[] = L"\\DosDevices\\Global\\ :"; UNICODE_STRING sym_link; sym_link_global_wchar[19] = letter+65; KdPrint(("[VDUM] GLinkLetter: Creating/Remoing symlink '%ws' .\n", sym_link_global_wchar)); RtlInitUnicodeString(&sym_link, sym_link_global_wchar); if (c_link) status = IoCreateUnprotectedSymbolicLink(&sym_link, &device_name); else status = IoDeleteSymbolicLink(&sym_link); return status; } NTSTATUS VDUM_InternalCreateDisk(IN PDRIVER_OBJECT DriverObject,PCREATEVD createvd,CHAR index) { NTSTATUS status; UNICODE_STRING device_name; PWCHAR device_name_buffer; UNICODE_STRING dos_name; PWCHAR dos_name_buffer; ULONG DeviceNumber; PDEVICE_OBJECT DeviceObject; PPARAMVD pvd; HANDLE thread_handle; DeviceNumber=(ULONG)createvd->letter; // Buffer for device name device_name_buffer = ExAllocatePool(PagedPool, MAXIMUM_FILENAME_LENGTH * sizeof(*device_name_buffer)); if (device_name_buffer==NULL) { return STATUS_INSUFFICIENT_RESOURCES; } dos_name_buffer = ExAllocatePool(PagedPool, MAXIMUM_FILENAME_LENGTH * sizeof(*dos_name_buffer)); if (device_name_buffer==NULL) { ExFreePool(device_name_buffer); return STATUS_INSUFFICIENT_RESOURCES; } _snwprintf(device_name_buffer, MAXIMUM_FILENAME_LENGTH - 1, VDUM_DEVICE_BASE_NAME L"%u", DeviceNumber); device_name_buffer[MAXIMUM_FILENAME_LENGTH - 1] = 0; _snwprintf(dos_name_buffer, MAXIMUM_FILENAME_LENGTH - 1, VDUM_DOS_BASE_NAME L"%u", DeviceNumber); dos_name_buffer[MAXIMUM_FILENAME_LENGTH - 1] = 0; KdPrint (("VDUM: Creating device '%ws'. \n", device_name_buffer)); RtlInitUnicodeString(&device_name, device_name_buffer); status = IoCreateDevice(DriverObject, sizeof(TPARAMVD), &device_name, FILE_DEVICE_VDUMS, 0, FALSE, &DeviceObject); if (status==STATUS_SUCCESS) { KdPrint(("[VDUM] IoCreateDevice OK\n")); pvd=(PPARAMVD)DeviceObject->DeviceExtension; RtlZeroMemory(pvd, sizeof(TPARAMVD)); /*pvd->eventrecv=NULL; pvd->eventsend=NULL; pvd->letter=createvd->letter; pvd->pipe=NULL; pvd->index=DeviceNumber;*/ device_letter[index]=DeviceObject; pvd->namedevice=device_name; pvd->DeviceObject=DeviceObject; // pvd->letter=createvd->letter; InitializeListHead(&pvd->list_head); KeInitializeSpinLock(&pvd->list_lock); KeInitializeEvent(&pvd->request_event, SynchronizationEvent, FALSE); pvd->terminate_thread = FALSE; (*DeviceObject).Flags &= ~DO_DEVICE_INITIALIZING; status=GLinkLetter(createvd->letter,device_name,TRUE); if (status==STATUS_SUCCESS) { KdPrint(("[VDUM] VDUM_InternalCreateDisk OK\n")); status = PsCreateSystemThread(&thread_handle, (ACCESS_MASK) 0L, NULL, NULL, NULL, VDUM_DeviceThread, pvd); if (!NT_SUCCESS(status)) { KdPrint(("[VDUM] Cannot create device thread. (%#x)\n", status)); IoDeleteDevice(DeviceObject); device_letter[index]=NULL; GLinkLetter(createvd->letter,device_name,FALSE); return status; } ZwClose(thread_handle); } else { KdPrint(("[VDUM] GLinkLetter Fail status %x\n",status)); IoDeleteDevice(DeviceObject); device_letter[index]=NULL; } } else { KdPrint(("[VDUM] IoCreateDevice Error %x\n",status)); } KdPrint(("[VDUM] VDUM_InternalCreateDisk Freepool\n")); ExFreePool(device_name_buffer); ExFreePool(dos_name_buffer); KdPrint(("[VDUM] VDUM_InternalCreateDisk End\n")); return status; } NTSTATUS VDUM_CreateDisk(IN PDRIVER_OBJECT DriverObject,PCREATEVD createvd) { int i; for (i = 0 ; i < maxdevice ; i++) { if (device_letter[i]==NULL) { NTSTATUS status; status=VDUM_InternalCreateDisk(DriverObject,createvd,i); if (status==STATUS_SUCCESS) { if (device_letter[i]!=NULL) { createvd->create_d=TRUE; createvd->iddevice=i; return STATUS_SUCCESS; } else return STATUS_UNSUCCESSFUL; } return status; } } return STATUS_INSUFFICIENT_RESOURCES; } NTSTATUS VDUM_DeleteDisk(PDEVICE_OBJECT lod) { NTSTATUS status; PPARAMVD pvd=(PPARAMVD)lod->DeviceExtension; KdPrint(("Unload Device letter %s\n",pvd->letter+65)); status=STATUS_SUCCESS; GLinkLetter(pvd->letter,pvd->namedevice,FALSE); if (status==STATUS_SUCCESS) { KdPrint(("Unload Terminate Thread %s\n",pvd->letter+65)); pvd->terminate_thread=TRUE; KeWaitForSingleObject(&pvd->thread, Executive, KernelMode, FALSE, NULL); device_letter[pvd->index]=NULL; KdPrint(("Unload CloseHandles %s\n",pvd->letter+65)); //if (status==STATUS_SUCCESS) { KdPrint(("Unload CloseHandles %s eventrecv\n",pvd->letter+65)); if (pvd->eventrecv!=NULL) ZwClose(pvd->eventrecv); KdPrint(("Unload CloseHandles %s eventsend\n",pvd->letter+65)); if (pvd->eventsend!=NULL) ZwClose(pvd->eventsend); KdPrint(("Unload CloseHandles %s file_handle\n",pvd->letter+65)); if (pvd->file_handle!=NULL) ZwClose(pvd->file_handle); KdPrint(("Unload CloseHandles %s Dereferencepipe\n",pvd->letter+65)); ObDereferenceObject(pvd->pipe); KdPrint(("Unload CloseHandles %s Close notify event\n",pvd->letter+65)); ZwClose(pvd->NotifyHandleRecv); ZwClose(pvd->NotifyHandleSend); } KdPrint(("Unload IoDeleteDevice %s\n",pvd->letter+65)); IoDeleteDevice(lod); } } PDEVICE_OBJECT VDUM_GetDevice(CHAR letter) { PDEVICE_OBJECT x=NULL; int i; for (i = 0 ; i < maxdevice ; i++) { if (device_letter[i]!=NULL) { PPARAMVD k=(PPARAMVD)device_letter[i]->DeviceExtension; if (k!=NULL) { if (k->letter==letter) return k; } } } return NULL; } NTSTATUS vdums_deviceiocontrol(IN PDEVICE_OBJECT DeviceObject, IN PIRP irp, PIO_STACK_LOCATION irps) { NTSTATUS status=STATUS_NOT_IMPLEMENTED; IN PDEVICE_OBJECT lod; WORD *ccver; PCREATEVD createvd; PCONFIGVD configvd; PPARAMVD paramvd; HANDLE file_handle = NULL; OBJECT_ATTRIBUTES attr; ULONG iocode; IO_STATUS_BLOCK io_status; WCHAR wpipe[256]; iocode=irps->Parameters.DeviceIoControl.IoControlCode; KdPrint(("[VDUM] IoControl %x\n",iocode)); switch (iocode) { case IOCTL_CMD_GETVER: { KdPrint(("[VDUM] CMD GETVER\n")); if (irps->Parameters.DeviceIoControl.InputBufferLength < 2) { KdPrint(("[VDUM] CMD GETVER buffer to small\n")); status = STATUS_INVALID_PARAMETER; irp->IoStatus.Information = 0; } ccver=(WORD*)irp->AssociatedIrp.SystemBuffer; *ccver=0x0100; status = STATUS_SUCCESS; //irp->IoStatus.Status=status; irp->IoStatus.Information=2; //IoCompleteRequest (irp, IO_NO_INCREMENT); return status; } break; case IOCTL_CMD_CREATEVIRTUALDISK: { KdPrint(("[VDUM] CMD CreateVirtualDisk\n")); if ((irps->Parameters.DeviceIoControl.InputBufferLength < sizeof(TCREATEVD)) | (irps->Parameters.DeviceIoControl.OutputBufferLength < sizeof(TCREATEVD))) { KdPrint(("[VDUM] CMD CreateVirtualDisk Size mismatch\n")); status = STATUS_INVALID_PARAMETER; irp->IoStatus.Information = 0; break; } createvd=(PCREATEVD)irp->AssociatedIrp.SystemBuffer; irp->IoStatus.Information=0; if (createvd->create_d) { IN PDEVICE_OBJECT lod=VDUM_GetDevice(createvd->letter); irp->IoStatus.Information=sizeof(TCREATEVD); if (lod==NULL) { status=VDUM_CreateDisk(DeviceObject->DriverObject,createvd); KdPrint(("[VDUM] CMD CreateVirtualDisk letter %c: success\n",createvd->letter+65)); } else { status=STATUS_OBJECT_NAME_EXISTS; KdPrint(("[VDUM] CMD CreateVirtualDisk letter %c: already exist\n",createvd->letter+65)); } createvd->create_d=status==STATUS_SUCCESS; } //status = STATUS_INVALID_PARAMETER; } break; case IOCTL_CMD_DELETEVIRTUALDISK: { KdPrint(("[VDUM] CMD DeleteVirtualDisk\n")); if ((irps->Parameters.DeviceIoControl.InputBufferLength < sizeof(TCREATEVD)) | (irps->Parameters.DeviceIoControl.OutputBufferLength < sizeof(TCREATEVD))) { KdPrint(("[VDUM] CMD DeleteVirtualDisk Size mismatch\n")); status = STATUS_INVALID_PARAMETER; irp->IoStatus.Information = 0; break; } createvd=(PCREATEVD)irp->AssociatedIrp.SystemBuffer; irp->IoStatus.Information=0; if (createvd->create_d) { KdPrint(("[VDUM] CMD DeleteVirtualDisk letter %c:\n",createvd->letter+65)); lod=VDUM_GetDevice(createvd->letter); if (lod!=NULL) { status=VDUM_DeleteDisk(lod); irp->IoStatus.Information=sizeof(TCREATEVD); KdPrint(("[VDUM] CMD DeleteVirtualDisk letter %c: success\n",createvd->letter+65)); } else { status=STATUS_UNSUCCESSFUL; KdPrint(("[VDUM] CMD DeleteVirtualDisk letter %c: not exists\n",createvd->letter+65)); } KdPrint(("X1\n")); createvd->create_d=status==STATUS_SUCCESS; KdPrint(("X2\n")); } } break; case IOCTL_CMD_DEPARAMETERVIRTUALDISK: { KdPrint(("[VDUM] CMD DeParameterVirtualDisk\n")); if ((irps->Parameters.DeviceIoControl.InputBufferLength < sizeof(TCREATEVD)) | (irps->Parameters.DeviceIoControl.OutputBufferLength < sizeof(TCREATEVD))) { KdPrint(("[VDUM] CMD DeParameterVirtualDisk Size mismatch\n")); status = STATUS_INVALID_PARAMETER; irp->IoStatus.Information = 0; break; } createvd=(PCREATEVD)irp->AssociatedIrp.SystemBuffer; lod=VDUM_GetDevice(createvd->letter); status=STATUS_INVALID_HANDLE; if (lod!=0) { KdPrint(("[VDUM] CMD DeParameterVirtualDisk OK\n")); paramvd=(PPARAMVD)lod->DeviceExtension; if (paramvd->file_handle!=NULL)ZwClose(paramvd->file_handle); if (paramvd->NotifyHandleRecv)ZwClose(paramvd->NotifyHandleRecv); if (paramvd->NotifyHandleSend)ZwClose(paramvd->NotifyHandleSend); ObDereferenceObject(paramvd->pipe); paramvd->pipe=NULL; paramvd->NotifyHandleRecv=paramvd->NotifyHandleSend=paramvd->pipe=paramvd->eventrecv=paramvd->eventsend=NULL; paramvd->parametrer=FALSE; status=STATUS_SUCCESS; } } break; case IOCTL_CMD_PARAMETERVIRTUALDISK: { KdPrint(("[VDUM] CMD ParametreVirtualDisk\n")); if ((irps->Parameters.DeviceIoControl.InputBufferLength < sizeof(TCONFIGVD))) { KdPrint(("[VDUM] CMD ParametreVirtualDisk Size mismatch\n")); status = STATUS_INVALID_PARAMETER; irp->IoStatus.Information = 0; break; } configvd=(PCONFIGVD)irp->AssociatedIrp.SystemBuffer; lod=VDUM_GetDevice(configvd->letter); status=STATUS_INVALID_HANDLE; if (lod!=0) { UNICODE_STRING uszNotifyEventString,pipe_name; KdPrint(("[VDUM] CMD ParametreVirtualDisk lod ok\n")); paramvd=(PPARAMVD)lod->DeviceExtension; RtlInitUnicodeString(&uszNotifyEventString, configvd->eventrecv); paramvd->eventrecv = IoCreateNotificationEvent(&uszNotifyEventString, ¶mvd->NotifyHandleRecv); if (paramvd->eventrecv!=NULL) { KdPrint(("[VDUM] CMD ParametreVirtualDisk eventrecv ok\n")); RtlInitUnicodeString(&uszNotifyEventString, configvd->eventsend); paramvd->eventsend = IoCreateNotificationEvent(&uszNotifyEventString, ¶mvd->NotifyHandleSend); if (paramvd->eventsend!=NULL) { KdPrint(("[VDUM] CMD ParametreVirtualDisk eventsend ok\n")); wcscpy(wpipe,L"\\??\\pipe\\"); wcscat(wpipe,configvd->pipe); paramvd->sizeko=configvd->sizeko; paramvd->disk_geometry=configvd->disk_geometry; paramvd->time_out=configvd->time_out; KdPrint(("[VDUM] CMD ParametreVirtualDisk pipe name %ws\n",wpipe)); RtlInitUnicodeString( &pipe_name, wpipe ); InitializeObjectAttributes( &attr, &pipe_name, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL); status = ZwCreateFile( ¶mvd->file_handle, SYNCHRONIZE | FILE_WRITE_DATA , // or FILE_READ_DATA &attr, &io_status, NULL, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ | FILE_SHARE_DELETE | FILE_SHARE_WRITE, FILE_OPEN, //IMDISK_TYPE(CreateData->Flags) == IMDISK_TYPE_PROXY ? FILE_NON_DIRECTORY_FILE | FILE_SEQUENTIAL_ONLY | FILE_NO_INTERMEDIATE_BUFFERING | FILE_SYNCHRONOUS_IO_NONALERT | FILE_NON_DIRECTORY_FILE | FILE_RANDOM_ACCESS | FILE_NO_INTERMEDIATE_BUFFERING | FILE_SYNCHRONOUS_IO_NONALERT, NULL, 0); status = ObReferenceObjectByHandle(file_handle, FILE_READ_ATTRIBUTES | FILE_READ_DATA | FILE_WRITE_DATA, *IoFileObjectType, KernelMode, &configvd->pipe, NULL); if (status==STATUS_SUCCESS) { KdPrint(("[VDUM] CMD ParametreVirtualDisk pipe ok\n")); irp->IoStatus.Information=0; paramvd->parametrer=TRUE; status=STATUS_SUCCESS; } else { KdPrint(("[VDUM] CMD ParametreVirtualDisk pipeerror %x \n",status)); } } else { KdPrint(("[VDUM] CMD ParametreVirtualDisk eventsend fail\n")); ZwClose(¶mvd->eventrecv); status=STATUS_INSUFFICIENT_RESOURCES; } } else { KdPrint(("[VDUM] CMD ParametreVirtualDisk eventrecv fail\n")); status=STATUS_INSUFFICIENT_RESOURCES; } } } break; } KdPrint(("[VDUM] End DeviceIocontrol VDUMS\n")); return status; } NTSTATUS vdums_control(IN PDEVICE_OBJECT DeviceObject, IN PIRP irp) { NTSTATUS status=STATUS_NOT_IMPLEMENTED; PIO_STACK_LOCATION irps; irps = IoGetCurrentIrpStackLocation(irp); KdPrint(("[VDUM] vdums_control : Majorfunction %d\n",irps->MajorFunction)); switch (irps->MajorFunction) { case IRP_MJ_CREATE: KdPrint(("[VDUM] IRP_MJ_CREATE\n")); return STATUS_SUCCESS; break; case IRP_MJ_CLOSE: KdPrint(("[VDUM] IRP_MJ_CLOSE\n")); return STATUS_SUCCESS; break; case IRP_MJ_CLEANUP: KdPrint(("[VDUM] IRP_MJ_CLEANUP\n")); return STATUS_SUCCESS; break; case IRP_MJ_DEVICE_CONTROL: KdPrint(("[VDUM] IRP_MJ_DEVICE_CONTROL\n")); return vdums_deviceiocontrol(DeviceObject,irp,irps); break; } return status; } BOOLEAN vdums_validdevice(IN PDEVICE_OBJECT DeviceObject) { int i; for (i=0; i < maxdevice; i++) { if (device_letter[i]==DeviceObject) return TRUE; } return FALSE; } /* dispatch */ NTSTATUS DeviceDispatch(IN PDEVICE_OBJECT DeviceObject, IN PIRP irp) { //PIO_STACK_LOCATION irps; NTSTATUS status=STATUS_NOT_IMPLEMENTED; KdPrint(("[VDUM] Begin DeviceDispatch\n")); // sanity check irp->IoStatus.Information = FILE_OPENED; if (irp == NULL) { KdPrint(("[VDUM] DeviceDispatch: !irp\n")); return STATUS_SUCCESS; } if (DeviceObject==g_devcontrol) { KdPrint(("[VDUM] DeviceDispatch vdums control\n")); status=vdums_control(DeviceObject,irp); KdPrint(("[VDUM] End DeviceDispatch vdums control\n")); } else { if (vdums_validdevice(DeviceObject)) { KdPrint(("[VDUM] DeviceDispatch vdisk control\n")); status=vdums_vdisk_control(DeviceObject,irp); } else { KdPrint(("[VDUM] DeviceDispatch invalid device\n")); status=STATUS_INVALID_HANDLE; } } //irps = IoGetCurrentIrpStackLocation(irp); if (status!=STATUS_SUCCESS) { KdPrint(("[VDUM] Unkown Commande\n")); } KdPrint(("[VDUM] End DeviceDispatch\n")); irp->IoStatus.Status = status; IoCompleteRequest(irp, IO_NO_INCREMENT); return status; } /* deinitialization */ VOID OnUnload(IN PDRIVER_OBJECT DriverObject) { UNICODE_STRING linkname,name; int i; KdPrint(("[VDUM] Unload Device: \n")); for (i = 0;i<maxdevice; i++) { if (device_letter[i]!=NULL) { //PPARAMVD pvd=(PPARAMVD)device_letter[i]->DeviceExtension; KdPrint(("Unload device index %d\n",i)); VDUM_DeleteDisk(device_letter[i]); } } //RtlInitUnicodeString(&name, namedriver); RtlInitUnicodeString(&linkname, VDUM_CTL_SYMLINK_NAME); IoDeleteSymbolicLink(&linkname); IoDeleteDevice(g_devcontrol); } NTSTATUS DriverEntry(IN PDRIVER_OBJECT theDriverObject, IN PUNICODE_STRING theRegistryPath) { //KdPrint(("vns_init\n",STATUS_SUCCESS)); NTSTATUS status; UNICODE_STRING name, linkname; int i; KdPrint(("[VDUM] Init\n")); for (i = 0; i < maxdevice ; i++) device_letter[i] = NULL; for (i = 0; i < IRP_MJ_MAXIMUM_FUNCTION; i++) theDriverObject->MajorFunction[i] = DeviceDispatch; theDriverObject->DriverUnload = OnUnload; RtlInitUnicodeString(&name, namedriver); status = IoCreateDevice(theDriverObject, sizeof (DEVICE_EXTENSION_MOTHER), &name, FILE_DEVICE_DISK, 0, FALSE, // exclusive! &g_devcontrol); if (status != STATUS_SUCCESS) { KdPrint(("[VDUM] DriverEntry: IoCreateDevice(control): 0x%x!\n", status)); goto done; } RtlInitUnicodeString(&linkname, VDUM_CTL_SYMLINK_NAME); status = IoCreateUnprotectedSymbolicLink(&linkname, &name); if (status != STATUS_SUCCESS) { KdPrint(("[VDUM] DriverEntry: IoCreateSymbolicLink: 0x%x!\n", status)); IoDeleteDevice(g_devcontrol); goto done; } //(*g_devcontrol).Flags &= ~DO_DEVICE_INITIALIZING; done:; if (status!=STATUS_SUCCESS) { KdPrint(("[VDUM] Status Error DriveEntry %x\n",status)); } return status; } -------------------- Thank you for help me for finding a problem solution.
From: Thomas J. Gritzan on 18 Oct 2009 14:21 Mathieu schrieb: > Bug in the Windows Kernel. > The event DeviceDispatch IRP_MJ_CREATE and IRP_MJ_CLOSE are not invoked > why call the API Function CreateFile function of User-Mode. > > SOURCE INCOMPLETE! > Help me please ! > > #define VDUM_DOS_BASE_NAME "\\\\.\\VDUMInternal_Sivaller" > hFile= CreateFile(VDUM_DOS_BASE_NAME, GENERIC_READ | GENERIC_WRITE, > 0, NULL, OPEN_EXISTING, 0, NULL); > CloseHandle(hFile); > > IRP_MJ_CREATE not called , why bug in the windows kernel ! Check the return value of CreateFile. If it is an invalid handle, check the error reason using GetLastError(). -- Thomas
|
Pages: 1 Prev: WinDDK and the GenPrint Example Next: IoGetDmaAdapter() fails with Win2003 Server with 4GB RAM |