From: shakti on 17 Dec 2009 03:02 On Dec 17, 4:32 am, "Doron Holan [MSFT]" <doron.ho...(a)online.microsoft.com> wrote: > I would use ZwCreateFile, not IoGetDeviceObjectPointer. > IoGetDeviceObjectPointer will close the handle which will send a > IRP_MJ_CLEANUP to the stack which is probably not what you want to happen > > d > > -- > > This posting is provided "AS IS" with no warranties, and confers no rights. > > "shakti" <shaktisi...(a)gmail.com> wrote in message > > news:36f6e5f2-ff1d-4b6c-9d48-08645b635031(a)m33g2000pri.googlegroups.com... > > > > > On Dec 15, 8:27 pm, "Alexander Grigoriev" <al...(a)earthlink.net> wrote: > >> L"\\DosDevices\\C:" > > >> "shakti" <shaktisi...(a)gmail.com> wrote in message > > >>news:4688d708-f196-4284-b2f5-181a95a623a1(a)u1g2000pre.googlegroups.com.... > > >> > Hi, > > >> > I'm trying to get the device object pointer for a volume in a driver > >> > (kernel mode) by using IoGetDeviceObjectPointer. > > >> > If I use "/PhysicalDrive0", the call succeeds. But if i use "/Device/ > >> > Harddisk0" or "/Device/HarddiskVolume1" the call fails. > > >> > Actually I wanted to get a way to send IOCTL_PASS_THROUGH to a > >> > specified drive, for eg. C:, which I can do easily from user mode by > >> > opening a handle to the drive using CreateFile(). > > >> > Can somebody please explain, why is it happening. > > >> > Thanks- Hide quoted text - > > >> - Show quoted text - > > > Thanks Alexander. > > > But if I use L"\\DosDevices\\C:" , the IoGetDeviceObjectPointer() > > call is successful; but when I use the obtained pointer to do a > > IoCallDriver(), I get a bug check 0x23 ( FAT_FILE_SYSTEM bug check ). > > > But the same code runs properly if I pass L"\\??\\PhysicalDrive1" to > > get the device object pointer. > > > PhysicalDrive1 is a USB pen drive. > > > Thanks- Hide quoted text - > > - Show quoted text - I need a device object pointer, since I'm gonna use that in IoCallDriver(), whereas ZwCreateFile will give me a file handle. I've another doubt: Is it possible to lock a volume from kernel mode. As I understand, its a two step process: 1. open handle to L"\\??\\PhysicalDrive1" 2. send FSCTL_LOCK_VOLUME to the target. But the IOCTL is failing in this case with STATUS_NOT_SUPPORTED Thanks Thanks
From: Maxim S. Shatskih on 17 Dec 2009 03:29 >I need a device object pointer, since I'm gonna use that in >IoCallDriver(), whereas ZwCreateFile will give me a file handle. Call ObReferenceObjectByHandle and IoGetRelatedDeviceObject after ZwCreateFile. This is what IoGetDeviceObjectPointer does: ZwCreateFile ObReferenceObjectByHandle ZwClose IoGetRelatedDeviceObject >1. open handle to L"\\??\\PhysicalDrive1" >2. send FSCTL_LOCK_VOLUME to the target. PhysicalDrive1 is not a volume, and has no FSD mounted on it. -- Maxim S. Shatskih Windows DDK MVP maxim(a)storagecraft.com http://www.storagecraft.com
From: shakti on 17 Dec 2009 05:34 On Dec 17, 1:29 pm, "Maxim S. Shatskih" <ma...(a)storagecraft.com.no.spam> wrote: > >I need a device object pointer, since I'm gonna use that in > >IoCallDriver(), whereas ZwCreateFile will give me a file handle. > > Call ObReferenceObjectByHandle and IoGetRelatedDeviceObject after ZwCreateFile. > > This is what IoGetDeviceObjectPointer does: > ZwCreateFile > ObReferenceObjectByHandle > ZwClose > IoGetRelatedDeviceObject > > >1. open handle to L"\\??\\PhysicalDrive1" > >2. send FSCTL_LOCK_VOLUME to the target. > > PhysicalDrive1 is not a volume, and has no FSD mounted on it. > > -- > Maxim S. Shatskih > Windows DDK MVP > ma...(a)storagecraft.comhttp://www.storagecraft.com Did the following as suggested: 1. ZwCreateFile on L"\\DosDevices\\E:" 2. ObReferenceObjectByHandle 3. IoGetRelatedDeviceObject Now using the device object pointer which I got from IoGetRelatedDeviceObject, I do IoCallDriver(), which is causing a BugCheck 0x23. WinDbg points out: Probably caused by : Fastfat.SYS ( Fastfat!FatFsdDeviceControl+2d ) Please help me explain, why can this happen. Thanks
From: Maxim S. Shatskih on 17 Dec 2009 05:45 >Now using the device object pointer which I got from >IoGetRelatedDeviceObject, I do IoCallDriver(), >which is causing a BugCheck 0x23. Have you filled nextSp->FileObject? -- Maxim S. Shatskih Windows DDK MVP maxim(a)storagecraft.com http://www.storagecraft.com
From: shakti on 17 Dec 2009 06:44 On Dec 17, 3:45 pm, "Maxim S. Shatskih" <ma...(a)storagecraft.com.no.spam> wrote: > >Now using the device object pointer which I got from > >IoGetRelatedDeviceObject, I do IoCallDriver(), > >which is causing a BugCheck 0x23. > > Have you filled nextSp->FileObject? > > -- > Maxim S. Shatskih > Windows DDK MVP > ma...(a)storagecraft.comhttp://www.storagecraft.com Thanks, that fixed the bug check. But still FSCTL_LOCK_VOLUME fails with STATUS_NOT_SUPPORTED.
First
|
Prev
|
Pages: 1 2 Prev: How to install Unidrv.dll programmatically Next: Ndis protocol driver and windows 7 |