Discussion:
IoGetDeviceProperty call failed
(too old to reply)
kobi n
2008-12-03 12:59:03 UTC
Permalink
Hi.

i'm working with a wdm driver which is working for few years now. lately,
while installing my software, including the driver, on a specific machine,
the device related to the driver cannot be installed.
after debugging i found out that there's a call to IoGetDeviceProperty which
fails.
fail status - STATUS_INVALID_DEVICE_REQUEST. i understand from that that i
have a problem with the PDO i'm giving as a parameter to the routine.

basically my flow goes like this :

in the AddDevice PnP callback i create the device using IoCreateDevice.
later i use the IoAttachDeviceToDeviceStack with the device object i created
as the source parameter and as a target i send the Device Object that was
given at the AddDevice PnP call back.

later, when a StartDevice PnP callback is called i try to call the
IoGetDeviceProperty with the PDEVICE_OBJECT i stored from the
IoAttachDeviceToDeviceStack result
the call fails with the status described.


a bit of a code snapshot :

NTSTATUS NLOG_PnP_AddDevice(IN PDRIVER_OBJECT DriverObject,
IN
PDEVICE_OBJECT DeviceObject)
{
PDEVICE_OBJECT LocalDeviceObject;

... doing somthing ...

Status = IoCreateDevice( DriverObject, sizeof(NLOG_GeneralDeviceExtension),
NULL,
FILE_DEVICE_NLOG_PHYSICAL, 0, FALSE, LocalDeviceObject);


// Now storing the attched device object in a data structure for later use
DeviceExtensionDataStructure->LowerDevice =
IoAttachDeviceToDeviceStack(*DeviceObject, ParentDeviceObject);


}

Later a PnP call back for my device will be called - StartDevice.

and in my start device routine the call that fails will be :

Status = IoGetDeviceProperty(DeviceExtensionDataStructure->LowerDevice,
DevicePropertyAddress,
sizeof(ULONG), &PropertyAddr, &ResultLength );

This one fails with the described error.


NOTE : the result i get from IoAttachDeviceToDeviceStack is a DEVICE_OBJECT
with a device type ACPI which is not what i expected to find. it also not
enumerated device (i see this in the 'flags' member of the DEVICE_OBJECT
structure).

any ideas ?
Scott Noone
2008-12-03 14:53:17 UTC
Permalink
IoGetDeviceProperty takes a PDO so you want to pass the PDO given to you at
AddDevice as the first parameter.

It must have worked for you in the past because there has never been a
filter in between your FDO and your PDO, so the returned pointer from
IoAttachDeviceToDeviceStack *was* the PDO. In this case it's an ACPI filter
DO.

-scott
--
Scott Noone
Software Engineer
OSR Open Systems Resources, Inc.
http://www.osronline.com
Post by kobi n
Hi.
i'm working with a wdm driver which is working for few years now. lately,
while installing my software, including the driver, on a specific machine,
the device related to the driver cannot be installed.
after debugging i found out that there's a call to IoGetDeviceProperty which
fails.
fail status - STATUS_INVALID_DEVICE_REQUEST. i understand from that that i
have a problem with the PDO i'm giving as a parameter to the routine.
in the AddDevice PnP callback i create the device using IoCreateDevice.
later i use the IoAttachDeviceToDeviceStack with the device object i created
as the source parameter and as a target i send the Device Object that was
given at the AddDevice PnP call back.
later, when a StartDevice PnP callback is called i try to call the
IoGetDeviceProperty with the PDEVICE_OBJECT i stored from the
IoAttachDeviceToDeviceStack result
the call fails with the status described.
NTSTATUS NLOG_PnP_AddDevice(IN PDRIVER_OBJECT DriverObject,
IN
PDEVICE_OBJECT DeviceObject)
{
PDEVICE_OBJECT LocalDeviceObject;
... doing somthing ...
Status = IoCreateDevice( DriverObject,
sizeof(NLOG_GeneralDeviceExtension),
NULL,
FILE_DEVICE_NLOG_PHYSICAL, 0, FALSE, LocalDeviceObject);
// Now storing the attched device object in a data structure for later use
DeviceExtensionDataStructure->LowerDevice =
IoAttachDeviceToDeviceStack(*DeviceObject, ParentDeviceObject);
}
Later a PnP call back for my device will be called - StartDevice.
Status = IoGetDeviceProperty(DeviceExtensionDataStructure->LowerDevice,
DevicePropertyAddress,
sizeof(ULONG), &PropertyAddr, &ResultLength );
This one fails with the described error.
NOTE : the result i get from IoAttachDeviceToDeviceStack is a
DEVICE_OBJECT
with a device type ACPI which is not what i expected to find. it also not
enumerated device (i see this in the 'flags' member of the DEVICE_OBJECT
structure).
any ideas ?
kobi n
2008-12-03 15:06:05 UTC
Permalink
Thanks a lot for the answer.

