Tech Support > Microsoft Windows > Drivers > toaster sample(busenum.sys)
toaster sample(busenum.sys)
Posted by Vipin on May 18th, 2005


Hi,
I have a question in the bus driver, busenum.sys.
Just stepping through it I see in pnp.c
IRP_MN_QUERY_DEVICE_RELATIONS

length = sizeof(DEVICE_RELATIONS) +

((numPdosPresent + prevcount) * sizeof (PDEVICE_OBJECT)) -1;

I am not sure why there is "-1".

Isn't it a typo?

Thanks
Vipin


Posted by Doron Holan [MS] on May 18th, 2005


look at the definition of DEVICE_RELATIONS, it is

struct {
ULONG Count;
PDEVICE_OBJECT Relations[1];
};

so, if you sizeof(DEVICE_RELATIONS), you will have a count of one devobj.
you subtract the size of one element in the array to account for the built
in first element. i don't think you copied the code as is, it should be

length = sizeof(DEVICE_RELATIONS) + ((numPdosPresent + prevcount-1) * sizeof
(PDEVICE_OBJECT))

d

--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


"Vipin" <vipin@nospam.com> wrote in message
news:uRxD3W3WFHA.160@TK2MSFTNGP15.phx.gbl...


Posted by Vipin on May 18th, 2005


Thanks for the explanation but the DDK code has a bug anyway

The code is like this in XP ddk 2600.1106

//
// Need to allocate a new relations structure and add our
// PDOs to it.
//

length = sizeof(DEVICE_RELATIONS) +
((numPdosPresent + prevcount) * sizeof (PDEVICE_OBJECT)) -1;

relations = (PDEVICE_RELATIONS) ExAllocatePoolWithTag (PagedPool,
length, BUSENUM_POOL_TAG);

if (NULL == relations) {


Thanks
Vipin

"Doron Holan [MS]" <doronh@nospam.microsoft.com> wrote in message
news:Os3LEe3WFHA.828@TK2MSFTNGP10.phx.gbl...


Posted by Doron Holan [MS] on May 18th, 2005


you should use the latest DDK. the latest is server 2003 SP1 DDK. I will
look at the current sources to see if this is still there.

d

--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


"Vipin" <vipin@nospam.com> wrote in message
news:%23DafB03WFHA.3184@TK2MSFTNGP15.phx.gbl...



Similar Posts