Skip to content

Commit

Permalink
.NET 9 adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
LTRData committed Nov 12, 2024
1 parent 7e0fd50 commit 89481b2
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net48;net6.0-windows;net7.0-windows;net8.0-windows</TargetFrameworks>
<TargetFrameworks>net48;net8.0-windows;net9.0-windows</TargetFrameworks>
<GeneratePackageOnBuild Condition="'$(Configuration)' == 'Release'">true</GeneratePackageOnBuild>
<Description>Arsenal Image Mounter Windows Forms Library</Description>
<UseWindowsForms>true</UseWindowsForms>
Expand Down
6 changes: 3 additions & 3 deletions Managed Source/Arsenal.ImageMounter.Forms/DriverSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ public static Version GetSetupFileDriverVersion(string setupRoot) =>
/// <param name="infFile">.inf file used to identify version of driver.</param>
public static Version GetSetupFileDriverVersion(CachedIniFile infFile) =>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP
Version.Parse(GetInfFileVersionTag(infFile).AsSpan().SplitReverse(',').First());
Version.Parse(GetInfFileVersionTag(infFile).AsSpan().TokenEnumReverse(',').First());
#else
Version.Parse(GetInfFileVersionTag(infFile).AsSpan().SplitReverse(',').First().ToString());
Version.Parse(GetInfFileVersionTag(infFile).AsSpan().TokenEnumReverse(',').First().ToString());
#endif

private static string GetInfFileVersionTag(CachedIniFile infFile)
Expand Down Expand Up @@ -280,7 +280,7 @@ where File.Exists(p)

var pending_install_file = (from item in CachedIniFile.EnumerateFileSectionValuePairs(infPath, "PhysicalDiskMounterDevice.Services")
where "AddService".Equals(item.Key, StringComparison.OrdinalIgnoreCase)
select $"{item.Value.AsMemory().Split(',').First()}.sys").FirstOrDefault(installfile => array.Contains(installfile, StringComparer.OrdinalIgnoreCase));
select $"{item.Value.AsMemory().TokenEnum(',').First()}.sys").FirstOrDefault(installfile => array.Contains(installfile, StringComparer.OrdinalIgnoreCase));

if (pending_install_file != null)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net48;net8.0</TargetFrameworks>
<TargetFrameworks>net48;net8.0;net9.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>Arsenal.ImageMounter.PowerShell</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.PowerShell.5.ReferenceAssemblies" Version="*" Condition="'$(TargetFramework)' == 'net48'" />
<PackageReference Include="System.Management.Automation" Version="*" Condition="'$(TargetFramework)' == 'net8.0'" />
<PackageReference Include="System.Management.Automation" Version="*" Condition="'$(TargetFramework.CompareTo(`net8`))' &gt;= 0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ protected override void ProcessRecord()

service.StartServiceThreadAndMount(ScsiAdapter, 0);

var device_name = $@"\\?\{service.GetDiskDeviceName()}";

