New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x/sys/windows: add ExitWindowsEx #34271
Comments
Not sure to what extent x/sys/windows hopes to cover the entire Windows API. /cc @alexbrainman Can't you use something like |
Yup, I could certainly do something like that. I was looking to extend the standard library for the better on windows. Currently, I have to do a hodgepodge of the following to accomplish my goal: windows.OpenProcessToken() LookupPrivilegeValue.Call() AdjustTokenPrivileges.Call() syscall.GetLastError() ExitWindowsEx.Call() |
Sounds good to me. What exactly do you propose? Adding @zx2c4, because he makes most changes to golang.org/x/sys/windows lately. Alex |
I've got some plans to add some token manipulation functions. I'll try to add |
Thanks @alexbrainman and @zx2c4! My initial plan was to take the following calls: windows.OpenProcessToken() LookupPrivilegeValue.Call() AdjustTokenPrivileges.Call() syscall.GetLastError() ExitWindowsEx.Call() And make them look more like: windows.OpenProcessToken() windows.LookupPrivilegeValue() windows.AdjustTokenPrivileges() windows.GetLastError() windows.ExitWindowsEx() Some would need to be added and some would need to be ported from internal/syscall/windows. This would also include adding/moving the relevant constants. This will offer a more streamline experience similar to https://docs.microsoft.com/en-us/windows/win32/shutdown/how-to-shut-down-the-system. |
This is already returned by syscall.SyscallN as one of its return values. |
Try and write it yourself. And show your code, if you are not sure. We will correct it, if need be. Maybe we could put it all into golang.org/x/sys/windows.Reboot function (or similar name). Maybe we could even put it into golang.org/x/sys.Reboot function, if there is enough interest. Alex |
Change https://golang.org/cl/195497 mentions this issue: |
@bruceadowns let me know if that implementation is suitable. |
This is hard to do because different contexts require different calls. We could probably detect an interactive session and try to convert the arguments between the different types of calls, but that doesn't seem trivial.
Also a cool idea, but isn't shutdown somewhat different on different platforms, which have different notions of sessions and window stations and shutdown states and stuff? |
Sweet! I'll look at it later today. |
I would not know. I am not really a Windows expert. Forget my suggestion. Alex |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Tried to find windows reboot functionality in the standard library, but it was only found for linux.
What did you expect to see?
For Windows to have parity capability as linux.
What did you see instead?
Mention of ExitWindowsEx is missing in the standard library.
The following api will need to be added to /x/sys/windows:
ExitWindowsEx
The following apis will need to be moved from internal/syscall/windows:
LookupPrivilegeValue
AdjustTokenPrivileges
along with their various const dependencies.
The text was updated successfully, but these errors were encountered: