windows: fix PSAPI_WORKING_SET_EX_BLOCK bit accessors

Shared, Locked, LargePage and Bad compared a masked bit against 1,
as in (b & (1 << 22)) == 1, which is never true for a bit other than
bit 0. All four always returned false. Compare against 0 instead, and
do the same in Valid for consistency.

Add a table test over the bit positions, and a test that checks
QueryWorkingSetEx reports a page locked with VirtualLock as Locked.
Extend TestQueryWorkingSetEx to query pages of a file mapping and
check that they are reported as Shared. All fail without this change.

Fixes golang/go#81797

Change-Id: Ib4bf00c7406398c21b3eb31717f6da765aa51757
Reviewed-on: https://go-review.googlesource.com/c/sys/+/843385
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2 files changed
tree: 1466ad4d56fe31cd3e8927686a79cf3e9c56ab20
  1. cpu/
  2. execabs/
  3. plan9/
  4. unix/
  5. windows/
  6. .gitattributes
  7. .gitignore
  8. codereview.cfg
  9. CONTRIBUTING.md
  10. go.mod
  11. LICENSE
  12. PATENTS
  13. README.md
README.md

sys

Go Reference

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

Report Issues / Send Patches

This repository uses Gerrit for code changes. To learn how to submit changes to this repository, see https://go.dev/doc/contribute.

The git repository is https://go.googlesource.com/sys.

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