@@ -56,14 +56,14 @@ public class _HWiNFO_SENSOR
5656 {
5757 public uint SensorId ;
5858 public uint SensorInstance ;
59- [ MarshalAs ( UnmanagedType . ByValTStr , SizeConst = HWINFO_SENSORS_STRING_LEN ) ]
60- public string SensorNameOrig ;
61- [ MarshalAs ( UnmanagedType . ByValTStr , SizeConst = HWINFO_SENSORS_STRING_LEN ) ]
62- public string SensorNameUser ;
59+ [ MarshalAs ( UnmanagedType . ByValArray , SizeConst = HWINFO_SENSORS_STRING_LEN ) ]
60+ public byte [ ] SensorNameOrig ;
61+ [ MarshalAs ( UnmanagedType . ByValArray , SizeConst = HWINFO_SENSORS_STRING_LEN ) ]
62+ public byte [ ] SensorNameUser ;
6363
6464 // Version 2+ new:
65- [ MarshalAs ( UnmanagedType . ByValTStr , SizeConst = HWINFO_SENSORS_STRING_LEN ) ]
66- public string utfSensorNameUser ; // Sensor name displayed, which might be translated or renamed by user [UTF-8 string]
65+ [ MarshalAs ( UnmanagedType . ByValArray , SizeConst = HWINFO_SENSORS_STRING_LEN ) ]
66+ public byte [ ] UtfSensorNameUser ; // Sensor name displayed, which might be translated or renamed by user [UTF-8 string]
6767
6868 }
6969
@@ -73,22 +73,22 @@ public class _HWiNFO_ELEMENT
7373 public SENSOR_TYPE SensorType ;
7474 public uint SensorIndex ;
7575 public uint ElementId ;
76- [ MarshalAs ( UnmanagedType . ByValTStr , SizeConst = HWINFO_SENSORS_STRING_LEN ) ]
77- public string LabelOrig ;
78- [ MarshalAs ( UnmanagedType . ByValTStr , SizeConst = HWINFO_SENSORS_STRING_LEN ) ]
79- public string LabelUser ;
80- [ MarshalAs ( UnmanagedType . ByValTStr , SizeConst = HWINFO_UNIT_STRING_LEN ) ]
81- public string Unit ;
76+ [ MarshalAs ( UnmanagedType . ByValArray , SizeConst = HWINFO_SENSORS_STRING_LEN ) ]
77+ public byte [ ] LabelOrig ;
78+ [ MarshalAs ( UnmanagedType . ByValArray , SizeConst = HWINFO_SENSORS_STRING_LEN ) ]
79+ public byte [ ] LabelUser ;
80+ [ MarshalAs ( UnmanagedType . ByValArray , SizeConst = HWINFO_UNIT_STRING_LEN ) ]
81+ public byte [ ] Unit ;
8282 public double Value ;
8383 public double ValueMin ;
8484 public double ValueMax ;
8585 public double ValueAvg ;
8686
8787 // Version 2+ new:
88- [ MarshalAs ( UnmanagedType . ByValTStr , SizeConst = HWINFO_SENSORS_STRING_LEN ) ]
89- public string utfLabelUser ; // Label displayed, which might be translated or renamed by user [UTF-8 string]
90- [ MarshalAs ( UnmanagedType . ByValTStr , SizeConst = HWINFO_UNIT_STRING_LEN ) ]
91- public string utfUnit ; // e.g. "RPM" [UTF-8 string]
88+ [ MarshalAs ( UnmanagedType . ByValArray , SizeConst = HWINFO_SENSORS_STRING_LEN ) ]
89+ public byte [ ] UtfLabelUser ; // Label displayed, which might be translated or renamed by user [UTF-8 string]
90+ [ MarshalAs ( UnmanagedType . ByValArray , SizeConst = HWINFO_UNIT_STRING_LEN ) ]
91+ public byte [ ] UtfUnit ; // e.g. "RPM" [UTF-8 string]
9292 }
9393
9494 public class ElementObj
@@ -409,17 +409,21 @@ private static void ReadSensors(MemoryMappedFile mmf, _HWiNFO_SHARED_MEM hWiNFOM
409409
410410 if ( ! FullSensorData . ContainsKey ( index ) )
411411 {
412- var sensorName = structure . SensorNameUser ;
412+ var sensorNameOrig = Encoding . GetEncoding ( 1252 ) . GetString ( structure . SensorNameOrig ) . TrimEnd ( ( char ) 0 ) ;
413+
414+ var sensorName = Encoding . GetEncoding ( 1252 ) . GetString ( structure . SensorNameUser ) . TrimEnd ( ( char ) 0 ) ;
415+
413416 if ( hWiNFOMemory . Version > 1 )
414417 {
415- sensorName = structure . utfSensorNameUser ;
418+ sensorName = Encoding . UTF8 . GetString ( structure . UtfSensorNameUser ) . TrimEnd ( ( char ) 0 ) ;
419+
416420 }
417421
418422 var sensor = new SensorObj
419423 {
420424 SensorId = structure . SensorId ,
421425 SensorInstance = structure . SensorInstance ,
422- SensorNameOrig = structure . SensorNameOrig ,
426+ SensorNameOrig = sensorNameOrig ,
423427 SensorNameUser = sensorName ,
424428 Elements = new Dictionary < string , ElementObj > ( )
425429 } ;
@@ -461,16 +465,20 @@ private static void ReadElements(MemoryMappedFile mmf, _HWiNFO_SHARED_MEM hWiNFO
461465
462466 var elementKey = sensor . SensorId + "-" + sensor . SensorInstance + "-" + structure . ElementId ;
463467
464- var unit = structure . Unit ;
468+ var labelOrig = Encoding . GetEncoding ( 1252 ) . GetString ( structure . LabelOrig ) . TrimEnd ( ( char ) 0 ) ;
469+
470+ var unit = Encoding . GetEncoding ( 1252 ) . GetString ( structure . Unit ) . TrimEnd ( ( char ) 0 ) ;
471+
465472 if ( hWiNFOMemory . Version > 1 )
466473 {
467- unit = structure . utfUnit ;
474+ unit = Encoding . UTF8 . GetString ( structure . UtfUnit ) . TrimEnd ( ( char ) 0 ) ;
468475 }
469476
470- var label = structure . LabelUser ;
477+ var label = System . Text . Encoding . GetEncoding ( 1252 ) . GetString ( structure . LabelUser ) . TrimEnd ( ( char ) 0 ) ;
478+
471479 if ( hWiNFOMemory . Version > 1 )
472480 {
473- label = structure . utfLabelUser ;
481+ label = Encoding . UTF8 . GetString ( structure . UtfLabelUser ) . TrimEnd ( ( char ) 0 ) ;
474482 }
475483
476484 var element = new ElementObj
@@ -479,17 +487,17 @@ private static void ReadElements(MemoryMappedFile mmf, _HWiNFO_SHARED_MEM hWiNFO
479487
480488 SensorType = structure . SensorType ,
481489 ElementId = structure . ElementId ,
482- LabelOrig = structure . LabelOrig ,
490+ LabelOrig = labelOrig ,
483491 LabelUser = label ,
484492 Unit = unit ,
485- NumericValue = ( float ) RoundValue ( structure . SensorType , structure . Unit , structure . Value ) ,
486- Value = NumberFormat ( structure . SensorType , structure . Unit , structure . Value ) ,
487- ValueMin = NumberFormat ( structure . SensorType , structure . Unit , structure . ValueMin ) ,
488- ValueMax = NumberFormat ( structure . SensorType , structure . Unit , structure . ValueMax ) ,
489- ValueAvg = NumberFormat ( structure . SensorType , structure . Unit , structure . ValueAvg ) ,
493+ NumericValue = ( float ) RoundValue ( structure . SensorType , unit , structure . Value ) ,
494+ Value = NumberFormat ( structure . SensorType , unit , structure . Value ) ,
495+ ValueMin = NumberFormat ( structure . SensorType , unit , structure . ValueMin ) ,
496+ ValueMax = NumberFormat ( structure . SensorType , unit , structure . ValueMax ) ,
497+ ValueAvg = NumberFormat ( structure . SensorType , unit , structure . ValueAvg ) ,
490498 Node = null ,
491499 Name = null ,
492- DeviceClass = DeviceClass ( structure . SensorType , structure . Unit ) ,
500+ DeviceClass = DeviceClass ( structure . SensorType , unit ) ,
493501 Component = "sensor"
494502 } ;
495503
0 commit comments