ReactOS 0.4.15-dev-5863-g1fe3ab7
CcCopyWrite_drv.c File Reference
#include <kmt_test.h>
#include <debug.h>
Include dependency graph for CcCopyWrite_drv.c:

Go to the source code of this file.

Classes

struct  _TEST_FCB
 

Macros

#define NDEBUG
 
#define ok_read_called(_Offset, _Length)
 
#define ok_read_not_called()   ok(!ReadCalled, "CcCopyWrite shouldn't have triggered a read.\n")
 

Typedefs

typedef struct _TEST_FCB TEST_FCB
 
typedef struct _TEST_FCBPTEST_FCB
 

Functions

static BOOLEAN NTAPI FastIoRead (_In_ PFILE_OBJECT FileObject, _In_ PLARGE_INTEGER FileOffset, _In_ ULONG Length, _In_ BOOLEAN Wait, _In_ ULONG LockKey, _Out_ PVOID Buffer, _Out_ PIO_STATUS_BLOCK IoStatus, _In_ PDEVICE_OBJECT DeviceObject)
 
static BOOLEAN NTAPI FastIoWrite (_In_ PFILE_OBJECT FileObject, _In_ PLARGE_INTEGER FileOffset, _In_ ULONG Length, _In_ BOOLEAN Wait, _In_ ULONG LockKey, _Out_ PVOID Buffer, _Out_ PIO_STATUS_BLOCK IoStatus, _In_ PDEVICE_OBJECT DeviceObject)
 
NTSTATUS TestEntry (_In_ PDRIVER_OBJECT DriverObject, _In_ PCUNICODE_STRING RegistryPath, _Out_ PCWSTR *DeviceName, _Inout_ INT *Flags)
 
VOID TestUnload (_In_ PDRIVER_OBJECT DriverObject)
 
BOOLEAN NTAPI AcquireForLazyWrite (_In_ PVOID Context, _In_ BOOLEAN Wait)
 
VOID NTAPI ReleaseFromLazyWrite (_In_ PVOID Context)
 
BOOLEAN NTAPI AcquireForReadAhead (_In_ PVOID Context, _In_ BOOLEAN Wait)
 
VOID NTAPI ReleaseFromReadAhead (_In_ PVOID Context)
 
static PVOID MapAndLockUserBuffer (_In_ _Out_ PIRP Irp, _In_ ULONG BufferLength)
 
static void reset_read (void)
 
static VOID Test_CcCopyWrite (PFILE_OBJECT FileObject)
 
static NTSTATUS TestIrpHandler (_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _In_ PIO_STACK_LOCATION IoStack)
 

Variables

static PFILE_OBJECT TestFileObject
 
static PDEVICE_OBJECT TestDeviceObject
 
static KMT_IRP_HANDLER TestIrpHandler
 
static FAST_IO_DISPATCH TestFastIoDispatch
 
static BOOLEAN InBehaviourTest
 
BOOLEAN ReadCalled
 
LARGE_INTEGER ReadOffset
 
ULONG ReadLength
 
static CACHE_MANAGER_CALLBACKS Callbacks
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 10 of file CcCopyWrite_drv.c.

◆ ok_read_called

#define ok_read_called (   _Offset,
  _Length 
)
Value:
do { \
ok(ReadCalled, "CcCopyWrite should have triggerred a read.\n"); \
ok_eq_longlong(ReadOffset.QuadPart, _Offset); \
ok_eq_ulong(ReadLength, _Length); \
}while(0)
ULONG ReadLength
BOOLEAN ReadCalled
_Check_return_ _Ret_maybenull_ _In_ size_t _In_ size_t _Offset
Definition: malloc.h:140
_Must_inspect_result_ _In_ WDFUSBPIPE _In_ WDFREQUEST _In_opt_ WDFMEMORY _In_opt_ PWDFMEMORY_OFFSET ReadOffset
Definition: wdfusb.h:2003

Definition at line 186 of file CcCopyWrite_drv.c.

◆ ok_read_not_called

#define ok_read_not_called ( )    ok(!ReadCalled, "CcCopyWrite shouldn't have triggered a read.\n")

Definition at line 192 of file CcCopyWrite_drv.c.

