createfile does not work after creating and installing my device driver

  • Thread starter Thread starter AbdEllah Gogop
  • Start date Start date
A

AbdEllah Gogop

Guest
i have created and installed my driver mybeep.sys successfuly, but the createfile function fails with getlasterror = 1

some kernel part:

/* Create the device */
Status = IoCreateDevice(DriverObject,
sizeof(DEVICE_EXTENSION),
&DeviceName,
FILE_DEVICE_BEEP,
0,
FALSE,
&DeviceObject);
//KdPrint(("status from iocreatedevice 0x%x\n", Status));
if (!NT_SUCCESS(Status)) return Status;

/* Make it use buffered I/O */
DeviceObject->Flags |= DO_BUFFERED_IO;

/* Setup the Driver Object */
DriverObject->MajorFunction[IRP_MJ_CREATE] = BeepCreate;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = BeepClose;
DriverObject->MajorFunction[IRP_MJ_CLEANUP] = BeepCleanup;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = BeepDeviceControl;
DriverObject->DriverUnload = BeepUnload;
DriverObject->DriverStartIo = BeepStartIo;

// etc...

the user mode part:

HANDLE hbeep =
CreateFile(pdidd->DevicePath,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);

hbeep = -1 and getlasterror = 1

note that the device path is valid .

Continue reading...
 
Back
Top