TGViewer
C++ - Reddit C++ - Reddit @r_cpp · 229 subscribers
Post #24852 51
Triggering a silent Windows Factory Reset via C++: Reverse engineering the undocumented ResetEngine.dll

Hi r/cpp,

I wanted to share a project I've been working on. I needed a way to trigger a complete Windows factory reset (Push Button Reset) programmatically with zero UI overhead. Normally, this is done via SystemSettings.exe or WMI classes like MDM_RemoteWipe (which often require active MDM enrollment).

Instead of relying on those, I decided to interact directly with the underlying undocumented API: ResetEngine.dll.

I built a C++ tool that bypasses the standard UI and forces the system into the Windows Recovery Environment (WinRE) to format the partition.

The C++ Implementation: Since the API is undocumented, the code relies on dynamically loading the DLL (LoadLibraryW) and mapping function pointers (GetProcAddress) for the internal engine functions. The sequence looks like this:

1. ResetCreateSession: Initializes a session targeting the C: drive.
2. ResetPrepareSession: Configures the parameters. I pass scenarioType = 1 to force the "Remove Everything" wipe.
3. ResetStageOfflineBoot: Modifies the BCD to boot directly into WinRE, avoiding the need to manually configure ArmBootTrigger.
4. InitiateSystemShutdownExW: Triggers the reboot to let WinRE take over.

The tool requires SYSTEM privileges (easily tested via psexec -s) to successfully hook into the engine.

Repository: https://github.com/arielmendoza/Windows-factory-reset-tool

Disclaimer: If you compile and run this with the --force flag as SYSTEM, it WILL wipe your machine immediately with no confirmation. Please test in a VM.

I’d love to get your feedback on the code structure, the way the undocumented functions are handled, or if anyone here has explored the other scenario types exposed by this DLL.

https://redd.it/1rs2cir
@r_cpp
More from @r_cpp
  1. Oct 7, 2026Qt moc now can handle basic C++ modules (Qt 6.12) https://codereview.qt-project.org/c/qt/q…
  2. Oct 7, 2026New to c++ Hello everybody,im new to cpp,and want to learn it,i have some knowledge with C…
  3. Oct 7, 2026Optimizing the Compressed Log Pipeline: https://github.com/Tencent/BqLog/blob/main/docs/Ar…
  4. Oct 7, 2026BqLog 2.6.0: a C++ logging library running on 30M+ devices daily, benchmarked against quil…
  5. Oct 7, 2026BqLog 2.6.0: a C++ logging library running on 30M+ devices daily, benchmarked against quil…
  6. Oct 7, 2026LearnCPP taking 2.5 Go of RAM It's crazy that with the number of adds on the website, lear…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →