> Windows Syscalls
ntoskrnl.exeT1529T1485T1106

NtSetSystemPowerState

Transiciona el sistema al estado de energía solicitado (suspensión, hibernación, funcionamiento).

Prototipo

NTSTATUS NtSetSystemPowerState(
  POWER_ACTION         SystemAction,
  SYSTEM_POWER_STATE   MinSystemState,
  ULONG                Flags
);

Argumentos

NameTypeDirDescription
SystemActionPOWER_ACTIONinAcción: PowerActionNone, Reserved, Sleep, Hibernate, Shutdown, ShutdownReset, ShutdownOff, WarmEject, DisplayOff.
MinSystemStateSYSTEM_POWER_STATEinEstado de energía mínimo aceptable, p. ej. PowerSystemSleeping1..3, PowerSystemHibernate, PowerSystemShutdown.
FlagsULONGinFlags POWER_ACTION_*: QUERY_ALLOWED, UI_ALLOWED, OVERRIDE_APPS, LIGHTEST_FIRST, DISABLE_WAKES, CRITICAL.

IDs de syscalls por versión de Windows

Versión de WindowsID de syscallBuild
Win10 15070x18Fwin10-1507
Win10 16070x198win10-1607
Win10 17030x19Ewin10-1703
Win10 17090x1A1win10-1709
Win10 18030x1A3win10-1803
Win10 18090x1A4win10-1809
Win10 19030x1A5win10-1903
Win10 19090x1A5win10-1909
Win10 20040x1ABwin10-2004
Win10 20H20x1ABwin10-20h2
Win10 21H10x1ABwin10-21h1
Win10 21H20x1ADwin10-21h2
Win10 22H20x1ADwin10-22h2
Win11 21H20x1B6win11-21h2
Win11 22H20x1BAwin11-22h2
Win11 23H20x1BAwin11-23h2
Win11 24H20x1BDwin11-24h2
Server 20160x198winserver-2016
Server 20190x1A4winserver-2019
Server 20220x1B3winserver-2022
Server 20250x1BDwinserver-2025

Módulo del kernel

ntoskrnl.exeNtSetSystemPowerState

APIs relacionadas

SetSystemPowerStateInitiatePowerActionWNtInitiatePowerActionExitWindowsExInitiateShutdownWPowerSetActiveScheme

Stub del syscall

4C 8B D1            mov r10, rcx
B8 BD 01 00 00      mov eax, 0x1BD
F6 04 25 08 03 FE 7F 01   test byte ptr [0x7FFE0308], 1
75 03               jne short +3
0F 05               syscall
C3                  ret
CD 2E               int 2Eh
C3                  ret

Notas no documentadas

Primo de bajo nivel de `NtInitiatePowerAction` — `NtSetSystemPowerState` salta el arbitraje del policy manager y es la función que el propio kernel invoca una vez que el power manager terminó sus negociaciones. El wrapper Win32 `SetSystemPowerState` aterriza aquí. El llamador debe poseer `SeShutdownPrivilege` (sesiones interactivas) o `SeRemoteShutdownPrivilege` (variantes cross-machine). La función no retorna hasta que el sistema haya reanudado desde el estado objetivo o rechazado la transición (p. ej. un driver vetó Sleep). Pasar `POWER_ACTION_DISABLE_WAKES | POWER_ACTION_CRITICAL` es la combinación 'cállate y hazlo' que evita la mayoría de los vetos aplicativos al Sleep.

Uso común por malware

