From 7614363308dbc5dfc8b64ed919746d4f7f8bc37e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=B6ller?= Date: Tue, 30 Dec 2014 22:49:32 +0000 Subject: [PATCH] Fixed an OverflowException when trying to use (unsupported) 64-bit thread affinity masks on 32-bit systems. --- Hardware/ThreadAffinity.cs | 14 ++++++++++---- Properties/AssemblyVersion.cs | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Hardware/ThreadAffinity.cs b/Hardware/ThreadAffinity.cs index 014f8dd..a4b8560 100755 --- a/Hardware/ThreadAffinity.cs +++ b/Hardware/ThreadAffinity.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 Michael Möller + Copyright (C) 2010-2014 Michael Möller */ @@ -29,9 +29,15 @@ namespace OpenHardwareMonitor.Hardware { ref mask) != 0) return 0; return result; - } else { // Windows - return (ulong)NativeMethods.SetThreadAffinityMask( - NativeMethods.GetCurrentThread(), (UIntPtr)mask); + } else { // Windows + UIntPtr uIntPtrMask; + try { + uIntPtrMask = (UIntPtr)mask; + } catch (OverflowException) { + throw new ArgumentOutOfRangeException("mask"); + } + return (ulong)NativeMethods.SetThreadAffinityMask( + NativeMethods.GetCurrentThread(), uIntPtrMask); } } diff --git a/Properties/AssemblyVersion.cs b/Properties/AssemblyVersion.cs index 30f67a7..bd71a49 100644 --- a/Properties/AssemblyVersion.cs +++ b/Properties/AssemblyVersion.cs @@ -10,5 +10,5 @@ using System.Reflection; -[assembly: AssemblyVersion("0.7.0.0")] -[assembly: AssemblyInformationalVersion("0.7.0 Beta")] \ No newline at end of file +[assembly: AssemblyVersion("0.7.1.0")] +[assembly: AssemblyInformationalVersion("0.7.1 Beta")] \ No newline at end of file