1.1 --- a/Hardware/Ring0.cs Tue May 03 18:20:06 2011 +0000
1.2 +++ b/Hardware/Ring0.cs Sun May 08 22:10:13 2011 +0000
1.3 @@ -66,7 +66,9 @@
1.4 IOCTL_OLS_READ_PCI_CONFIG = new IOControlCode(OLS_TYPE, 0x851,
1.5 IOControlCode.Access.Read),
1.6 IOCTL_OLS_WRITE_PCI_CONFIG = new IOControlCode(OLS_TYPE, 0x852,
1.7 - IOControlCode.Access.Write);
1.8 + IOControlCode.Access.Write),
1.9 + IOCTL_OLS_READ_MEMORY = new IOControlCode(OLS_TYPE, 0x841,
1.10 + IOControlCode.Access.Read);
1.11
1.12 private static bool ExtractDriver(string fileName) {
1.13 string resourceName = "OpenHardwareMonitor.Hardware." +
1.14 @@ -310,5 +312,26 @@
1.15
1.16 return driver.DeviceIOControl(IOCTL_OLS_WRITE_PCI_CONFIG, input);
1.17 }
1.18 +
1.19 + [StructLayout(LayoutKind.Sequential, Pack = 1)]
1.20 + private struct ReadMemoryInput {
1.21 + public ulong address;
1.22 + public uint unitSize;
1.23 + public uint count;
1.24 + }
1.25 +
1.26 + public static bool ReadMemory<T>(ulong address, ref T buffer) {
1.27 + if (driver == null) {
1.28 + return false;
1.29 + }
1.30 +
1.31 + ReadMemoryInput input = new ReadMemoryInput();
1.32 + input.address = address;
1.33 + input.unitSize = 1;
1.34 + input.count = (uint)Marshal.SizeOf(buffer);
1.35 +
1.36 + return driver.DeviceIOControl(IOCTL_OLS_READ_MEMORY, input,
1.37 + ref buffer);
1.38 + }
1.39 }
1.40 }