1 /*
2  * PROJECT:     ReactOS Kernel
3  * LICENSE:     LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4  * PURPOSE:     Test for NtQueryInformationFile
5  * COPYRIGHT:   Copyright 2019 Thomas Faber (thomas.faber@reactos.org)
6  */
7 
8 #include "precomp.h"
9 
10 #define ntv6(x) (LOBYTE(LOWORD(GetVersion())) >= 6 ? (x) : 0)
11 
12 START_TEST(NtQueryInformationFile)
13 {
14     NTSTATUS Status;
15 
16     Status = NtQueryInformationFile(NULL, NULL, NULL, 0, 0);
17     ok(Status == STATUS_INVALID_INFO_CLASS ||
18        ntv6(Status == STATUS_NOT_IMPLEMENTED), "Status = %lx\n", Status);
19 
20     Status = NtQueryInformationFile(NULL, NULL, NULL, 0, 0x80000000);
21     ok(Status == STATUS_INVALID_INFO_CLASS ||
22        ntv6(Status == STATUS_NOT_IMPLEMENTED), "Status = %lx\n", Status);
23 
24     /* Get the full path of the current executable */
25     CHAR Path[MAX_PATH];
26     DWORD Length = GetModuleFileNameA(NULL, Path, _countof(Path));
27     ok(Length != 0, "GetModuleFileNameA failed\n");
28     if (Length == 0)
29         return;
30 
31     /* Open the file */
32     HANDLE hFile = CreateFileA(Path,
33                                GENERIC_READ,
34                                FILE_SHARE_READ,
35                                NULL,
36                                OPEN_EXISTING,
37                                FILE_ATTRIBUTE_NORMAL,
38                                NULL);
39     ok(hFile != INVALID_HANDLE_VALUE, "CreateFileA failed\n");
40     if (hFile == INVALID_HANDLE_VALUE)
41         return;
42 
43     /* Query FileEndOfFileInformation */
44     FILE_END_OF_FILE_INFORMATION EndOfFileInformation;
45     EndOfFileInformation.EndOfFile.QuadPart = 0xdeaddead;
46     Status = NtQueryInformationFile(hFile,
47                                     NULL,
48                                     &EndOfFileInformation,
49                                     sizeof(EndOfFileInformation),
50                                     FileEndOfFileInformation);
51     ok_hex(Status, STATUS_INVALID_INFO_CLASS);
52     ok(EndOfFileInformation.EndOfFile.QuadPart == 0xdeaddead, "EndOfFile is modified\n");
53 
54     CloseHandle(hFile);
55 }
56