Created
September 27, 2015 20:11
-
-
Save olleolleolle/cc8ce33ea1156f6d1c25 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // +build windows | |
| package architecture | |
| import ( | |
| "bytes" | |
| "errors" | |
| "io/ioutil" | |
| "syscall" | |
| "unsafe" | |
| ) | |
| // TODO: From the SYSTEM_INFO struct, we wish to extract `wProcessorArchitecture` | |
| // https://msdn.microsoft.com/en-us/library/windows/desktop/ms724958(v=vs.85).aspx | |
| type SYSTEM_INFO struct { | |
| // This is the first member of the union | |
| OemId uint32 | |
| // These are the second member of the union | |
| // ProcessorArchitecture uint16; | |
| // Reserved uint16; | |
| PageSize uint32 | |
| MinimumApplicationAddress uintptr | |
| MaximumApplicationAddress uintptr | |
| ActiveProcessorMask *uint32 | |
| NumberOfProcessors uint32 | |
| ProcessorType uint32 | |
| AllocationGranularity uint32 | |
| ProcessorLevel uint16 | |
| ProcessorRevision uint16 | |
| } | |
| var ( | |
| getSystemInfo = syscall.MustLoadDLL("kernel32.dll").MustFindProc("GetSystemInfo") | |
| ) | |
| // GetArchitecture returns the name of the runtime architecture. | |
| func GetArchitecture() (string, error) { | |
| // TODO: Implement architecture detection | |
| // See pkg/parsers/operatingsystem/operatingsystem_windows.go for example. | |
| // See https://msdn.microsoft.com/en-us/library/windows/desktop/ms724340(v=vs.85).aspx | |
| // for system call detail. | |
| return "", errors.New("Cannot detect architecture") | |
| ret := "Unknown Architecture" | |
| var si SYSTEM_INFO | |
| getSystemInfo(uintptr(unsafe.Pointer(&si))) | |
| fmt.Printf("SYSTEM_INFO=%+v\n", si) | |
| // TODO: Use si.ProcessorArchitecture to look up values in a table | |
| return ret, nil | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment