Bump Microsoft.Windows.CsWin32 from 0.3.235 to 0.3.236 (#1999)
* Bump Microsoft.Windows.CsWin32 from 0.3.235 to 0.3.236 --- updated-dependencies: - dependency-name: Microsoft.Windows.CsWin32 dependency-version: 0.3.236 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * Fix build compatibility with Microsoft.Windows.CsWin32 0.3.236 (#2000) * Initial plan * Fix compatibility with CsWin32 0.3.236 and resource path case sensitivity Co-authored-by: PhyxionNL <7643972+PhyxionNL@users.noreply.github.com> * Remove unnecessary local variable pData in BatteryGroup.cs Co-authored-by: PhyxionNL <7643972+PhyxionNL@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: PhyxionNL <7643972+PhyxionNL@users.noreply.github.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: PhyxionNL <7643972+PhyxionNL@users.noreply.github.com>
This commit is contained in:
co-authored by
PhyxionNL
copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Copilot
parent
b1b76c3d18
commit
cbd3f4b1d2
@@ -5,6 +5,7 @@
|
||||
|
||||
using System;
|
||||
using Windows.Win32;
|
||||
using Windows.Win32.Foundation;
|
||||
using Windows.Win32.System.Power;
|
||||
using LibreHardwareMonitor.Interop;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
@@ -137,7 +138,7 @@ internal sealed class Battery : Hardware
|
||||
BATTERY_WAIT_STATUS bws = default;
|
||||
bws.BatteryTag = _batteryTag;
|
||||
BATTERY_STATUS batteryStatus = default;
|
||||
if (PInvoke.DeviceIoControl(_batteryHandle,
|
||||
if (PInvoke.DeviceIoControl((HANDLE)_batteryHandle.DangerousGetHandle(),
|
||||
PInvoke.IOCTL_BATTERY_QUERY_STATUS,
|
||||
&bws,
|
||||
(uint)sizeof(BATTERY_WAIT_STATUS),
|
||||
@@ -201,7 +202,7 @@ internal sealed class Battery : Hardware
|
||||
BATTERY_QUERY_INFORMATION bqi = default;
|
||||
bqi.BatteryTag = _batteryTag;
|
||||
bqi.InformationLevel = BATTERY_QUERY_INFORMATION_LEVEL.BatteryEstimatedTime;
|
||||
if (PInvoke.DeviceIoControl(_batteryHandle,
|
||||
if (PInvoke.DeviceIoControl((HANDLE)_batteryHandle.DangerousGetHandle(),
|
||||
PInvoke.IOCTL_BATTERY_QUERY_INFORMATION,
|
||||
&bqi,
|
||||
(uint)sizeof(BATTERY_QUERY_INFORMATION),
|
||||
@@ -222,7 +223,7 @@ internal sealed class Battery : Hardware
|
||||
|
||||
uint temperature = 0;
|
||||
bqi.InformationLevel = BATTERY_QUERY_INFORMATION_LEVEL.BatteryTemperature;
|
||||
if (PInvoke.DeviceIoControl(_batteryHandle,
|
||||
if (PInvoke.DeviceIoControl((HANDLE)_batteryHandle.DangerousGetHandle(),
|
||||
PInvoke.IOCTL_BATTERY_QUERY_INFORMATION,
|
||||
&bqi,
|
||||
(uint)sizeof(BATTERY_QUERY_INFORMATION),
|
||||
|
||||
@@ -53,8 +53,8 @@ internal class BatteryGroup : IGroup
|
||||
{
|
||||
uint cbRequired = 0;
|
||||
|
||||
PInvoke.SetupDiGetDeviceInterfaceDetail(hdev,
|
||||
data,
|
||||
PInvoke.SetupDiGetDeviceInterfaceDetail((HDEVINFO)hdev.DangerousGetHandle(),
|
||||
&data,
|
||||
null,
|
||||
0,
|
||||
&cbRequired,
|
||||
@@ -63,19 +63,19 @@ internal class BatteryGroup : IGroup
|
||||
if (Marshal.GetLastWin32Error() == (int)WIN32_ERROR.ERROR_INSUFFICIENT_BUFFER)
|
||||
{
|
||||
IntPtr buffer = Marshal.AllocHGlobal((int)cbRequired);
|
||||
SP_DEVICE_INTERFACE_DETAIL_DATA_W* pData = (SP_DEVICE_INTERFACE_DETAIL_DATA_W*)buffer;
|
||||
pData->cbSize = (uint)sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W);
|
||||
SP_DEVICE_INTERFACE_DETAIL_DATA_W* pDetailData = (SP_DEVICE_INTERFACE_DETAIL_DATA_W*)buffer;
|
||||
pDetailData->cbSize = (uint)sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W);
|
||||
|
||||
if (PInvoke.SetupDiGetDeviceInterfaceDetail(hdev,
|
||||
data,
|
||||
pData,
|
||||
if (PInvoke.SetupDiGetDeviceInterfaceDetail((HDEVINFO)hdev.DangerousGetHandle(),
|
||||
&data,
|
||||
pDetailData,
|
||||
cbRequired,
|
||||
&cbRequired,
|
||||
null))
|
||||
{
|
||||
string devicePath;
|
||||
|
||||
fixed (void* pDevicePath = &pData->DevicePath.e0)
|
||||
fixed (void* pDevicePath = &pDetailData->DevicePath.e0)
|
||||
devicePath = new string((char*)pDevicePath);
|
||||
|
||||
SafeFileHandle battery = PInvoke.CreateFile(devicePath, (uint)FileAccess.ReadWrite, FILE_SHARE_MODE.FILE_SHARE_READ | FILE_SHARE_MODE.FILE_SHARE_WRITE, null, FILE_CREATION_DISPOSITION.OPEN_EXISTING, FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_NORMAL, null);
|
||||
@@ -85,7 +85,7 @@ internal class BatteryGroup : IGroup
|
||||
|
||||
uint dwWait = 0;
|
||||
uint bytesReturned = 0;
|
||||
if (PInvoke.DeviceIoControl(battery,
|
||||
if (PInvoke.DeviceIoControl((HANDLE)battery.DangerousGetHandle(),
|
||||
PInvoke.IOCTL_BATTERY_QUERY_TAG,
|
||||
&dwWait,
|
||||
sizeof(uint),
|
||||
@@ -97,7 +97,7 @@ internal class BatteryGroup : IGroup
|
||||
BATTERY_INFORMATION bi = default;
|
||||
bqi.InformationLevel = BATTERY_QUERY_INFORMATION_LEVEL.BatteryInformation;
|
||||
|
||||
if (PInvoke.DeviceIoControl(battery,
|
||||
if (PInvoke.DeviceIoControl((HANDLE)battery.DangerousGetHandle(),
|
||||
PInvoke.IOCTL_BATTERY_QUERY_INFORMATION,
|
||||
&bqi,
|
||||
(uint)sizeof(BATTERY_QUERY_INFORMATION),
|
||||
@@ -145,7 +145,7 @@ internal class BatteryGroup : IGroup
|
||||
{
|
||||
uint returnBytes = 0;
|
||||
|
||||
if (PInvoke.DeviceIoControl(battery,
|
||||
if (PInvoke.DeviceIoControl((HANDLE)battery.DangerousGetHandle(),
|
||||
PInvoke.IOCTL_BATTERY_QUERY_INFORMATION,
|
||||
&bqi,
|
||||
(uint)sizeof(BATTERY_QUERY_INFORMATION),
|
||||
|
||||
@@ -10,6 +10,7 @@ using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Windows.Win32;
|
||||
using Windows.Win32.Foundation;
|
||||
using Windows.Win32.Storage.FileSystem;
|
||||
using Windows.Win32.System.Ioctl;
|
||||
using LibreHardwareMonitor.Interop;
|
||||
@@ -184,7 +185,7 @@ public abstract class AbstractStorage : Hardware
|
||||
DISK_PERFORMANCE diskPerformance = new();
|
||||
|
||||
uint bytesReturned;
|
||||
if (!PInvoke.DeviceIoControl(_storageInfo.Handle, PInvoke.IOCTL_DISK_PERFORMANCE, null, 0, &diskPerformance, (uint)sizeof(DISK_PERFORMANCE), &bytesReturned, null))
|
||||
if (!PInvoke.DeviceIoControl((HANDLE)_storageInfo.Handle.DangerousGetHandle(), PInvoke.IOCTL_DISK_PERFORMANCE, null, 0, &diskPerformance, (uint)sizeof(DISK_PERFORMANCE), &bytesReturned, null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using Windows.Win32;
|
||||
using Windows.Win32.Foundation;
|
||||
using Windows.Win32.Storage.FileSystem;
|
||||
using Windows.Win32.Storage.IscsiDisc;
|
||||
using Windows.Win32.Storage.Nvme;
|
||||
@@ -56,7 +57,7 @@ internal class NVMeIntel : INVMeDrive
|
||||
IntPtr buffer = Marshal.AllocHGlobal(length);
|
||||
Marshal.StructureToPtr(passThrough, buffer, false);
|
||||
|
||||
bool validTransfer = PInvoke.DeviceIoControl(hDevice, PInvoke.IOCTL_SCSI_MINIPORT, (void*)buffer, (uint)length, (void*)buffer, (uint)length, null, null);
|
||||
bool validTransfer = PInvoke.DeviceIoControl((HANDLE)hDevice.DangerousGetHandle(), PInvoke.IOCTL_SCSI_MINIPORT, (void*)buffer, (uint)length, (void*)buffer, (uint)length, null, null);
|
||||
if (validTransfer)
|
||||
{
|
||||
IntPtr offset = Marshal.OffsetOf<AtaSmart.NVME_PASS_THROUGH_IOCTL>(nameof(AtaSmart.NVME_PASS_THROUGH_IOCTL.DataBuffer));
|
||||
@@ -105,7 +106,7 @@ internal class NVMeIntel : INVMeDrive
|
||||
IntPtr buffer = Marshal.AllocHGlobal(length);
|
||||
Marshal.StructureToPtr(passThrough, buffer, false);
|
||||
|
||||
bool validTransfer = PInvoke.DeviceIoControl(hDevice, PInvoke.IOCTL_SCSI_MINIPORT, (void*)buffer, (uint)length, (void*)buffer, (uint)length, null, null);
|
||||
bool validTransfer = PInvoke.DeviceIoControl((HANDLE)hDevice.DangerousGetHandle(), PInvoke.IOCTL_SCSI_MINIPORT, (void*)buffer, (uint)length, (void*)buffer, (uint)length, null, null);
|
||||
if (validTransfer)
|
||||
{
|
||||
IntPtr offset = Marshal.OffsetOf<AtaSmart.NVME_PASS_THROUGH_IOCTL>(nameof(AtaSmart.NVME_PASS_THROUGH_IOCTL.DataBuffer));
|
||||
@@ -157,7 +158,7 @@ internal class NVMeIntel : INVMeDrive
|
||||
IntPtr buffer = Marshal.AllocHGlobal(length);
|
||||
Marshal.StructureToPtr(passThrough, buffer, false);
|
||||
|
||||
bool validTransfer = PInvoke.DeviceIoControl(handle, PInvoke.IOCTL_SCSI_MINIPORT, (void*)buffer, (uint)length, (void*)buffer, (uint)length, null, null);
|
||||
bool validTransfer = PInvoke.DeviceIoControl((HANDLE)handle.DangerousGetHandle(), PInvoke.IOCTL_SCSI_MINIPORT, (void*)buffer, (uint)length, (void*)buffer, (uint)length, null, null);
|
||||
Marshal.FreeHGlobal(buffer);
|
||||
|
||||
if (validTransfer)
|
||||
|
||||
@@ -9,6 +9,7 @@ using System.Runtime.InteropServices;
|
||||
using LibreHardwareMonitor.Interop;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
using Windows.Win32;
|
||||
using Windows.Win32.Foundation;
|
||||
using Windows.Win32.Storage.FileSystem;
|
||||
using Windows.Win32.Storage.IscsiDisc;
|
||||
using Windows.Win32.Storage.Nvme;
|
||||
@@ -56,7 +57,7 @@ internal class NVMeIntelRst : INVMeDrive
|
||||
IntPtr buffer = Marshal.AllocHGlobal(length);
|
||||
Marshal.StructureToPtr(passThrough, buffer, false);
|
||||
|
||||
bool validTransfer = PInvoke.DeviceIoControl(hDevice, PInvoke.IOCTL_SCSI_MINIPORT, (void*)buffer, (uint)length, (void*)buffer, (uint)length, null, null);
|
||||
bool validTransfer = PInvoke.DeviceIoControl((HANDLE)hDevice.DangerousGetHandle(), PInvoke.IOCTL_SCSI_MINIPORT, (void*)buffer, (uint)length, (void*)buffer, (uint)length, null, null);
|
||||
if (validTransfer)
|
||||
{
|
||||
IntPtr offset = Marshal.OffsetOf<AtaSmart.NVME_PASS_THROUGH_IOCTL>(nameof(AtaSmart.NVME_PASS_THROUGH_IOCTL.DataBuffer));
|
||||
@@ -105,7 +106,7 @@ internal class NVMeIntelRst : INVMeDrive
|
||||
IntPtr buffer = Marshal.AllocHGlobal(length);
|
||||
Marshal.StructureToPtr(passThrough, buffer, false);
|
||||
|
||||
bool validTransfer = PInvoke.DeviceIoControl(hDevice, PInvoke.IOCTL_SCSI_MINIPORT, (void*)buffer, (uint)length, (void*)buffer, (uint)length, null, null);
|
||||
bool validTransfer = PInvoke.DeviceIoControl((HANDLE)hDevice.DangerousGetHandle(), PInvoke.IOCTL_SCSI_MINIPORT, (void*)buffer, (uint)length, (void*)buffer, (uint)length, null, null);
|
||||
if (validTransfer)
|
||||
{
|
||||
IntPtr offset = Marshal.OffsetOf<AtaSmart.NVME_PASS_THROUGH_IOCTL>(nameof(AtaSmart.NVME_PASS_THROUGH_IOCTL.DataBuffer));
|
||||
@@ -157,7 +158,7 @@ internal class NVMeIntelRst : INVMeDrive
|
||||
IntPtr buffer = Marshal.AllocHGlobal(length);
|
||||
Marshal.StructureToPtr(passThrough, buffer, false);
|
||||
|
||||
bool validTransfer = PInvoke.DeviceIoControl(handle, PInvoke.IOCTL_SCSI_MINIPORT, (void*)buffer, (uint)length, (void*)buffer, (uint)length, null, null);
|
||||
bool validTransfer = PInvoke.DeviceIoControl((HANDLE)handle.DangerousGetHandle(), PInvoke.IOCTL_SCSI_MINIPORT, (void*)buffer, (uint)length, (void*)buffer, (uint)length, null, null);
|
||||
Marshal.FreeHGlobal(buffer);
|
||||
|
||||
if (validTransfer)
|
||||
|
||||
@@ -9,6 +9,7 @@ using System.Runtime.InteropServices;
|
||||
using LibreHardwareMonitor.Interop;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
using Windows.Win32;
|
||||
using Windows.Win32.Foundation;
|
||||
using Windows.Win32.Storage.FileSystem;
|
||||
using Windows.Win32.Storage.IscsiDisc;
|
||||
using Windows.Win32.Storage.Nvme;
|
||||
@@ -56,7 +57,7 @@ internal class NVMeSamsung : INVMeDrive
|
||||
int length = (int)(Marshal.OffsetOf(typeof(AtaSmart.SCSI_PASS_THROUGH), nameof(AtaSmart.SCSI_PASS_THROUGH.DataBuf)).ToInt32() + buffers.Spt.DataTransferLength);
|
||||
IntPtr buffer = Marshal.AllocHGlobal(length);
|
||||
Marshal.StructureToPtr(buffers, buffer, false);
|
||||
bool validTransfer = PInvoke.DeviceIoControl(hDevice, PInvoke.IOCTL_SCSI_PASS_THROUGH, (void*)buffer, (uint)length, (void*)buffer, (uint)length, null, null);
|
||||
bool validTransfer = PInvoke.DeviceIoControl((HANDLE)hDevice.DangerousGetHandle(), PInvoke.IOCTL_SCSI_PASS_THROUGH, (void*)buffer, (uint)length, (void*)buffer, (uint)length, null, null);
|
||||
Marshal.FreeHGlobal(buffer);
|
||||
|
||||
bool result = false;
|
||||
@@ -86,7 +87,7 @@ internal class NVMeSamsung : INVMeDrive
|
||||
buffer = Marshal.AllocHGlobal(length);
|
||||
Marshal.StructureToPtr(buffers, buffer, false);
|
||||
|
||||
validTransfer = PInvoke.DeviceIoControl(hDevice, PInvoke.IOCTL_SCSI_PASS_THROUGH, (void*)buffer, (uint)length, (void*)buffer, (uint)length, null, null);
|
||||
validTransfer = PInvoke.DeviceIoControl((HANDLE)hDevice.DangerousGetHandle(), PInvoke.IOCTL_SCSI_PASS_THROUGH, (void*)buffer, (uint)length, (void*)buffer, (uint)length, null, null);
|
||||
|
||||
buffers = Marshal.PtrToStructure<AtaSmart.SCSI_PASS_THROUGH>(buffer);
|
||||
|
||||
@@ -138,7 +139,7 @@ internal class NVMeSamsung : INVMeDrive
|
||||
int length = Marshal.SizeOf<AtaSmart.SCSI_PASS_THROUGH>();
|
||||
IntPtr buffer = Marshal.AllocHGlobal(length);
|
||||
Marshal.StructureToPtr(buffers, buffer, false);
|
||||
bool validTransfer = PInvoke.DeviceIoControl(hDevice, PInvoke.IOCTL_SCSI_PASS_THROUGH, (void*)buffer, (uint)length, (void*)buffer, (uint)length, null, null);
|
||||
bool validTransfer = PInvoke.DeviceIoControl((HANDLE)hDevice.DangerousGetHandle(), PInvoke.IOCTL_SCSI_PASS_THROUGH, (void*)buffer, (uint)length, (void*)buffer, (uint)length, null, null);
|
||||
Marshal.FreeHGlobal(buffer);
|
||||
|
||||
if (validTransfer)
|
||||
@@ -166,7 +167,7 @@ internal class NVMeSamsung : INVMeDrive
|
||||
buffer = Marshal.AllocHGlobal(length);
|
||||
Marshal.StructureToPtr(buffers, buffer, false);
|
||||
|
||||
validTransfer = PInvoke.DeviceIoControl(hDevice, PInvoke.IOCTL_SCSI_PASS_THROUGH, (void*)buffer, (uint)length, (void*)buffer, (uint)length, null, null);
|
||||
validTransfer = PInvoke.DeviceIoControl((HANDLE)hDevice.DangerousGetHandle(), PInvoke.IOCTL_SCSI_PASS_THROUGH, (void*)buffer, (uint)length, (void*)buffer, (uint)length, null, null);
|
||||
if (validTransfer)
|
||||
{
|
||||
IntPtr offset = Marshal.OffsetOf<AtaSmart.SCSI_PASS_THROUGH>(nameof(AtaSmart.SCSI_PASS_THROUGH.DataBuf));
|
||||
@@ -219,7 +220,7 @@ internal class NVMeSamsung : INVMeDrive
|
||||
int length = Marshal.SizeOf<AtaSmart.SCSI_PASS_THROUGH>();
|
||||
IntPtr buffer = Marshal.AllocHGlobal(length);
|
||||
Marshal.StructureToPtr(buffers, buffer, false);
|
||||
bool validTransfer = PInvoke.DeviceIoControl(handle, PInvoke.IOCTL_SCSI_PASS_THROUGH, (void*)buffer, (uint)length, (void*)buffer, (uint)length, null, null);
|
||||
bool validTransfer = PInvoke.DeviceIoControl((HANDLE)handle.DangerousGetHandle(), PInvoke.IOCTL_SCSI_PASS_THROUGH, (void*)buffer, (uint)length, (void*)buffer, (uint)length, null, null);
|
||||
Marshal.FreeHGlobal(buffer);
|
||||
|
||||
if (validTransfer)
|
||||
@@ -247,7 +248,7 @@ internal class NVMeSamsung : INVMeDrive
|
||||
buffer = Marshal.AllocHGlobal(length);
|
||||
Marshal.StructureToPtr(buffers, buffer, false);
|
||||
|
||||
validTransfer = PInvoke.DeviceIoControl(handle, PInvoke.IOCTL_SCSI_PASS_THROUGH, (void*)buffer, (uint)length, (void*)buffer, (uint)length, null, null);
|
||||
validTransfer = PInvoke.DeviceIoControl((HANDLE)handle.DangerousGetHandle(), PInvoke.IOCTL_SCSI_PASS_THROUGH, (void*)buffer, (uint)length, (void*)buffer, (uint)length, null, null);
|
||||
if (validTransfer)
|
||||
{
|
||||
AtaSmart.SCSI_PASS_THROUGH result = Marshal.PtrToStructure<AtaSmart.SCSI_PASS_THROUGH>(buffer);
|
||||
|
||||
@@ -9,6 +9,7 @@ using System.Runtime.InteropServices;
|
||||
using LibreHardwareMonitor.Interop;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
using Windows.Win32;
|
||||
using Windows.Win32.Foundation;
|
||||
using Windows.Win32.Storage.FileSystem;
|
||||
using Windows.Win32.Storage.Nvme;
|
||||
using Windows.Win32.System.Ioctl;
|
||||
@@ -46,7 +47,7 @@ internal class NVMeWindows : INVMeDrive
|
||||
protocolData->ProtocolDataOffset = (uint)sizeof(STORAGE_PROTOCOL_SPECIFIC_DATA);
|
||||
protocolData->ProtocolDataLength = (uint)sizeof(NVME_IDENTIFY_CONTROLLER_DATA);
|
||||
|
||||
bool validTransfer = PInvoke.DeviceIoControl(hDevice, PInvoke.IOCTL_STORAGE_QUERY_PROPERTY, (void*)ptr, (uint)cb, (void*)ptr, (uint)cb, null, null);
|
||||
bool validTransfer = PInvoke.DeviceIoControl((HANDLE)hDevice.DangerousGetHandle(), PInvoke.IOCTL_STORAGE_QUERY_PROPERTY, (void*)ptr, (uint)cb, (void*)ptr, (uint)cb, null, null);
|
||||
if (validTransfer)
|
||||
{
|
||||
var dataDescriptor = (STORAGE_PROTOCOL_DATA_DESCRIPTOR*)ptr;
|
||||
@@ -86,7 +87,7 @@ internal class NVMeWindows : INVMeDrive
|
||||
protocolData->ProtocolDataOffset = (uint)sizeof(STORAGE_PROTOCOL_SPECIFIC_DATA);
|
||||
protocolData->ProtocolDataLength = (uint)sizeof(NVME_HEALTH_INFO_LOG);
|
||||
|
||||
bool validTransfer = PInvoke.DeviceIoControl(hDevice, PInvoke.IOCTL_STORAGE_QUERY_PROPERTY, (void*)ptr, (uint)cb, (void*)ptr, (uint)cb, null, null);
|
||||
bool validTransfer = PInvoke.DeviceIoControl((HANDLE)hDevice.DangerousGetHandle(), PInvoke.IOCTL_STORAGE_QUERY_PROPERTY, (void*)ptr, (uint)cb, (void*)ptr, (uint)cb, null, null);
|
||||
if (validTransfer)
|
||||
{
|
||||
var dataDescriptor = (STORAGE_PROTOCOL_DATA_DESCRIPTOR*)ptr;
|
||||
|
||||
@@ -10,6 +10,7 @@ using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using LibreHardwareMonitor.Interop;
|
||||
using Windows.Win32;
|
||||
using Windows.Win32.Foundation;
|
||||
using Windows.Win32.Storage.FileSystem;
|
||||
using Windows.Win32.System.Ioctl;
|
||||
using static LibreHardwareMonitor.Interop.AtaSmart;
|
||||
@@ -59,7 +60,7 @@ internal class WindowsSmart : ISmart
|
||||
|
||||
var result = new SENDCMDOUTPARAMS();
|
||||
|
||||
return PInvoke.DeviceIoControl(_handle,
|
||||
return PInvoke.DeviceIoControl((HANDLE)_handle.DangerousGetHandle(),
|
||||
PInvoke.SMART_SEND_DRIVE_COMMAND,
|
||||
¶meter,
|
||||
(uint)sizeof(SENDCMDINPARAMS),
|
||||
@@ -89,7 +90,7 @@ internal class WindowsSmart : ISmart
|
||||
int cb = sizeof(SENDCMDOUTPARAMS) + 512; // 512 bytes buffer.
|
||||
IntPtr buffer = Marshal.AllocHGlobal(cb);
|
||||
|
||||
bool isValid = PInvoke.DeviceIoControl(_handle,
|
||||
bool isValid = PInvoke.DeviceIoControl((HANDLE)_handle.DangerousGetHandle(),
|
||||
PInvoke.SMART_RCV_DRIVE_DATA,
|
||||
¶meter,
|
||||
(uint)sizeof(SENDCMDINPARAMS),
|
||||
@@ -139,7 +140,7 @@ internal class WindowsSmart : ISmart
|
||||
|
||||
int cb = sizeof(SENDCMDOUTPARAMS) + 512; // 2 bytes padding + 512 bytes buffer.
|
||||
IntPtr buffer = Marshal.AllocHGlobal(cb);
|
||||
bool isValid = PInvoke.DeviceIoControl(_handle,
|
||||
bool isValid = PInvoke.DeviceIoControl((HANDLE)_handle.DangerousGetHandle(),
|
||||
PInvoke.SMART_RCV_DRIVE_DATA,
|
||||
¶meter,
|
||||
(uint)sizeof(SENDCMDINPARAMS),
|
||||
@@ -186,7 +187,7 @@ internal class WindowsSmart : ISmart
|
||||
int cb = sizeof(SENDCMDOUTPARAMS) + sizeof(IDENTIFY_DEVICE_DATA);
|
||||
IntPtr buffer = Marshal.AllocHGlobal(cb);
|
||||
|
||||
bool valid = PInvoke.DeviceIoControl(_handle,
|
||||
bool valid = PInvoke.DeviceIoControl((HANDLE)_handle.DangerousGetHandle(),
|
||||
PInvoke.SMART_RCV_DRIVE_DATA,
|
||||
¶meter,
|
||||
(uint)sizeof(SENDCMDINPARAMS),
|
||||
|
||||
@@ -9,6 +9,7 @@ using System.IO;
|
||||
using System.Management;
|
||||
using System.Runtime.InteropServices;
|
||||
using Windows.Win32;
|
||||
using Windows.Win32.Foundation;
|
||||
using Windows.Win32.Storage.FileSystem;
|
||||
using Windows.Win32.System.Ioctl;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
@@ -33,7 +34,7 @@ internal static class WindowsStorage
|
||||
var query = new STORAGE_PROPERTY_QUERY { PropertyId = STORAGE_PROPERTY_ID.StorageDeviceProperty, QueryType = STORAGE_QUERY_TYPE.PropertyStandardQuery };
|
||||
STORAGE_DESCRIPTOR_HEADER result = new();
|
||||
|
||||
if (!PInvoke.DeviceIoControl(handle, PInvoke.IOCTL_STORAGE_QUERY_PROPERTY, &query, (uint)sizeof(STORAGE_PROPERTY_QUERY), &result, (uint)sizeof(STORAGE_DESCRIPTOR_HEADER), null, null))
|
||||
if (!PInvoke.DeviceIoControl((HANDLE)handle.DangerousGetHandle(), PInvoke.IOCTL_STORAGE_QUERY_PROPERTY, &query, (uint)sizeof(STORAGE_PROPERTY_QUERY), &result, (uint)sizeof(STORAGE_DESCRIPTOR_HEADER), null, null))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -42,7 +43,7 @@ internal static class WindowsStorage
|
||||
|
||||
try
|
||||
{
|
||||
return PInvoke.DeviceIoControl(handle, PInvoke.IOCTL_STORAGE_QUERY_PROPERTY, &query, (uint)sizeof(STORAGE_PROPERTY_QUERY), (void*)descriptorPtr, result.Size, null, null)
|
||||
return PInvoke.DeviceIoControl((HANDLE)handle.DangerousGetHandle(), PInvoke.IOCTL_STORAGE_QUERY_PROPERTY, &query, (uint)sizeof(STORAGE_PROPERTY_QUERY), (void*)descriptorPtr, result.Size, null, null)
|
||||
? new StorageInfo((int)driveIndex, descriptorPtr)
|
||||
: null;
|
||||
}
|
||||
|
||||
@@ -38,12 +38,12 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\PawnIO\LpcIO.bin" />
|
||||
<EmbeddedResource Include="Resources\PawnIo\LpcACPIEC.bin" />
|
||||
<EmbeddedResource Include="Resources\PawnIo\IntelMSR.bin" />
|
||||
<EmbeddedResource Include="Resources\PawnIo\RyzenSMU.bin" />
|
||||
<EmbeddedResource Include="Resources\PawnIo\AMDFamily0F.bin" />
|
||||
<EmbeddedResource Include="Resources\PawnIo\AMDFamily10.bin" />
|
||||
<EmbeddedResource Include="Resources\PawnIo\AMDFamily17.bin" />
|
||||
<EmbeddedResource Include="Resources\PawnIO\LpcACPIEC.bin" />
|
||||
<EmbeddedResource Include="Resources\PawnIO\IntelMSR.bin" />
|
||||
<EmbeddedResource Include="Resources\PawnIO\RyzenSMU.bin" />
|
||||
<EmbeddedResource Include="Resources\PawnIO\AMDFamily0F.bin" />
|
||||
<EmbeddedResource Include="Resources\PawnIO\AMDFamily10.bin" />
|
||||
<EmbeddedResource Include="Resources\PawnIO\AMDFamily17.bin" />
|
||||
<EmbeddedResource Include="Resources\PawnIO\SmbusI801.bin" />
|
||||
<EmbeddedResource Include="Resources\PawnIO\SmbusNCT6793.bin" />
|
||||
<EmbeddedResource Include="Resources\PawnIO\SmbusPIIX4.bin" />
|
||||
@@ -56,7 +56,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="HidSharp" Version="2.6.4" />
|
||||
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.235">
|
||||
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.236">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
||||
@@ -83,7 +83,7 @@ public class PawnIo
|
||||
|
||||
fixed (byte* pIn = bin)
|
||||
{
|
||||
if (PInvoke.DeviceIoControl(handle, (uint)ControlCode.LoadBinary, pIn, (uint)bin.Length, null, 0u, null, null))
|
||||
if (PInvoke.DeviceIoControl((HANDLE)handle.DangerousGetHandle(), (uint)ControlCode.LoadBinary, pIn, (uint)bin.Length, null, 0u, null, null))
|
||||
return new PawnIo(handle);
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ public class PawnIo
|
||||
|
||||
fixed (byte* pIn = totalInput, pOut = output)
|
||||
{
|
||||
if (PInvoke.DeviceIoControl(_handle, (uint)ControlCode.Execute, pIn, (uint)totalInput.Length, pOut, (uint)output.Length, &read, null))
|
||||
if (PInvoke.DeviceIoControl((HANDLE)_handle.DangerousGetHandle(), (uint)ControlCode.Execute, pIn, (uint)totalInput.Length, pOut, (uint)output.Length, &read, null))
|
||||
{
|
||||
long[] outp = new long[read / sizeof(long)];
|
||||
Buffer.BlockCopy(output, 0, outp, 0, (int)read);
|
||||
@@ -144,7 +144,7 @@ public class PawnIo
|
||||
|
||||
fixed (byte* pIn = totalInput, pOut = output)
|
||||
{
|
||||
if (PInvoke.DeviceIoControl(_handle, (uint)ControlCode.Execute, pIn, (uint)totalInput.Length, pOut, (uint)output.Length, &read, null))
|
||||
if (PInvoke.DeviceIoControl((HANDLE)_handle.DangerousGetHandle(), (uint)ControlCode.Execute, pIn, (uint)totalInput.Length, pOut, (uint)output.Length, &read, null))
|
||||
{
|
||||
Buffer.BlockCopy(output, 0, outBuffer, 0, Math.Min((int)read, outBuffer.Length * sizeof(long)));
|
||||
returnSize = read / sizeof(long);
|
||||
|
||||
Reference in New Issue
Block a user