Hi all:
I have a question about power manager in my driver, could you help me
and tell me what's the problem about it.
The driver I wrote for all windows platform, I want to turn off the monitor,
so I build a IOCTL IRP and send it to display adapter, it can work well in
2k/xp/2003, but when it run in vista, IoCallDriver return
0xC0000010,STATUS_INVALID_DEVICE_HANDLE.
The main code list below:

RtlInitUnicodeString( &videoName, L"\\Device\\NTPNP_PCI0015" ); // this
is adapter PDO Name, we can get it through
"DeviceManager"->display->detail->Phy Obj Name.

status = IoGetDeviceObjectPointer( &videoName, FILE_READ_ATTRIBUTES,
&pFile, &pDevice );
SIOCTL_KDPRINT((0, "IoGetDeviceObjectPointer returned %i\n", result));
if ( status == STATUS_SUCCESS )
{
KeInitializeEvent( &kEvent, NotificationEvent, FALSE );

newIrp = IoBuildDeviceIoControlRequest(
IOCTL_VIDEO_SET_OUTPUT_DEVICE_POWER_STATE,
pDevice,
&mode,
sizeof(ULONG),
0,
0,
FALSE,
&kEvent,
&ioStatus
);

SIOCTL_KDPRINT((0, "IoBuildDeviceIoControlRequest returned %i\n",
newIrp));
if ( newIrp )
{
status = IoCallDriver( pDevice, newIrp );
driverBlanked = 1;
}
else
{
result = 242;
}
if ( pFile )
{
SIOCTL_KDPRINT((0, "ObDereferenceObject being called\n"));
ObDereferenceObject( pFile );
pFile = 0;
}
}

if ( driverBlanked )
{
result = 0;
}
SIOCTL_KDPRINT((0, "VideoSleep returns %i\n", result));
return result;

Re: IoCallDriver Problem in vista, but ok in 2k/xp/2k3 by Mark

Mark
Fri Dec 14 14:00:15 PST 2007

Wllee wrote:
> Hi all:
> I have a question about power manager in my driver, could you help me
> and tell me what's the problem about it.
> The driver I wrote for all windows platform, I want to turn off the monitor,
> so I build a IOCTL IRP and send it to display adapter, it can work well in
> 2k/xp/2003, but when it run in vista, IoCallDriver return
> 0xC0000010,STATUS_INVALID_DEVICE_HANDLE.
> The main code list below:
>
> RtlInitUnicodeString( &videoName, L"\\Device\\NTPNP_PCI0015" ); // this
> is adapter PDO Name, we can get it through
> "DeviceManager"->display->detail->Phy Obj Name.
>
> status = IoGetDeviceObjectPointer( &videoName, FILE_READ_ATTRIBUTES,
> &pFile, &pDevice );
> SIOCTL_KDPRINT((0, "IoGetDeviceObjectPointer returned %i\n", result));
> if ( status == STATUS_SUCCESS )
> {
> KeInitializeEvent( &kEvent, NotificationEvent, FALSE );
>
> newIrp = IoBuildDeviceIoControlRequest(
> IOCTL_VIDEO_SET_OUTPUT_DEVICE_POWER_STATE,


That would be because this is not supported in vista. It never was
documented it seems, so you have made use of undocumented interfaces and
are now stuck with broken functionality. Note that your IOCTL is marked
deprecated in the WDK 6000 version of ntddvdeo.h.





> pDevice,
> &mode,
> sizeof(ULONG),
> 0,
> 0,
> FALSE,
> &kEvent,
> &ioStatus
> );
>
> SIOCTL_KDPRINT((0, "IoBuildDeviceIoControlRequest returned %i\n",
> newIrp));
> if ( newIrp )
> {
> status = IoCallDriver( pDevice, newIrp );
> driverBlanked = 1;
> }
> else
> {
> result = 242;
> }
> if ( pFile )
> {
> SIOCTL_KDPRINT((0, "ObDereferenceObject being called\n"));
> ObDereferenceObject( pFile );
> pFile = 0;
> }
> }
>
> if ( driverBlanked )
> {
> result = 0;
> }
> SIOCTL_KDPRINT((0, "VideoSleep returns %i\n", result));
> return result;


--

=====================
Mark Roddy DDK MVP
Windows Vista/2003/XP Consulting
Hollis Technology Solutions 603-321-1032
www.hollistech.com

Re: IoCallDriver Problem in vista, but ok in 2k/xp/2k3 by Tim

Tim
Fri Dec 14 23:20:27 PST 2007

Wllee <Wllee@discussions.microsoft.com> wrote:
>
> I have a question about power manager in my driver, could you help me
>and tell me what's the problem about it.
>The driver I wrote for all windows platform, I want to turn off the monitor,
>so I build a IOCTL IRP and send it to display adapter, it can work well in
>2k/xp/2003, but when it run in vista, IoCallDriver return
>0xC0000010,STATUS_INVALID_DEVICE_HANDLE.
> The main code list below:
>
> RtlInitUnicodeString( &videoName, L"\\Device\\NTPNP_PCI0015" ); // this
>is adapter PDO Name, we can get it through
>"DeviceManager"->display->detail->Phy Obj Name.

