1 /*
2  * PROJECT:         ReactOS API Tests
3  * LICENSE:         GPLv2+ - See COPYING in the top level directory
4  * PURPOSE:         NtQueryVolumeInformationFile tests
5  * PROGRAMMER:      Víctor Martínez Calvo <vicmarcal@gmail.com>
6  */
7 
8 #include "precomp.h"
9 
10 static
11 VOID
12 TestFileFsDeviceInformation(HANDLE handle)
13 {
14     IO_STATUS_BLOCK IoStatusBlock;
15     FILE_FS_DEVICE_INFORMATION FileFsDevice;
16     NTSTATUS status;
17 
18     /*Testing VALID handle, with NULL IN parameters*/
19     SetLastError(0xdeadb33f);
20     status = NtQueryVolumeInformationFile(handle, NULL, &FileFsDevice, sizeof(FILE_FS_DEVICE_INFORMATION), FileFsDeviceInformation);
21     ok(status == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got 0x%lx\n", status);
22     ok(GetLastError() == 0xdeadb33f, "Expected 0xdeadb33f, got %lx\n", GetLastError());
23 
24     SetLastError(0xcacacaca);
25     status = NtQueryVolumeInformationFile(handle,  &IoStatusBlock, NULL, sizeof(FILE_FS_DEVICE_INFORMATION), FileFsDeviceInformation);
26     ok(status == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got 0x%lx\n", status);
27     ok(GetLastError() == 0xcacacaca, "Expected 0xcacacaca, got %lx\n", GetLastError());
28 
29     SetLastError(0xdadadada);
30     status = NtQueryVolumeInformationFile(handle,  &IoStatusBlock, &FileFsDevice, 0, FileFsDeviceInformation);
31     ok(status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got 0x%lx\n", status);
32     ok(GetLastError() == 0xdadadada, "Expected 0xdadadada, got %lx\n", GetLastError());
33 
34     /*All valid, invalid FsInformationClass value.*/
35     SetLastError(0xdeadbeef);
36     status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, &FileFsDevice, sizeof(FILE_FS_DEVICE_INFORMATION), 0);
37     ok(status == STATUS_INVALID_INFO_CLASS, "Expected STATUS_INVALID_INFO_CLASS, got 0x%lx\n", status);
38     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %lx\n", GetLastError());
39 
40     /*Testing NULL handle*/
41     SetLastError(0xdeadbeef);
42     status = NtQueryVolumeInformationFile(NULL, &IoStatusBlock, &FileFsDevice, sizeof(FILE_FS_DEVICE_INFORMATION), FileFsDeviceInformation);
43     ok(status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got 0x%lx\n", status);
44     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %lx\n", GetLastError());
45 
46     /*Testing INVALID_HANDLE_VALUE*/
47     SetLastError(0xdeaddead);
48     status = NtQueryVolumeInformationFile((HANDLE)(-1), &IoStatusBlock, &FileFsDevice, sizeof(FILE_FS_DEVICE_INFORMATION), FileFsDeviceInformation);
49     ok(status == STATUS_OBJECT_TYPE_MISMATCH, "Expected STATUS_OBJECT_TYPE_MISMATCH, got 0x%lx\n", status);
50     ok(GetLastError() == 0xdeaddead, "Expected 0xdeaddead, got %lx\n", GetLastError());
51 
52     /*Almost all NULL. Then it checks against the Length!*/
53     SetLastError(0xdeadbeef);
54     status = NtQueryVolumeInformationFile(NULL, NULL, NULL, 0, FileFsDeviceInformation);
55     ok(status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got 0x%lx\n", status);
56     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %lx\n", GetLastError());
57 }
58 
59 static
60 VOID
61 TestFileFsVolumeInformation(HANDLE handle)
62 {
63     IO_STATUS_BLOCK IoStatusBlock;
64     ULONG Buffer[(sizeof(FILE_FS_VOLUME_INFORMATION) + MAX_PATH * sizeof(WCHAR)) / sizeof(ULONG)];
65     PFILE_FS_VOLUME_INFORMATION VolumeInfo = (PFILE_FS_VOLUME_INFORMATION)Buffer;
66     NTSTATUS status;
67 
68     status = NtQueryVolumeInformationFile(handle, NULL, NULL, 0, FileFsVolumeInformation);
69     ok(status == STATUS_INFO_LENGTH_MISMATCH, "Got status 0x%lx\n", status);
70 
71     RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55);
72     status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, NULL, 0, FileFsVolumeInformation);
73     ok(status == STATUS_INFO_LENGTH_MISMATCH, "Got status 0x%lx\n", status);
74     ok(IoStatusBlock.Status == 0x55555555, "IoStatusBlock.Status = 0x%lx\n", IoStatusBlock.Status);
75     ok(IoStatusBlock.Information == (ULONG_PTR)0x5555555555555555, "IoStatusBlock.Information = %Iu\n", IoStatusBlock.Information);
76 
77     status = NtQueryVolumeInformationFile(handle, NULL, VolumeInfo, 0, FileFsVolumeInformation);
78     ok(status == STATUS_INFO_LENGTH_MISMATCH, "Got status 0x%lx\n", status);
79 
80     RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55);
81     status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, (PUCHAR)Buffer + 2, sizeof(FILE_FS_VOLUME_INFORMATION), FileFsVolumeInformation);
82     ok(status == STATUS_DATATYPE_MISALIGNMENT, "Got status 0x%lx\n", status);
83     ok(IoStatusBlock.Status == 0x55555555, "IoStatusBlock.Status = 0x%lx\n", IoStatusBlock.Status);
84     ok(IoStatusBlock.Information == (ULONG_PTR)0x5555555555555555, "IoStatusBlock.Information = %Iu\n", IoStatusBlock.Information);
85 
86     RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55);
87     status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, VolumeInfo, 0, FileFsVolumeInformation);
88     ok(status == STATUS_INFO_LENGTH_MISMATCH, "Got status 0x%lx\n", status);
89     ok(IoStatusBlock.Status == 0x55555555, "IoStatusBlock.Status = 0x%lx\n", IoStatusBlock.Status);
90     ok(IoStatusBlock.Information == (ULONG_PTR)0x5555555555555555, "IoStatusBlock.Information = %Iu\n", IoStatusBlock.Information);
91 
92     RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55);
93     status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, VolumeInfo, FIELD_OFFSET(FILE_FS_VOLUME_INFORMATION, VolumeLabel), FileFsVolumeInformation);
94     ok(status == STATUS_INFO_LENGTH_MISMATCH, "Got status 0x%lx\n", status);
95     ok(IoStatusBlock.Status == 0x55555555, "IoStatusBlock.Status = 0x%lx\n", IoStatusBlock.Status);
96     ok(IoStatusBlock.Information == (ULONG_PTR)0x5555555555555555, "IoStatusBlock.Information = %Iu\n", IoStatusBlock.Information);
97 
98     RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55);
99     status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, VolumeInfo, sizeof(FILE_FS_VOLUME_INFORMATION) - 1, FileFsVolumeInformation);
100     ok(status == STATUS_INFO_LENGTH_MISMATCH, "Got status 0x%lx\n", status);
101     ok(IoStatusBlock.Status == 0x55555555, "IoStatusBlock.Status = 0x%lx\n", IoStatusBlock.Status);
102     ok(IoStatusBlock.Information == (ULONG_PTR)0x5555555555555555, "IoStatusBlock.Information = %Iu\n", IoStatusBlock.Information);
103 
104     RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
105     RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55);
106     status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, VolumeInfo, sizeof(FILE_FS_VOLUME_INFORMATION), FileFsVolumeInformation);
107     ok(status == STATUS_SUCCESS || status == STATUS_BUFFER_OVERFLOW, "Got status 0x%lx\n", status);
108     ok(IoStatusBlock.Status == status, "IoStatusBlock.Status = 0x%lx, expected 0x%lx\n", IoStatusBlock.Status, status);
109     if (status == STATUS_SUCCESS)
110     {
111         ok(VolumeInfo->VolumeLabelLength <= sizeof(FILE_FS_VOLUME_INFORMATION) - FIELD_OFFSET(FILE_FS_VOLUME_INFORMATION, VolumeLabel),
112            "VolumeInfo->VolumeLabelLength = %Iu\n", VolumeInfo->VolumeLabelLength);
113         ok(IoStatusBlock.Information >= FIELD_OFFSET(FILE_FS_VOLUME_INFORMATION, VolumeLabel),
114            "IoStatusBlock.Information = %Iu, expected >=%lu\n", IoStatusBlock.Information, (ULONG)FIELD_OFFSET(FILE_FS_VOLUME_INFORMATION, VolumeLabel));
115         ok(IoStatusBlock.Information <= sizeof(FILE_FS_VOLUME_INFORMATION),
116            "IoStatusBlock.Information = %Iu, expected <=%lu\n", IoStatusBlock.Information, (ULONG)sizeof(FILE_FS_VOLUME_INFORMATION));
117     }
118     else
119     {
120         ok(VolumeInfo->VolumeLabelLength > sizeof(FILE_FS_VOLUME_INFORMATION) - FIELD_OFFSET(FILE_FS_VOLUME_INFORMATION, VolumeLabel),
121            "VolumeInfo->VolumeLabelLength = %Iu\n", VolumeInfo->VolumeLabelLength);
122         ok(IoStatusBlock.Information == sizeof(FILE_FS_VOLUME_INFORMATION),
123            "IoStatusBlock.Information = %Iu, expected %lu\n", IoStatusBlock.Information, (ULONG)sizeof(FILE_FS_VOLUME_INFORMATION));
124     }
125     ok(VolumeInfo->VolumeLabel[VolumeInfo->VolumeLabelLength / sizeof(WCHAR)] == 0x5555,
126        "Got %x\n", VolumeInfo->VolumeLabel[VolumeInfo->VolumeLabelLength / sizeof(WCHAR)]);
127 
128     RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
129     RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55);
130     status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, VolumeInfo, sizeof(Buffer), FileFsVolumeInformation);
131     ok(status == STATUS_SUCCESS, "Got status 0x%lx\n", status);
132     ok(IoStatusBlock.Status == STATUS_SUCCESS, "IoStatusBlock.Status = 0x%lx\n", IoStatusBlock.Status);
133     ok(IoStatusBlock.Information == FIELD_OFFSET(FILE_FS_VOLUME_INFORMATION, VolumeLabel) + VolumeInfo->VolumeLabelLength,
134        "IoStatusBlock.Information = %Iu, expected %lu+%lu\n", IoStatusBlock.Information, (ULONG)FIELD_OFFSET(FILE_FS_VOLUME_INFORMATION, VolumeLabel), VolumeInfo->VolumeLabelLength);
135     ok(VolumeInfo->VolumeCreationTime.QuadPart != 0x5555555555555555, "VolumeInfo->VolumeCreationTime = %I64d\n", VolumeInfo->VolumeCreationTime.QuadPart);
136     ok(VolumeInfo->VolumeSerialNumber != 0x55555555, "VolumeInfo->VolumeSerialNumber = %lu\n", VolumeInfo->VolumeSerialNumber);
137     ok(VolumeInfo->SupportsObjects == FALSE || VolumeInfo->SupportsObjects == TRUE, "VolumeInfo->SupportsObjects = %u\n", VolumeInfo->SupportsObjects);
138     ok(VolumeInfo->VolumeLabelLength % sizeof(WCHAR) == 0, "VolumeInfo->VolumeLabelLength = %Iu\n", VolumeInfo->VolumeLabelLength);
139     if (VolumeInfo->VolumeLabelLength >= sizeof(WCHAR))
140         ok(VolumeInfo->VolumeLabel[VolumeInfo->VolumeLabelLength / sizeof(WCHAR) - 1] != 0x5555, "Incorrect VolumeLabel or Length\n");
141     trace("VolumeLabel = %.*ls\n", (int)VolumeInfo->VolumeLabelLength / sizeof(WCHAR), VolumeInfo->VolumeLabel);
142     ok(VolumeInfo->VolumeLabel[VolumeInfo->VolumeLabelLength / sizeof(WCHAR)] == 0x5555,
143        "Got %x\n", VolumeInfo->VolumeLabel[VolumeInfo->VolumeLabelLength / sizeof(WCHAR)]);
144 }
145 
146 static
147 VOID
148 TestFileFsAttributeInformation(HANDLE handle)
149 {
150     IO_STATUS_BLOCK IoStatusBlock;
151     ULONG Buffer[(sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 32 * sizeof(WCHAR)) / sizeof(ULONG)];
152     PFILE_FS_ATTRIBUTE_INFORMATION AttributeInfo = (PFILE_FS_ATTRIBUTE_INFORMATION)Buffer;
153     NTSTATUS status;
154 
155     status = NtQueryVolumeInformationFile(handle, NULL, NULL, 0, FileFsAttributeInformation);
156     ok(status == STATUS_INFO_LENGTH_MISMATCH, "Got status 0x%lx\n", status);
157 
158     RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55);
159     status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, NULL, 0, FileFsAttributeInformation);
160     ok(status == STATUS_INFO_LENGTH_MISMATCH, "Got status 0x%lx\n", status);
161     ok(IoStatusBlock.Status == 0x55555555, "IoStatusBlock.Status = 0x%lx\n", IoStatusBlock.Status);
162     ok(IoStatusBlock.Information == (ULONG_PTR)0x5555555555555555, "IoStatusBlock.Information = %Iu\n", IoStatusBlock.Information);
163 
164     status = NtQueryVolumeInformationFile(handle, NULL, AttributeInfo, 0, FileFsAttributeInformation);
165     ok(status == STATUS_INFO_LENGTH_MISMATCH, "Got status 0x%lx\n", status);
166 
167     RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55);
168     status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, (PUCHAR)Buffer + 2, sizeof(FILE_FS_ATTRIBUTE_INFORMATION), FileFsAttributeInformation);
169     ok(status == STATUS_DATATYPE_MISALIGNMENT, "Got status 0x%lx\n", status);
170     ok(IoStatusBlock.Status == 0x55555555, "IoStatusBlock.Status = 0x%lx\n", IoStatusBlock.Status);
171     ok(IoStatusBlock.Information == (ULONG_PTR)0x5555555555555555, "IoStatusBlock.Information = %Iu\n", IoStatusBlock.Information);
172 
173     RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55);
174     status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, AttributeInfo, 0, FileFsAttributeInformation);
175     ok(status == STATUS_INFO_LENGTH_MISMATCH, "Got status 0x%lx\n", status);
176     ok(IoStatusBlock.Status == 0x55555555, "IoStatusBlock.Status = 0x%lx\n", IoStatusBlock.Status);
177     ok(IoStatusBlock.Information == (ULONG_PTR)0x5555555555555555, "IoStatusBlock.Information = %Iu\n", IoStatusBlock.Information);
178 
179     RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55);
180     status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, AttributeInfo, FIELD_OFFSET(FILE_FS_ATTRIBUTE_INFORMATION, FileSystemName), FileFsAttributeInformation);
181     ok(status == STATUS_INFO_LENGTH_MISMATCH, "Got status 0x%lx\n", status);
182     ok(IoStatusBlock.Status == 0x55555555, "IoStatusBlock.Status = 0x%lx\n", IoStatusBlock.Status);
183     ok(IoStatusBlock.Information == (ULONG_PTR)0x5555555555555555, "IoStatusBlock.Information = %Iu\n", IoStatusBlock.Information);
184 
185     RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55);
186     status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, AttributeInfo, sizeof(FILE_FS_ATTRIBUTE_INFORMATION) - 1, FileFsAttributeInformation);
187     ok(status == STATUS_INFO_LENGTH_MISMATCH, "Got status 0x%lx\n", status);
188     ok(IoStatusBlock.Status == 0x55555555, "IoStatusBlock.Status = 0x%lx\n", IoStatusBlock.Status);
189     ok(IoStatusBlock.Information == (ULONG_PTR)0x5555555555555555, "IoStatusBlock.Information = %Iu\n", IoStatusBlock.Information);
190 
191     RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
192     RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55);
193     status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, AttributeInfo, sizeof(FILE_FS_ATTRIBUTE_INFORMATION), FileFsAttributeInformation);
194     ok(status == STATUS_BUFFER_OVERFLOW, "Got status 0x%lx\n", status);
195     ok(IoStatusBlock.Status == STATUS_BUFFER_OVERFLOW, "IoStatusBlock.Status = 0x%lx\n", IoStatusBlock.Status);
196     ok(AttributeInfo->FileSystemNameLength == sizeof(FILE_FS_ATTRIBUTE_INFORMATION) - FIELD_OFFSET(FILE_FS_ATTRIBUTE_INFORMATION, FileSystemName),
197        "AttributeInfo->FileSystemNameLength = %Iu\n", AttributeInfo->FileSystemNameLength);
198     ok(IoStatusBlock.Information == sizeof(FILE_FS_ATTRIBUTE_INFORMATION),
199        "IoStatusBlock.Information = %Iu, expected %lu\n", IoStatusBlock.Information, (ULONG)sizeof(FILE_FS_ATTRIBUTE_INFORMATION));
200     ok(AttributeInfo->FileSystemName[AttributeInfo->FileSystemNameLength / sizeof(WCHAR)] == 0x5555,
201        "Got %x\n", AttributeInfo->FileSystemName[AttributeInfo->FileSystemNameLength / sizeof(WCHAR)]);
202 
203     RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
204     RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55);
205     status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, AttributeInfo, sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 1, FileFsAttributeInformation);
206     ok(status == STATUS_BUFFER_OVERFLOW, "Got status 0x%lx\n", status);
207     ok(IoStatusBlock.Status == STATUS_BUFFER_OVERFLOW, "IoStatusBlock.Status = 0x%lx\n", IoStatusBlock.Status);
208     ok(AttributeInfo->FileSystemNameLength == sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 1 - FIELD_OFFSET(FILE_FS_ATTRIBUTE_INFORMATION, FileSystemName),
209        "AttributeInfo->FileSystemNameLength = %Iu\n", AttributeInfo->FileSystemNameLength);
210     ok(IoStatusBlock.Information == sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 1,
211        "IoStatusBlock.Information = %Iu, expected %lu\n", IoStatusBlock.Information, (ULONG)sizeof(FILE_FS_ATTRIBUTE_INFORMATION));
212     ok((AttributeInfo->FileSystemName[AttributeInfo->FileSystemNameLength / sizeof(WCHAR)] & 0xff00) == 0x5500,
213        "Got %x\n", AttributeInfo->FileSystemName[AttributeInfo->FileSystemNameLength / sizeof(WCHAR)]);
214     ok(AttributeInfo->FileSystemName[AttributeInfo->FileSystemNameLength / sizeof(WCHAR) + 1] == 0x5555,
215        "Got %x\n", AttributeInfo->FileSystemName[AttributeInfo->FileSystemNameLength / sizeof(WCHAR) + 1]);
216 
217     RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
218     RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55);
219     status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, AttributeInfo, sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + sizeof(WCHAR), FileFsAttributeInformation);
220     if (status != STATUS_SUCCESS)
221     {
222         ok(status == STATUS_BUFFER_OVERFLOW, "Got status 0x%lx\n", status);
223         ok(IoStatusBlock.Status == STATUS_BUFFER_OVERFLOW, "IoStatusBlock.Status = 0x%lx\n", IoStatusBlock.Status);
224         ok(AttributeInfo->FileSystemNameLength == sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + sizeof(WCHAR) - FIELD_OFFSET(FILE_FS_ATTRIBUTE_INFORMATION, FileSystemName),
225            "AttributeInfo->FileSystemNameLength = %Iu\n", AttributeInfo->FileSystemNameLength);
226         ok(IoStatusBlock.Information == sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + sizeof(WCHAR),
227            "IoStatusBlock.Information = %Iu, expected %lu\n", IoStatusBlock.Information, (ULONG)sizeof(FILE_FS_ATTRIBUTE_INFORMATION));
228         ok(AttributeInfo->FileSystemName[AttributeInfo->FileSystemNameLength / sizeof(WCHAR)] == 0x5555,
229            "Got %x\n", AttributeInfo->FileSystemName[AttributeInfo->FileSystemNameLength / sizeof(WCHAR)]);
230     }
231 
232     RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
233     RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55);
234     status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, AttributeInfo, sizeof(Buffer), FileFsAttributeInformation);
235     ok(status == STATUS_SUCCESS, "Got status 0x%lx\n", status);
236     ok(IoStatusBlock.Status == STATUS_SUCCESS, "IoStatusBlock.Status = 0x%lx\n", IoStatusBlock.Status);
237     ok(IoStatusBlock.Information == FIELD_OFFSET(FILE_FS_ATTRIBUTE_INFORMATION, FileSystemName) + AttributeInfo->FileSystemNameLength,
238        "IoStatusBlock.Information = %Iu, expected %lu+%lu\n", IoStatusBlock.Information, (ULONG)FIELD_OFFSET(FILE_FS_ATTRIBUTE_INFORMATION, FileSystemName), AttributeInfo->FileSystemNameLength);
239     ok(AttributeInfo->FileSystemAttributes != 0x55555555, "AttributeInfo->FileSystemAttributes = 0x%lx\n", AttributeInfo->FileSystemAttributes);
240     ok(AttributeInfo->MaximumComponentNameLength != 0x55555555, "AttributeInfo->MaximumComponentNameLength = 0x%lx\n", AttributeInfo->MaximumComponentNameLength);
241     ok(AttributeInfo->FileSystemNameLength % sizeof(WCHAR) == 0, "AttributeInfo->FileSystemNameLength = %Iu\n", AttributeInfo->FileSystemNameLength);
242     ok(!wcsncmp(AttributeInfo->FileSystemName, L"NTFS", 4) ||
243        !wcsncmp(AttributeInfo->FileSystemName, L"FAT", 3) ||
244        !wcsncmp(AttributeInfo->FileSystemName, L"FAT32", 5),
245        "FileSystemName = %.*ls\n", (int)AttributeInfo->FileSystemNameLength / sizeof(WCHAR), AttributeInfo->FileSystemName);
246     trace("FileSystemName = %.*ls\n", (int)AttributeInfo->FileSystemNameLength / sizeof(WCHAR), AttributeInfo->FileSystemName);
247     ok(AttributeInfo->FileSystemName[AttributeInfo->FileSystemNameLength / sizeof(WCHAR)] == 0x5555,
248        "Got %x\n", AttributeInfo->FileSystemName[AttributeInfo->FileSystemNameLength / sizeof(WCHAR)]);
249 }
250 
251 START_TEST(NtQueryVolumeInformationFile)
252 {
253     IO_STATUS_BLOCK IoStatusBlock;
254     OBJECT_ATTRIBUTES attr;
255     HANDLE handle;
256     WCHAR path[MAX_PATH];
257     UNICODE_STRING pathW;
258     NTSTATUS status;
259 
260     /*Store a valid Handle*/
261     GetWindowsDirectoryW(path, MAX_PATH);
262     RtlDosPathNameToNtPathName_U(path, &pathW, NULL, NULL);
263 
264     InitializeObjectAttributes(&attr, &pathW, OBJ_CASE_INSENSITIVE, NULL, NULL);
265     status = NtOpenFile(&handle, SYNCHRONIZE|FILE_LIST_DIRECTORY, &attr, &IoStatusBlock, FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_DIRECTORY_FILE|FILE_SYNCHRONOUS_IO_NONALERT);
266     ok(status == STATUS_SUCCESS, "NtOpenFile failed: 0x%lx\n", status);
267     RtlFreeUnicodeString(&pathW);
268 
269     if (!NT_SUCCESS(status))
270     {
271         skip("NtOpenFile failed: 0x%lx\n", status);
272         return;
273     }
274 
275     /*Now all NULL. Priority check: FsInformationClass value!*/
276     SetLastError(0xcacacaca);
277     status = NtQueryVolumeInformationFile(NULL, NULL, NULL, 0, 0);
278     ok(status == STATUS_INVALID_INFO_CLASS, "Expected STATUS_INVALID_INFO_CLASS, got 0x%lx\n", status);
279     ok(GetLastError() == 0xcacacaca, "Expected 0xcacacaca, got %lx\n", GetLastError());
280 
281     TestFileFsDeviceInformation(handle);
282     TestFileFsVolumeInformation(handle);
283     TestFileFsAttributeInformation(handle);
284 
285     NtClose(handle);
286 }
287