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;