Typedef Documentation

◆ PTEST_FCB

◆ TEST_FCB

Function Documentation

◆ AcquireForLazyWrite()

BOOLEAN NTAPI AcquireForLazyWrite ( _In_ PVOID  Context,
_In_ BOOLEAN  Wait 
)

Definition at line 106 of file CcCopyWrite_drv.c.

109{
110 return TRUE;
111}
#define TRUE
Definition: types.h:120

◆ AcquireForReadAhead()

BOOLEAN NTAPI AcquireForReadAhead ( _In_ PVOID  Context,
_In_ BOOLEAN  Wait 
)

Definition at line 123 of file CcCopyWrite_drv.c.

126{
127 return TRUE;
128}

◆ FastIoRead()

static BOOLEAN NTAPI FastIoRead ( _In_ PFILE_OBJECT  FileObject,
_In_ PLARGE_INTEGER  FileOffset,
_In_ ULONG  Length,
_In_ BOOLEAN  Wait,
_In_ ULONG  LockKey,
_Out_ PVOID  Buffer,
_Out_ PIO_STATUS_BLOCK  IoStatus,
_In_ PDEVICE_OBJECT  DeviceObject 
)
static

Definition at line 34 of file CcCopyWrite_drv.c.

43{
45 return FALSE;
46}
#define FALSE
Definition: types.h:117
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:159
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423

Referenced by TestEntry().

◆ FastIoWrite()

static BOOLEAN NTAPI FastIoWrite ( _In_ PFILE_OBJECT  FileObject,
_In_ PLARGE_INTEGER  FileOffset,
_In_ ULONG  Length,
_In_ BOOLEAN  Wait,
_In_ ULONG  LockKey,
_Out_ PVOID  Buffer,
_Out_ PIO_STATUS_BLOCK  IoStatus,
_In_ PDEVICE_OBJECT  DeviceObject 
)
static

Definition at line 51 of file CcCopyWrite_drv.c.

60{
62 return FALSE;
63}

Referenced by TestEntry().

◆ MapAndLockUserBuffer()

static PVOID MapAndLockUserBuffer ( _In_ _Out_ PIRP  Irp,
_In_ ULONG  BufferLength 
)
static

Definition at line 147 of file CcCopyWrite_drv.c.

150{
151 PMDL Mdl;
152
153 if (Irp->MdlAddress == NULL)
154 {
155 Mdl = IoAllocateMdl(Irp->UserBuffer, BufferLength, FALSE, FALSE, Irp);
156 if (Mdl == NULL)
157 {
158 return NULL;
159 }
160
162 {
163 MmProbeAndLockPages(Mdl, Irp->RequestorMode, IoWriteAccess);
164 }
166 {
167 IoFreeMdl(Mdl);
168 Irp->MdlAddress = NULL;
169 _SEH2_YIELD(return NULL);
170 }
171 _SEH2_END;
172 }
173
175}
_In_ PIRP Irp
Definition: csq.h:116
#define NULL
Definition: types.h:112
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
#define IoFreeMdl
Definition: fxmdl.h:89
#define IoAllocateMdl
Definition: fxmdl.h:88
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
VOID NTAPI MmProbeAndLockPages(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN LOCK_OPERATION Operation)
Definition: mdlsup.c:931
@ NormalPagePriority
Definition: imports.h:56
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:162
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
@ IoWriteAccess
Definition: ketypes.h:852
#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority)

Referenced by TestIrpHandler().

◆ ReleaseFromLazyWrite()

VOID NTAPI ReleaseFromLazyWrite ( _In_ PVOID  Context)

Definition at line 115 of file CcCopyWrite_drv.c.

117{
118 return;
119}

◆ ReleaseFromReadAhead()

VOID NTAPI ReleaseFromReadAhead ( _In_ PVOID  Context)

Definition at line 132 of file CcCopyWrite_drv.c.

134{
135 return;
136}

◆ reset_read()

static void reset_read ( void  )
static

Definition at line 179 of file CcCopyWrite_drv.c.

180{
182 ReadOffset.QuadPart = MAXLONGLONG;
184}
#define MAXLONGLONG
#define MAXULONG
Definition: typedefs.h:251

