diff --git a/baseboard_windows.go b/baseboard_windows.go index 5c2791f2..55544bd1 100644 --- a/baseboard_windows.go +++ b/baseboard_windows.go @@ -10,10 +10,10 @@ import "github.com/StackExchange/wmi" const wqlBaseboard = "SELECT Manufacturer, SerialNumber, Tag, Version FROM Win32_BaseBoard" type win32Baseboard struct { - Manufacturer string - SerialNumber string - Tag string - Version string + Manufacturer *string + SerialNumber *string + Tag *string + Version *string } func (ctx *context) baseboardFillInfo(info *BaseboardInfo) error { @@ -23,10 +23,10 @@ func (ctx *context) baseboardFillInfo(info *BaseboardInfo) error { return err } if len(win32BaseboardDescriptions) > 0 { - info.AssetTag = win32BaseboardDescriptions[0].Tag - info.SerialNumber = win32BaseboardDescriptions[0].SerialNumber - info.Vendor = win32BaseboardDescriptions[0].Manufacturer - info.Version = win32BaseboardDescriptions[0].Version + info.AssetTag = *win32BaseboardDescriptions[0].Tag + info.SerialNumber = *win32BaseboardDescriptions[0].SerialNumber + info.Vendor = *win32BaseboardDescriptions[0].Manufacturer + info.Version = *win32BaseboardDescriptions[0].Version } return nil diff --git a/bios_windows.go b/bios_windows.go index 11a76eef..d1882add 100644 --- a/bios_windows.go +++ b/bios_windows.go @@ -10,9 +10,9 @@ import "github.com/StackExchange/wmi" const wqlBIOS = "SELECT InstallDate, Manufacturer, Version FROM CIM_BIOSElement" type win32BIOS struct { - InstallDate string - Manufacturer string - Version string + InstallDate *string + Manufacturer *string + Version *string } func (ctx *context) biosFillInfo(info *BIOSInfo) error { @@ -22,9 +22,9 @@ func (ctx *context) biosFillInfo(info *BIOSInfo) error { return err } if len(win32BIOSDescriptions) > 0 { - info.Vendor = win32BIOSDescriptions[0].Manufacturer - info.Version = win32BIOSDescriptions[0].Version - info.Date = win32BIOSDescriptions[0].InstallDate + info.Vendor = *win32BIOSDescriptions[0].Manufacturer + info.Version = *win32BIOSDescriptions[0].Version + info.Date = *win32BIOSDescriptions[0].InstallDate } return nil } diff --git a/block_windows.go b/block_windows.go index 2aacf4bf..7a708c6d 100644 --- a/block_windows.go +++ b/block_windows.go @@ -14,19 +14,19 @@ import ( const wqlDiskDrive = "SELECT Caption, CreationClassName, DefaultBlockSize, Description, DeviceID, Index, InterfaceType, Manufacturer, MediaType, Model, Name, Partitions, SerialNumber, Size, TotalCylinders, TotalHeads, TotalSectors, TotalTracks, TracksPerCylinder FROM Win32_DiskDrive" type win32DiskDrive struct { - Caption string - CreationClassName string + Caption *string + CreationClassName *string DefaultBlockSize uint64 - Description string - DeviceID string + Description *string + DeviceID *string Index uint32 // Used to link with partition - InterfaceType string - Manufacturer string - MediaType string - Model string - Name string + InterfaceType *string + Manufacturer *string + MediaType *string + Model *string + Name *string Partitions int32 - SerialNumber string + SerialNumber *string Size uint64 TotalCylinders int64 TotalHeads int32 @@ -40,37 +40,37 @@ const wqlDiskPartition = "SELECT Access, BlockSize, Caption, CreationClassName, type win32DiskPartition struct { Access uint16 BlockSize uint64 - Caption string - CreationClassName string - Description string - DeviceID string + Caption *string + CreationClassName *string + Description *string + DeviceID *string DiskIndex uint32 // Used to link with Disk Drive Index uint32 - Name string + Name *string Size int64 - SystemName string - Type string + SystemName *string + Type *string } const wqlLogicalDiskToPartition = "SELECT Antecedent, Dependent FROM Win32_LogicalDiskToPartition" type win32LogicalDiskToPartition struct { - Antecedent string - Dependent string + Antecedent *string + Dependent *string } const wqlLogicalDisk = "SELECT Caption, CreationClassName, Description, DeviceID, FileSystem, FreeSpace, Name, Size, SystemName FROM Win32_LogicalDisk" type win32LogicalDisk struct { - Caption string - CreationClassName string - Description string - DeviceID string - FileSystem string + Caption *string + CreationClassName *string + Description *string + DeviceID *string + FileSystem *string FreeSpace uint64 - Name string + Name *string Size uint64 - SystemName string + SystemName *string } func (ctx *context) blockFillInfo(info *BlockInfo) error { @@ -98,17 +98,17 @@ func (ctx *context) blockFillInfo(info *BlockInfo) error { disks := make([]*Disk, 0) for _, diskdrive := range win32DiskDriveDescriptions { disk := &Disk{ - Name: strings.TrimSpace(diskdrive.DeviceID), + Name: strings.TrimSpace(*diskdrive.DeviceID), SizeBytes: diskdrive.Size, PhysicalBlockSizeBytes: diskdrive.DefaultBlockSize, - DriveType: toDriveType(diskdrive.MediaType, diskdrive.Caption), - StorageController: toStorageController(diskdrive.InterfaceType), - BusType: toBusType(diskdrive.InterfaceType), + DriveType: toDriveType(*diskdrive.MediaType, *diskdrive.Caption), + StorageController: toStorageController(*diskdrive.InterfaceType), + BusType: toBusType(*diskdrive.InterfaceType), BusPath: UNKNOWN, // TODO: add information NUMANodeID: -1, - Vendor: strings.TrimSpace(diskdrive.Manufacturer), - Model: strings.TrimSpace(diskdrive.Caption), - SerialNumber: strings.TrimSpace(diskdrive.SerialNumber), + Vendor: strings.TrimSpace(*diskdrive.Manufacturer), + Model: strings.TrimSpace(*diskdrive.Caption), + SerialNumber: strings.TrimSpace(*diskdrive.SerialNumber), WWN: UNKNOWN, // TODO: add information Partitions: make([]*Partition, 0), } @@ -119,16 +119,16 @@ func (ctx *context) blockFillInfo(info *BlockInfo) error { // Finding logical partition linked to current disk partition for _, logicaldisk := range win32LogicalDiskDescriptions { for _, logicaldisktodiskpartition := range win32LogicalDiskToPartitionDescriptions { - var desiredAntecedent = "\\\\" + diskpartition.SystemName + "\\root\\cimv2:" + diskpartition.CreationClassName + ".DeviceID=\"" + diskpartition.DeviceID + "\"" - var desiredDependent = "\\\\" + logicaldisk.SystemName + "\\root\\cimv2:" + logicaldisk.CreationClassName + ".DeviceID=\"" + logicaldisk.DeviceID + "\"" - if logicaldisktodiskpartition.Antecedent == desiredAntecedent && logicaldisktodiskpartition.Dependent == desiredDependent { + var desiredAntecedent = "\\\\" + *diskpartition.SystemName + "\\root\\cimv2:" + *diskpartition.CreationClassName + ".DeviceID=\"" + *diskpartition.DeviceID + "\"" + var desiredDependent = "\\\\" + *logicaldisk.SystemName + "\\root\\cimv2:" + *logicaldisk.CreationClassName + ".DeviceID=\"" + *logicaldisk.DeviceID + "\"" + if *logicaldisktodiskpartition.Antecedent == desiredAntecedent && *logicaldisktodiskpartition.Dependent == desiredDependent { // Appending Partition p := &Partition{ - Name: strings.TrimSpace(logicaldisk.Caption), - Label: strings.TrimSpace(logicaldisk.Caption), + Name: strings.TrimSpace(*logicaldisk.Caption), + Label: strings.TrimSpace(*logicaldisk.Caption), SizeBytes: logicaldisk.Size, - MountPoint: logicaldisk.DeviceID, - Type: diskpartition.Type, + MountPoint: *logicaldisk.DeviceID, + Type: *diskpartition.Type, IsReadOnly: toReadOnly(diskpartition.Access), } disk.Partitions = append(disk.Partitions, p) diff --git a/chassis_windows.go b/chassis_windows.go index 9c804771..b9af4eba 100644 --- a/chassis_windows.go +++ b/chassis_windows.go @@ -12,15 +12,15 @@ import ( const wqlChassis = "SELECT Caption, Description, Name, Manufacturer, Model, SerialNumber, Tag, TypeDescriptions, Version FROM CIM_Chassis" type win32Chassis struct { - Caption string - Description string - Name string - Manufacturer string - Model string - SerialNumber string - Tag string + Caption *string + Description *string + Name *string + Manufacturer *string + Model *string + SerialNumber *string + Tag *string TypeDescriptions []string - Version string + Version *string } func (ctx *context) chassisFillInfo(info *ChassisInfo) error { @@ -30,12 +30,12 @@ func (ctx *context) chassisFillInfo(info *ChassisInfo) error { return err } if len(win32ChassisDescriptions) > 0 { - info.AssetTag = win32ChassisDescriptions[0].Tag - info.SerialNumber = win32ChassisDescriptions[0].SerialNumber + info.AssetTag = *win32ChassisDescriptions[0].Tag + info.SerialNumber = *win32ChassisDescriptions[0].SerialNumber info.Type = UNKNOWN // TODO: - info.TypeDescription = win32ChassisDescriptions[0].Model - info.Vendor = win32ChassisDescriptions[0].Manufacturer - info.Version = win32ChassisDescriptions[0].Version + info.TypeDescription = *win32ChassisDescriptions[0].Model + info.Vendor = *win32ChassisDescriptions[0].Manufacturer + info.Version = *win32ChassisDescriptions[0].Version } return nil } diff --git a/cpu_windows.go b/cpu_windows.go index d372f231..50d0b06c 100644 --- a/cpu_windows.go +++ b/cpu_windows.go @@ -13,8 +13,8 @@ import ( const wmqlProcessor = "SELECT Manufacturer, Name, NumberOfLogicalProcessors, NumberOfCores FROM Win32_Processor" type win32Processor struct { - Manufacturer string - Name string + Manufacturer *string + Name *string NumberOfLogicalProcessors uint32 NumberOfCores uint32 } @@ -44,8 +44,8 @@ func (ctx *context) processorsGet(win32descriptions []win32Processor) []*Process for index, description := range win32descriptions { p := &Processor{ Id: index, // TODO: how to get a decent "Physical ID" to use ? - Model: description.Name, - Vendor: description.Manufacturer, + Model: *description.Name, + Vendor: *description.Manufacturer, NumCores: description.NumberOfCores, NumThreads: description.NumberOfLogicalProcessors, } diff --git a/memory_windows.go b/memory_windows.go index 3d7e518a..f8cfa7e9 100644 --- a/memory_windows.go +++ b/memory_windows.go @@ -19,19 +19,19 @@ type win32OperatingSystem struct { const wqlPhysicalMemory = "SELECT BankLabel, Capacity, DataWidth, Description, DeviceLocator, Manufacturer, Model, Name, PartNumber, PositionInRow, SerialNumber, Speed, Tag, TotalWidth FROM Win32_PhysicalMemory" type win32PhysicalMemory struct { - BankLabel string + BankLabel *string Capacity uint64 DataWidth uint16 - Description string - DeviceLocator string - Manufacturer string - Model string - Name string - PartNumber string + Description *string + DeviceLocator *string + Manufacturer *string + Model *string + Name *string + PartNumber *string PositionInRow uint32 - SerialNumber string + SerialNumber *string Speed uint32 - Tag string + Tag *string TotalWidth uint16 } @@ -51,11 +51,11 @@ func (ctx *context) memFillInfo(info *MemoryInfo) error { for _, description := range win32MemDescriptions { totalPhysicalBytes += description.Capacity info.Modules = append(info.Modules, &MemoryModule{ - Label: description.BankLabel, - Location: description.DeviceLocator, - SerialNumber: description.SerialNumber, + Label: *description.BankLabel, + Location: *description.DeviceLocator, + SerialNumber: *description.SerialNumber, SizeBytes: int64(description.Capacity), - Vendor: description.Manufacturer, + Vendor: *description.Manufacturer, }) } var totalUsableBytes uint64 diff --git a/net_windows.go b/net_windows.go index 1141a7d2..4c1d6646 100644 --- a/net_windows.go +++ b/net_windows.go @@ -14,16 +14,16 @@ import ( const wqlNetworkAdapter = "SELECT Description, DeviceID, Index, InterfaceIndex, MACAddress, Manufacturer, Name, NetConnectionID, ProductName, ServiceName FROM Win32_NetworkAdapter" type win32NetworkAdapter struct { - Description string - DeviceID string + Description *string + DeviceID *string Index uint32 InterfaceIndex uint32 - MACAddress string - Manufacturer string - Name string - NetConnectionID string - ProductName string - ServiceName string + MACAddress *string + Manufacturer *string + Name *string + NetConnectionID *string + ProductName *string + ServiceName *string } func (ctx *context) netFillInfo(info *NetworkInfo) error { @@ -43,7 +43,7 @@ func (ctx *context) nics(win32NetDescriptions []win32NetworkAdapter) []*NIC { for _, nicDescription := range win32NetDescriptions { nic := &NIC{ Name: ctx.netDeviceName(nicDescription), - MacAddress: nicDescription.MACAddress, + MacAddress: *nicDescription.MACAddress, IsVirtual: false, Capabilities: []*NICCapability{}, } @@ -56,10 +56,10 @@ func (ctx *context) nics(win32NetDescriptions []win32NetworkAdapter) []*NIC { func (ctx *context) netDeviceName(description win32NetworkAdapter) string { var name string - if strings.TrimSpace(description.NetConnectionID) != "" { - name = description.NetConnectionID + " - " + description.Description + if strings.TrimSpace(*description.NetConnectionID) != "" { + name = *description.NetConnectionID + " - " + *description.Description } else { - name = description.Description + name = *description.Description } return name } diff --git a/product_windows.go b/product_windows.go index c5483778..75fcf94b 100644 --- a/product_windows.go +++ b/product_windows.go @@ -12,14 +12,14 @@ import ( const wqlProduct = "SELECT Caption, Description, IdentifyingNumber, Name, SKUNumber, Vendor, Version, UUID FROM Win32_ComputerSystemProduct" type win32Product struct { - Caption string - Description string - IdentifyingNumber string - Name string - SKUNumber string - Vendor string - Version string - UUID string + Caption *string + Description *string + IdentifyingNumber *string + Name *string + SKUNumber *string + Vendor *string + Version *string + UUID *string } func (ctx *context) productFillInfo(info *ProductInfo) error { @@ -31,12 +31,12 @@ func (ctx *context) productFillInfo(info *ProductInfo) error { } if len(win32ProductDescriptions) > 0 { info.Family = UNKNOWN - info.Name = win32ProductDescriptions[0].Name - info.Vendor = win32ProductDescriptions[0].Vendor - info.SerialNumber = win32ProductDescriptions[0].IdentifyingNumber - info.UUID = win32ProductDescriptions[0].UUID - info.SKU = win32ProductDescriptions[0].SKUNumber - info.Version = win32ProductDescriptions[0].Version + info.Name = *win32ProductDescriptions[0].Name + info.Vendor = *win32ProductDescriptions[0].Vendor + info.SerialNumber = *win32ProductDescriptions[0].IdentifyingNumber + info.UUID = *win32ProductDescriptions[0].UUID + info.SKU = *win32ProductDescriptions[0].SKUNumber + info.Version = *win32ProductDescriptions[0].Version } return nil