Commit Graph

30 Commits

Author SHA1 Message Date
mertakman
adbb8bbcaf windows/mkwinsyscall: use syscall.SyscallN instead of syscall.Syscall{6,9,12,15}
Replace syscall.Syscall6, Syscall9, Syscall12, and Syscall15 with syscall.SyscallN for Go 1.18+. This simplifies system calls by allowing the exact number of arguments needed, eliminating zero padding and reducing potential errors.

Updated TestSyscallXGeneration to TestSyscallNGeneration to verify correct SyscallN generation for different argument counts.

Change-Id: Icd6662b591d7548e367b88f34243f5529e177eab
GitHub-Last-Rev: c06fca1aa4
GitHub-Pull-Request: golang/sys#219
Reviewed-on: https://go-review.googlesource.com/c/sys/+/614082
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
2024-10-21 13:42:39 +00:00
cuishuang
d58f986c89 all: fix some typos in comment
Change-Id: I40f9866661bad30ee2f4be2e9d0beee54db860b3
Reviewed-on: https://go-review.googlesource.com/c/sys/+/611775
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-09-09 19:33:19 +00:00
Dmitri Shuralyov
1bfbee0e20 all: update go directive to 1.18
Done with:

go get go@1.18
go mod tidy
go fix ./...

Using go1.21.3.

Also update code generators to use only the new go:build lines,
not the old +build ones.

For golang/go#60268.

Change-Id: I6aabc42efb6ab3329981100e1db2263aac5e92a6
Reviewed-on: https://go-review.googlesource.com/c/sys/+/534222
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-10-11 21:54:30 +00:00
Russ Cox
b5fbb4746d all: gofmt
Gofmt to update doc comments to the new formatting.

For golang/go#51082.