Referenced by Test_CcCopyWrite().

◆ Test_CcCopyWrite()

static VOID Test_CcCopyWrite ( PFILE_OBJECT  FileObject)
static

Definition at line 196 of file CcCopyWrite_drv.c.

197{
198
199 BOOLEAN Ret;
201 CHAR Buffer[10];
202
203 memset(Buffer, 0xAC, 10);
204
205 /* Test bogus file object & file offset */
206 Ret = 'x';
208 Ret = CcCopyWrite(FileObject, NULL, 0, FALSE, NULL);
210 ok_eq_char(Ret, 'x');
211
212 Ret = 'x';
213 Offset.QuadPart = 0;
215 Ret = CcCopyWrite(NULL, &Offset, 10, FALSE, Buffer);
217 ok_eq_char(Ret, 'x');
218
219 /* What happens on invalid buffer */
220 Ret = 'x';
221 Offset.QuadPart = 0;
222 reset_read();
224 Ret = CcCopyWrite(FileObject, &Offset, 0, TRUE, NULL);
226 ok_bool_true(Ret, "CcCopyWrite(0, NULL) should succeed\n");
227 /* When there is nothing to write, there is no reason to read */
229
230 Ret = 'x';
231 Offset.QuadPart = 0;
232 reset_read();
234 Ret = CcCopyWrite(FileObject, &Offset, 10, TRUE, NULL);
236 ok_eq_char(Ret, 'x');
237 /* This raises an exception, but it actually triggered a read */
239
240 /* So this one succeeds, as the page is now resident */
241 Ret = 'x';
242 Offset.QuadPart = 0;
243 reset_read();
247 ok_bool_true(Ret, "CcCopyWrite should succeed\n");
248 /* But there was no read triggered, as the page is already resident. */
250
251 /* But this one doesn't */
252 Ret = 'x';
254 reset_read();
258 ok_bool_false(Ret, "CcCopyWrite should fail\n");
259 /* But it triggered a read anyway. */
261
262 /* Of course, waiting for it succeeds and triggers the read */
263 Ret = 'x';
265 reset_read();
267 Ret = CcCopyWrite(FileObject, &Offset, 10, TRUE, Buffer);
269 ok_bool_true(Ret, "CcCopyWrite should succeed\n");
271}
#define ok_read_not_called()
static void reset_read(void)
#define ok_read_called(_Offset, _Length)
unsigned char BOOLEAN
Definition: bufpool.h:45
#define PAGE_SIZE
Definition: env_spec_w32.h:49
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLdouble n
Definition: glext.h:7729
#define KmtStartSeh()
Definition: kmt_test.h:279
#define ok_eq_char(value, expected)
Definition: kmt_test.h:246
#define ok_bool_false(value, desc)
Definition: kmt_test.h:259
#define ok_bool_true(value, desc)
Definition: kmt_test.h:258
#define KmtEndSeh(ExpectedStatus)
Definition: kmt_test.h:285
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
BOOLEAN NTAPI CcCopyWrite(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN PVOID Buffer)
Definition: copysup.c:129
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
return succeed
Definition: scsi.h:3736
#define memset(x, y, z)
Definition: compat.h:39
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_INVALID_USER_BUFFER
Definition: udferr_usr.h:166
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
ret QuadPart
Definition: rtlfuncs.h:3089
char CHAR
Definition: xmlstorage.h:175

◆ TestEntry()

NTSTATUS TestEntry ( _In_ PDRIVER_OBJECT  DriverObject,
_In_ PCUNICODE_STRING  RegistryPath,
_Out_ PCWSTR DeviceName,
_Inout_ INT Flags 
)

Definition at line 66 of file CcCopyWrite_drv.c.

