Device Object problem

For All,

i write drive letter to the registry “Parameter” key of the the driver,
Driver Entry routine read registry and create device object and its a
valid CD-ROM object, after it i cn access it from application OK.
but when i want to create Device object from VC++ Application through
sending control

DWORD r = DeviceIoControl( h, // handle to device of interest
IOCTL_VCDD_CREATE_DEVICE, // control code of operation to perform
NULL, // buffer no need
0, // size of buffer
NULL, // pointer to output buffer
0, // size, in bytes, of lpOutBuffer
&dwBytes,
FALSE
);

Driver side this control is like:

case IOCTL_VCDD_CREATE_DEVICE:
{
UNICODE_STRING driveLetterString;
STRING ansiFN;
UNICODE_STRING imagePathString;
UNICODE_STRING Letter;
WCHAR DName[3];

RtlInitString(&ansiFN, "\??\D:\winxp.vcd);
ntStatus = RtlAnsiStringToUnicodeString(&imagePathString,&ansiFN,TRUE);

DName[0] = L’Z’;
DName[1] = L’:‘;
DName[2] = L’\0’;
RtlInitUnicodeString(&Letter, DName);

ntStatus =
InitializeDisk(DeviceObject->DriverObject,imagePathString,Letter);

Irp->IoStatus.Information = 0;
Irp->IoStatus.Status = STATUS_SUCCESS;

}
where initially i pass fix drive letter and image path not got from user
side(further i will do), InitializeDisk(…) call to create same as from
Driver Entry routine. but the problem is it create device object(becoz
Drive Icon show to MY COMPUTER) but after it i think it remove from memory
or untraceable, becoz i cant get the handle of this drive. may u have some
idea. i think its enough information, any other info requied plz tell me.

main functionality of InitializeDisk(…) is

InitializeDisk(IN PDRIVER_OBJECT DriverObject, IN UNICODE_STRING
filename, IN UNICODE_STRING Letter)
{

IoCreateDevice(DriverObject,
sizeof(VCDD_DEV_EXT),
&str,
FILE_DEVICE_CD_ROM,
0,
FALSE,
&deviceObject);

deviceObject->Flags |= DO_DIRECT_IO;
deviceObject->Characteristics=FILE_REMOVABLE_MEDIA |
FILE_READ_ONLY_DEVICE;
deviceObject->AlignmentRequirement = FILE_WORD_ALIGNMENT;

devExt = (PVCDD_DEV_EXT)(deviceObject->DeviceExtension);
devExt->DeviceObject = deviceObject;

}

is there need to set additional Flag value to “deviceObject->Flags |=
DO_DIRECT_IO”.

Kishwar Naushahi

Hello,

I am not sure about this, but I think you have to unmount/mount your existing drive before you can create/access it again. May be
you should look for a similar project at :

http://sourceforge.net/projects/vaporcd

One step further at :
http://sourceforge.net/project/showfiles.php?group_id=23800&release_id=33865
you can get the the VaporCDSource141.zip from the server of our choice,
for example
http://telia.dl.sourceforge.net/sourceforge/vaporcd/VaporCDSource141.zip

Have success ,

Christiaan

----- Original Message -----
From: “Naushahi”
To: “Windows System Software Developers Interest List”
Sent: Friday, August 15, 2003 11:01 AM
Subject: [ntdev] Device Object problem

> For All,
>
> i write drive letter to the registry “Parameter” key of the the driver,
> Driver Entry routine read registry and create device object and its a
> valid CD-ROM object, after it i cn access it from application OK.
> but when i want to create Device object from VC++ Application through
> sending control
>
>
>
> DWORD r = DeviceIoControl( h, // handle to device of interest
> IOCTL_VCDD_CREATE_DEVICE, // control code of operation to perform
> NULL, // buffer no need
> 0, // size of buffer
> NULL, // pointer to output buffer
> 0, // size, in bytes, of lpOutBuffer
> &dwBytes,
> FALSE
> );
>
>
> Driver side this control is like:
>
>
> case IOCTL_VCDD_CREATE_DEVICE:
> {
> UNICODE_STRING driveLetterString;
> STRING ansiFN;
> UNICODE_STRING imagePathString;
> UNICODE_STRING Letter;
> WCHAR DName[3];
>
> RtlInitString(&ansiFN, "\??\D:\winxp.vcd);
> ntStatus = RtlAnsiStringToUnicodeString(&imagePathString,&ansiFN,TRUE);
>
> DName[0] = L’Z’;
> DName[1] = L’:‘;
> DName[2] = L’\0’;
> RtlInitUnicodeString(&Letter, DName);
>
>
> ntStatus =
> InitializeDisk(DeviceObject->DriverObject,imagePathString,Letter);
>
>
> Irp->IoStatus.Information = 0;
> Irp->IoStatus.Status = STATUS_SUCCESS;
>
> }
> where initially i pass fix drive letter and image path not got from user
> side(further i will do), InitializeDisk(…) call to create same as from
> Driver Entry routine. but the problem is it create device object(becoz
> Drive Icon show to MY COMPUTER) but after it i think it remove from memory
> or untraceable, becoz i cant get the handle of this drive. may u have some
> idea. i think its enough information, any other info requied plz tell me.
>
> main functionality of InitializeDisk(…) is
>
>
> InitializeDisk(IN PDRIVER_OBJECT DriverObject, IN UNICODE_STRING
> filename, IN UNICODE_STRING Letter)
> {
> …
>
> IoCreateDevice(DriverObject,
> sizeof(VCDD_DEV_EXT),
> &str,
> FILE_DEVICE_CD_ROM,
> 0,
> FALSE,
> &deviceObject);
>
>
> deviceObject->Flags |= DO_DIRECT_IO;
> deviceObject->Characteristics=FILE_REMOVABLE_MEDIA |
> FILE_READ_ONLY_DEVICE;
> deviceObject->AlignmentRequirement = FILE_WORD_ALIGNMENT;
>
>
> devExt = (PVCDD_DEV_EXT)(deviceObject->DeviceExtension);
> devExt->DeviceObject = deviceObject;
> …
> }
>
>
>
> is there need to set additional Flag value to “deviceObject->Flags |=
> DO_DIRECT_IO”.
>
>
> Kishwar Naushahi
>
>
>
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@compaqnet.be
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>

thanks for reply Christiaan,

i have this source code already and i know its functionality but the
problem is still that i post this. my code is different than the source
that u give just follow the code shots that i have given in my question

thank
Kishwar Naushahi