Author: tfaber
Date: Sat Oct 29 20:14:16 2016
New Revision: 73071
URL:
http://svn.reactos.org/svn/reactos?rev=73071&view=rev
Log:
[NTDLL_APITEST]
- Add a test for NtReadFile, also covering buffer size too large for an MDL
CORE-12132
Added:
trunk/rostests/apitests/ntdll/NtReadFile.c
- copied, changed from r73059, trunk/rostests/apitests/ntdll/NtWriteFile.c
Modified:
trunk/rostests/apitests/ntdll/CMakeLists.txt
trunk/rostests/apitests/ntdll/testlist.c
Modified: trunk/rostests/apitests/ntdll/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/CMakeLists…
==============================================================================
--- trunk/rostests/apitests/ntdll/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/rostests/apitests/ntdll/CMakeLists.txt [iso-8859-1] Sat Oct 29 20:14:16 2016
@@ -18,6 +18,7 @@
NtQueryKey.c
NtQuerySystemEnvironmentValue.c
NtQueryVolumeInformationFile.c
+ NtReadFile.c
NtSaveKey.c
NtSetValueKey.c
NtWriteFile.c
Copied: trunk/rostests/apitests/ntdll/NtReadFile.c (from r73059,
trunk/rostests/apitests/ntdll/NtWriteFile.c)
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/NtReadFile…
==============================================================================
--- trunk/rostests/apitests/ntdll/NtWriteFile.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/ntdll/NtReadFile.c [iso-8859-1] Sat Oct 29 20:14:16 2016
@@ -1,7 +1,7 @@
/*
* PROJECT: ReactOS API tests
* LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
- * PURPOSE: Test for NtWriteFile
+ * PURPOSE: Test for NtReadFile
* PROGRAMMER: Thomas Faber <thomas.faber(a)reactos.org>
*/
@@ -47,11 +47,11 @@
return Is64BitSystem() ? 48 : 28;
}
-START_TEST(NtWriteFile)
+START_TEST(NtReadFile)
{
NTSTATUS Status;
HANDLE FileHandle;
- UNICODE_STRING FileName =
RTL_CONSTANT_STRING(L"\\SystemRoot\\ntdll-apitest-NtWriteFile-test.bin");
+ UNICODE_STRING FileName =
RTL_CONSTANT_STRING(L"\\SystemRoot\\ntdll-apitest-NtReadFile-test.bin");
PVOID Buffer;
SIZE_T BufferSize;
LARGE_INTEGER ByteOffset;
@@ -73,7 +73,7 @@
0,
&BufferSize,
MEM_RESERVE | MEM_COMMIT,
- PAGE_READONLY);
+ PAGE_READWRITE);
if (!NT_SUCCESS(Status))
{
skip("Failed to allocate memory, status %lx\n", Status);
@@ -86,7 +86,7 @@
NULL,
NULL);
Status = NtCreateFile(&FileHandle,
- FILE_WRITE_DATA | DELETE | SYNCHRONIZE,
+ FILE_READ_DATA | FILE_WRITE_DATA | DELETE | SYNCHRONIZE,
&ObjectAttributes,
&IoStatus,
NULL,
@@ -99,53 +99,66 @@
0);
ok_hex(Status, STATUS_SUCCESS);
- /* non-cached, max size -- succeeds */
+ ByteOffset.QuadPart = 0x10000;
Status = NtWriteFile(FileHandle,
NULL,
NULL,
NULL,
&IoStatus,
Buffer,
- LargeMdlMaxDataSize - PAGE_SIZE,
+ BufferSize - 0x10000,
&ByteOffset,
NULL);
ok_hex(Status, STATUS_SUCCESS);
+ ByteOffset.QuadPart = 0;
/* non-cached, max size -- succeeds */
- Status = NtWriteFile(FileHandle,
- NULL,
- NULL,
- NULL,
- &IoStatus,
- Buffer,
- LargeMdlMaxDataSize,
- &ByteOffset,
- NULL);
+ Status = NtReadFile(FileHandle,
+ NULL,
+ NULL,
+ NULL,
+ &IoStatus,
+ Buffer,
+ LargeMdlMaxDataSize - PAGE_SIZE,
+ &ByteOffset,
+ NULL);
+ ok_hex(Status, STATUS_SUCCESS);
+
+ /* non-cached, max size -- succeeds */
+ Status = NtReadFile(FileHandle,
+ NULL,
+ NULL,
+ NULL,
+ &IoStatus,
+ Buffer,
+ LargeMdlMaxDataSize,
+ &ByteOffset,
+ NULL);
ok_hex(Status, STATUS_SUCCESS);
/* non-cached, too large -- fails to allocate MDL
* Note: this returns STATUS_SUCCESS on Win7 -- higher MDL size limit */
- Status = NtWriteFile(FileHandle,
- NULL,
- NULL,
- NULL,
- &IoStatus,
- Buffer,
- LargeMdlMaxDataSize + PAGE_SIZE,
- &ByteOffset,
- NULL);
+ Status = NtReadFile(FileHandle,
+ NULL,
+ NULL,
+ NULL,
+ &IoStatus,
+ Buffer,
+ LargeMdlMaxDataSize + PAGE_SIZE,
+ &ByteOffset,
+ NULL);
ok_hex(Status, STATUS_INSUFFICIENT_RESOURCES);
/* non-cached, unaligned -- fails with invalid parameter */
- Status = NtWriteFile(FileHandle,
- NULL,
- NULL,
- NULL,
- &IoStatus,
- Buffer,
- LargeMdlMaxDataSize + 1,
- &ByteOffset,
- NULL);
+ Status = NtReadFile(FileHandle,
+ NULL,
+ NULL,
+ NULL,
+ &IoStatus,
+ Buffer,
+ LargeMdlMaxDataSize + 1,
+ &ByteOffset,
+ NULL);
ok_hex(Status, STATUS_INVALID_PARAMETER);
DispositionInfo.DeleteFile = TRUE;
@@ -159,7 +172,7 @@
ok_hex(Status, STATUS_SUCCESS);
Status = NtCreateFile(&FileHandle,
- FILE_WRITE_DATA | DELETE | SYNCHRONIZE,
+ FILE_READ_DATA | FILE_WRITE_DATA | DELETE | SYNCHRONIZE,
&ObjectAttributes,
&IoStatus,
NULL,
@@ -171,38 +184,51 @@
0);
ok_hex(Status, STATUS_SUCCESS);
- /* cached: succeeds with arbitrary length */
+ ByteOffset.QuadPart = 0x10000;
Status = NtWriteFile(FileHandle,
NULL,
NULL,
NULL,
&IoStatus,
Buffer,
- LargeMdlMaxDataSize,
+ BufferSize - 0x10000,
&ByteOffset,
NULL);
ok_hex(Status, STATUS_SUCCESS);
-
- Status = NtWriteFile(FileHandle,
- NULL,
- NULL,
- NULL,
- &IoStatus,
- Buffer,
- LargeMdlMaxDataSize + 1,
- &ByteOffset,
- NULL);
- ok_hex(Status, STATUS_SUCCESS);
-
- Status = NtWriteFile(FileHandle,
- NULL,
- NULL,
- NULL,
- &IoStatus,
- Buffer,
- TooLargeDataSize,
- &ByteOffset,
- NULL);
+ ByteOffset.QuadPart = 0;
+
+ /* cached: succeeds with arbitrary length */
+ Status = NtReadFile(FileHandle,
+ NULL,
+ NULL,
+ NULL,
+ &IoStatus,
+ Buffer,
+ LargeMdlMaxDataSize,
+ &ByteOffset,
+ NULL);
+ ok_hex(Status, STATUS_SUCCESS);
+
+ Status = NtReadFile(FileHandle,
+ NULL,
+ NULL,
+ NULL,
+ &IoStatus,
+ Buffer,
+ LargeMdlMaxDataSize + 1,
+ &ByteOffset,
+ NULL);
+ ok_hex(Status, STATUS_SUCCESS);
+
+ Status = NtReadFile(FileHandle,
+ NULL,
+ NULL,
+ NULL,
+ &IoStatus,
+ Buffer,
+ TooLargeDataSize,
+ &ByteOffset,
+ NULL);
ok_hex(Status, STATUS_SUCCESS);
DispositionInfo.DeleteFile = TRUE;
Modified: trunk/rostests/apitests/ntdll/testlist.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/testlist.c…
==============================================================================
--- trunk/rostests/apitests/ntdll/testlist.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/ntdll/testlist.c [iso-8859-1] Sat Oct 29 20:14:16 2016
@@ -21,6 +21,7 @@
extern void func_NtQueryKey(void);
extern void func_NtQuerySystemEnvironmentValue(void);
extern void func_NtQueryVolumeInformationFile(void);
+extern void func_NtReadFile(void);
extern void func_NtSaveKey(void);
extern void func_NtSetValueKey(void);
extern void func_NtSystemInformation(void);
@@ -68,6 +69,7 @@
{ "NtQueryKey", func_NtQueryKey },
{ "NtQuerySystemEnvironmentValue", func_NtQuerySystemEnvironmentValue },
{ "NtQueryVolumeInformationFile", func_NtQueryVolumeInformationFile },
+ { "NtReadFile", func_NtReadFile },
{ "NtSaveKey", func_NtSaveKey},
{ "NtSetValueKey", func_NtSetValueKey},
{ "NtSystemInformation", func_NtSystemInformation },