71{
73
74 PAGED_CODE();
75
77
78 *DeviceName = L"CcCopyWrite";
79 *Flags = TESTENTRY_NO_EXCLUSIVE_DEVICE |
80 TESTENTRY_BUFFERED_IO_DEVICE |
81 TESTENTRY_NO_READONLY_DEVICE;
82
88
91 DriverObject->FastIoDispatch = &TestFastIoDispatch;
92
93
94 return Status;
95}
#define PAGED_CODE()
static FAST_IO_DISPATCH TestFastIoDispatch
static BOOLEAN NTAPI FastIoWrite(_In_ PFILE_OBJECT FileObject, _In_ PLARGE_INTEGER FileOffset, _In_ ULONG Length, _In_ BOOLEAN Wait, _In_ ULONG LockKey, _Out_ PVOID Buffer, _Out_ PIO_STATUS_BLOCK IoStatus, _In_ PDEVICE_OBJECT DeviceObject)
static BOOLEAN NTAPI FastIoRead(_In_ PFILE_OBJECT FileObject, _In_ PLARGE_INTEGER FileOffset, _In_ ULONG Length, _In_ BOOLEAN Wait, _In_ ULONG LockKey, _Out_ PVOID Buffer, _Out_ PIO_STATUS_BLOCK IoStatus, _In_ PDEVICE_OBJECT DeviceObject)
static KMT_IRP_HANDLER TestIrpHandler
LONG NTSTATUS
Definition: precomp.h:26
Status
Definition: gdiplustypes.h:25
NTSTATUS KmtRegisterIrpHandler(IN UCHAR MajorFunction, IN PDEVICE_OBJECT DeviceObject OPTIONAL, IN PKMT_IRP_HANDLER IrpHandler)
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define L(x)
Definition: ntvdm.h:50
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
PFAST_IO_WRITE FastIoWrite
Definition: iotypes.h:1736
PFAST_IO_READ FastIoRead
Definition: iotypes.h:1735
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define IRP_MJ_FLUSH_BUFFERS
#define IRP_MJ_CLEANUP

◆ TestIrpHandler()

static NTSTATUS TestIrpHandler ( _In_ PDEVICE_OBJECT  DeviceObject,
_In_ PIRP  Irp,
_In_ PIO_STACK_LOCATION  IoStack 
)
static

Definition at line 275 of file CcCopyWrite_drv.c.

