func NativeArchitecture()

in providers/windows/arch_windows.go [44:74]


func NativeArchitecture() (string, error) {
	var processMachine, nativeMachine uint16
	// the pseudo handle doesn't need to be closed
	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
	}

	var nativeArch string

	switch nativeMachine {
	case imageFileMachineAmd64:
		// for parity with Architecture() as amd64 and x86_64 are used interchangeably
		nativeArch = archIntel
	case imageFileMachineArm64:
		nativeArch = archArm64
	}

	return nativeArch, nil
}