NET5 support (#312)

Thanks to @Pomianowski
This commit is contained in:
Pomian
2020-11-24 10:01:15 +01:00
committed by GitHub
parent db74902da6
commit 9ee5238798
3 changed files with 19 additions and 18 deletions
@@ -78,7 +78,7 @@ namespace LibreHardwareMonitor.Hardware
AdvApi32.CloseServiceHandle(service);
AdvApi32.CloseServiceHandle(manager);
#if !NETSTANDARD2_0
#if NETFRAMEWORK
try
{
// restrict the driver access to system (SY) and builtin admins (BA)
+10 -10
View File
@@ -1,7 +1,7 @@
// 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) LibreHardwareMonitor and Contributors.
// Partial Copyright (C) Michael Möller <mmoeller@openhardwaremonitor.org> and Contributors.
// Partial Copyright (C) Michael Möller <mmoeller@openhardwaremonitor.org> and Contributors.
// All Rights Reserved.
using System;
@@ -220,25 +220,25 @@ namespace LibreHardwareMonitor.Hardware
try
{
#if NETSTANDARD2_0
_isaBusMutex = new Mutex(false, isaMutexName);
#else
#if NETFRAMEWORK
//mutex permissions set to everyone to allow other software to access the hardware
//otherwise other monitoring software cant access
var allowEveryoneRule = new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), MutexRights.FullControl, AccessControlType.Allow);
var securitySettings = new MutexSecurity();
securitySettings.AddAccessRule(allowEveryoneRule);
_isaBusMutex = new Mutex(false, isaMutexName, out _, securitySettings);
#else
_isaBusMutex = new Mutex(false, isaMutexName);
#endif
}
catch (UnauthorizedAccessException)
{
try
{
#if NETSTANDARD2_0
_isaBusMutex = Mutex.OpenExisting(isaMutexName);
#else
#if NETFRAMEWORK
_isaBusMutex = Mutex.OpenExisting(isaMutexName, MutexRights.Synchronize);
#else
_isaBusMutex = Mutex.OpenExisting(isaMutexName);
#endif
}
catch
@@ -255,10 +255,10 @@ namespace LibreHardwareMonitor.Hardware
{
try
{
#if NETSTANDARD2_0
_pciBusMutex = Mutex.OpenExisting(pciMutexName);
#else
#if NETFRAMEWORK
_pciBusMutex = Mutex.OpenExisting(pciMutexName, MutexRights.Synchronize);
#else
_pciBusMutex = Mutex.OpenExisting(pciMutexName);
#endif
}
catch
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net452;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net452;netstandard2.0;net5.0</TargetFrameworks>
<AssemblyName>LibreHardwareMonitorLib</AssemblyName>
<RootNamespace>LibreHardwareMonitor</RootNamespace>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
@@ -26,12 +26,13 @@
<EmbeddedResource Include="Hardware\WinRing0x64.sys" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.Win32.Registry">
<Version>4.7.0</Version>
</PackageReference>
<PackageReference Include="System.IO.Ports">
<Version>4.7.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.Win32.Registry" Version="4.7.0" />
<PackageReference Include="System.IO.Ports" Version="4.7.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
<PackageReference Include="System.IO.Ports" Version="5.0.0" />
<PackageReference Include="System.Management" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="HidSharp" Version="2.1.0" />