Are you assuming that the monitor will always be called
\Device\NTPNP_PCI0015, on every computer and every operating system? You
don't really believe that, do you?
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Re: IoCallDriver Problem in vista, but ok in 2k/xp/2k3 by Wllee

Wllee
Sat Dec 15 07:38:01 PST 2007

Hi Tim:
yes, in my program, have a function to enum the adapter in the computer,
so I can get the adapter's device name, and pass it to this function. this
function is just a sample, so we can all understand it.

"Tim Roberts" wrote:

> Wllee <Wllee@discussions.microsoft.com> wrote:
> >
> > I have a question about power manager in my driver, could you help me
> >and tell me what's the problem about it.
> >The driver I wrote for all windows platform, I want to turn off the monitor,
> >so I build a IOCTL IRP and send it to display adapter, it can work well in
> >2k/xp/2003, but when it run in vista, IoCallDriver return
> >0xC0000010,STATUS_INVALID_DEVICE_HANDLE.
> > The main code list below:
> >
> > RtlInitUnicodeString( &videoName, L"\\Device\\NTPNP_PCI0015" ); // this
> >is adapter PDO Name, we can get it through
> >"DeviceManager"->display->detail->Phy Obj Name.
>
> Are you assuming that the monitor will always be called
> \Device\NTPNP_PCI0015, on every computer and every operating system? You
> don't really believe that, do you?
> --
> Tim Roberts, timr@probo.com
> Providenza & Boekelheide, Inc.
>

Re: IoCallDriver Problem in vista, but ok in 2k/xp/2k3 by Wllee

Wllee
Sat Dec 15 17:26:00 PST 2007

Hi Mark:
Thanks, and Could you tell me in the vista, which ioctl_code can do same
thing, or could you tell me other method to implement it?

"Mark Roddy" wrote:

> Wllee wrote:
> > Hi all:
> > I have a question about power manager in my driver, could you help me
> > and tell me what's the problem about it.
> > The driver I wrote for all windows platform, I want to turn off the monitor,
> > so I build a IOCTL IRP and send it to display adapter, it can work well in
> > 2k/xp/2003, but when it run in vista, IoCallDriver return
> > 0xC0000010,STATUS_INVALID_DEVICE_HANDLE.
> > The main code list below:
> >
> > RtlInitUnicodeString( &videoName, L"\\Device\\NTPNP_PCI0015" ); // this
> > is adapter PDO Name, we can get it through
> > "DeviceManager"->display->detail->Phy Obj Name.
> >
> > status = IoGetDeviceObjectPointer( &videoName, FILE_READ_ATTRIBUTES,
> > &pFile, &pDevice );
> > SIOCTL_KDPRINT((0, "IoGetDeviceObjectPointer returned %i\n", result));
> > if ( status == STATUS_SUCCESS )
> > {
> > KeInitializeEvent( &kEvent, NotificationEvent, FALSE );
> >
> > newIrp = IoBuildDeviceIoControlRequest(
> > IOCTL_VIDEO_SET_OUTPUT_DEVICE_POWER_STATE,
>
>
> That would be because this is not supported in vista. It never was
> documented it seems, so you have made use of undocumented interfaces and
> are now stuck with broken functionality. Note that your IOCTL is marked
> deprecated in the WDK 6000 version of ntddvdeo.h.
>
====>Maybe you're right, I try another IOCTL code: query current mode, it
can works well in vista. but I don't which ioctl code for same function?

>
>
>
> > pDevice,
> > &mode,
> > sizeof(ULONG),
> > 0,
> > 0,
> > FALSE,
> > &kEvent,
> > &ioStatus
> > );
> >
> > SIOCTL_KDPRINT((0, "IoBuildDeviceIoControlRequest returned %i\n",
> > newIrp));
> > if ( newIrp )
> > {
> > status = IoCallDriver( pDevice, newIrp );
> > driverBlanked = 1;
> > }
> > else
> > {
> > result = 242;
> > }
> > if ( pFile )
> > {
> > SIOCTL_KDPRINT((0, "ObDereferenceObject being called\n"));
> > ObDereferenceObject( pFile );
> > pFile = 0;
> > }
> > }
> >
> > if ( driverBlanked )
> > {
> > result = 0;
> > }
> > SIOCTL_KDPRINT((0, "VideoSleep returns %i\n", result));
> > return result;
>
>
> --
>
> =====================
> Mark Roddy DDK MVP
> Windows Vista/2003/XP Consulting
> Hollis Technology Solutions 603-321-1032
> www.hollistech.com
>