Fixed Issue 274. Fixed Issue 107.
authormoel.mich
Wed, 11 Jul 2012 22:28:39 +0000
changeset 3610a386ef7d5bb
parent 360 c1a4377c11d1
child 362 1dfe9dac1651
Fixed Issue 274. Fixed Issue 107.
Hardware/ATI/ADL.cs
Hardware/OperatingSystem.cs
Hardware/Ring0.cs
OpenHardwareMonitorLib.csproj
     1.1 --- a/Hardware/ATI/ADL.cs	Wed Jul 11 17:35:30 2012 +0000
     1.2 +++ b/Hardware/ATI/ADL.cs	Wed Jul 11 22:28:39 2012 +0000
     1.3 @@ -162,7 +162,7 @@
     1.4        where T : class 
     1.5      {
     1.6        DllImportAttribute attribute = new DllImportAttribute(dllName);
     1.7 -      attribute.CallingConvention = CallingConvention.StdCall;
     1.8 +      attribute.CallingConvention = CallingConvention.Cdecl;
     1.9        attribute.PreserveSig = true;
    1.10        attribute.EntryPoint = entryPoint;
    1.11        PInvokeDelegateFactory.CreateDelegate(attribute, out newDelegate);
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/Hardware/OperatingSystem.cs	Wed Jul 11 22:28:39 2012 +0000
     2.3 @@ -0,0 +1,38 @@
     2.4 +/*
     2.5 + 
     2.6 +  This Source Code Form is subject to the terms of the Mozilla Public
     2.7 +  License, v. 2.0. If a copy of the MPL was not distributed with this
     2.8 +  file, You can obtain one at http://mozilla.org/MPL/2.0/.
     2.9 + 
    2.10 +  Copyright (C) 2012 Michael Möller <mmoeller@openhardwaremonitor.org>
    2.11 +	
    2.12 +*/
    2.13 +
    2.14 +using System;
    2.15 +using System.Diagnostics;
    2.16 +using System.Runtime.InteropServices;
    2.17 +
    2.18 +namespace OpenHardwareMonitor.Hardware {
    2.19 +  internal static class OperatingSystem {
    2.20 +
    2.21 +    public static bool Is64BitOperatingSystem() {
    2.22 +      if (IntPtr.Size == 8)
    2.23 +        return true;
    2.24 +
    2.25 +      try {
    2.26 +        bool wow64Process;
    2.27 +        bool result = IsWow64Process(
    2.28 +          Process.GetCurrentProcess().Handle, out wow64Process);
    2.29 +
    2.30 +        return result && wow64Process;
    2.31 +      } catch (EntryPointNotFoundException) {
    2.32 +        return false;
    2.33 +      }
    2.34 +    }
    2.35 +
    2.36 +    [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
    2.37 +    [return: MarshalAs(UnmanagedType.Bool)]
    2.38 +    private static extern bool IsWow64Process(IntPtr hProcess,
    2.39 +      out bool wow64Process);
    2.40 +  }
    2.41 +}
     3.1 --- a/Hardware/Ring0.cs	Wed Jul 11 17:35:30 2012 +0000
     3.2 +++ b/Hardware/Ring0.cs	Wed Jul 11 22:28:39 2012 +0000
     3.3 @@ -4,7 +4,7 @@
     3.4    License, v. 2.0. If a copy of the MPL was not distributed with this
     3.5    file, You can obtain one at http://mozilla.org/MPL/2.0/.
     3.6   
     3.7 -  Copyright (C) 2010-2011 Michael Möller <mmoeller@openhardwaremonitor.org>
     3.8 +  Copyright (C) 2010-2012 Michael Möller <mmoeller@openhardwaremonitor.org>
     3.9  	
    3.10  */
    3.11  
    3.12 @@ -75,7 +75,8 @@
    3.13  
    3.14      private static bool ExtractDriver(string fileName) {
    3.15        string resourceName = "OpenHardwareMonitor.Hardware." +
    3.16 -        (IntPtr.Size == 4 ? "WinRing0.sys" : "WinRing0x64.sys");
    3.17 +        (OperatingSystem.Is64BitOperatingSystem() ? "WinRing0x64.sys" : 
    3.18 +        "WinRing0.sys");
    3.19  
    3.20        string[] names =
    3.21          Assembly.GetExecutingAssembly().GetManifestResourceNames();
     4.1 --- a/OpenHardwareMonitorLib.csproj	Wed Jul 11 17:35:30 2012 +0000
     4.2 +++ b/OpenHardwareMonitorLib.csproj	Wed Jul 11 22:28:39 2012 +0000
     4.3 @@ -92,6 +92,7 @@
     4.4      <Compile Include="Hardware\LPC\NCT677X.cs" />
     4.5      <Compile Include="Hardware\Mainboard\GigabyteTAMG.cs" />
     4.6      <Compile Include="Hardware\Opcode.cs" />
     4.7 +    <Compile Include="Hardware\OperatingSystem.cs" />
     4.8      <Compile Include="Hardware\Ring0.cs" />
     4.9      <Compile Include="Hardware\KernelDriver.cs" />
    4.10      <Compile Include="Hardware\Hardware.cs" />