Converted project to VisualStudio 2012.
Adding SoundGraphDisplay and SensorFrontView classes.
They were respectively based on SystemTray and SensorNotifyIcon.
SoundGraphDisplay is now able to load iMONDisplay.dll providing it lives on your PATH.
Adding option to sensor context menu for adding it into FrontView.
3 This Source Code Form is subject to the terms of the Mozilla Public
4 License, v. 2.0. If a copy of the MPL was not distributed with this
5 file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 Copyright (C) 2011 Michael Möller <mmoeller@openhardwaremonitor.org>
12 using System.ComponentModel;
13 using System.Runtime.InteropServices;
16 namespace OpenHardwareMonitor.Hardware {
18 internal static class FirmwareTable {
20 public static byte[] GetTable(Provider provider, string table) {
21 int id = table[3] << 24 | table[2] << 16 | table[1] << 8 | table[0];
22 return GetTable(provider, id);
25 public static byte[] GetTable(Provider provider, int table) {
29 size = NativeMethods.GetSystemFirmwareTable(provider, table,
31 } catch (DllNotFoundException) { return null; }
32 catch (EntryPointNotFoundException) { return null; }
37 IntPtr nativeBuffer = Marshal.AllocHGlobal(size);
38 NativeMethods.GetSystemFirmwareTable(provider, table, nativeBuffer, size);
40 if (Marshal.GetLastWin32Error() != 0)
43 byte[] buffer = new byte[size];
44 Marshal.Copy(nativeBuffer, buffer, 0, size);
45 Marshal.FreeHGlobal(nativeBuffer);
50 public static string[] EnumerateTables(Provider provider) {
53 size = NativeMethods.EnumSystemFirmwareTables(
54 provider, IntPtr.Zero, 0);
55 } catch (DllNotFoundException) { return null; }
56 catch (EntryPointNotFoundException) { return null; }
58 IntPtr nativeBuffer = Marshal.AllocHGlobal(size);
59 NativeMethods.EnumSystemFirmwareTables(
60 provider, nativeBuffer, size);
61 byte[] buffer = new byte[size];
62 Marshal.Copy(nativeBuffer, buffer, 0, size);
63 Marshal.FreeHGlobal(nativeBuffer);
65 string[] result = new string[size / 4];
66 for (int i = 0; i < result.Length; i++)
67 result[i] = Encoding.ASCII.GetString(buffer, 4 * i, 4);
72 public enum Provider : int {
73 ACPI = (byte)'A' << 24 | (byte)'C' << 16 | (byte)'P' << 8 | (byte)'I',
74 FIRM = (byte)'F' << 24 | (byte)'I' << 16 | (byte)'R' << 8 | (byte)'M',
75 RSMB = (byte)'R' << 24 | (byte)'S' << 16 | (byte)'M' << 8 | (byte)'B'
78 private static class NativeMethods {
79 private const string KERNEL = "kernel32.dll";
81 [DllImport(KERNEL, CallingConvention = CallingConvention.Winapi,
83 public static extern int EnumSystemFirmwareTables(
84 Provider firmwareTableProviderSignature,
85 IntPtr firmwareTableBuffer, int bufferSize);
87 [DllImport(KERNEL, CallingConvention = CallingConvention.Winapi,
89 public static extern int GetSystemFirmwareTable(
90 Provider firmwareTableProviderSignature,
91 int firmwareTableID, IntPtr firmwareTableBuffer, int bufferSize);