279{
283 CACHE_UNINITIALIZE_EVENT CacheUninitEvent;
284
285 PAGED_CODE();
286
287 DPRINT("IRP %x/%x\n", IoStack->MajorFunction, IoStack->MinorFunction);
288 ASSERT(IoStack->MajorFunction == IRP_MJ_CLEANUP ||
289 IoStack->MajorFunction == IRP_MJ_CREATE ||
290 IoStack->MajorFunction == IRP_MJ_READ ||
291 IoStack->MajorFunction == IRP_MJ_WRITE ||
292 IoStack->MajorFunction == IRP_MJ_FLUSH_BUFFERS);
293
295 Irp->IoStatus.Information = 0;
296
297 if (IoStack->MajorFunction == IRP_MJ_CREATE)
298 {
299 ok_irql(PASSIVE_LEVEL);
300
301 if (IoStack->FileObject->FileName.Length >= 2 * sizeof(WCHAR))
302 {
304 TestFileObject = IoStack->FileObject;
305 }
306 Fcb = ExAllocatePoolWithTag(NonPagedPool, sizeof(*Fcb), 'FwrI');
307 RtlZeroMemory(Fcb, sizeof(*Fcb));
308 ExInitializeFastMutex(&Fcb->HeaderMutex);
309 FsRtlSetupAdvancedHeader(&Fcb->Header, &Fcb->HeaderMutex);
310 if (IoStack->FileObject->FileName.Length >= 2 * sizeof(WCHAR) &&
311 IoStack->FileObject->FileName.Buffer[1] == 'B')
312 {
313 Fcb->Header.AllocationSize.QuadPart = 1000000;
314 Fcb->Header.FileSize.QuadPart = 1000000;
315 Fcb->Header.ValidDataLength.QuadPart = 1000000;
316 }
317 else if (IoStack->FileObject->FileName.Length >= 2 * sizeof(WCHAR) &&
318 IoStack->FileObject->FileName.Buffer[1] == 'S')
319 {
320 Fcb->Header.AllocationSize.QuadPart = 512;
321 Fcb->Header.FileSize.QuadPart = 512;
322 Fcb->Header.ValidDataLength.QuadPart = 512;
323 }
324 else if (IoStack->FileObject->FileName.Length >= 2 * sizeof(WCHAR) &&
325 IoStack->FileObject->FileName.Buffer[1] == 'V')
326 {
327 Fcb->Header.AllocationSize.QuadPart = 62;
328 Fcb->Header.FileSize.QuadPart = 62;
329 Fcb->Header.ValidDataLength.QuadPart = 62;
330 }
331 else
332 {
333 Fcb->Header.AllocationSize.QuadPart = 1004;
334 Fcb->Header.FileSize.QuadPart = 1004;
335 Fcb->Header.ValidDataLength.QuadPart = 1004;
336 }
337 Fcb->Header.IsFastIoPossible = FastIoIsNotPossible;
338 IoStack->FileObject->FsContext = Fcb;
339 IoStack->FileObject->SectionObjectPointer = &Fcb->SectionObjectPointers;
340
341 CcInitializeCacheMap(IoStack->FileObject,
342 (PCC_FILE_SIZES)&Fcb->Header.AllocationSize,
343 FALSE, &Callbacks, NULL);
344
345 Irp->IoStatus.Information = FILE_OPENED;
347 }
348 else if (IoStack->MajorFunction == IRP_MJ_READ)
349 {
350 PMDL Mdl;
354
355 Offset = IoStack->Parameters.Read.ByteOffset;
356 Length = IoStack->Parameters.Read.Length;
357 Fcb = IoStack->FileObject->FsContext;
358
360 ok_eq_pointer(IoStack->FileObject, TestFileObject);
361
362 ok(BooleanFlagOn(Irp->Flags, IRP_NOCACHE), "IRP not coming from Cc!\n");
363 ok_irql(APC_LEVEL);
364 ok((Offset.QuadPart == 0 || Offset.QuadPart == 4096 || Offset.QuadPart == 8192), "Unexpected offset: %I64i\n", Offset.QuadPart);
365 ok(Length % PAGE_SIZE == 0, "Length is not aligned: %I64i\n", Length);
366
370
371 ok(Irp->AssociatedIrp.SystemBuffer == NULL, "A SystemBuffer was allocated!\n");
373 ok(Buffer != NULL, "Null pointer!\n");
375
377
378 Mdl = Irp->MdlAddress;
379 ok(Mdl != NULL, "Null pointer for MDL!\n");
380 ok((Mdl->MdlFlags & MDL_PAGES_LOCKED) != 0, "MDL not locked\n");
381 ok((Mdl->MdlFlags & MDL_SOURCE_IS_NONPAGED_POOL) == 0, "MDL from non paged\n");
382 ok((Mdl->MdlFlags & MDL_IO_PAGE_READ) != 0, "Non paging IO\n");
383 ok((Irp->Flags & IRP_PAGING_IO) != 0, "Non paging IO\n");
384
385 Irp->IoStatus.Information = Length;
386 IoStack->FileObject->CurrentByteOffset.QuadPart = Offset.QuadPart + Length;
387 }
388 else if (IoStack->MajorFunction == IRP_MJ_WRITE)
389 {
390 PMDL Mdl;
394 static const UNICODE_STRING BehaviourTestFileName = RTL_CONSTANT_STRING(L"\\BehaviourTestFile");
395
396 Offset = IoStack->Parameters.Read.ByteOffset;
397 Length = IoStack->Parameters.Read.Length;
398 Fcb = IoStack->FileObject->FsContext;
399
400 ok_bool_false(InBehaviourTest, "Shouldn't trigger write from CcCopyWrite\n");
401 /* Check special file name */
402 InBehaviourTest = RtlCompareUnicodeString(&IoStack->FileObject->FileName, &BehaviourTestFileName, TRUE) == 0;
403
404 if (!FlagOn(Irp->Flags, IRP_NOCACHE))
405 {
406 BOOLEAN Ret;
407
408 ok_irql(PASSIVE_LEVEL);
409
410 if (InBehaviourTest)
411 {
412 Test_CcCopyWrite(IoStack->FileObject);
413 Status = Irp->IoStatus.Status = STATUS_SUCCESS;
414 }
415 else
416 {
417 Buffer = Irp->AssociatedIrp.SystemBuffer;
418 ok(Buffer != NULL, "Null pointer!\n");
419
420 Fcb->WriteLength = Length;
421
423 {
424 Ret = CcCopyWrite(IoStack->FileObject, &Offset, Length, TRUE, Buffer);
425 ok_bool_true(Ret, "CcCopyWrite");
426 }
428 {
429 Irp->IoStatus.Status = _SEH2_GetExceptionCode();
430 }
431 _SEH2_END;
432
433 Status = Irp->IoStatus.Status;
434 }
435 }
436 else
437 {
438 ok_irql(PASSIVE_LEVEL);
439
440 if (InBehaviourTest)
441 {
442 /* We wrote only to the 1st and 3rd page */
443 ok((Offset.QuadPart == 0) || (Offset.QuadPart == PAGE_SIZE * 2), "Expected a non-cached write on 1st or 3rd page\n");
444 /* We wrote that much with CcCopyWrite */
446 }
447 else
448 {
449 ok((Offset.QuadPart == 0 || Offset.QuadPart == 4096), "Unexpected offset: %I64i\n", Offset.QuadPart);
450 ok_eq_ulong(Length, ROUND_TO_PAGES(Fcb->WriteLength));
451 }
452
453 ok(Irp->AssociatedIrp.SystemBuffer == NULL, "A SystemBuffer was allocated!\n");
455 ok(Buffer != NULL, "Null pointer!\n");
456
458
459 Mdl = Irp->MdlAddress;
460 ok(Mdl != NULL, "Null pointer for MDL!\n");
461 ok((Mdl->MdlFlags & MDL_PAGES_LOCKED) != 0, "MDL not locked\n");
462 ok((Mdl->MdlFlags & MDL_SOURCE_IS_NONPAGED_POOL) == 0, "MDL from non paged\n");
463 ok((Mdl->MdlFlags & MDL_IO_PAGE_READ) == 0, "MDL for read paging IO\n");
464 ok((Irp->Flags & IRP_PAGING_IO) != 0, "Non paging IO\n");
465 }
466
468 }
469 else if (IoStack->MajorFunction == IRP_MJ_FLUSH_BUFFERS)
470 {
472
473 Fcb = IoStack->FileObject->FsContext;
475
477 }
478 else if (IoStack->MajorFunction == IRP_MJ_CLEANUP)
479 {
480 ok_irql(PASSIVE_LEVEL);
481 KeInitializeEvent(&CacheUninitEvent.Event, NotificationEvent, FALSE);
482 CcUninitializeCacheMap(IoStack->FileObject, &Zero, &CacheUninitEvent);
484 Fcb = IoStack->FileObject->FsContext;
485 ExFreePoolWithTag(Fcb, 'FwrI');
486 IoStack->FileObject->FsContext = NULL;
488 }
489
490 if (Status == STATUS_PENDING)
491 {
495 }
496 else
497 {
498 Irp->IoStatus.Status = Status;
500 }
501
502 return Status;
503}
static PDEVICE_OBJECT TestDeviceObject
static PFILE_OBJECT TestFileObject
static BOOLEAN InBehaviourTest
static PVOID MapAndLockUserBuffer(_In_ _Out_ PIRP Irp, _In_ ULONG BufferLength)
static CACHE_MANAGER_CALLBACKS Callbacks
#define ok_eq_pointer(value, expected)
#define ok_eq_ulong(value, expected)
#define ok(value,...)
Definition: atltest.h:57
VOID NTAPI CcFlushCache(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN OPTIONAL PLARGE_INTEGER FileOffset, IN ULONG Length, OUT OPTIONAL PIO_STATUS_BLOCK IoStatus)
Definition: cachesub.c:222
_In_ PFCB Fcb
Definition: cdprocs.h:159
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define APC_LEVEL
Definition: env_spec_w32.h:695
#define NonPagedPool
Definition: env_spec_w32.h:307
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
#define BooleanFlagOn(F, SF)
Definition: ext2fs.h:183
IN PVCB IN VBO IN ULONG OUT PBCB OUT PVOID IN BOOLEAN IN BOOLEAN Zero
Definition: fatprocs.h:418
@ FastIoIsNotPossible
Definition: fsrtltypes.h:240
VOID NTAPI CcInitializeCacheMap(IN PFILE_OBJECT FileObject, IN PCC_FILE_SIZES FileSizes, IN BOOLEAN PinAccess, IN PCACHE_MANAGER_CALLBACKS Callbacks, IN PVOID LazyWriteContext)
Definition: fssup.c:195
BOOLEAN NTAPI CcUninitializeCacheMap(IN PFILE_OBJECT FileObject, IN OPTIONAL PLARGE_INTEGER TruncateSize, IN OPTIONAL PCACHE_UNINITIALIZE_EVENT UninitializeEvent)
Definition: fssup.c:286
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:593
IoMarkIrpPending(Irp)
#define ASSERT(a)
Definition: mode.c:44
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define KernelMode
Definition: asm.h:34
#define RTL_CONSTANT_LARGE_INTEGER(quad_part)
Definition: rtltypes.h:418
#define FILE_OPENED
Definition: nt_native.h:769
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
@ NotificationEvent
#define IoCompleteRequest
Definition: irp.c:1240
#define STATUS_PENDING
Definition: ntstatus.h:82
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:159
KMT_TESTFUNC Test_CcCopyWrite
Definition: testlist.c:10
#define DPRINT
Definition: sndvol32.h:71
SECTION_OBJECT_POINTERS SectionObjectPointers
Definition: ntfs.h:518
FSRTL_ADVANCED_FCB_HEADER Header
Definition: cdstruc.h:925
PFILE_OBJECT FileObject
Definition: ntfs.h:520
#define LL
Definition: tui.h:150
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define IRP_PAGING_IO
#define IRP_NOCACHE
@ Executive
Definition: ketypes.h:403
#define ROUND_TO_PAGES(Size)
#define MDL_PAGES_LOCKED
Definition: mmtypes.h:19
#define MDL_IO_PAGE_READ
Definition: mmtypes.h:24
#define MDL_SOURCE_IS_NONPAGED_POOL
Definition: mmtypes.h:20
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ TestUnload()

