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