https://git.reactos.org/?p=reactos.git;a=commitdiff;h=bdaa8e5ad1064e6bbb3a6…
commit bdaa8e5ad1064e6bbb3a61c23248b8d2b22e117d
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Thu May 2 13:59:47 2019 +0200
Commit: Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Thu May 2 13:59:47 2019 +0200
[NTDLL_APITEST] Query sector size for NtWriteFile tests
---
modules/rostests/apitests/ntdll/NtWriteFile.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/modules/rostests/apitests/ntdll/NtWriteFile.c
b/modules/rostests/apitests/ntdll/NtWriteFile.c
index 1383e4e71c..7080fa84ec 100644
--- a/modules/rostests/apitests/ntdll/NtWriteFile.c
+++ b/modules/rostests/apitests/ntdll/NtWriteFile.c
@@ -38,6 +38,24 @@ SizeOfMdl(VOID)
return Is64BitSystem() ? 48 : 28;
}
+static
+ULONG
+SizeOfSector(VOID)
+{
+ BOOL Ret;
+ ULONG SectorSize;
+
+ /* FIXME: Would be better to actually open systemroot */
+ Ret = GetDiskFreeSpaceW(NULL, NULL, &SectorSize, NULL, NULL);
+ ok(Ret != FALSE, "GetDiskFreeSpaceW failed: %lx\n", GetLastError());
+ if (!Ret)
+ {
+ SectorSize = 4096; /* On failure, assume max size */
+ }
+
+ return SectorSize;
+}
+
START_TEST(NtWriteFile)
{
NTSTATUS Status;
@@ -213,7 +231,10 @@ START_TEST(NtWriteFile)
ok_hex(Status, STATUS_SUCCESS);
/* Now, testing aligned/non aligned writes */
- BufferSize = 4096; /* We assume max sector size */
+
+ BufferSize = SizeOfSector();
+ trace("Sector is %ld bytes\n", BufferSize);
+
Status = NtAllocateVirtualMemory(NtCurrentProcess(),
&Buffer,
0,