3

The Windows API supports a GetVolumeInformation function. This function provides information about a Windows volume. Specifically, it returns a FILE_CASE_SENSITIVE_SEARCH switch. In the kernel there are FltQueryVolumeInformation and ZwQueryVolumeInformationFile, but I don't see any way to derive the case sensitivity information from the available information classes.

Am I correct in understanding that the FILE_CASE_SENSITIVE_SEARCH switch only specifies that a case sensitive search is possible (not that it is done by default)? Is it correct that you only know about case sensitivity based on the way the file is opened (i.e. you must call CreateFile with the FILE_FLAG_POSIX_SEMANTICS flag, otherwise Win32 case-insensitive behavior is used)?

Dweeberly
  • 4,668
  • 2
  • 22
  • 41
  • An interesting question. As I understand it, case sensitivity has to be enabled in the kernel, be supported by the file system, *and* be requested by the CreateFile (or ZwCreateFile) call in order for it to work. But I'm not sure whether NTFS allows you to turn it on and off on a per-volume basis, and if not I don't know what GetVolumeInformation is actually looking up. – Harry Johnston Apr 25 '16 at 23:52

1 Answers1

1

Ok, I ask this question on MSDN and found the answer

Somehow I missed that FILE_FS_ATTRIBUTE_INFORMATION information class attribute will allow ZwQueryVolumeInformationFile and FltQueryVolumeInformation functions to return a struct that contains a FileSystemAttributes field with various bit flags including FILE_CASE_PRESERVED_NAMES and FILE_CASE_SENSITIVE_SEARCH.

This only shows that the volume will support case sensitive name searches (not that it defaults to it). You still need to use the FILE_FLAG_POSTIX_SEMANTICS flag on CreateFile to take advantage of case sensitivity. There also appears to be a registry setting to make this the default (you can google/bing that).

Dweeberly
  • 4,668
  • 2
  • 22
  • 41