if (Online)
{
var device_name = $@"\\?\{service.GetDiskDeviceName()}";

using (var device = new DiskDevice(device_name, FileAccess.ReadWrite))
{
if (device.DiskPolicyReadOnly == true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public override string ToString()

var msgs = msg
.AsMemory()
.SplitReverse('\n')
.TokenEnumReverse('\n')
.Select(msg => msg.TrimEnd('\r'));

return string.Join(Environment.NewLine, msgs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public override string ToString()

var msgs = msg
.AsMemory()
.SplitReverse('\n')
.TokenEnumReverse('\n')
.Select(msg => msg.TrimEnd('\r'));

return string.Join(Environment.NewLine, msgs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
using System.Security.AccessControl;
using System.Threading;



namespace Arsenal.ImageMounter.IO.Devices;

/// <summary>
Expand Down
26 changes: 13 additions & 13 deletions Managed Source/Arsenal.ImageMounter/IO/Native/NativeFileIO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -344,19 +344,19 @@ public static partial class UnsafeNativeMethods

[LibraryImport("kernel32", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool DeviceIoControl(SafeFileHandle hDevice, uint dwIoControlCode, nint lpInBuffer, uint nInBufferSize, out byte lpOutBuffer, uint nOutBufferSize, out uint lpBytesReturned, nint lpOverlapped);
internal static partial bool DeviceIoControl(SafeFileHandle hDevice, uint dwIoControlCode, nint lpInBuffer, uint nInBufferSize, ref byte lpOutBuffer, uint nOutBufferSize, out uint lpBytesReturned, nint lpOverlapped);

[LibraryImport("kernel32", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool DeviceIoControl(SafeFileHandle hDevice, uint dwIoControlCode, in long lpInBuffer, uint nInBufferSize, out byte lpOutBuffer, uint nOutBufferSize, out uint lpBytesReturned, nint lpOverlapped);
internal static partial bool DeviceIoControl(SafeFileHandle hDevice, uint dwIoControlCode, in long lpInBuffer, uint nInBufferSize, ref byte lpOutBuffer, uint nOutBufferSize, out uint lpBytesReturned, nint lpOverlapped);

[LibraryImport("kernel32", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool DeviceIoControl(SafeFileHandle hDevice, uint dwIoControlCode, in byte lpInBuffer, uint nInBufferSize, nint lpOutBuffer, uint nOutBufferSize, out uint lpBytesReturned, nint lpOverlapped);

[LibraryImport("kernel32", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool DeviceIoControl(SafeFileHandle hDevice, uint dwIoControlCode, in byte lpInBuffer, int nInBufferSize, out byte lpOutBuffer, int nOutBufferSize, out int lpBytesReturned, nint lpOverlapped);
internal static partial bool DeviceIoControl(SafeFileHandle hDevice, uint dwIoControlCode, in byte lpInBuffer, int nInBufferSize, ref byte lpOutBuffer, int nOutBufferSize, out int lpBytesReturned, nint lpOverlapped);

[LibraryImport("kernel32", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
Expand Down Expand Up @@ -420,7 +420,7 @@ public static partial class UnsafeNativeMethods

[LibraryImport("kernel32", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool DeviceIoControl(SafeFileHandle hDevice, uint dwIoControlCode, in STORAGE_PROPERTY_QUERY lpInBuffer, uint nInBufferSize, out byte lpOutBuffer, uint nOutBufferSize, out uint lpBytesReturned, nint lpOverlapped);
internal static partial bool DeviceIoControl(SafeFileHandle hDevice, uint dwIoControlCode, in STORAGE_PROPERTY_QUERY lpInBuffer, uint nInBufferSize, ref byte lpOutBuffer, uint nOutBufferSize, out uint lpBytesReturned, nint lpOverlapped);

[LibraryImport("kernel32", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GetModuleFileNameW(nint hModule, out char lpFilename, int nSize);
Expand Down Expand Up @@ -838,16 +838,16 @@ public static partial class UnsafeNativeMethods
internal static extern bool DeviceIoControl(SafeFileHandle hDevice, uint dwIoControlCode, in bool lpInBuffer, uint nInBufferSize, nint lpOutBuffer, uint nOutBufferSize, out uint lpBytesReturned, nint lpOverlapped);

[DllImport("kernel32", SetLastError = true)]
internal static extern bool DeviceIoControl(SafeFileHandle hDevice, uint dwIoControlCode, nint lpInBuffer, uint nInBufferSize, out byte lpOutBuffer, uint nOutBufferSize, out uint lpBytesReturned, nint lpOverlapped);
internal static extern bool DeviceIoControl(SafeFileHandle hDevice, uint dwIoControlCode, nint lpInBuffer, uint nInBufferSize, ref byte lpOutBuffer, uint nOutBufferSize, out uint lpBytesReturned, nint lpOverlapped);

[DllImport("kernel32", SetLastError = true)]
internal static extern bool DeviceIoControl(SafeFileHandle hDevice, uint dwIoControlCode, in long lpInBuffer, uint nInBufferSize, out byte lpOutBuffer, uint nOutBufferSize, out uint lpBytesReturned, nint lpOverlapped);
internal static extern bool DeviceIoControl(SafeFileHandle hDevice, uint dwIoControlCode, in long lpInBuffer, uint nInBufferSize, ref byte lpOutBuffer, uint nOutBufferSize, out uint lpBytesReturned, nint lpOverlapped);

[DllImport("kernel32", SetLastError = true)]
internal static extern bool DeviceIoControl(SafeFileHandle hDevice, uint dwIoControlCode, in byte lpInBuffer, uint nInBufferSize, nint lpOutBuffer, uint nOutBufferSize, out uint lpBytesReturned, nint lpOverlapped);

[DllImport("kernel32", SetLastError = true)]
internal static extern bool DeviceIoControl(SafeFileHandle hDevice, uint dwIoControlCode, in byte lpInBuffer, int nInBufferSize, out byte lpOutBuffer, int nOutBufferSize, out int lpBytesReturned, nint lpOverlapped);
internal static extern bool DeviceIoControl(SafeFileHandle hDevice, uint dwIoControlCode, in byte lpInBuffer, int nInBufferSize, ref byte lpOutBuffer, int nOutBufferSize, out int lpBytesReturned, nint lpOverlapped);

[DllImport("kernel32", SetLastError = true)]
internal static extern bool DeviceIoControl(SafeFileHandle hDevice, uint dwIoControlCode, nint lpInBuffer, uint nInBufferSize, nint lpOutBuffer, uint nOutBufferSize, out uint lpBytesReturned, nint lpOverlapped);
Expand Down Expand Up @@ -895,7 +895,7 @@ public static partial class UnsafeNativeMethods
internal static extern bool DeviceIoControl(SafeFileHandle hDevice, uint dwIoControlCode, in STORAGE_PROPERTY_QUERY lpInBuffer, uint nInBufferSize, out DEVICE_TRIM_DESCRIPTOR lpOutBuffer, uint nOutBufferSize, out uint lpBytesReturned, nint lpOverlapped);

[DllImport("kernel32", SetLastError = true)]
internal static extern bool DeviceIoControl(SafeFileHandle hDevice, uint dwIoControlCode, in STORAGE_PROPERTY_QUERY lpInBuffer, uint nInBufferSize, out byte lpOutBuffer, uint nOutBufferSize, out uint lpBytesReturned, nint lpOverlapped);
internal static extern bool DeviceIoControl(SafeFileHandle hDevice, uint dwIoControlCode, in STORAGE_PROPERTY_QUERY lpInBuffer, uint nInBufferSize, ref byte lpOutBuffer, uint nOutBufferSize, out uint lpBytesReturned, nint lpOverlapped);

[DllImport("kernel32", SetLastError = true, CharSet = CharSet.Unicode)]
internal static extern int GetModuleFileNameW(nint hModule, out char lpFilename, int nSize);
Expand Down Expand Up @@ -2333,7 +2333,7 @@ public static unsafe bool GetAllocationBitmap(SafeFileHandle rootDirectory,
NativeConstants.FSCTL_GET_VOLUME_BITMAP,
startingCluster,
sizeof(long),
out buffer[0],
ref buffer[0],
(uint)buffer.Length,
out var bytesReturned,
0))
Expand Down Expand Up @@ -2423,7 +2423,7 @@ public static Span<byte> DeviceIoControl(SafeFileHandle device, uint ctrlcode, S
ctrlcode,
indata.AsRef(),
indatasize,
out data.AsRef(),
ref data.AsRef(),
data.Length,
out outdatasize,
0);
Expand Down Expand Up @@ -3225,7 +3225,7 @@ public static async Task<bool> DismountVolumeFilesystemAsync(SafeFileHandle Devi
NativeConstants.IOCTL_STORAGE_QUERY_PROPERTY,
StoragePropertyQuery,
(uint)PinnedBuffer<STORAGE_PROPERTY_QUERY>.TypeSize,
out buffer[0],
ref buffer[0],
(uint)buffer.Length,
out _,
0)
Expand Down Expand Up @@ -3362,7 +3362,7 @@ public static void SetFileSparseFlag(SafeFileHandle file, bool flag)
NativeConstants.FSCTL_GET_REPARSE_POINT,
0,
0U,
out buffer[0],
ref buffer[0],
(uint)buffer.Length,
out var size,
0))
Expand Down Expand Up @@ -3672,7 +3672,7 @@ public DriveLayoutInformationGPT(DRIVE_LAYOUT_INFORMATION_EX DriveLayoutInformat
NativeConstants.IOCTL_DISK_GET_DRIVE_LAYOUT_EX,
0,
0U,
out buffer[0],
ref buffer[0],
(uint)buffer.Length,
out var arglpBytesReturned,
0))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -881,9 +881,9 @@ public struct FindStreamData

private unsafe fixed char _streamName[296];

public ReadOnlySpan<char> NamePart => StreamName.Split(':').ElementAtOrDefault(1);
public ReadOnlySpan<char> NamePart => StreamName.TokenEnum(':').ElementAtOrDefault(1);

public ReadOnlySpan<char> TypePart => StreamName.Split(':').ElementAtOrDefault(2);
public ReadOnlySpan<char> TypePart => StreamName.TokenEnum(':').ElementAtOrDefault(2);

public unsafe ReadOnlySpan<char> StreamName => BufferExtensions.CreateReadOnlySpan(_streamName[0], 296).ReadNullTerminatedUnicode();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<OutputType>Exe</OutputType>
<UseWindowsForms>true</UseWindowsForms>
<Title>Arsenal Image Mounter Command Line Setup</Title>
<TargetFrameworks>net48;net6.0-windows;net7.0-windows;net8.0-windows</TargetFrameworks>
<TargetFrameworks>net48;net8.0-windows;net9.0-windows</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<UseWindowsForms>true</UseWindowsForms>
<Title>Arsenal Image Mounter Setup</Title>
<StartupObject>Arsenal.ImageMounter.MainForm</StartupObject>
<TargetFrameworks>net48;net6.0-windows;net7.0-windows;net8.0-windows</TargetFrameworks>
<TargetFrameworks>net48;net8.0-windows;net9.0-windows</TargetFrameworks>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<OutputType>WinExe</OutputType>
<UseWindowsForms>true</UseWindowsForms>
<Title>Arsenal Image Mounter Mount Tool</Title>
<TargetFrameworks>net48;net6.0-windows;net7.0-windows;net8.0-windows</TargetFrameworks>
<TargetFrameworks>net48;net8.0-windows;net9.0-windows</TargetFrameworks>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>

Expand Down
4 changes: 2 additions & 2 deletions Managed Source/Directory.build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>

<TargetFrameworks>net48;netstandard2.1;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net48;netstandard2.1;net8.0;net9.0</TargetFrameworks>
<RootNamespace>Arsenal.ImageMounter</RootNamespace>
<OutputPath Condition="'$(MSBuildProjectExtension)' != '.shfbproj'">..\bin\$(Configuration)\</OutputPath>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand All @@ -26,7 +26,7 @@
<Product>Arsenal Image Mounter</Product>
<Copyright>Copyright © Arsenal Recon, 2015 - 2024</Copyright>
<Trademark />
<FileVersion>3.11.294.0</FileVersion>
<FileVersion>3.11.295.0</FileVersion>
<ProductVersion>$(FileVersion)</ProductVersion>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<Authors>Arsenal Recon</Authors>
Expand Down
2 changes: 1 addition & 1 deletion Managed Source/TestProject/TestProject.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0-windows;net7.0-windows;net8.0-windows;net48</TargetFrameworks>
<TargetFrameworks>net8.0-windows;net9.0-windows;net48</TargetFrameworks>
<RegisterForComInterop>false</RegisterForComInterop>
<IsPackable>false</IsPackable>
<NoWarn>1591</NoWarn>
Expand Down

0 comments on commit 89481b2

Please sign in to comment.