I get a list of physical disks with wmic diskdrive list command. There are two internal SSDs, one USB flash drive and one external SSD connected to USB-C port. CreateFile works for all of them except for external SSD, I get ERROR_INVALID_FUNCTION. When I connect the same SSD to USB port, it works as expected. What could be the problem?
I found some suggestions to look into IRP_MJ_CREATE, but there is no info how to use in VB.NET.
Code:
Dim result = CreateFile("\\.\PHYSICALDRIVE2", EFileAccess.GenericRead Or EFileAccess.GenericWrite, EFileShare.Read Or EFileShare.Write, IntPtr.Zero, ECreationDisposition.OpenExisting, EFileAttributes.Normal, IntPtr.Zero)
If result.IsInvalid Then
Console.WriteLine(New Win32Exception(Marshal.GetLastWin32Error()).Message)
End If