# HG changeset patch # User moel.mich # Date 1342045719 0 # Node ID 0a386ef7d5bb7b91850477fffaf7a46048cfbe9a # Parent c1a4377c11d1e84b29620ac2ad5fecc057552b48 Fixed Issue 274. Fixed Issue 107. diff -r c1a4377c11d1 -r 0a386ef7d5bb Hardware/ATI/ADL.cs --- a/Hardware/ATI/ADL.cs Wed Jul 11 17:35:30 2012 +0000 +++ b/Hardware/ATI/ADL.cs Wed Jul 11 22:28:39 2012 +0000 @@ -162,7 +162,7 @@ where T : class { DllImportAttribute attribute = new DllImportAttribute(dllName); - attribute.CallingConvention = CallingConvention.StdCall; + attribute.CallingConvention = CallingConvention.Cdecl; attribute.PreserveSig = true; attribute.EntryPoint = entryPoint; PInvokeDelegateFactory.CreateDelegate(attribute, out newDelegate); diff -r c1a4377c11d1 -r 0a386ef7d5bb Hardware/OperatingSystem.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Hardware/OperatingSystem.cs Wed Jul 11 22:28:39 2012 +0000 @@ -0,0 +1,38 @@ +/* + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + + Copyright (C) 2012 Michael Möller + +*/ + +using System; +using System.Diagnostics; +using System.Runtime.InteropServices; + +namespace OpenHardwareMonitor.Hardware { + internal static class OperatingSystem { + + public static bool Is64BitOperatingSystem() { + if (IntPtr.Size == 8) + return true; + + try { + bool wow64Process; + bool result = IsWow64Process( + Process.GetCurrentProcess().Handle, out wow64Process); + + return result && wow64Process; + } catch (EntryPointNotFoundException) { + return false; + } + } + + [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + private static extern bool IsWow64Process(IntPtr hProcess, + out bool wow64Process); + } +} diff -r c1a4377c11d1 -r 0a386ef7d5bb Hardware/Ring0.cs --- a/Hardware/Ring0.cs Wed Jul 11 17:35:30 2012 +0000 +++ b/Hardware/Ring0.cs Wed Jul 11 22:28:39 2012 +0000 @@ -4,7 +4,7 @@ License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - Copyright (C) 2010-2011 Michael Möller + Copyright (C) 2010-2012 Michael Möller */ @@ -75,7 +75,8 @@ private static bool ExtractDriver(string fileName) { string resourceName = "OpenHardwareMonitor.Hardware." + - (IntPtr.Size == 4 ? "WinRing0.sys" : "WinRing0x64.sys"); + (OperatingSystem.Is64BitOperatingSystem() ? "WinRing0x64.sys" : + "WinRing0.sys"); string[] names = Assembly.GetExecutingAssembly().GetManifestResourceNames(); diff -r c1a4377c11d1 -r 0a386ef7d5bb OpenHardwareMonitorLib.csproj --- a/OpenHardwareMonitorLib.csproj Wed Jul 11 17:35:30 2012 +0000 +++ b/OpenHardwareMonitorLib.csproj Wed Jul 11 22:28:39 2012 +0000 @@ -92,6 +92,7 @@ +