Tres patrones reales. (1) **Wipers**: HermeticWiper, IsaacWiper y CaddyWiper han sido observados llamando acciones de reboot al final de su pasada de destrucción para forzar al equipo a arrancar con datos de boot corruptos — el usuario ve un BSOD o pantalla 'Inaccessible Boot Device' en el siguiente arranque. (2) **Reboot post-cifrado de ransomware**: Royal, BlackCat/ALPHV y BlackSuit han disparado un reboot vía esta familia de syscalls tras dejar su nota, tanto para imponer un estado limpio sobre el volumen cifrado como para asegurar que los ficheros abiertos queden cerrados. (3) **Evasión de sandbox**: un pequeño conjunto de loaders red-team llama PowerSystemSleeping3 o DisplayOff dentro de una VM de análisis automático con la esperanza de que el harness trate la transición como 'ejecución completada' y desmonte antes de que el payload real corra. A menudo combinado con `NtDelayExecution` para sesgar los relojes que el harness usa para computar runtime.

Oportunidades de detección

`SetSystemPowerState` y su syscall subyacente son rastreados por el proveedor ETW Microsoft-Windows-Kernel-Power — cada transición Sleep/Hibernate/Shutdown emite eventos bien definidos que incluyen el proceso iniciador. Sysmon no tiene evento dedicado pero el log System registra 1074 (shutdown limpio iniciado) y 6008 (shutdown inesperado), ambos útiles para reconstrucción retroactiva. La regla individual más fuerte: un proceso no-sistema que invoca una POWER_ACTION de clase Shutdown habiendo escrito muchos ficheros en el minuto anterior es esencialmente una huella de wiper o ransomware. SeShutdownPrivilege debería estar desactivado para la mayoría de cuentas de servicio — alertar sobre el ajuste de privilegio inmediatamente anterior a la llamada.

Ejemplos de syscalls directos

asmx64 direct stub (Win11 24H2)

; Direct syscall stub for NtSetSystemPowerState (SSN 0x1BD on Win11 24H2)
NtSetSystemPowerState PROC
    mov  r10, rcx          ; syscall convention
    mov  eax, 1BDh         ; SSN — varies per build
    syscall
    ret
NtSetSystemPowerState ENDP

cWiper finale — force reboot into corrupted boot

// Final stage of a destructive payload: enable shutdown privilege then
// request an immediate Shutdown-Reset, bypassing user prompts.
#include <windows.h>
#include <winternl.h>

static VOID EnableShutdownPriv(VOID) {
    HANDLE hTok; LUID luid; TOKEN_PRIVILEGES tp = { 0 };
    OpenProcessToken(GetCurrentProcess(),
        TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hTok);
    LookupPrivilegeValueW(NULL, SE_SHUTDOWN_NAME, &luid);
    tp.PrivilegeCount = 1; tp.Privileges[0].Luid = luid;
    tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
    AdjustTokenPrivileges(hTok, FALSE, &tp, sizeof(tp), NULL, NULL);
    CloseHandle(hTok);
}

typedef NTSTATUS (NTAPI *pNtSetSystemPowerState)(ULONG, ULONG, ULONG);

VOID WiperReboot(VOID) {
    EnableShutdownPriv();
    pNtSetSystemPowerState NtSetSystemPowerState = (pNtSetSystemPowerState)
        GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtSetSystemPowerState");
    // PowerActionShutdownReset = 6, PowerSystemShutdown = 6,
    // DISABLE_WAKES | CRITICAL = 0x40000000 | 0x80000000
    NtSetSystemPowerState(6, 6, 0xC0000000);
}

rustDirect-syscall sleep request (sandbox evasion attempt)

// Cargo: windows-sys = "0.59"
use std::arch::asm;

#[unsafe(naked)]
unsafe extern "system" fn nt_set_system_power_state_stub(
    _action: u32, _min_state: u32, _flags: u32) -> i32 {
    asm!(
        "mov r10, rcx",
        "mov eax, 0x1BD", // Win11 24H2 SSN
        "syscall",
        "ret",
        options(noreturn),
    );
}

fn try_sleep_evasion() {
    // PowerActionSleep = 2, PowerSystemSleeping3 = 5, UI_ALLOWED=4
    let _ = unsafe { nt_set_system_power_state_stub(2, 5, 4) };
}

Mapeos MITRE ATT&CK

Last verified: 2026-05-20