windows: add SetupAPI and CfgMgr32 functions

Simon and I have worked on these on and off for a number of projects
over the last 3 years and by now it's quite stable and mature. Rather
than carrying this around privately, these have now been updated to be
in the style of x/sys/windows, in this case matching how the
security_windows.go file does things. Specifically, because these APIs
are kind of hard to work with, and quite lengthy, we split them off into
a setupapi_windows.go file, just like security_windows.go.  We already
had the setupapierrors_windows.go file, so that's been folded into the
new one that contains the additional definitions nad functions.

These APIs are among the most obtuse to work with in all of Win32, so
considerable attention has been spent trying to make these wrappers both
quite "raw" so that they match the win32, but also accessible from Go.
The fact that they're so old in Windows history makes for a few tricky
things, like struct padding that doesn't quite match Go's rules, but
we've been able to accommodate basically everything after quite a bit of

Change-Id: I0c2dd85e4bb40eee10186ffc92558a858bdf8c6a
Trust: Jason A. Donenfeld <>
Trust: Patrik Nyblom <>
Run-TryBot: Jason A. Donenfeld <>
TryBot-Result: Go Bot <>
Reviewed-by: Simon Rozman <>
Reviewed-by: Patrik Nyblom <>
6 files changed
tree: eac88e154a161b52c6af3fded2447daf4c313bda
  1. cpu/
  2. execabs/
  3. internal/
  4. plan9/
  5. unix/
  6. windows/
  7. .gitattributes
  8. .gitignore
  10. codereview.cfg
  13. go.mod


Go Reference

This repository holds supplemental Go packages for low-level interactions with the operating system.


The easiest way to install is to run go get -u You can also manually git clone the repository to $GOPATH/src/

Report Issues / Send Patches

This repository uses Gerrit for code changes. To learn how to submit changes to this repository, see

The main issue tracker for the sys repository is located at Prefix your issue with “x/sys:” in the subject line, so it is easy to find.