mirror of
https://github.com/rwinkhart/sys.git
synced 2026-08-27 20:36:31 -04:00
windows: add QueryWorkingSetEx
This change adds the QueryWorkingSetEx function for inspecting the virtual memory details of pointers. https://docs.microsoft.com/en-us/windows/win32/api/psapi/nf-psapi-queryworkingsetex Change-Id: I2bc92bb0b65d34ed1caf88e4d368d64946dfcc5c GitHub-Last-Rev: c5ac00435245c4d6b83003949dd06014b52e59e0 GitHub-Pull-Request: golang/sys#124 Reviewed-on: https://go-review.googlesource.com/c/sys/+/402494 Run-TryBot: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
This commit is contained in:
committed by
Alex Brainman
parent
3c1f35247d
commit
1609e554cd
@@ -777,6 +777,25 @@ func TestProcessModules(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestQueryWorkingSetEx(t *testing.T) {
|
||||
var a int
|
||||
|
||||
process := windows.CurrentProcess()
|
||||
information := windows.PSAPI_WORKING_SET_EX_INFORMATION{
|
||||
VirtualAddress: windows.Pointer(unsafe.Pointer(&a)),
|
||||
}
|
||||
infos := []windows.PSAPI_WORKING_SET_EX_INFORMATION{information}
|
||||
|
||||
cb := uint32(uintptr(len(infos)) * unsafe.Sizeof(infos[0]))
|
||||
if err := windows.QueryWorkingSetEx(process, uintptr(unsafe.Pointer(&infos[0])), cb); err != nil {
|
||||
t.Fatalf("%+v", err)
|
||||
}
|
||||
|
||||
if !infos[0].VirtualAttributes.Valid() {
|
||||
t.Errorf("memory location not valid")
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadWriteProcessMemory(t *testing.T) {
|
||||
testBuffer := []byte{0xBA, 0xAD, 0xF0, 0x0D}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user