From bebf99aaf1b7ddee0ebc5529928c0e875170c2dd Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 22 Apr 2024 11:41:00 +0300 Subject: [PATCH] [NTDLL_APITEST] Add test for FileEndOfFileInformation --- .../apitests/ntdll/NtQueryInformationFile.c | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/modules/rostests/apitests/ntdll/NtQueryInformationFile.c b/modules/rostests/apitests/ntdll/NtQueryInformationFile.c index 74739bb390b..bc03e6f744a 100644 --- a/modules/rostests/apitests/ntdll/NtQueryInformationFile.c +++ b/modules/rostests/apitests/ntdll/NtQueryInformationFile.c @@ -20,4 +20,36 @@ START_TEST(NtQueryInformationFile) Status = NtQueryInformationFile(NULL, NULL, NULL, 0, 0x80000000); ok(Status == STATUS_INVALID_INFO_CLASS || ntv6(Status == STATUS_NOT_IMPLEMENTED), "Status = %lx\n", Status); + + /* Get the full path of the current executable */ + CHAR Path[MAX_PATH]; + DWORD Length = GetModuleFileNameA(NULL, Path, _countof(Path)); + ok(Length != 0, "GetModuleFileNameA failed\n"); + if (Length == 0) + return; + + /* Open the file */ + HANDLE hFile = CreateFileA(Path, + GENERIC_READ, + FILE_SHARE_READ, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + ok(hFile != INVALID_HANDLE_VALUE, "CreateFileA failed\n"); + if (hFile == INVALID_HANDLE_VALUE) + return; + + /* Query FileEndOfFileInformation */ + FILE_END_OF_FILE_INFORMATION EndOfFileInformation; + EndOfFileInformation.EndOfFile.QuadPart = 0xdeaddead; + Status = NtQueryInformationFile(hFile, + NULL, + &EndOfFileInformation, + sizeof(EndOfFileInformation), + FileEndOfFileInformation); + ok_hex(Status, STATUS_INVALID_INFO_CLASS); + ok(EndOfFileInformation.EndOfFile.QuadPart == 0xdeaddead, "EndOfFile is modified\n"); + + CloseHandle(hFile); }