views:

11

answers:

0
RtlInitUnicodeString(&sddl, _T("D:P(A;;GA;;;SY)(A;;GA;;;BA)(A;;GA;;;BU)"));

status = IoCreateDeviceSecure(
    pDriverObject,
    sizeof(DEVICE_EXTENSION),
    pDeviceName,
    FILE_DEVICE_DISK,
    0,
    FALSE,
    &sddl,
    NULL,
    &pDeviceObject
    ); // Succeed

IoCreateSymbolicLink(...) // Succeed

And I tried to open in user mode(Run as administrator)

CreateFile(DeviceSymlinkName, ...) // fail ERROR_FILE_NOT_FOUND

The device has been created and it's symbolic link created well(in /GLOBAL?? namespace)

Sysinternals WinObj can't open the device either.(But the device is represented well on WinObj's list)

If I create the device on DriverEntry routine, I can open the device well.
But I create the device on DeviceIoControl routine, I can't open and WinObj can't either.
So, I tried to make a system thread in DeviceIoContol routine, and made a device in system thread. But it didn't work.

What's wrong?

Edit: I have got the answer.
I missed clearing DO_DEVICE_INITIALIZING flag.
http://www.osronline.com/cf.cfm?PageURL=showlists.CFM?list=NTDEV