No description
  • C++ 96.4%
  • CMake 1.8%
  • Batchfile 1.7%
  • C 0.1%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Aaron Wu 0cef774591 Fix event log query: read newest events instead of oldest
EvtNext returns oldest-first by default, so the first 50 events
were from months ago. Add EvtSeek to jump near the end of the
result set so we surface the most recent power events.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
2026-05-28 21:46:32 +08:00
.github/workflows Add build log capture for diagnostics 2026-05-28 01:03:55 +08:00
src Fix event log query: read newest events instead of oldest 2026-05-28 21:46:32 +08:00
build.bat Initial commit: Windows sleep/wake diagnostics tool 2026-05-28 00:46:18 +08:00
CMakeLists.txt Remove /permissive- flag 2026-05-28 01:08:07 +08:00
README.md Initial commit: Windows sleep/wake diagnostics tool 2026-05-28 00:46:18 +08:00

diag_wake

Windows 10 Sleep/Wake Events Diagnostic Tool

A lightweight C++ console utility that monitors and diagnoses Windows power management events in real-time, reads the System event log for sleep/wake history, and generates diagnostic reports.

Features

  • Real-time monitoring (monitor) — listens for sleep, wake, display state changes, AC/battery transitions, and power setting changes via the Windows power notification APIs.
  • Event log reader (events) — queries the Windows Event Log for Microsoft-Windows-Kernel-Power and Microsoft-Windows-Power-Troubleshooter entries with descriptions.
  • Diagnostic report (report) — prints current power status, active power plan, recent events, and an event ID legend.

Building

Option A: Visual Studio Developer Command Prompt (no CMake needed)

Open Developer Command Prompt for VS (or "x64 Native Tools Command Prompt") and run:

cd /d F:\diag_wake
cl /EHsc /W4 /O2 /std:c++17 src\main.cpp src\monitor.cpp src\eventlog.cpp src\report.cpp /Fediag_wake.exe powrprof.lib wevtapi.lib ole32.lib oleaut32.lib

Option B: CMake + Visual Studio

cd /d F:\diag_wake
cmake -B build -S . -G "Visual Studio 17 2022"
cmake --build build --config Release

The executable will be at build\Release\diag_wake.exe (or build\diag_wake.exe for single-config generators).

Usage

diag_wake.exe monitor    # Real-time power event monitoring. Ctrl+C to stop.
diag_wake.exe report     # One-time diagnostic report.
diag_wake.exe events     # Show recent power events from System log.

Run as Administrator if you want the fullest event log access.

Event IDs Tracked

ID Meaning
1 Power transition initiated
41 Unclean shutdown / previous sleep failed
42 Entering sleep
107 Resumed from sleep
131 Wake source identified
132 Sleep reason
506 Entering connected standby
507 Exiting connected standby