diff -r 803f98bf1418 -r 6bce967ba1b5 Hardware/Ring0.cs --- a/Hardware/Ring0.cs Tue May 03 18:20:06 2011 +0000 +++ b/Hardware/Ring0.cs Sun May 08 22:10:13 2011 +0000 @@ -66,7 +66,9 @@ IOCTL_OLS_READ_PCI_CONFIG = new IOControlCode(OLS_TYPE, 0x851, IOControlCode.Access.Read), IOCTL_OLS_WRITE_PCI_CONFIG = new IOControlCode(OLS_TYPE, 0x852, - IOControlCode.Access.Write); + IOControlCode.Access.Write), + IOCTL_OLS_READ_MEMORY = new IOControlCode(OLS_TYPE, 0x841, + IOControlCode.Access.Read); private static bool ExtractDriver(string fileName) { string resourceName = "OpenHardwareMonitor.Hardware." + @@ -310,5 +312,26 @@ return driver.DeviceIOControl(IOCTL_OLS_WRITE_PCI_CONFIG, input); } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + private struct ReadMemoryInput { + public ulong address; + public uint unitSize; + public uint count; + } + + public static bool ReadMemory(ulong address, ref T buffer) { + if (driver == null) { + return false; + } + + ReadMemoryInput input = new ReadMemoryInput(); + input.address = address; + input.unitSize = 1; + input.count = (uint)Marshal.SizeOf(buffer); + + return driver.DeviceIOControl(IOCTL_OLS_READ_MEMORY, input, + ref buffer); + } } }