#ifndef _NTPOAPI_H
#if (PHNT_MODE != PHNT_MODE_KERNEL)
/**
* The NtPowerInformation routine sets or retrieves system power information.
*
* \param InformationLevel Specifies the requested information level, which indicates the specific power information to be set or retrieved.
* \param InputBuffer Optional pointer to a caller-allocated input buffer.
* \param InputBufferLength Size, in bytes, of the buffer at InputBuffer.
* \param OutputBuffer Optional pointer to an output buffer. The type depends on the InformationLevel requested.
* \param OutputBufferLength Size, in bytes, of the output buffer.
* \return Successful or errant status.
* \sa https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-ntpowerinformation
*/
NTSYSCALLAPI
NTSTATUS
NTAPI
NtPowerInformation(
_In_ POWER_INFORMATION_LEVEL InformationLevel,
_In_reads_bytes_opt_(InputBufferLength) PVOID InputBuffer,
_In_ ULONG InputBufferLength,
_Out_writes_bytes_opt_(OutputBufferLength) PVOID OutputBuffer,
_In_ ULONG OutputBufferLength
);
View code on GitHub#ifndef _NTZWAPI_H
NTSYSCALLAPI
NTSTATUS
NTAPI
ZwPowerInformation(
_In_ POWER_INFORMATION_LEVEL InformationLevel,
_In_reads_bytes_opt_(InputBufferLength) PVOID InputBuffer,
_In_ ULONG InputBufferLength,
_Out_writes_bytes_opt_(OutputBufferLength) PVOID OutputBuffer,
_In_ ULONG OutputBufferLength
);
View code on GitHub// ntddk.h
NTSYSAPI NTSTATUS ZwPowerInformation(
[in] POWER_INFORMATION_LEVEL InformationLevel,
[in, optional] PVOID InputBuffer,
[in] ULONG InputBufferLength,
[out, optional] PVOID OutputBuffer,
[in] ULONG OutputBufferLength
);
View the official Windows Driver Kit DDI reference// ntpoapi.h
__kernel_entry NTSYSCALLAPI NTSTATUS NtPowerInformation(
[in] POWER_INFORMATION_LEVEL InformationLevel,
[in, optional] PVOID InputBuffer,
[in] ULONG InputBufferLength,
[out, optional] PVOID OutputBuffer,
[in] ULONG OutputBufferLength
);
View the official Windows Driver Kit DDI reference// wdm.h
__kernel_entry NTSYSCALLAPI NTSTATUS NtPowerInformation(
[in] POWER_INFORMATION_LEVEL InformationLevel,
[in, optional] PVOID InputBuffer,
[in] ULONG InputBufferLength,
[out, optional] PVOID OutputBuffer,
[in] ULONG OutputBufferLength
);
View the official Windows Driver Kit DDI referenceThe ZwPowerInformation routine sets or retrieves system power information.
InformationLevel [in]Specifies the requested information level, which indicates the specific power information to be set or retrieved. Currently, the only supported POWER_INFORMATION_LEVEL value is PlatformInformation.
| Value | Meaning |
|---|---|
| PlatformInformation | Information represents the currently supported power capabilities of the system. Information may change as drivers are installed. For example, the installation of legacy device drivers that do not support power management might modify the capabilities of the system. |
InputBuffer [in, optional]Pointer to a caller-allocated input buffer. This parameter must be NULL, otherwise ERROR_INVALID_PARAMETER is returned.
InputBufferLength [in]Size, in bytes, of the buffer at InputBuffer. The parameter must be set to zero.
OutputBuffer [out, optional]A pointer to an output buffer. The data type of this buffer depends on the information level requested in the InformationLevel parameter. For the PlatformInformation level, the only currently supported value, the OutputBuffer parameter is required and should be of the POWER_PLATFORM_INFORMATION type.
OutputBufferLength [in]Size, in bytes, of the output buffer. Depending on the information level requested, the buffer may be variably sized. PlatformInformation, the only currently supported value, requires a buffer that is the size of a POWER_PLATFORM_INFORMATION structure.
Returns STATUS_SUCCESS if the call is successful. If the call fails, possible error codes include the following:
| Return code | Description |
|---|---|
| STATUS_BUFFER_TOO_SMALL | The output buffer is of insufficient size to contain the data being returned. |
| STATUS_INVALID_PARAMETER | The PlatformInformation information level, which is the only currently supported value, requires no input buffer and must contain an output buffer. The caller either supplied an input buffer or no output buffer. |
| STATUS_ACCESS_DENIED | The caller had insufficient access rights to perform the requested action. |
NtPowerInformation and ZwPowerInformation are two versions of the same Windows Native System Services routine.
For calls from kernel-mode drivers, the Nt*Xxx* and Zw*Xxx* versions of a Windows Native System Services routine can behave differently in the way that they handle and interpret input parameters. For more information about the relationship between the Nt*Xxx* and Zw*Xxx* versions of a routine, see Using Nt and Zw Versions of the Native System Services Routines.
This example illustrates a valid function call.
POWER_PLATFORM_INFORMATION PlatformInfo = {0};
NTSTATUS Result = NtPowerInformation(PlatformInformation, NULL, 0, &PlatformInfo, sizeof(PlatformInfo));
Using Nt and Zw Versions of the Native System Services Routines
The ZwPowerInformation routine sets or retrieves system power information.
InformationLevel [in]Specifies the requested information level, which indicates the specific power information to be set or retrieved. Currently, the only supported POWER_INFORMATION_LEVEL value is PlatformInformation.
| Value | Meaning |
|---|---|
| PlatformInformation | Information represents the currently supported power capabilities of the system. Information may change as drivers are installed. For example, the installation of legacy device drivers that do not support power management might modify the capabilities of the system. |
InputBuffer [in, optional]Pointer to a caller-allocated input buffer. This parameter must be NULL, otherwise ERROR_INVALID_PARAMETER is returned.
InputBufferLength [in]Size, in bytes, of the buffer at InputBuffer. The parameter must be set to zero.
OutputBuffer [out, optional]A pointer to an output buffer. The data type of this buffer depends on the information level requested in the InformationLevel parameter. For the PlatformInformation level, the only currently supported value, the OutputBuffer parameter is required and should be of the POWER_PLATFORM_INFORMATION type.
OutputBufferLength [in]Size, in bytes, of the output buffer. Depending on the information level requested, the buffer may be variably sized. PlatformInformation, the only currently supported value, requires a buffer that is the size of a POWER_PLATFORM_INFORMATION structure.
Returns STATUS_SUCCESS if the call is successful. If the call fails, possible error codes include the following:
| Return code | Description |
|---|---|
| STATUS_BUFFER_TOO_SMALL | The output buffer is of insufficient size to contain the data being returned. |
| STATUS_INVALID_PARAMETER | The PlatformInformation information level, which is the only currently supported value, requires no input buffer and must contain an output buffer. The caller either supplied an input buffer or no output buffer. |
| STATUS_ACCESS_DENIED | The caller had insufficient access rights to perform the requested action. |
NtPowerInformation and ZwPowerInformation are two versions of the same Windows Native System Services routine.
For calls from kernel-mode drivers, the Nt*Xxx* and Zw*Xxx* versions of a Windows Native System Services routine can behave differently in the way that they handle and interpret input parameters. For more information about the relationship between the Nt*Xxx* and Zw*Xxx* versions of a routine, see Using Nt and Zw Versions of the Native System Services Routines.
This example illustrates a valid function call.
POWER_PLATFORM_INFORMATION PlatformInfo = {0};
NTSTATUS Result = NtPowerInformation(PlatformInformation, NULL, 0, &PlatformInfo, sizeof(PlatformInfo));
Using Nt and Zw Versions of the Native System Services Routines
The NtPowerInformation routine sets or retrieves system power information.
InformationLevel [in]Specifies the requested information level, which indicates the specific power information to be set or retrieved. Currently, the only supported POWER_INFORMATION_LEVEL value is PlatformInformation.
| Value | Description |
|---|---|
| PlatformInformation | Information represents the currently supported power capabilities of the system. Information may change as drivers are installed. For example, the installation of legacy device drivers that do not support power management might modify the capabilities of the system. |
InputBuffer [in, optional]Pointer to a caller-allocated input buffer. This parameter must be NULL, otherwise ERROR_INVALID_PARAMETER is returned.
InputBufferLength [in]Size, in bytes, of the buffer at InputBuffer. The parameter must be set to zero.
OutputBuffer [out, optional]A pointer to an output buffer. The data type of this buffer depends on the information level requested in the InformationLevel parameter. For the PlatformInformation level, the only currently supported value, the OutputBuffer parameter is required and should be of the POWER_PLATFORM_INFORMATION type.
OutputBufferLength [in]Size, in bytes, of the output buffer. Depending on the information level requested, the buffer may be variably sized. PlatformInformation, the only currently supported value, requires a buffer that is the size of a POWER_PLATFORM_INFORMATION structure.
Returns STATUS_SUCCESS if the call is successful. If the call fails, possible error codes include the following:
| Return code | Description |
|---|---|
| STATUS_BUFFER_TOO_SMALL | The output buffer is of insufficient size to contain the data being returned. |
| STATUS_INVALID_PARAMETER | The PlatformInformation information level, which is the only currently supported value, requires no input buffer and must contain an output buffer. The caller either supplied an input buffer or no output buffer. |
| STATUS_ACCESS_DENIED | The caller had insufficient access rights to perform the requested action. |
NtPowerInformation and ZwPowerInformation are two versions of the same Windows Native System Services routine.
For calls from kernel-mode drivers, the Nt*Xxx* and Zw*Xxx* versions of a Windows Native System Services routine can behave differently in the way that they handle and interpret input parameters. For more information about the relationship between the Nt*Xxx* and Zw*Xxx* versions of a routine, see Using Nt and Zw Versions of the Native System Services Routines.
This example illustrates a valid function call.
POWER_PLATFORM_INFORMATION PlatformInfo = {0};
NTSTATUS Result = NtPowerInformation(PlatformInformation, NULL, 0, &PlatformInfo, sizeof(PlatformInfo));
Using Nt and Zw Versions of the Native System Services Routines