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

HostInfo.NativeArchitecture support older Windows builds #201

Merged
merged 2 commits into from
Feb 13, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/201.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
HostInfo.NativeArchitecture is not available on Windows system prior Windows 10 version 1709.
```
11 changes: 11 additions & 0 deletions providers/windows/arch_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
package windows

import (
"errors"

"golang.org/x/sys/windows"

gowindows "github.com/elastic/go-windows"
Expand All @@ -44,8 +46,17 @@ func NativeArchitecture() (string, error) {
// the pseudo handle doesn't need to be closed
var currentProcessHandle = windows.CurrentProcess()

// IsWow64Process2 was introduced in version 1709 (build 16299 acording to the tables)
// https://learn.microsoft.com/en-us/windows/release-health/release-information
// https://learn.microsoft.com/en-us/windows/release-health/windows-server-release-info
err := windows.IsWow64Process2(currentProcessHandle, &processMachine, &nativeMachine)
if err != nil {
if errors.Is(err, windows.ERROR_PROC_NOT_FOUND) {
major, minor, build := windows.RtlGetNtVersionNumbers()
if major < 10 || (major == 10 && minor == 0 && build < 16299) {
return "", nil
}
}
return "", err
}

Expand Down
Loading