turn off monitor

I noticed that LogMeIn have a DMPS driver, that can turn off all monitors

I have searched this a long time and made many useless code…
any one have an example to do that or instructions for me?

I have tried this post:
http://www.osronline.com/showThread.cfm?link=94746

IoGetDeviceInterfaces returns 3 strings, like ??\ROOT\DISPLAY0##,
here is my code, it’s not working:

DbgPrint( “About to list display adapter devices\n” );
guidDisplay = GUID_DEVINTERFACE_DISPLAY_ADAPTER;
nResult = IoGetDeviceInterfaces( (LPGUID)&guidDisplay,
NULL, 0, &pDeviceList );
if (nResult != STATUS_SUCCESS)
{
DbgPrint( “IoGetDeviceInterfaces() failed with error %d\n”,
nResult );
}
else
{
pTemp = pDeviceList;

DbgPrint( “Printing device list (%d)\n”, 0xffff & *pTemp );

while (*pTemp != UNICODE_NULL)
{
DbgPrint( “RtlInitUnicodeString %ws\n”, pTemp);
RtlInitUnicodeString( &sTemp, pTemp );
pFO = NULL;
pDO = NULL;
nResult = IoGetDeviceObjectPointer ( &sTemp, FILE_ALL_ACCESS, &pFO,
&pDO );
if (nResult == STATUS_SUCCESS)
{
DbgPrint( “IoGetDeviceObjectPointer() returned %x\n”, nResult );
switch (irpStack->Parameters.DeviceIoControl.IoControlCode)
{
case IOCTL_DPMSDRV_NORMAL:
case IOCTL_DPMSDRV_OFF:
{

KeInitializeEvent(&ke_event, NotificationEvent, FALSE);
VideoPowerValue = VideoPowerOff;
irp = IoBuildDeviceIoControlRequest(
IOCTL_VIDEO_SET_OUTPUT_DEVICE_POWER_STATE,
pDO,
&VideoPowerValue,
sizeof(ULONG),
NULL, 0, // no output buffer
FALSE, &ke_event, &ioStatus);
DbgPrint( “IoBuildDeviceIoControlRequest() done.\n”);
PoStartNextPowerIrp(irp);
nResult = PoCallDriver(pDO, irp);
DbgPrint( “PoCallDriver() returned %x\n”, nResult );
if (nResult == STATUS_PENDING)
{
KeWaitForSingleObject(&ke_event, Executive, KernelMode, FALSE, NULL);
}
}
break;
case IOCTL_DPMSDRV_REDUCED:
case IOCTL_DPMSDRV_STANDBY:
case IOCTL_DPMSDRV_SUSPEND:
break;
}

}
else
{
// TODO: ObDeferenceObject( pDO )
}
DbgPrint( “while() done.\n”);

pTemp += (sTemp.Length + sizeof( UNICODE_NULL )) / sizeof( WCHAR );
DbgPrint( “RtlInitUnicodeString2\n”);
//break;
}

//TODO: ExFreePool( pDeviceList );
}

You want to call IoCallDriver, not PoCallDriver. Also, you need to release the ob ref

d

debt from my phone


From: xxxxx@gmail.com
Sent: 10/20/2011 9:02 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] turn off monitor

I have tried this post:
http://www.osronline.com/showThread.cfm?link=94746

IoGetDeviceInterfaces returns 3 strings, like ??\ROOT\DISPLAY0##,
here is my code, it’s not working:

DbgPrint( “About to list display adapter devices\n” );
guidDisplay = GUID_DEVINTERFACE_DISPLAY_ADAPTER;
nResult = IoGetDeviceInterfaces( (LPGUID)&guidDisplay,
NULL, 0, &pDeviceList );
if (nResult != STATUS_SUCCESS)
{
DbgPrint( “IoGetDeviceInterfaces() failed with error %d\n”,
nResult );
}
else
{
pTemp = pDeviceList;

DbgPrint( “Printing device list (%d)\n”, 0xffff & *pTemp );

while (*pTemp != UNICODE_NULL)
{
DbgPrint( “RtlInitUnicodeString %ws\n”, pTemp);
RtlInitUnicodeString( &sTemp, pTemp );
pFO = NULL;
pDO = NULL;
nResult = IoGetDeviceObjectPointer ( &sTemp, FILE_ALL_ACCESS, &pFO,
&pDO );
if (nResult == STATUS_SUCCESS)
{
DbgPrint( “IoGetDeviceObjectPointer() returned %x\n”, nResult );
switch (irpStack->Parameters.DeviceIoControl.IoControlCode)
{
case IOCTL_DPMSDRV_NORMAL:
case IOCTL_DPMSDRV_OFF:
{

KeInitializeEvent(&ke_event, NotificationEvent, FALSE);
VideoPowerValue = VideoPowerOff;
irp = IoBuildDeviceIoControlRequest(
IOCTL_VIDEO_SET_OUTPUT_DEVICE_POWER_STATE,
pDO,
&VideoPowerValue,
sizeof(ULONG),
NULL, 0, // no output buffer
FALSE, &ke_event, &ioStatus);
DbgPrint( “IoBuildDeviceIoControlRequest() done.\n”);
PoStartNextPowerIrp(irp);
nResult = PoCallDriver(pDO, irp);
DbgPrint( “PoCallDriver() returned %x\n”, nResult );
if (nResult == STATUS_PENDING)
{
KeWaitForSingleObject(&ke_event, Executive, KernelMode, FALSE, NULL);
}
}
break;
case IOCTL_DPMSDRV_REDUCED:
case IOCTL_DPMSDRV_STANDBY:
case IOCTL_DPMSDRV_SUSPEND:
break;
}

}
else
{
// TODO: ObDeferenceObject( pDO )
}
DbgPrint( “while() done.\n”);

pTemp += (sTemp.Length + sizeof( UNICODE_NULL )) / sizeof( WCHAR );
DbgPrint( “RtlInitUnicodeString2\n”);
//break;
}

//TODO: ExFreePool( pDeviceList );
}


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

I have tried IoCallDriver and ObDeferenceObject,
still not working

I studied some at LogMeIn dpms driver, it seems replaced system display driver, how to do this?

xxxxx@gmail.com wrote:

I studied some at LogMeIn dpms driver, it seems replaced system display driver, how to do this?

Through very dangerous registry hacking.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

So, is it still possible to do this without “dangerous registry hacking”?

I studied some at logmein driver, it can be installed just through INF file,
so I don’t think it did any registry hacking
It’s a real driver for monitor, and more than windows, it provided a sys
file replaced monitor.sys, that can accept application request to turn off
monitor, it also can ignore windows system power requests to display during
his blanking screen time.

On Sat, Oct 22, 2011 at 12:46 AM, Tim Roberts wrote:

> xxxxx@gmail.com wrote:
> > I studied some at LogMeIn dpms driver, it seems replaced system display
> driver, how to do this?
>
> Through very dangerous registry hacking.
>
> –
> Tim Roberts, xxxxx@probo.com
> Providenza & Boekelheide, Inc.
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

the driver is ok now, it’s easy