13#define IOCTL_START_TEST 1
14#define IOCTL_FINISH_TEST 2
59 *
Flags = TESTENTRY_NO_EXCLUSIVE_DEVICE |
60 TESTENTRY_BUFFERED_IO_DEVICE |
61 TESTENTRY_NO_READONLY_DEVICE;
92 trace(
"System with %I64dMb RAM and terminal services %S\n",
Memory, (
TS ?
L"enabled" :
L"disabled"));
189#define ok_bcb(B, L, O) \
191 PPUBLIC_BCB public_bcb = (B); \
192 ok(public_bcb->NodeTypeCode == 0x2FD, "Not a BCB: %04x\n", public_bcb->NodeTypeCode); \
193 ok(public_bcb->NodeByteSize == 0, "Invalid size: %d\n", public_bcb->NodeByteSize); \
194 ok_eq_ulong(public_bcb->MappedLength, (L)); \
195 ok_eq_longlong(public_bcb->MappedFileOffset.QuadPart, (O)); \
213 ok(TestContext !=
NULL,
"Called in invalid context!\n");
214 ok(TestContext->
Bcb !=
NULL,
"Called in invalid context!\n");
215 ok(TestContext->
Buffer !=
NULL,
"Called in invalid context!\n");
216 ok(TestContext->
Length != 0,
"Called in invalid context!\n");
224 if (!
skip(Ret ==
TRUE,
"CcPinRead failed\n"))
237 if (!
skip(Ret ==
TRUE,
"CcPinRead failed\n"))
250 if (!
skip(Ret ==
TRUE,
"CcPinRead failed\n"))
263 if (!
skip(Ret ==
TRUE,
"CcMapData failed\n"))
265 ok(
Bcb != TestContext->
Bcb,
"Returned same BCB!\n");
272 TestContext->
Length -= 0x500;
278 if (!
skip(Ret ==
TRUE,
"CcPinRead failed\n"))
291 if (!
skip(Ret ==
TRUE,
"CcPinRead failed\n"))
304 if (!
skip(Ret ==
TRUE,
"CcPinRead failed\n"))
331 ok(TestContext !=
NULL,
"Called in invalid context!\n");
332 ok(TestContext->
Bcb !=
NULL,
"Called in invalid context!\n");
333 ok(TestContext->
Buffer !=
NULL,
"Called in invalid context!\n");
334 ok(TestContext->
Length != 0,
"Called in invalid context!\n");
341 ok(Ret ==
FALSE,
"CcPinRead succeed\n");
352 if (!
skip(Ret ==
TRUE,
"CcMapData failed\n"))
354 ok(
Bcb != TestContext->
Bcb,
"Returned same BCB!\n");
361 TestContext->
Length -= 0x500;
366 ok(Ret ==
FALSE,
"CcPinRead succeed\n");
376 ok(Ret ==
FALSE,
"CcPinRead succeed\n");
387 if (!
skip(Ret ==
TRUE,
"CcMapData failed\n"))
389 ok(
Bcb != TestContext->
Bcb,
"Returned same BCB!\n");
422 BOOLEAN PinAccess = (TestId != 4);
426 FsRtlSetupAdvancedHeader(&
Fcb->
Header, &
Fcb->HeaderMutex);
447 Offset.QuadPart = TestId * 0x1000;
452 if (!
skip(Ret ==
TRUE,
"CcPinRead failed\n"))
460 else if (TestId == 3)
465 if (!
skip(TestContext !=
NULL,
"ExAllocatePool failed\n"))
474 ok(Ret ==
FALSE,
"CcPinRead succeed\n");
484 if (!
skip(Ret ==
TRUE,
"CcPinRead failed\n"))
496 "Buffer %p not mapped in system space\n", TestContext->
Buffer);
501 "Buffer %p not mapped in system space\n", TestContext->
Buffer);
506 "Buffer %p not mapped in system space\n", TestContext->
Buffer);
508#elif defined(_M_AMD64)
510 "Buffer %p not mapped in system space\n", TestContext->
Buffer);
512 skip(
FALSE,
"System space mapping not defined\n");
530 if (!
skip(Ret ==
TRUE,
"CcPinRead failed\n"))
546 else if (TestId == 4)
554 if (!
skip(Ret ==
TRUE,
"CcPinRead failed\n"))
562 else if (TestId == 5)
574 ok(Ret ==
TRUE,
"CcPinRead failed\n");
587 ok(Ret ==
TRUE,
"CcPinRead failed\n");
600 ok(Ret ==
TRUE,
"CcPinRead failed\n");
624 ok(Ret ==
TRUE,
"CcPinRead failed\n");
648 ok(Ret ==
TRUE,
"CcPinRead failed\n");
665 else if (TestId == 6)
674 if (!
skip(Ret ==
TRUE,
"CcPinRead failed\n"))
782 DPRINT(
"IRP %x/%x\n", IoStack->MajorFunction, IoStack->MinorFunction);
789 Irp->IoStatus.Information = 0;
798 Offset = IoStack->Parameters.Read.ByteOffset;
799 Length = IoStack->Parameters.Read.Length;
810 ok(
Irp->AssociatedIrp.SystemBuffer ==
NULL,
"A SystemBuffer was allocated!\n");
822 ok(
Mdl !=
NULL,
"Null pointer for MDL!\n");
837 Offset = IoStack->Parameters.Write.ByteOffset;
838 Length = IoStack->Parameters.Write.Length;
868 ok(
Offset.QuadPart == 0,
"Offset is not null: %I64i\n",
Offset.QuadPart);
876 ok(
Mdl !=
NULL,
"Null pointer for MDL!\n");
struct _TEST_CONTEXT TEST_CONTEXT
static CC_FILE_SIZES SmallFileSizes
VOID NTAPI ReleaseFromReadAhead(_In_ PVOID Context)
static PDEVICE_OBJECT TestDeviceObject
static PFILE_OBJECT TestFileObject
#define IOCTL_FINISH_TEST
static CC_FILE_SIZES FileSizes
static VOID PerformTest(ULONG TestId, PDEVICE_OBJECT DeviceObject)
struct _TEST_FCB TEST_FCB
LARGE_INTEGER WriteOffset
BOOLEAN NTAPI AcquireForReadAhead(_In_ PVOID Context, _In_ BOOLEAN Wait)
static VOID CleanupTest(ULONG TestId, PDEVICE_OBJECT DeviceObject)
struct _TEST_FCB * PTEST_FCB
VOID TestUnload(_In_ PDRIVER_OBJECT DriverObject)
static BOOLEAN TestWriteCalled
struct _TEST_CONTEXT * PTEST_CONTEXT
static PVOID MapAndLockUserBuffer(_In_ _Out_ PIRP Irp, _In_ ULONG BufferLength)
static CACHE_MANAGER_CALLBACKS Callbacks
static KMT_MESSAGE_HANDLER TestMessageHandler
VOID NTAPI ReleaseFromLazyWrite(_In_ PVOID Context)
NTSTATUS TestEntry(_In_ PDRIVER_OBJECT DriverObject, _In_ PCUNICODE_STRING RegistryPath, _Out_ PCWSTR *DeviceName, _Inout_ INT *Flags)
static VOID NTAPI PinInAnotherThread(IN PVOID Context)
BOOLEAN NTAPI AcquireForLazyWrite(_In_ PVOID Context, _In_ BOOLEAN Wait)
static KMT_IRP_HANDLER TestIrpHandler
static VOID NTAPI PinInAnotherThreadExclusive(IN PVOID Context)
#define ok_eq_pointer(value, expected)
#define ok_eq_ulong(value, expected)
#define ok_eq_longlong(value, expected)
#define ok_bool_false(value, desc)
#define ok_bool_true(value, desc)
OSVERSIONINFOW VersionInfo
VOID NTAPI CcFlushCache(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN OPTIONAL PLARGE_INTEGER FileOffset, IN ULONG Length, OUT OPTIONAL PIO_STATUS_BLOCK IoStatus)
VOID NTAPI CcSetDirtyPinnedData(IN PVOID BcbVoid, IN OPTIONAL PLARGE_INTEGER Lsn)
#define CcIsFileCached(FO)
#define STATUS_NOT_SUPPORTED
#define STATUS_NOT_IMPLEMENTED
#define NT_SUCCESS(StatCode)
NTSTATUS NTAPI RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
#define KeInitializeEvent(pEvt, foo, foo2)
#define BooleanFlagOn(F, SF)
IN PVCB IN VBO IN ULONG OUT PBCB * Bcb
IN PVCB IN VBO IN ULONG OUT PBCB OUT PVOID IN BOOLEAN IN BOOLEAN Zero
#define ExAllocatePool(type, size)
NTSYSAPI NTSTATUS NTAPI ZwQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
VOID NTAPI CcSetFileSizes(IN PFILE_OBJECT FileObject, IN PCC_FILE_SIZES FileSizes)
VOID NTAPI CcInitializeCacheMap(IN PFILE_OBJECT FileObject, IN PCC_FILE_SIZES FileSizes, IN BOOLEAN PinAccess, IN PCACHE_MANAGER_CALLBACKS Callbacks, IN PVOID LazyWriteContext)
BOOLEAN NTAPI CcUninitializeCacheMap(IN PFILE_OBJECT FileObject, IN OPTIONAL PLARGE_INTEGER TruncateSize, IN OPTIONAL PCACHE_UNINITIALIZE_EVENT UninitializeEvent)
#define RtlFillMemory(Dest, Length, Fill)
#define EXCEPTION_EXECUTE_HANDLER
#define KmtEndSeh(ExpectedStatus)
PKTHREAD KmtStartThread(IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext OPTIONAL)
VOID KmtFinishThread(IN PKTHREAD Thread OPTIONAL, IN PKEVENT Event OPTIONAL)
NTSTATUS KmtRegisterMessageHandler(IN ULONG ControlCode OPTIONAL, IN PDEVICE_OBJECT DeviceObject OPTIONAL, IN PKMT_MESSAGE_HANDLER MessageHandler)
NTSTATUS KmtRegisterIrpHandler(IN UCHAR MajorFunction, IN PDEVICE_OBJECT DeviceObject OPTIONAL, IN PKMT_IRP_HANDLER IrpHandler)
VOID NTAPI MmProbeAndLockPages(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN LOCK_OPERATION Operation)
#define RTL_CONSTANT_LARGE_INTEGER(quad_part)
#define VER_SUITE_TERMINAL
#define UNREFERENCED_PARAMETER(P)
#define VER_SUITE_SINGLEUSERTS
_In_ ULONG _In_ ULONG Offset
_In_ ULONG _In_ ULONG _In_ ULONG Length
PFILE_OBJECT NTAPI IoCreateStreamFileObject(IN PFILE_OBJECT FileObject, IN PDEVICE_OBJECT DeviceObject)
#define IoCompleteRequest
VOID NTAPI CcUnpinData(IN PVOID Bcb)
BOOLEAN NTAPI CcPinRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG Flags, OUT PVOID *Bcb, OUT PVOID *Buffer)
BOOLEAN NTAPI CcMapData(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG Flags, OUT PVOID *BcbResult, OUT PVOID *Buffer)
#define _SEH2_EXCEPT(...)
#define _SEH2_YIELD(__stmt)
LARGE_INTEGER AllocationSize
SECTION_OBJECT_POINTERS SectionObjectPointers
FSRTL_ADVANCED_FCB_HEADER Header
ULONG dwOSVersionInfoSize
SECTION_OBJECT_POINTERS SectionObjectPointers
FSRTL_ADVANCED_FCB_HEADER Header
#define RtlZeroMemory(Destination, Length)
_In_ PDEVICE_OBJECT DeviceObject
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
_In_ WDFDPC _In_ BOOLEAN Wait
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _Strict_type_match_ POOL_TYPE _In_opt_ ULONG _In_ _Out_ WDFMEMORY * Memory
_Must_inspect_result_ _In_ WDFUSBPIPE _In_ WDFREQUEST _In_opt_ WDFMEMORY _In_opt_ PWDFMEMORY_OFFSET WriteOffset
_IRQL_requires_same_ typedef _In_ ULONG ControlCode
_Must_inspect_result_ _In_ ULONG Flags
#define VACB_MAPPING_GRANULARITY
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority)
#define MDL_SOURCE_IS_NONPAGED_POOL
#define ObDereferenceObject