Skip to content
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

Use NewLazySystemDLL instead of NewLazyDLL #13234

Merged
merged 1 commit into from
Aug 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- ILM: Use GET instead of HEAD when checking for alias to expose detailed error message. {pull}12886[12886]
- Fix seccomp policy preventing some features to function properly on 32bit Linux systems. {issue}12990[12990] {pull}13008[13008]
- Fix install-service.ps1's ability to set Windows service's delay start configuration. {pull}13173[13173]
- Load DLLs only from Windows system directory. {pull}13234[13234]

*Auditbeat*

Expand Down
2 changes: 1 addition & 1 deletion libbeat/common/file/file_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type StateOS struct {
}

var (
modkernel32 = windows.NewLazyDLL("kernel32.dll")
modkernel32 = windows.NewLazySystemDLL("kernel32.dll")

procGetFileInformationByHandleEx = modkernel32.NewProc("GetFileInformationByHandleEx")
)
Expand Down
15 changes: 6 additions & 9 deletions metricbeat/module/system/diskio/diskstat_windows_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ import (
"syscall"
"unsafe"

windows2 "golang.org/x/sys/windows"

"github.com/elastic/beats/libbeat/logp"

"github.com/pkg/errors"
"github.com/shirou/gopsutil/disk"
"golang.org/x/sys/windows"
"golang.org/x/sys/windows/registry"

"github.com/shirou/gopsutil/disk"
"github.com/elastic/beats/libbeat/logp"
)

const (
Expand All @@ -41,10 +39,9 @@ const (
)

var (
modkernel32 = syscall.NewLazyDLL("kernel32.dll")
modkernel32 = windows.NewLazySystemDLL("kernel32.dll")
procGetLogicalDriveStringsW = modkernel32.NewProc("GetLogicalDriveStringsW")
procGetDriveTypeW = modkernel32.NewProc("GetDriveTypeW")
logger = logp.NewLogger("diskio")
)

type logicalDrive struct {
Expand Down Expand Up @@ -145,7 +142,7 @@ func enablePerformanceCounters() error {
if err = key.SetDWordValue("EnableCounterForIoctl", 1); err != nil {
return errors.Errorf("cannot create HKLM:SYSTEM\\CurrentControlSet\\Services\\Partmgr\\EnableCounterForIoctl key in the registry in order to enable the performance counters: %s", err)
}
logger.Info("The registry key EnableCounterForIoctl at HKLM:SYSTEM\\CurrentControlSet\\Services\\Partmgr has been created in order to enable the performance counters")
logp.L().Named("diskio").Info("The registry key EnableCounterForIoctl at HKLM:SYSTEM\\CurrentControlSet\\Services\\Partmgr has been created in order to enable the performance counters")
}
return nil
}
Expand Down Expand Up @@ -247,7 +244,7 @@ func GetVolumeLabel(path *uint16) (string, error) {
lpMaximumComponentLength := uint32(0)
lpFileSystemFlags := uint32(0)
lpFileSystemNameBuffer := make([]uint16, 256)
err := windows2.GetVolumeInformation(
err := windows.GetVolumeInformation(
path,
&lpVolumeNameBuffer[0],
uint32(len(lpVolumeNameBuffer)),
Expand Down