-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed: API Moved from
IntPtr
to nuint
for addresses.
- Loading branch information
Showing
33 changed files
with
329 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
Source/Reloaded.Memory.Tests.x86/LargeAddressAwareTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using Xunit; | ||
|
||
namespace Reloaded.Memory.Tests.x86 | ||
{ | ||
public class LargeAddressAwareTests | ||
{ | ||
// TODO: Bring a new version of Reloaded.Memory.Buffers in. | ||
// once we make it large address aware using this latest Memory patch. | ||
|
||
#region P/Invoke | ||
void AssertLargeAddressAware() | ||
{ | ||
var maxAddress = GetMaxAddress(); | ||
if ((long)maxAddress <= int.MaxValue) | ||
Assert.False(true, "Test host is not large address aware!!"); | ||
} | ||
|
||
/// <summary> | ||
/// Contains information about the current computer system. This includes the architecture and type of the processor, the number of | ||
/// processors in the system, the page size, and other such information. | ||
/// </summary> | ||
[StructLayout(LayoutKind.Sequential, Pack = 2)] | ||
public struct SYSTEM_INFO | ||
{ | ||
public int wProcessorArchitecture; | ||
public ushort wReserved; | ||
public uint dwPageSize; | ||
public nuint lpMinimumApplicationAddress; | ||
public nuint lpMaximumApplicationAddress; | ||
public UIntPtr dwActiveProcessorMask; | ||
public uint dwNumberOfProcessors; | ||
public uint dwProcessorType; | ||
public uint dwAllocationGranularity; | ||
public ushort wProcessorLevel; | ||
public ushort wProcessorRevision; | ||
} | ||
|
||
/// <summary> | ||
/// <para>Retrieves information about the current system.</para> | ||
/// <para>To retrieve accurate information for an application running on WOW64, call the <c>GetNativeSystemInfo</c> function.</para> | ||
/// </summary> | ||
/// <param name="lpSystemInfo">A pointer to a <c>SYSTEM_INFO</c> structure that receives the information.</param> | ||
/// <returns>This function does not return a value.</returns> | ||
[DllImport("kernel32.dll")] | ||
public static extern void GetSystemInfo(out SYSTEM_INFO lpSystemInfo); | ||
|
||
/// <summary> | ||
/// Returns the max addressable address of the process sitting behind the <see cref="MemoryBufferHelper"/>. | ||
/// </summary> | ||
private nuint GetMaxAddress() | ||
{ | ||
// Is this Windows on Windows 64? (x86 app running on x64 Windows) | ||
GetSystemInfo(out SYSTEM_INFO systemInfo); | ||
long maxAddress = 0x7FFFFFFF; | ||
|
||
// Check for large address aware | ||
if (IntPtr.Size == 4 && (uint)systemInfo.lpMaximumApplicationAddress > maxAddress) | ||
maxAddress = (uint)systemInfo.lpMaximumApplicationAddress; | ||
|
||
return (nuint)maxAddress; | ||
} | ||
#endregion | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
Source/Reloaded.Memory.Tests.x86/Reloaded.Memory.Tests.x86.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks> | ||
<IsPackable>false</IsPackable> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<PlatformTarget>x86</PlatformTarget> | ||
<LangVersion>preview</LangVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="..\Reloaded.Memory.Tests\Memory\Endian.cs" Link="AnyCPU\Endian.cs" /> | ||
<Compile Include="..\Reloaded.Memory.Tests\Memory\Helpers\IArrayPtrGenerator.cs" Link="AnyCPU\Helpers\IArrayPtrGenerator.cs" /> | ||
<Compile Include="..\Reloaded.Memory.Tests\Memory\Helpers\IMemoryTools.cs" Link="AnyCPU\Helpers\IMemoryTools.cs" /> | ||
<Compile Include="..\Reloaded.Memory.Tests\Memory\Interop\Pinnable.cs" Link="AnyCPU\Interop\Pinnable.cs" /> | ||
<Compile Include="..\Reloaded.Memory.Tests\Memory\Interop\PinnableDisposable.cs" Link="AnyCPU\Interop\PinnableDisposable.cs" /> | ||
<Compile Include="..\Reloaded.Memory.Tests\Memory\Pointers\BlittablePointer.cs" Link="AnyCPU\Pointers\BlittablePointer.cs" /> | ||
<Compile Include="..\Reloaded.Memory.Tests\Memory\Pointers\FixedArrayPtr.cs" Link="AnyCPU\Pointers\FixedArrayPtr.cs" /> | ||
<Compile Include="..\Reloaded.Memory.Tests\Memory\Pointers\IArrayPtr.cs" Link="AnyCPU\Pointers\IArrayPtr.cs" /> | ||
<Compile Include="..\Reloaded.Memory.Tests\Memory\Pointers\Pointer.cs" Link="AnyCPU\Pointers\Pointer.cs" /> | ||
<Compile Include="..\Reloaded.Memory.Tests\Memory\Pointers\RefArrayPtr.cs" Link="AnyCPU\Pointers\RefArrayPtr.cs" /> | ||
<Compile Include="..\Reloaded.Memory.Tests\Memory\Pointers\RefFixedArrayPtr.cs" Link="AnyCPU\Pointers\RefFixedArrayPtr.cs" /> | ||
<Compile Include="..\Reloaded.Memory.Tests\Memory\Pointers\RefPointer.cs" Link="AnyCPU\Pointers\RefPointer.cs" /> | ||
<Compile Include="..\Reloaded.Memory.Tests\Memory\Sources\ExternalMemory.cs" Link="AnyCPU\Sources\ExternalMemory.cs" /> | ||
<Compile Include="..\Reloaded.Memory.Tests\Memory\Sources\IMemory.cs" Link="AnyCPU\Sources\IMemory.cs" /> | ||
<Compile Include="..\Reloaded.Memory.Tests\Memory\Sources\MemoryExtensions.cs" Link="AnyCPU\Sources\MemoryExtensions.cs" /> | ||
<Compile Include="..\Reloaded.Memory.Tests\Memory\Streams\BigEndianBufferedStreamReader.cs" Link="AnyCPU\Streams\BigEndianBufferedStreamReader.cs" /> | ||
<Compile Include="..\Reloaded.Memory.Tests\Memory\Streams\BigEndianExtendedMemoryStream.cs" Link="AnyCPU\Streams\BigEndianExtendedMemoryStream.cs" /> | ||
<Compile Include="..\Reloaded.Memory.Tests\Memory\Streams\BufferedStreamReader.cs" Link="AnyCPU\Streams\BufferedStreamReader.cs" /> | ||
<Compile Include="..\Reloaded.Memory.Tests\Memory\Streams\ExtendedMemoryStream.cs" Link="AnyCPU\Streams\ExtendedMemoryStream.cs" /> | ||
<Compile Include="..\Reloaded.Memory.Tests\Memory\StructArray.cs" Link="AnyCPU\StructArray.cs" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="coverlet.msbuild" Version="2.5.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> | ||
<PackageReference Include="xunit" Version="2.4.1" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Reloaded.Memory.Shared\Reloaded.Memory.Shared.csproj" /> | ||
<ProjectReference Include="..\Reloaded.Memory\Reloaded.Memory.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="AnyCPU\Helpers\" /> | ||
<Folder Include="AnyCPU\Interop\" /> | ||
<Folder Include="AnyCPU\Utilities\" /> | ||
<Folder Include="AnyCPU\Streams\" /> | ||
<Folder Include="AnyCPU\Sources\" /> | ||
<Folder Include="AnyCPU\Pointers\" /> | ||
<Folder Include="Properties\" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Include="..\Reloaded.Memory.Tests\HelloWorld.exe" Link="HelloWorld.exe"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Include="..\Reloaded.Memory.Tests\phys.bin" Link="phys.bin"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="HelloWorld.exe"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="phys.bin"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
</Project> |
2 changes: 2 additions & 0 deletions
2
Source/Reloaded.Memory.Tests.x86/Reloaded.Memory.Tests.x86.csproj.DotSettings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:String x:Key="/Default/CodeInspection/CSharpLanguageProject/LanguageLevel/@EntryValue">CSharp90</s:String></wpf:ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.