mirror of
https://github.com/rwinkhart/sys.git
synced 2026-09-05 08:37:31 -04:00
windows/svc: safely load system DLLs
These DLLs, well advapi32.dll in particular, are vulnerable to classic DLL directory injection attacks. The rest of x/sys/windows moved over to the safe system loader, but apparently the svc package was forgotten. This tidies up that oversight. Change-Id: I330fa752cf2d49ccc5cf1bd60fb4bd612bd2b6b0 Reviewed-on: https://go-review.googlesource.com/c/sys/+/165758 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
3e9a981b8d
commit
70f5298506
@@ -115,11 +115,11 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
k := syscall.MustLoadDLL("kernel32.dll")
|
k := windows.NewLazySystemDLL("kernel32.dll")
|
||||||
cSetEvent = k.MustFindProc("SetEvent").Addr()
|
cSetEvent = k.NewProc("SetEvent").Addr()
|
||||||
cWaitForSingleObject = k.MustFindProc("WaitForSingleObject").Addr()
|
cWaitForSingleObject = k.NewProc("WaitForSingleObject").Addr()
|
||||||
a := syscall.MustLoadDLL("advapi32.dll")
|
a := windows.NewLazySystemDLL("advapi32.dll")
|
||||||
cRegisterServiceCtrlHandlerExW = a.MustFindProc("RegisterServiceCtrlHandlerExW").Addr()
|
cRegisterServiceCtrlHandlerExW = a.NewProc("RegisterServiceCtrlHandlerExW").Addr()
|
||||||
}
|
}
|
||||||
|
|
||||||
type ctlEvent struct {
|
type ctlEvent struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user