Hi,
I’m trying to write a win2k driver that looks like a Tape, but actually
writes to a CDRW. It’s my first driver, and I don’t know if it will work,
but it’s partly for fun, anyway.
To minimise the amount of code I have to write, I’m thinking of writing a
minitape driver, and a “Virtual Bus” (cdrwport.sys) driver. The Bus driver
is a nonPnP (I.e. startType=SERVICE_SYSTEM_START) that enumerates that
virtual tape (cdrwtape.sys) which in turn gets driven by the minitape
driver (cdrwtape.sys).
At the moment, I’m just trying to get the virtual bus driver working. As I
understand it, I need to call IoReportDetectedDevice in my DriverEntry, to
report the presence of the virtual bus. IoReportDetectedDevice requires a
CM_RESOURCE_LIST called ResourceList, that "Points to the resource list
the driver used to detect the device. Resources in this list are in raw,
untranslated form.
"
The thing is, I don’t need any resources, 'cause I don’t use any hardware,
'cause I’m a virtual device.
Here’s the problem: When I set ResourceList=NULL, I get an access
violation.
As a hack, I try to claim some custom resource (not addresses or anything)
like this:
/****** SNIPPET ******/
CmResourceList->Count = 1;
CmResourceList->List[0].InterfaceType = Internal;
//CmResourceList->List[0].BusNumber = -1;
CmResourceList->List[0].PartialResourceList.Version = 1;
CmResourceList->List[0].PartialResourceList.Revision = 1;
CmResourceList->List[0].PartialResourceList.Count = 1;
CmResourceList->List[0].PartialResourceList.PartialDescriptors[0].Type
= CmResourceTypeDeviceSpecific;
CmResourceList->List[0].PartialResourceList.PartialDescriptors[0].ShareDisposition
= CmResourceShareDeviceExclusive;
CmResourceList->List[0].PartialResourceList.PartialDescriptors[0].Flags
= 0;
CmResourceList->List[0].PartialResourceList.PartialDescriptors[0].u.DeviceSpecificData.DataSize
= sizeof(ULONG);
/****** END SNIPPET ******/
I also get an access violation when I call IOReportDetectedDevice.
When I use the above structure to call IoReportResourceForDetection, it
returns STATUS_UNSUCCESSFUL which is helpfully documented as meaning “The
DeviceList or DriverList is invalid.”
I also get an access violation when I set CmResourceList->Count=0.
If anyone can tell me how to IoReportDetectedDevice while specifying no
resource requirements, that’d be great!
I haven’t got a checked build of windows, or another computer to debug
with (using dbgview) - I can send a memory dump if you’d like.
Please let me know if anything in my approach is wrong, or any other hints
and tips.
Many thanks,
Keith
p.s. is there an easy way of taking a blue screen with all those lovely
memory addresses and working out which line of my code caused the fault?