Virtual Bus Driver (?) causes Access Violation calling IoReportDetectedDevice

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?

> 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?

Set up the system to take memory dumps on bluescreens.

Then go off to MS and download the latest version of windbg and install it
on your system.

Now when you get a crash and reboot, you will have a memoory dump file that
you can analyze with windbg.

Obviously crashdump debugging is harder than realtime debugging, but it is
certainly possible to find out what is going wrong that way, with enough
crashes.

If at some point you decide that you are serious about driver development, I
think you realize that a $300 PC and a null modem cable will be WELL worth
the investment, just in time saved debugging and developing. It really
doesn’t need much more than a disk, a monitor, and a serial port and a
network card.

Loren

wrote in message news:xxxxx@ntdev…
>
>
>

Good news for you: You don’t need to call IoReportDetectedDevice.

You don’t need any resources? Cool. After startup of your “bus” driver,
wait for the I/O Manager to send you a Query Device Relations for Bus
Relations. Or, whenever it’s convenient, stimulate the I/O Manager to send
you one by calling IoInvalidateDeviceRelations for bus relations.

Check out the article from The NT Insider on this topic:
http://www.osronline.com/article.cfm?id=48 (you’ll have to subscribe, but
it’s free, so why not).

And DO consider the advice to get a second PC so you can run the debugger.
I think you’ll find that trying to write a driver without this is, well, a
bit frustrating.

Peter
OSR

Search the web, this was done many years ago and is available to the
public for free

Jamey

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@ieee.org
Sent: Saturday, September 06, 2003 4:15 PM
To: Windows System Software Developers Interest List
Subject: [ntdev] Virtual Bus Driver (?) causes Access Violation calling
IoReportDetectedDevice

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].ShareD
isposition
= CmResourceShareDeviceExclusive;

CmResourceList->List[0].PartialResourceList.PartialDescriptors[0].Flags
= 0;

CmResourceList->List[0].PartialResourceList.PartialDescriptors[0].u.Devi
ceSpecificData.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?


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com