Change-Id: I9a1c4b671c06820a1c383ee515f7884965fefa54
Reviewed-on: https://go-review.googlesource.com/c/sys/+/399602
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
2022-04-29 23:34:32 +00:00
Bryan C. Mills
99a53858aa all: add missing //go:build comments
These were apparently overlooked in CL 357329, CL 294490, CL 296889,
and other various updates to this module. (I noticed them via gopls
while investigating golang/go#49466.)

Updates golang/go#41184

Change-Id: Id042bb6fe5282e6d528e9315acf2ad29d0df58ba
Reviewed-on: https://go-review.googlesource.com/c/sys/+/362577
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-11-10 15:43:04 +00:00
Bryan C. Mills
51b60fd695 windows/registry: lock OS thread while enumerating keys
CL 361154 updated the standard syscall package to document that
successive calls to syscall.RegEnumKeyEx must occur on the same OS
thread (after that requirement was empirically discovered in
golang/go#49320).

This use in x/sys needs to be updated to comply with the
newly-discovered requirement.

Fixes golang/go#49466.

Change-Id: Idc45d91f175e1db25c215213fcaa45982c2f5e6e
Reviewed-on: https://go-review.googlesource.com/c/sys/+/362576
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-09 18:48:56 +00:00
Alex Brainman
9f70ab9862 windows/mkwinsyscall: use global variable to avoid allocation in errnoErr
Change-Id: I6f089ea96bfbad6390c50a63e9d2fb290cc8654a
Reviewed-on: https://go-review.googlesource.com/c/sys/+/264578
Trust: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-10-24 23:29:16 +00:00
Alex Brainman
0aaa271806 windows/mkwinsyscall: sort by dll names and dll function names
Otherwise generated file changes every time //sys lines are moved
around, or when mkwinsyscall command parameters are reordered.

Change-Id: Ie4bdbee2ba50f9cea36ec78ce9951c57bd5da8a7
Reviewed-on: https://go-review.googlesource.com/c/sys/+/260900
Trust: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-10-13 08:18:32 +00:00
Alex Brainman
f43be2a459 windows/registry: make '-gcflags=all=-d=checkptr' flag work
Mostly replaced [:x] slice operation with [:x:x]. 

This change is copy of CL 203442.

Updates golang/go#34972

Change-Id: I9b725a39aea469bd5669cc1deb3d02a88912843e
Reviewed-on: https://go-review.googlesource.com/c/sys/+/204017
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-10-29 15:55:21 +00:00
Jason A. Donenfeld
f8518d3b36 windows/registry: remove TestWalkFullRegistry due to false assumptions
This test's existence was predicated upon assumptions about the full
range of known data types and known data into those types. However,
we've learned from Microsoft that there are several undocumented secret
registry types that are in use by various parts of Windows, and we've
learned from inspection that many Microsoft uses of registry types don't
strictly adhere to the recommended value size. It's therefore foolhardy
to make any assumptions about what goes in and out of the registry, and
so this test is meaningless and error-prone.

Updates golang/go#35084

Change-Id: Ie545229afd8dc5bde90fffa0f735f7102cd4a6eb
Reviewed-on: https://go-review.googlesource.com/c/sys/+/203605
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-10-27 21:15:39 +00:00
Jason A. Donenfeld
53bf42e6b3 windows/registry: allow for non-null terminated strings
According to MSDN, "If the data has the REG_SZ, REG_MULTI_SZ or
REG_EXPAND_SZ type, this size includes any terminating null character or
characters unless the data was stored without them. [...] If the data
has the REG_SZ, REG_MULTI_SZ or REG_EXPAND_SZ type, the string may not
have been stored with the proper terminating null characters. Therefore,
even if the function returns ERROR_SUCCESS, the application should
ensure that the string is properly terminated before using it;
otherwise, it may overwrite a buffer."

It's therefore dangerous to pass it off unbounded as we do, and in fact
this led to crashes on real systems.

Change-Id: I2ab324e85f75dc3e4d6d62fec3b96937fec77510
Reviewed-on: https://go-review.googlesource.com/c/sys/+/202957
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2019-10-25 09:01:51 +00:00
Jason A. Donenfeld
c178f38b41 windows/mkwinsyscall: import mksyscall_windows.go from go repo
This allows us to modify this file and fix it more fluidly. Users can
invoke it from go generate via:

   go run golang.org/x/sys/windows/mkwinsyscall

This was taken from Go repo commit 6b85fa80.

Updates golang/go#34388

Change-Id: I8dc39eed96b2499ccbde53554b3e16e6c1f6aa98
Reviewed-on: https://go-review.googlesource.com/c/sys/+/198637
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-10-03 21:23:58 +00:00
Jason A. Donenfeld
c46e0d965b windows/registry: do not generate unaligned loads
Byte slices aren't necessarily aligned, which means casting them to
integer types and dereferencing may result in an unaligned load. This
is mostly fine on Intel but isn't necessarily fine on other platforms.
Any good compiler will generate optimal code for the platform using the
pattern of this commit.

Change-Id: I6dd8debad1cb850b8562ee96ae0f366d1f822a6f
Reviewed-on: https://go-review.googlesource.com/c/sys/+/176857
Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-05-22 03:42:48 +00:00
Tobias Klauser
a5b02f93d8 windows: add "generate" build tag
cmd/go supports the "generate" build tag as of CL 175983. Add it to the
files which are just used for generating errors and syscall wrappers.

Also see golang/go#31920

Change-Id: Ib26c90af0ac1fb7bae81366a46dedf028b787566
Reviewed-on: https://go-review.googlesource.com/c/sys/+/175899
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-09 14:14:14 +00:00
Tobias Klauser
8014b7b116 windows: follow convention for generated code comment
Regenerated with go tip to get the generated code comment following the
convention (https://golang.org/s/generatedcode).

Change-Id: Ie1365ecfa532b940bf7cfc8579c4cbda71cf7f76
Reviewed-on: https://go-review.googlesource.com/118817
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2018-06-15 09:36:15 +00:00
Shamil Garatuev
f6cff0780e windows/registry: improve ReadSubKeyNames permissions
The existing implementation requires QUERY_VALUE and ENUMERATE_SUB_KEYS permissions to enumerate
subkeys, so, using registry key name limits, Stat function could be excluded
from methods body and improved method requires only ENUMERATE_SUB_KEYS permission

Registry elements size limits described there:
https://msdn.microsoft.com/library/windows/desktop/ms724872.aspx

Fixes golang/go#23869

Change-Id: Id96beb9b0b294f01cc6eb1bb53bee5f50d02ea7e
Reviewed-on: https://go-review.googlesource.com/95655
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-02-24 23:21:35 +00:00
Francesc Campoy
6faef541c7 golang.org/x/sys: fix typo in test
Change-Id: I5709137db7308934e627d866da1cc8aa5abca7db
Reviewed-on: https://go-review.googlesource.com/47310
Reviewed-by: Rob Pike <r@golang.org>
2017-07-05 19:55:40 +00:00
Alex Brainman
f5a6bd4305 windows/registry: add code to access remote pc registry
Introduce OpenRemoteKey function that opens some
root registry keys on remote computer.

Also add PERFORMANCE_DATA key, since it is one of
root keys accessible via OpenRemoteKey.

Change-Id: I738fdfee52a34acd4dc09ddb91fcf0e4c707bd83
Reviewed-on: https://go-review.googlesource.com/33814
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-12-04 22:43:27 +00:00
Alex Brainman
ca83bd2cb9 windows: run "go generate"
Change-Id: Ide01e409af85a5e2615ba647b44eda67bc14c07f
Reviewed-on: https://go-review.googlesource.com/33812
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-12-02 08:03:26 +00:00
Alex Brainman
a646d33e2e windows: make "go generate" command work on any OS
See issue golang/go#16368 for details.

Updates golang/go#16368

Change-Id: Ic3294385a350aee41887f59cbcf5b0af7742ff3b
Reviewed-on: https://go-review.googlesource.com/24952
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-07-17 07:19:31 +00:00
Alex Brainman
e82cb4d7df windows: remove non-existing now mksyscall_windows.go -xsys flag
Updates golang/go#15167

Change-Id: I58bd7e4e6ba88a2ffba11506e5ac0495de303b5b
Reviewed-on: https://go-review.googlesource.com/23023
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
2016-05-12 03:25:10 +00:00
Alex Brainman
042a8f53ce windows: add NewLazySystemDLL and use it in zsyscall_windows.go
If we want new secure DLL approach to be adopted, we should make
conversion as simple as possible to explain and implement.
I think that replacing

syscall.NewLazyDLL(...) -> windows.NewLazySystemDLL(...)

is easier than

syscall.NewLazyDLL(...) -> &windows.LazyDLL{Name: ..., System: true}

So I propose we introduce convenience function NewLazySystemDLL.

$GOROOT/src/mksyscall_windows.go changes in the following CL.

Change-Id: If3432aff301c347cb355e4e837834696191b2219
Reviewed-on: https://go-review.googlesource.com/21592
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-06 06:33:47 +00:00
Brad Fitzpatrick
3dff6e19a5 windows: add LoadLibraryEx, add LazyDLL.System
Updates golang/go#14959

Change-Id: Ib91c359c3df919df0b30e584d38e56f79f3e3dc9
Reviewed-on: https://go-review.googlesource.com/21388
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-02 00:33:28 +00:00
Alex Brainman
442cd60086 windows: copy latest changes from internal/syscall/windows
Copy of CL 4310, 6140, 17412, 17997 and 17998.

Change-Id: I7db8722a1c37f033d5ce6644859ef15c58289a46
Reviewed-on: https://go-review.googlesource.com/18552
Reviewed-by: Rob Pike <r@golang.org>
2016-01-13 01:14:10 +00:00
Alex Brainman
16e60ce682 windows/registry: do not panic when data is large
Allow registry blobs to be as large as 500MB

Copy of CL 14287.

Fixes golang/go#12493

Change-Id: I37b82fcf90ff2acef83c66016375fcae15e6eefc
Reviewed-on: https://go-review.googlesource.com/14288
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-09 02:29:49 +00:00
Daniel Johansson
98fc11432b windows/registry: copy latest changes from internal/syscall/registry
This CL includes changes from:

https://golang.org/cl/13929
https://golang.org/cl/13854

Part of fixing https://golang.org/issue/12015

Change-Id: I62e00e165d97d2349c89a783aed7fcbe9e0abd34
Reviewed-on: https://go-review.googlesource.com/14016
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2015-08-30 10:08:33 +00:00
Alex Brainman
0879c8a4d6 windows/registry: remove debugging dreg
copy of CL 13828 change

Change-Id: I48ea36171281eed8e59b92e130c762142fb94604
Reviewed-on: https://go-review.googlesource.com/13829
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-24 23:40:35 +00:00
Alex Brainman
87f732a730 windows/registry: copy latest changes from internal/syscall/registry
This CL includes changes from:

http://golang.org/cl/9805
http://golang.org/cl/9806
http://golang.org/cl/9901

Change-Id: I1f41a8215f9f760c0d3b84596e37bf48bf4c9bc2
Reviewed-on: https://go-review.googlesource.com/10132
Reviewed-by: Rob Pike <r@golang.org>
2015-05-15 05:08:24 +00:00
Alex Brainman
bbc47fbbc8 windows/registry: mark string end with 0 before calling Windows ExpandEnvironmentStrings
Change-Id: I02bfcdeac44167d1dbeb15bcd5c82111fba3f527
Reviewed-on: https://go-review.googlesource.com/9234
Reviewed-by: Rob Pike <r@golang.org>
2015-04-23 02:52:27 +00:00
Alex Brainman
e961698092 windows/registry: add new package to manipulate Windows registry
Change-Id: Ia7c3d6250c041b95aa43ca5ca2a92251c480ef77
Reviewed-on: https://go-review.googlesource.com/8843
Reviewed-by: Rob Pike <r@golang.org>
2015-04-15 07:18:44 +00:00