mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
[Refactor] Rollback to DllImport calls that need custom marshallers for now.
This commit is contained in:
@@ -38,7 +38,7 @@ namespace Aaru.Devices.Linux;
|
||||
|
||||
[Flags]
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
||||
enum FileFlags
|
||||
enum FileFlags : uint
|
||||
{
|
||||
/// <summary>O_RDONLY</summary>
|
||||
Readonly = 0x0,
|
||||
|
||||
@@ -42,7 +42,7 @@ static partial class Extern
|
||||
SetLastError = true,
|
||||
StringMarshalling = StringMarshalling.Custom,
|
||||
StringMarshallingCustomType = typeof(AnsiStringMarshaller))]
|
||||
internal static partial int open(string pathname, [MarshalAs(UnmanagedType.U4)] FileFlags flags);
|
||||
internal static partial int open(string pathname, FileFlags flags);
|
||||
|
||||
[LibraryImport("libc")]
|
||||
internal static partial int close(int fd);
|
||||
@@ -50,8 +50,8 @@ static partial class Extern
|
||||
[LibraryImport("libc", EntryPoint = "ioctl", SetLastError = true)]
|
||||
internal static partial int ioctlSg(int fd, LinuxIoctl request, ref SgIoHdrT value);
|
||||
|
||||
[LibraryImport("libc", EntryPoint = "ioctl", SetLastError = true)]
|
||||
internal static partial int ioctlMmc(int fd, LinuxIoctl request, ref MmcIocCmd value);
|
||||
[DllImport("libc", EntryPoint = "ioctl", SetLastError = true)]
|
||||
internal static extern int ioctlMmc(int fd, LinuxIoctl request, ref MmcIocCmd value);
|
||||
|
||||
[LibraryImport("libc",
|
||||
SetLastError = true,
|
||||
|
||||
@@ -46,20 +46,17 @@ static partial class Extern
|
||||
SetLastError = true,
|
||||
StringMarshalling = StringMarshalling.Utf16)]
|
||||
internal static partial SafeFileHandle CreateFile([MarshalAs(UnmanagedType.LPTStr)] string filename,
|
||||
[MarshalAs(UnmanagedType.U4)] FileAccess access,
|
||||
[MarshalAs(UnmanagedType.U4)] FileShare share,
|
||||
FileAccess access, FileShare share,
|
||||
nint securityAttributes, // optional SECURITY_ATTRIBUTES struct or IntPtr.Zero
|
||||
[MarshalAs(UnmanagedType.U4)] FileMode creationDisposition,
|
||||
[MarshalAs(UnmanagedType.U4)] FileAttributes flagsAndAttributes,
|
||||
FileMode creationDisposition, FileAttributes flagsAndAttributes,
|
||||
nint templateFile);
|
||||
|
||||
[LibraryImport("Kernel32.dll", EntryPoint = "DeviceIoControl", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static partial bool DeviceIoControlScsi(SafeFileHandle hDevice, WindowsIoctl ioControlCode,
|
||||
ref ScsiPassThroughDirectAndSenseBuffer inBuffer,
|
||||
uint nInBufferSize,
|
||||
ref ScsiPassThroughDirectAndSenseBuffer outBuffer,
|
||||
uint nOutBufferSize, ref uint pBytesReturned, nint overlapped);
|
||||
[DllImport("Kernel32.dll", SetLastError = true, EntryPoint = "DeviceIoControl", CharSet = CharSet.Auto)]
|
||||
internal static extern bool DeviceIoControlScsi(SafeFileHandle hDevice, WindowsIoctl ioControlCode,
|
||||
ref ScsiPassThroughDirectAndSenseBuffer inBuffer,
|
||||
uint nInBufferSize,
|
||||
ref ScsiPassThroughDirectAndSenseBuffer outBuffer,
|
||||
uint nOutBufferSize, ref uint pBytesReturned, nint overlapped);
|
||||
|
||||
[LibraryImport("Kernel32.dll", EntryPoint = "DeviceIoControl", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
@@ -68,19 +65,17 @@ static partial class Extern
|
||||
ref AtaPassThroughDirect outBuffer, uint nOutBufferSize,
|
||||
ref uint pBytesReturned, nint overlapped);
|
||||
|
||||
[LibraryImport("Kernel32.dll", EntryPoint = "DeviceIoControl", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static partial bool DeviceIoControlStorageQuery(SafeFileHandle hDevice, WindowsIoctl ioControlCode,
|
||||
ref StoragePropertyQuery inBuffer, uint nInBufferSize,
|
||||
nint outBuffer, uint nOutBufferSize,
|
||||
ref uint pBytesReturned, nint overlapped);
|
||||
[DllImport("Kernel32.dll", SetLastError = true, EntryPoint = "DeviceIoControl", CharSet = CharSet.Auto)]
|
||||
internal static extern bool DeviceIoControlStorageQuery(SafeFileHandle hDevice, WindowsIoctl ioControlCode,
|
||||
ref StoragePropertyQuery inBuffer, uint nInBufferSize,
|
||||
nint outBuffer, uint nOutBufferSize,
|
||||
ref uint pBytesReturned, nint overlapped);
|
||||
|
||||
[LibraryImport("Kernel32.dll", EntryPoint = "DeviceIoControl", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static partial bool DeviceIoControlIde(SafeFileHandle hDevice, WindowsIoctl ioControlCode,
|
||||
ref IdePassThroughDirect inBuffer, uint nInBufferSize,
|
||||
ref IdePassThroughDirect outBuffer, uint nOutBufferSize,
|
||||
ref uint pBytesReturned, nint overlapped);
|
||||
[DllImport("Kernel32.dll", SetLastError = true, EntryPoint = "DeviceIoControl", CharSet = CharSet.Auto)]
|
||||
internal static extern bool DeviceIoControlIde(SafeFileHandle hDevice, WindowsIoctl ioControlCode,
|
||||
ref IdePassThroughDirect inBuffer, uint nInBufferSize,
|
||||
ref IdePassThroughDirect outBuffer, uint nOutBufferSize,
|
||||
ref uint pBytesReturned, nint overlapped);
|
||||
|
||||
[LibraryImport("Kernel32.dll", EntryPoint = "DeviceIoControl", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
|
||||
@@ -1187,16 +1187,14 @@ static partial class Usb
|
||||
ref SpDeviceInterfaceData
|
||||
deviceInterfaceData);
|
||||
|
||||
[LibraryImport("setupapi.dll", EntryPoint = "SetupDiGetDeviceInterfaceDetailW", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static partial bool SetupDiGetDeviceInterfaceDetail(IntPtr deviceInfoSet,
|
||||
ref SpDeviceInterfaceData
|
||||
deviceInterfaceData,
|
||||
ref SpDeviceInterfaceDetailData
|
||||
deviceInterfaceDetailData,
|
||||
int deviceInterfaceDetailDataSize,
|
||||
ref int requiredSize,
|
||||
ref SpDevinfoData deviceInfoData);
|
||||
[DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
static extern bool SetupDiGetDeviceInterfaceDetail(IntPtr deviceInfoSet,
|
||||
ref SpDeviceInterfaceData deviceInterfaceData,
|
||||
ref SpDeviceInterfaceDetailData
|
||||
deviceInterfaceDetailData,
|
||||
int deviceInterfaceDetailDataSize,
|
||||
ref int requiredSize,
|
||||
ref SpDevinfoData deviceInfoData);
|
||||
|
||||
[LibraryImport("setupapi.dll",
|
||||
EntryPoint = "SetupDiGetDeviceRegistryPropertyW",
|
||||
@@ -1216,11 +1214,10 @@ static partial class Usb
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static partial bool SetupDiDestroyDeviceInfoList(IntPtr deviceInfoSet);
|
||||
|
||||
[LibraryImport("setupapi.dll", EntryPoint = "SetupDiGetDeviceInstanceIdW", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static partial bool SetupDiGetDeviceInstanceId(
|
||||
IntPtr deviceInfoSet, ref SpDevinfoData deviceInfoData, StringBuilder deviceInstanceId,
|
||||
int deviceInstanceIdSize, out int requiredSize);
|
||||
[DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
static extern bool SetupDiGetDeviceInstanceId(IntPtr deviceInfoSet, ref SpDevinfoData deviceInfoData,
|
||||
StringBuilder deviceInstanceId,
|
||||
int deviceInstanceIdSize, out int requiredSize);
|
||||
|
||||
[LibraryImport("kernel32.dll", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
|
||||
Reference in New Issue
Block a user