could you please elaborate regarding what yuo said about not having a filter
in the past.. ("there has never been a
filter in between your FDO and your PDO")
i did not understand that part. how come at the past there wasn't a filter
and now there is. and what filter do you mean ?

thanks a lot,
Kobi.
Post by Scott Noone
IoGetDeviceProperty takes a PDO so you want to pass the PDO given to you at
AddDevice as the first parameter.
It must have worked for you in the past because there has never been a
filter in between your FDO and your PDO, so the returned pointer from
IoAttachDeviceToDeviceStack *was* the PDO. In this case it's an ACPI filter
DO.
-scott
--
Scott Noone
Software Engineer
OSR Open Systems Resources, Inc.
http://www.osronline.com
Post by kobi n
Hi.
i'm working with a wdm driver which is working for few years now. lately,
while installing my software, including the driver, on a specific machine,
the device related to the driver cannot be installed.
after debugging i found out that there's a call to IoGetDeviceProperty which
fails.
fail status - STATUS_INVALID_DEVICE_REQUEST. i understand from that that i
have a problem with the PDO i'm giving as a parameter to the routine.
in the AddDevice PnP callback i create the device using IoCreateDevice.
later i use the IoAttachDeviceToDeviceStack with the device object i created
as the source parameter and as a target i send the Device Object that was
given at the AddDevice PnP call back.
later, when a StartDevice PnP callback is called i try to call the
IoGetDeviceProperty with the PDEVICE_OBJECT i stored from the
IoAttachDeviceToDeviceStack result
the call fails with the status described.
NTSTATUS NLOG_PnP_AddDevice(IN PDRIVER_OBJECT DriverObject,
IN
PDEVICE_OBJECT DeviceObject)
{
PDEVICE_OBJECT LocalDeviceObject;
... doing somthing ...
Status = IoCreateDevice( DriverObject,
sizeof(NLOG_GeneralDeviceExtension),
NULL,
FILE_DEVICE_NLOG_PHYSICAL, 0, FALSE, LocalDeviceObject);
// Now storing the attched device object in a data structure for later use
DeviceExtensionDataStructure->LowerDevice =
IoAttachDeviceToDeviceStack(*DeviceObject, ParentDeviceObject);
}
Later a PnP call back for my device will be called - StartDevice.
Status = IoGetDeviceProperty(DeviceExtensionDataStructure->LowerDevice,
DevicePropertyAddress,
sizeof(ULONG), &PropertyAddr, &ResultLength );
This one fails with the described error.
NOTE : the result i get from IoAttachDeviceToDeviceStack is a DEVICE_OBJECT
with a device type ACPI which is not what i expected to find. it also not
enumerated device (i see this in the 'flags' member of the DEVICE_OBJECT
structure).
any ideas ?
Scott Noone
2008-12-03 15:19:13 UTC
Permalink
Post by kobi n
i did not understand that part. how come at the past there wasn't a filter
and now there is. and what filter do you mean ?
There could be a filter there for any number of reasons, filters are used
for lots of things from lots of different drivers. In this case however you
mentioned that the device object returned had a type of ACPI, so I assumed
it's an ACPI filter DO (could be confirmed with !devobj in WinDBG).

As to why ACPI is filtering your stack, it's normal. See here for a very
brief explanation:

http://msdn.microsoft.com/en-us/library/ms798257.aspx

(for the most part one just doesn't care though)


-scott
--
Scott Noone
Software Engineer
OSR Open Systems Resources, Inc.
http://www.osronline.com
Post by kobi n
Thanks a lot for the answer.
could you please elaborate regarding what yuo said about not having a filter
in the past.. ("there has never been a
filter in between your FDO and your PDO")
i did not understand that part. how come at the past there wasn't a filter
and now there is. and what filter do you mean ?
thanks a lot,
Kobi.
Post by Scott Noone
IoGetDeviceProperty takes a PDO so you want to pass the PDO given to you at
AddDevice as the first parameter.
It must have worked for you in the past because there has never been a
filter in between your FDO and your PDO, so the returned pointer from
IoAttachDeviceToDeviceStack *was* the PDO. In this case it's an ACPI filter
DO.
-scott
--
Scott Noone
Software Engineer
OSR Open Systems Resources, Inc.
http://www.osronline.com
Post by kobi n
Hi.
i'm working with a wdm driver which is working for few years now. lately,
while installing my software, including the driver, on a specific machine,
the device related to the driver cannot be installed.
after debugging i found out that there's a call to IoGetDeviceProperty which
fails.
fail status - STATUS_INVALID_DEVICE_REQUEST. i understand from that
that
i
have a problem with the PDO i'm giving as a parameter to the routine.
in the AddDevice PnP callback i create the device using
IoCreateDevice.
later i use the IoAttachDeviceToDeviceStack with the device object i created
as the source parameter and as a target i send the Device Object that was
given at the AddDevice PnP call back.
later, when a StartDevice PnP callback is called i try to call the
IoGetDeviceProperty with the PDEVICE_OBJECT i stored from the
IoAttachDeviceToDeviceStack result
the call fails with the status described.
NTSTATUS NLOG_PnP_AddDevice(IN PDRIVER_OBJECT DriverObject,
IN
PDEVICE_OBJECT DeviceObject)
{
PDEVICE_OBJECT LocalDeviceObject;
... doing somthing ...
Status = IoCreateDevice( DriverObject,
sizeof(NLOG_GeneralDeviceExtension),
NULL,
FILE_DEVICE_NLOG_PHYSICAL, 0, FALSE, LocalDeviceObject);
// Now storing the attched device object in a data structure for later use
DeviceExtensionDataStructure->LowerDevice =
IoAttachDeviceToDeviceStack(*DeviceObject, ParentDeviceObject);
}
Later a PnP call back for my device will be called - StartDevice.
Status = IoGetDeviceProperty(DeviceExtensionDataStructure->LowerDevice,
DevicePropertyAddress,
sizeof(ULONG), &PropertyAddr, &ResultLength );
This one fails with the described error.
NOTE : the result i get from IoAttachDeviceToDeviceStack is a DEVICE_OBJECT
with a device type ACPI which is not what i expected to find. it also not
enumerated device (i see this in the 'flags' member of the
DEVICE_OBJECT
structure).
any ideas ?
kobi n
2008-12-03 15:30:01 UTC
Permalink
Scott,

got it. thanks a lot for the answers !

now, if i may, is there a common way to know that i do hold the PDO of the
stack ?
can i retrieve it from my device's FDO ?

thanks,
Kobi.
Post by Scott Noone
Post by kobi n
i did not understand that part. how come at the past there wasn't a filter
and now there is. and what filter do you mean ?
There could be a filter there for any number of reasons, filters are used
for lots of things from lots of different drivers. In this case however you
mentioned that the device object returned had a type of ACPI, so I assumed
it's an ACPI filter DO (could be confirmed with !devobj in WinDBG).
As to why ACPI is filtering your stack, it's normal. See here for a very
http://msdn.microsoft.com/en-us/library/ms798257.aspx
(for the most part one just doesn't care though)
-scott
--
Scott Noone
Software Engineer
OSR Open Systems Resources, Inc.
http://www.osronline.com
Post by kobi n
Thanks a lot for the answer.
could you please elaborate regarding what yuo said about not having a filter
in the past.. ("there has never been a
filter in between your FDO and your PDO")
i did not understand that part. how come at the past there wasn't a filter
and now there is. and what filter do you mean ?
thanks a lot,
Kobi.
Post by Scott Noone
IoGetDeviceProperty takes a PDO so you want to pass the PDO given to you at
AddDevice as the first parameter.
It must have worked for you in the past because there has never been a
filter in between your FDO and your PDO, so the returned pointer from
IoAttachDeviceToDeviceStack *was* the PDO. In this case it's an ACPI filter
DO.
-scott
--
Scott Noone
Software Engineer
OSR Open Systems Resources, Inc.
http://www.osronline.com
Post by kobi n
Hi.
i'm working with a wdm driver which is working for few years now. lately,
while installing my software, including the driver, on a specific machine,
the device related to the driver cannot be installed.
after debugging i found out that there's a call to IoGetDeviceProperty which
fails.
fail status - STATUS_INVALID_DEVICE_REQUEST. i understand from that
that
i
have a problem with the PDO i'm giving as a parameter to the routine.
in the AddDevice PnP callback i create the device using
IoCreateDevice.
later i use the IoAttachDeviceToDeviceStack with the device object i created
as the source parameter and as a target i send the Device Object that was
given at the AddDevice PnP call back.
later, when a StartDevice PnP callback is called i try to call the
IoGetDeviceProperty with the PDEVICE_OBJECT i stored from the
IoAttachDeviceToDeviceStack result
the call fails with the status described.
NTSTATUS NLOG_PnP_AddDevice(IN PDRIVER_OBJECT DriverObject,
IN
PDEVICE_OBJECT DeviceObject)
{
PDEVICE_OBJECT LocalDeviceObject;
... doing somthing ...
Status = IoCreateDevice( DriverObject,
sizeof(NLOG_GeneralDeviceExtension),
NULL,
FILE_DEVICE_NLOG_PHYSICAL, 0, FALSE, LocalDeviceObject);
// Now storing the attched device object in a data structure for later use
DeviceExtensionDataStructure->LowerDevice =
IoAttachDeviceToDeviceStack(*DeviceObject, ParentDeviceObject);
}
Later a PnP call back for my device will be called - StartDevice.
Status = IoGetDeviceProperty(DeviceExtensionDataStructure->LowerDevice,
DevicePropertyAddress,
sizeof(ULONG), &PropertyAddr, &ResultLength );
This one fails with the described error.
NOTE : the result i get from IoAttachDeviceToDeviceStack is a DEVICE_OBJECT
with a device type ACPI which is not what i expected to find. it also not
enumerated device (i see this in the 'flags' member of the DEVICE_OBJECT
structure).
any ideas ?
Scott Noone
2008-12-03 15:47:32 UTC
Permalink
Post by kobi n
now, if i may, is there a common way to know that i do hold the PDO of the
stack ?
The PDO is always the second parameter passed to AddDevice, so you can use
that and be sure you have the PDO.
Post by kobi n
can i retrieve it from my device's FDO ?
You can (see IRP_MN_QUERY_DEVICE_RELATIONS for TargetDeviceRelation), but it
shouldn't be necessary since you can just cache the PDO passed to your
AddDevice.

-scott
--
Scott Noone
Software Engineer
OSR Open Systems Resources, Inc.
http://www.osronline.com
Post by kobi n
Scott,
got it. thanks a lot for the answers !
now, if i may, is there a common way to know that i do hold the PDO of the
stack ?
can i retrieve it from my device's FDO ?
thanks,
Kobi.
Post by Scott Noone
Post by kobi n
i did not understand that part. how come at the past there wasn't a filter
and now there is. and what filter do you mean ?
There could be a filter there for any number of reasons, filters are used
for lots of things from lots of different drivers. In this case however you
mentioned that the device object returned had a type of ACPI, so I assumed
it's an ACPI filter DO (could be confirmed with !devobj in WinDBG).
As to why ACPI is filtering your stack, it's normal. See here for a very
http://msdn.microsoft.com/en-us/library/ms798257.aspx
(for the most part one just doesn't care though)
-scott
--
Scott Noone
Software Engineer
OSR Open Systems Resources, Inc.
http://www.osronline.com
Post by kobi n
Thanks a lot for the answer.
could you please elaborate regarding what yuo said about not having a filter
in the past.. ("there has never been a
filter in between your FDO and your PDO")
i did not understand that part. how come at the past there wasn't a filter
and now there is. and what filter do you mean ?
thanks a lot,
Kobi.
Post by Scott Noone
IoGetDeviceProperty takes a PDO so you want to pass the PDO given to
you
at
AddDevice as the first parameter.
It must have worked for you in the past because there has never been a
filter in between your FDO and your PDO, so the returned pointer from
IoAttachDeviceToDeviceStack *was* the PDO. In this case it's an ACPI filter
DO.
-scott
--
Scott Noone
Software Engineer
OSR Open Systems Resources, Inc.
http://www.osronline.com
Post by kobi n
Hi.
i'm working with a wdm driver which is working for few years now. lately,
while installing my software, including the driver, on a specific machine,
the device related to the driver cannot be installed.
after debugging i found out that there's a call to
IoGetDeviceProperty
which
fails.
fail status - STATUS_INVALID_DEVICE_REQUEST. i understand from that
that
i
have a problem with the PDO i'm giving as a parameter to the routine.
in the AddDevice PnP callback i create the device using
IoCreateDevice.
later i use the IoAttachDeviceToDeviceStack with the device object i created
as the source parameter and as a target i send the Device Object
that
was
given at the AddDevice PnP call back.
later, when a StartDevice PnP callback is called i try to call the
IoGetDeviceProperty with the PDEVICE_OBJECT i stored from the
IoAttachDeviceToDeviceStack result
the call fails with the status described.
NTSTATUS NLOG_PnP_AddDevice(IN PDRIVER_OBJECT DriverObject,
IN
PDEVICE_OBJECT DeviceObject)
{
PDEVICE_OBJECT LocalDeviceObject;
... doing somthing ...
Status = IoCreateDevice( DriverObject,
sizeof(NLOG_GeneralDeviceExtension),
NULL,
FILE_DEVICE_NLOG_PHYSICAL, 0, FALSE, LocalDeviceObject);
// Now storing the attched device object in a data structure for
later
use
DeviceExtensionDataStructure->LowerDevice =
IoAttachDeviceToDeviceStack(*DeviceObject, ParentDeviceObject);
}
Later a PnP call back for my device will be called - StartDevice.
Status =
IoGetDeviceProperty(DeviceExtensionDataStructure->LowerDevice,
DevicePropertyAddress,
sizeof(ULONG), &PropertyAddr, &ResultLength );
This one fails with the described error.
NOTE : the result i get from IoAttachDeviceToDeviceStack is a DEVICE_OBJECT
with a device type ACPI which is not what i expected to find. it
also
not
enumerated device (i see this in the 'flags' member of the DEVICE_OBJECT
structure).
any ideas ?
Alexander Grigoriev
2008-12-03 15:26:47 UTC
Permalink
AddDevice function gets a PDO address. Save it in your device extension and
pass later to IoGetDeviceProperty.
Post by kobi n
Thanks a lot for the answer.
could you please elaborate regarding what yuo said about not having a filter
in the past.. ("there has never been a
filter in between your FDO and your PDO")
i did not understand that part. how come at the past there wasn't a filter
and now there is. and what filter do you mean ?
thanks a lot,
Kobi.
Post by Scott Noone
IoGetDeviceProperty takes a PDO so you want to pass the PDO given to you at
AddDevice as the first parameter.
It must have worked for you in the past because there has never been a
filter in between your FDO and your PDO, so the returned pointer from
IoAttachDeviceToDeviceStack *was* the PDO. In this case it's an ACPI filter
DO.
-scott
--
Scott Noone
Software Engineer
OSR Open Systems Resources, Inc.
http://www.osronline.com
Post by kobi n
Hi.
i'm working with a wdm driver which is working for few years now. lately,
while installing my software, including the driver, on a specific machine,
the device related to the driver cannot be installed.
after debugging i found out that there's a call to IoGetDeviceProperty which
fails.
fail status - STATUS_INVALID_DEVICE_REQUEST. i understand from that
that
i
have a problem with the PDO i'm giving as a parameter to the routine.
in the AddDevice PnP callback i create the device using
IoCreateDevice.
later i use the IoAttachDeviceToDeviceStack with the device object i created
as the source parameter and as a target i send the Device Object that was
given at the AddDevice PnP call back.
later, when a StartDevice PnP callback is called i try to call the
IoGetDeviceProperty with the PDEVICE_OBJECT i stored from the
IoAttachDeviceToDeviceStack result
the call fails with the status described.
NTSTATUS NLOG_PnP_AddDevice(IN PDRIVER_OBJECT DriverObject,
IN
PDEVICE_OBJECT DeviceObject)
{
PDEVICE_OBJECT LocalDeviceObject;
... doing somthing ...
Status = IoCreateDevice( DriverObject,
sizeof(NLOG_GeneralDeviceExtension),
NULL,
FILE_DEVICE_NLOG_PHYSICAL, 0, FALSE, LocalDeviceObject);
// Now storing the attched device object in a data structure for later use
DeviceExtensionDataStructure->LowerDevice =
IoAttachDeviceToDeviceStack(*DeviceObject, ParentDeviceObject);
}
Later a PnP call back for my device will be called - StartDevice.
Status = IoGetDeviceProperty(DeviceExtensionDataStructure->LowerDevice,
DevicePropertyAddress,
sizeof(ULONG), &PropertyAddr, &ResultLength );
This one fails with the described error.
NOTE : the result i get from IoAttachDeviceToDeviceStack is a DEVICE_OBJECT
with a device type ACPI which is not what i expected to find. it also not
enumerated device (i see this in the 'flags' member of the
DEVICE_OBJECT
structure).
any ideas ?
Maxim S. Shatskih
2008-12-03 15:44:26 UTC
Permalink
IoGetDeviceProperty fails if the device is not a PDO. In some older Windows, it IIRC even could BSOD due to this.

You are calling IoGetDeviceProperty for ->LowerDevice.

When you have no filter below you, ->LowerDevice is a PDO and all is fine. When the filter appeared, ->LowerDevice is no more a PDO.

The fix is to create a devext field of ->Pdo, and initialize it in AddDevice where the PDO pointer is passed.

Note that you must still use ->LowerDevice to send IRPs, use ->Pdo only for calls like IoGetDeviceProperty.
--
Maxim S. Shatskih
Windows DDK MVP
***@storagecraft.com
http://www.storagecraft.com
Post by kobi n
Thanks a lot for the answer.
could you please elaborate regarding what yuo said about not having a filter
in the past.. ("there has never been a
filter in between your FDO and your PDO")
i did not understand that part. how come at the past there wasn't a filter
and now there is. and what filter do you mean ?
thanks a lot,
Kobi.
Post by Scott Noone
IoGetDeviceProperty takes a PDO so you want to pass the PDO given to you at
AddDevice as the first parameter.
It must have worked for you in the past because there has never been a
filter in between your FDO and your PDO, so the returned pointer from
IoAttachDeviceToDeviceStack *was* the PDO. In this case it's an ACPI filter
DO.
-scott
--
Scott Noone
Software Engineer
OSR Open Systems Resources, Inc.
http://www.osronline.com
Post by kobi n
Hi.
i'm working with a wdm driver which is working for few years now. lately,
while installing my software, including the driver, on a specific machine,
the device related to the driver cannot be installed.
after debugging i found out that there's a call to IoGetDeviceProperty which
fails.
fail status - STATUS_INVALID_DEVICE_REQUEST. i understand from that that i
have a problem with the PDO i'm giving as a parameter to the routine.
in the AddDevice PnP callback i create the device using IoCreateDevice.
later i use the IoAttachDeviceToDeviceStack with the device object i created
as the source parameter and as a target i send the Device Object that was
given at the AddDevice PnP call back.
later, when a StartDevice PnP callback is called i try to call the
IoGetDeviceProperty with the PDEVICE_OBJECT i stored from the
IoAttachDeviceToDeviceStack result
the call fails with the status described.
NTSTATUS NLOG_PnP_AddDevice(IN PDRIVER_OBJECT DriverObject,
IN
PDEVICE_OBJECT DeviceObject)
{
PDEVICE_OBJECT LocalDeviceObject;
... doing somthing ...
Status = IoCreateDevice( DriverObject,
sizeof(NLOG_GeneralDeviceExtension),
NULL,
FILE_DEVICE_NLOG_PHYSICAL, 0, FALSE, LocalDeviceObject);
// Now storing the attched device object in a data structure for later use
DeviceExtensionDataStructure->LowerDevice =
IoAttachDeviceToDeviceStack(*DeviceObject, ParentDeviceObject);
}
Later a PnP call back for my device will be called - StartDevice.
Status = IoGetDeviceProperty(DeviceExtensionDataStructure->LowerDevice,
DevicePropertyAddress,
sizeof(ULONG), &PropertyAddr, &ResultLength );
This one fails with the described error.
NOTE : the result i get from IoAttachDeviceToDeviceStack is a DEVICE_OBJECT
with a device type ACPI which is not what i expected to find. it also not
enumerated device (i see this in the 'flags' member of the DEVICE_OBJECT
structure).
any ideas ?
kobi n
2008-12-03 16:31:02 UTC
Permalink
Got it !


thanks a lot.
Post by Maxim S. Shatskih
IoGetDeviceProperty fails if the device is not a PDO. In some older Windows, it IIRC even could BSOD due to this.
You are calling IoGetDeviceProperty for ->LowerDevice.
When you have no filter below you, ->LowerDevice is a PDO and all is fine. When the filter appeared, ->LowerDevice is no more a PDO.
The fix is to create a devext field of ->Pdo, and initialize it in AddDevice where the PDO pointer is passed.
Note that you must still use ->LowerDevice to send IRPs, use ->Pdo only for calls like IoGetDeviceProperty.
--
Maxim S. Shatskih
Windows DDK MVP
http://www.storagecraft.com
Post by kobi n
Thanks a lot for the answer.
could you please elaborate regarding what yuo said about not having a filter
in the past.. ("there has never been a
filter in between your FDO and your PDO")
i did not understand that part. how come at the past there wasn't a filter
and now there is. and what filter do you mean ?
thanks a lot,
Kobi.
Post by Scott Noone
IoGetDeviceProperty takes a PDO so you want to pass the PDO given to you at
AddDevice as the first parameter.
It must have worked for you in the past because there has never been a
filter in between your FDO and your PDO, so the returned pointer from
IoAttachDeviceToDeviceStack *was* the PDO. In this case it's an ACPI filter
DO.
-scott
--
Scott Noone
Software Engineer
OSR Open Systems Resources, Inc.
http://www.osronline.com
Post by kobi n
Hi.
i'm working with a wdm driver which is working for few years now. lately,
while installing my software, including the driver, on a specific machine,
the device related to the driver cannot be installed.
after debugging i found out that there's a call to IoGetDeviceProperty which
fails.
fail status - STATUS_INVALID_DEVICE_REQUEST. i understand from that that i
have a problem with the PDO i'm giving as a parameter to the routine.
in the AddDevice PnP callback i create the device using IoCreateDevice.
later i use the IoAttachDeviceToDeviceStack with the device object i created
as the source parameter and as a target i send the Device Object that was
given at the AddDevice PnP call back.
later, when a StartDevice PnP callback is called i try to call the
IoGetDeviceProperty with the PDEVICE_OBJECT i stored from the
IoAttachDeviceToDeviceStack result
the call fails with the status described.
NTSTATUS NLOG_PnP_AddDevice(IN PDRIVER_OBJECT DriverObject,
IN
PDEVICE_OBJECT DeviceObject)
{
PDEVICE_OBJECT LocalDeviceObject;
... doing somthing ...
Status = IoCreateDevice( DriverObject,
sizeof(NLOG_GeneralDeviceExtension),
NULL,
FILE_DEVICE_NLOG_PHYSICAL, 0, FALSE, LocalDeviceObject);
// Now storing the attched device object in a data structure for later use
DeviceExtensionDataStructure->LowerDevice =
IoAttachDeviceToDeviceStack(*DeviceObject, ParentDeviceObject);
}
Later a PnP call back for my device will be called - StartDevice.
Status = IoGetDeviceProperty(DeviceExtensionDataStructure->LowerDevice,
DevicePropertyAddress,
sizeof(ULONG), &PropertyAddr, &ResultLength );
This one fails with the described error.
NOTE : the result i get from IoAttachDeviceToDeviceStack is a DEVICE_OBJECT
with a device type ACPI which is not what i expected to find. it also not
enumerated device (i see this in the 'flags' member of the DEVICE_OBJECT
structure).
any ideas ?
Loading...