Skip to content

Commit

Permalink
Fixes #51
Browse files Browse the repository at this point in the history
  • Loading branch information
nefarius committed Mar 11, 2024
1 parent 92fdfa2 commit 4aaa5b1
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/PnP/Devcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,14 @@ public static bool FindInDeviceClassByHardwareId(Guid target, string hardwareId)
: DeviceLocationFlags.Phantom
);

List<string> hardwareIds = device.GetProperty<string[]>(DevicePropertyKey.Device_HardwareIds)
.Select(id => id.ToUpper()).ToList();
string[] property = device.GetProperty<string[]>(DevicePropertyKey.Device_HardwareIds);

if (property is null)
{
continue;
}

List<string> hardwareIds = property.Select(id => id.ToUpper()).ToList();

if (
/* partial match */
Expand Down Expand Up @@ -316,7 +322,7 @@ public static bool Create(string className, Guid classGuid, string node)
className,
ref classGuid,
null,
HWND.Null,
HWND.Null,
(int)PInvoke.DICD_GENERATE_ID,
ref deviceInfoData
))
Expand Down Expand Up @@ -386,7 +392,7 @@ public static unsafe bool Remove(Guid classGuid, string instanceId, out bool reb
deviceInfoSet = SetupApi.SetupDiGetClassDevs(
ref classGuid,
IntPtr.Zero,
HWND.Null,
HWND.Null,
(int)PInvoke.DIGCF_PRESENT | (int)PInvoke.DIGCF_DEVICEINTERFACE
);

Expand Down Expand Up @@ -543,7 +549,7 @@ public static void DeleteDriver(string oemInfName, string fullInfPath = default,
if (forceDelete
&& Kernel32.MethodExists("newdev.dll", "DiUninstallDriverW")
&& !SetupApi.DiUninstallDriver(
HWND.Null,
HWND.Null,
fullInfPath,
PInvoke.DIURFLAG_NO_REMOVE_INF,
out _))
Expand Down

0 comments on commit 4aaa5b1

Please sign in to comment.