ZwShutDownSystem, ZwSetSystemPowerState or ZwInitiatePowerAction Native API for WXP

Hi All,

I want to call one of the above 3 native APIs from my driver and got build error. It seems that these APIs work for w2k ddk. So may I know they are not supported any more for higher versions? What are the alternative options?

Basically I want to use it in my keyboard filter driver. When 1 specific key is pressed, I want to call these API to shut down the windows system. I have searched winuser.h and found the ACPI scan code (E0, 5E) is not supported for XP and server 2003. That is why I am searching these APIs.

Thanks and Regards,
Jeff

Calling these APIs will *not* cleanly shut down the system and will result in the user losing data.

Why are you writing a keyboard filter to do this?

  • S (Msft)

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@hotmail.com
Sent: Sunday, February 26, 2012 8:03 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] ZwShutDownSystem, ZwSetSystemPowerState or ZwInitiatePowerAction Native API for WXP

Hi All,

I want to call one of the above 3 native APIs from my driver and got build error. It seems that these APIs work for w2k ddk. So may I know they are not supported any more for higher versions? What are the alternative options?

Basically I want to use it in my keyboard filter driver. When 1 specific key is pressed, I want to call these API to shut down the windows system. I have searched winuser.h and found the ACPI scan code (E0, 5E) is not supported for XP and server 2003. That is why I am searching these APIs.

Thanks and Regards,
Jeff


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

You typically do this with a user mode helper service

d

debt from my phone


From: Skywing
Sent: 2/26/2012 8:08 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] ZwShutDownSystem, ZwSetSystemPowerState or ZwInitiatePowerAction Native API for WXP

Calling these APIs will *not* cleanly shut down the system and will result in the user losing data.

Why are you writing a keyboard filter to do this?

  • S (Msft)

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@hotmail.com
Sent: Sunday, February 26, 2012 8:03 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] ZwShutDownSystem, ZwSetSystemPowerState or ZwInitiatePowerAction Native API for WXP

Hi All,

I want to call one of the above 3 native APIs from my driver and got build error. It seems that these APIs work for w2k ddk. So may I know they are not supported any more for higher versions? What are the alternative options?

Basically I want to use it in my keyboard filter driver. When 1 specific key is pressed, I want to call these API to shut down the windows system. I have searched winuser.h and found the ACPI scan code (E0, 5E) is not supported for XP and server 2003. That is why I am searching these APIs.

Thanks and Regards,
Jeff


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


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

Hi Doron, Ken and All,

Actually I want to have one “Power” key as the standard Keyboard.
But as I said, if you search the winuser.h(win Server 2003), the ACPI scan code (E0, 5E) is not supported.

If we use a user mode service, we need to send a signal from the keyboard driver. But my driver is based on the ddk filter sample, which means I will need to “send this signal” from the KbFilter_ServiceCallback() function. But this callback function is running on dispatch IRQL, set SetEvent() doesn’t work.

That is why I want to use these API functions.

I have checked the DDK XP ntdll.lib, the API symbols are inside. Just wonder why the build process failed.

Thanks and Regards,
Jeff

You can certainly call KeSetEvent at dispatch level, there is no problem there. What documentation led you to think otherwise? A better design would be to complete a pended IRP because then you can send data back to the user mode application/service in the output buffer.

I am confused about your statements such as " the ACPI scan code (E0, 5E) is not supported." Do you mean ps2 scan code? Acpi has nothing to do with keyboard scan codes. If you look at the pnpi8042 sample in the vista wdk (removed for the win7 wdk), you will see the scan code is handled, but it is mapped to GUID_DEVICE_SYS_BUTTON, http://msdn.microsoft.com/en-us/library/windows/hardware/ff545782(v=vs.85).aspx. If you truly want to report a power button from your driver, enumerate a raw PDO and report this device interface from it. You want to report SYS_BUTTON_POWER for IOCTL_GET_SYS_BUTTON_CAPS and then pend IOCTL_GET_SYS_BUTTON_EVENT until the button is pressed or you when want to “inject” and then set SYS_BUTTON_POWER when you complete the irp.

I think a user mode service is much simpler.

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@hotmail.com
Sent: Sunday, February 26, 2012 10:35 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] ZwShutDownSystem, ZwSetSystemPowerState or ZwInitiatePowerAction Native API for WXP

Hi Doron, Ken and All,

Actually I want to have one “Power” key as the standard Keyboard.
But as I said, if you search the winuser.h(win Server 2003), the ACPI scan code (E0, 5E) is not supported.

If we use a user mode service, we need to send a signal from the keyboard driver. But my driver is based on the ddk filter sample, which means I will need to “send this signal” from the KbFilter_ServiceCallback() function. But this callback function is running on dispatch IRQL, set SetEvent() doesn’t work.

That is why I want to use these API functions.

I have checked the DDK XP ntdll.lib, the API symbols are inside. Just wonder why the build process failed.

Thanks and Regards,
Jeff


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

Hi Doron,

Actually I asked the similar question before. http://www.osronline.com/showthread.cfm?link=217257

So for KeSetEvent running at dispatch level, do we need some special processing?

Regarding the ACPI scan code, I mean: http://www.computer-engineering.org/ps2keyboard/scancodes1.html.

I also thought about the raw PDO. But the problem is that when one key is pressed, I “want to my driver” to inform the application". But for the raw PDO device IOCTL, it is the application polling on the result. Can it achieve the timing requirements?

Thanks and Regards,
Jeff