VOID TestUnload ( _In_ PDRIVER_OBJECT  DriverObject)

Definition at line 98 of file CcCopyWrite_drv.c.

100{
101 PAGED_CODE();
102}

Variable Documentation

◆ Callbacks

CACHE_MANAGER_CALLBACKS Callbacks
static
Initial value:
= {
}
VOID NTAPI ReleaseFromReadAhead(_In_ PVOID Context)
BOOLEAN NTAPI AcquireForReadAhead(_In_ PVOID Context, _In_ BOOLEAN Wait)
VOID NTAPI ReleaseFromLazyWrite(_In_ PVOID Context)
BOOLEAN NTAPI AcquireForLazyWrite(_In_ PVOID Context, _In_ BOOLEAN Wait)

Definition at line 138 of file CcCopyWrite_drv.c.

Referenced by TestIrpHandler().

◆ InBehaviourTest

BOOLEAN InBehaviourTest
static

Definition at line 25 of file CcCopyWrite_drv.c.

Referenced by TestIrpHandler().

◆ ReadCalled

BOOLEAN ReadCalled

Definition at line 27 of file CcCopyWrite_drv.c.

Referenced by reset_read(), and TestIrpHandler().

◆ ReadLength

ULONG ReadLength

Definition at line 29 of file CcCopyWrite_drv.c.

Referenced by reset_read(), and TestIrpHandler().

◆ ReadOffset

Definition at line 28 of file CcCopyWrite_drv.c.

◆ TestDeviceObject

PDEVICE_OBJECT TestDeviceObject
static

Definition at line 22 of file CcCopyWrite_drv.c.

Referenced by TestIrpHandler().

◆ TestFastIoDispatch

FAST_IO_DISPATCH TestFastIoDispatch
static

Definition at line 24 of file CcCopyWrite_drv.c.

Referenced by TestEntry().

◆ TestFileObject

PFILE_OBJECT TestFileObject
static

Definition at line 21 of file CcCopyWrite_drv.c.

Referenced by TestIrpHandler().

◆ TestIrpHandler

KMT_IRP_HANDLER TestIrpHandler
static

Definition at line 23 of file CcCopyWrite_drv.c.

Referenced by TestEntry().