diff --git a/Hardware/ATI/ADL.cs b/Hardware/ATI/ADL.cs index b594031..51f14f2 100644 --- a/Hardware/ATI/ADL.cs +++ b/Hardware/ATI/ADL.cs @@ -162,7 +162,7 @@ namespace OpenHardwareMonitor.Hardware.ATI { 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 --git a/Hardware/OperatingSystem.cs b/Hardware/OperatingSystem.cs new file mode 100644 index 0000000..6cc2b34 --- /dev/null +++ b/Hardware/OperatingSystem.cs @@ -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 --git a/Hardware/Ring0.cs b/Hardware/Ring0.cs index 48d4797..d03893b 100644 --- a/Hardware/Ring0.cs +++ b/Hardware/Ring0.cs @@ -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 @@ namespace OpenHardwareMonitor.Hardware { 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 --git a/OpenHardwareMonitorLib.csproj b/OpenHardwareMonitorLib.csproj index 5e46a02..a590237 100644 --- a/OpenHardwareMonitorLib.csproj +++ b/OpenHardwareMonitorLib.csproj @@ -92,6 +92,7 @@ +