On Mon, 2020-05-25 at 10:02 -0500, Zebediah Figura wrote:
On 5/25/20 8:46 AM, Hans Leidekker wrote:
+static WCHAR *get_diskdrive_serialnumber( WCHAR letter ) +{
- WCHAR *ret = NULL;
- STORAGE_DEVICE_DESCRIPTOR *desc;
- HANDLE handle = INVALID_HANDLE_VALUE;
- STORAGE_PROPERTY_QUERY query = {0};
- WCHAR drive[7];
- DWORD size;
- swprintf( drive, ARRAY_SIZE(drive), L"\\.\%c:", letter );
- handle = CreateFileW( drive, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
You shouldn't need read permissions to open the file; IOCTL_STORAGE_QUERY_PROPERTY has FILE_ANY_ACCESS permissions.
Passing 0 desired access make no difference here, it ends up in the same open(O_RDONLY) call on the Unix device file.