Skip to content

Commit

Permalink
syscall: point to x/sys in DLL loading docs, update syscall generator
Browse files Browse the repository at this point in the history
Updates the syscall generator for patchset 4 of https://golang.org/cl/21388.

Updates #14959

Change-Id: Icbd6df489887d3dcc076dfc73d4feb1376abaf8b
Reviewed-on: https://go-review.googlesource.com/21428
Reviewed-by: Alex Brainman <[email protected]>
  • Loading branch information
bradfitz committed Apr 2, 2016
1 parent 75a22d0 commit 6a0bb87
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/syscall/dll_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ type DLL struct {
}

// LoadDLL loads the named DLL file into memory.
//
// If name is not an absolute path and is not a known system DLL used by
// Go, Windows will search for the named DLL in many locations, causing
// potential DLL preloading attacks.
//
// Use LazyDLL in golang.org/x/sys/windows for a secure way to
// load system DLLs.
func LoadDLL(name string) (*DLL, error) {
namep, err := UTF16PtrFromString(name)
if err != nil {
Expand Down Expand Up @@ -174,6 +181,12 @@ func (p *Proc) Call(a ...uintptr) (r1, r2 uintptr, lastErr error) {
// It will delay the load of the DLL until the first
// call to its Handle method or to one of its
// LazyProc's Addr method.
//
// LazyDLL is subject to the same DLL preloading attacks as documented
// on LoadDLL.
//
// Use LazyDLL in golang.org/x/sys/windows for a secure way to
// load system DLLs.
type LazyDLL struct {
mu sync.Mutex
dll *DLL // non nil once DLL is loaded
Expand Down
4 changes: 2 additions & 2 deletions src/syscall/mksyscall_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -707,9 +707,9 @@ func (src *Source) Generate(w io.Writer) error {
}
if *sysRepo {
if packageName == "windows" {
return "&LazyDLL{Name: " + arg + ", Flags: LoadLibrarySearchSystem32}"
return "&LazyDLL{Name: " + arg + ", System: true}"
} else {
return "&windows.LazyDLL{Name: " + arg + ", Flags: windows.LoadLibrarySearchSystem32}"
return "&windows.LazyDLL{Name: " + arg + ", System: true}"
}
} else {
return syscalldot() + "NewLazyDLL(" + arg + ")"
Expand Down

0 comments on commit 6a0bb87

Please sign in to comment.