Skip to content

Commit cc3d597

Browse files
added .Net 9 support + changes
1 parent 44d24be commit cc3d597

19 files changed

+702
-342
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
using System.Runtime.InteropServices;
3+
4+
namespace BSS.Random
5+
{
6+
/// <summary>
7+
/// Allows you to directly call the RDSEED and RDRAND instruction from C#
8+
/// </summary>
9+
public static partial class HWRandom
10+
{
11+
/// <summary>
12+
/// Executes the CPUID instruction and checks if RDRAND and RDSEED are implemented.
13+
/// </summary>
14+
/// <remarks><see href="https://www.intel.com/content/www/us/en/developer/articles/guide/intel-digital-random-number-generator-drng-software-implementation-guide.html#inpage-nav-5-undefined">Determining Processor Support for RDRAND and RDSEED - Intel.com</see></remarks>
15+
[DllImport("native.dll", EntryPoint = "GetSupportedInstructions")]
16+
public static extern SupportedInstructions GetSupportedInstructions();
17+
18+
/// <summary>
19+
/// Return value of <see cref="GetSupportedInstructions()"/>
20+
/// </summary>
21+
public enum SupportedInstructions : Int32
22+
{
23+
/// <summary>No support detected.</summary>
24+
None = 0,
25+
26+
/// <summary>RDSEEN and RDRAND are supported.</summary>
27+
All = 1,
28+
29+
/// <summary>Only RDRAND is supported.</summary>
30+
RDRAND = 2
31+
}
32+
}
33+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{831A5A0A-7036-40E9-BCAA-A7111F2369C6}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>HWRand.Net</RootNamespace>
11+
<AssemblyName>HWRand.Net</AssemblyName>
12+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
13+
<LangVersion>12.0</LangVersion>
14+
<Nullable>enable</Nullable>
15+
<FileAlignment>512</FileAlignment>
16+
<Deterministic>true</Deterministic>
17+
</PropertyGroup>
18+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
19+
<DebugSymbols>true</DebugSymbols>
20+
<DebugType>full</DebugType>
21+
<Optimize>false</Optimize>
22+
<OutputPath>bin\Debug\</OutputPath>
23+
<DefineConstants>DEBUG;TRACE</DefineConstants>
24+
<ErrorReport>prompt</ErrorReport>
25+
<WarningLevel>4</WarningLevel>
26+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
27+
<DocumentationFile>bin\Debug\HWRand.Net.xml</DocumentationFile>
28+
<PlatformTarget>x64</PlatformTarget>
29+
</PropertyGroup>
30+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
31+
<DebugType>pdbonly</DebugType>
32+
<Optimize>true</Optimize>
33+
<OutputPath>bin\Release\</OutputPath>
34+
<DefineConstants>TRACE</DefineConstants>
35+
<ErrorReport>prompt</ErrorReport>
36+
<WarningLevel>4</WarningLevel>
37+
<PlatformTarget>x64</PlatformTarget>
38+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
39+
<DocumentationFile>bin\Release\HWRand.Net.xml</DocumentationFile>
40+
</PropertyGroup>
41+
<ItemGroup>
42+
<Reference Include="System" />
43+
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
44+
<HintPath>..\..\..\7. Nuget Packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
45+
</Reference>
46+
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
47+
<HintPath>..\..\..\7. Nuget Packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
48+
</Reference>
49+
<Reference Include="System.Numerics" />
50+
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
51+
<HintPath>..\..\..\7. Nuget Packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
52+
</Reference>
53+
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
54+
<HintPath>..\..\..\7. Nuget Packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
55+
</Reference>
56+
</ItemGroup>
57+
<ItemGroup>
58+
<Compile Include="CheckHardwareSupport.cs" />
59+
<Compile Include="NextBytes.cs" />
60+
<Compile Include="Properties\AssemblyInfo.cs" />
61+
<Compile Include="RDRAND.cs" />
62+
<Compile Include="RDSEED.cs" />
63+
</ItemGroup>
64+
<ItemGroup>
65+
<None Include="app.config" />
66+
<None Include="packages.config" />
67+
</ItemGroup>
68+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
69+
<PropertyGroup>
70+
<PreBuildEvent>copy ..\..\..\x64\Release\native.dll native.dll
71+
</PreBuildEvent>
72+
</PropertyGroup>
73+
<PropertyGroup>
74+
<PostBuildEvent>copy ..\..\..\x64\Release\native.dll ..\..\..\Test-CLI-App\bin\Debug\native.dll
75+
copy ..\..\..\x64\Release\native.dll ..\..\..\Test-CLI-App\bin\Release\native.dll
76+
77+
robocopy .\ ..\..\..\Test-CLI-App\bin\Debug\ /xf *.tmp
78+
IF %25ERRORLEVEL%25 GEQ 8 exit 1
79+
80+
robocopy .\ ..\..\..\Test-CLI-App\bin\Release\ /xf *.tmp
81+
IF %25ERRORLEVEL%25 GEQ 8 exit 1
82+
exit 0</PostBuildEvent>
83+
</PropertyGroup>
84+
</Project>

0 commit comments

Comments
 (0)