ReactOS 0.4.16-dev-321-g63bb46a
CcMapData_drv.c File Reference
#include <kmt_test.h>
#include <debug.h>
Include dependency graph for CcMapData_drv.c:

Go to the source code of this file.

Classes

struct  _TEST_FCB
 
struct  _TEST_CONTEXT
 

Macros

#define NDEBUG
 
#define IOCTL_START_TEST   1
 
#define IOCTL_FINISH_TEST   2
 

Typedefs

typedef struct _TEST_FCB TEST_FCB
 
typedef struct _TEST_FCBPTEST_FCB
 
typedef struct _TEST_CONTEXT TEST_CONTEXT
 
typedef struct _TEST_CONTEXTPTEST_CONTEXT
 

Functions

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 NTAPI MapInAnotherThread (IN PVOID Context)
 
static VOID PerformTest (ULONG TestId, PDEVICE_OBJECT DeviceObject)
 
static VOID CleanupTest (ULONG TestId, PDEVICE_OBJECT DeviceObject)
 
static NTSTATUS TestMessageHandler (_In_ PDEVICE_OBJECT DeviceObject, _In_ ULONG ControlCode, _In_opt_ PVOID Buffer, _In_ SIZE_T InLength, _Inout_ PSIZE_T OutLength)
 
static NTSTATUS TestIrpHandler (_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _In_ PIO_STACK_LOCATION IoStack)
 

Variables

static ULONG TestTestId = -1
 
static PFILE_OBJECT TestFileObject
 
static PDEVICE_OBJECT TestDeviceObject
 
static KMT_IRP_HANDLER TestIrpHandler
 
static KMT_MESSAGE_HANDLER TestMessageHandler
 
static ULONGLONG Memory = 0
 
static BOOLEAN TS = FALSE
 
static CACHE_MANAGER_CALLBACKS Callbacks
 
static CC_FILE_SIZES FileSizes
 

Macro Definition Documentation

◆ IOCTL_FINISH_TEST

#define IOCTL_FINISH_TEST   2

Definition at line 14 of file CcMapData_drv.c.

◆ IOCTL_START_TEST

#define IOCTL_START_TEST   1

Definition at line 13 of file CcMapData_drv.c.

◆ NDEBUG

#define NDEBUG

Definition at line 10 of file CcMapData_drv.c.

Typedef Documentation

◆ PTEST_CONTEXT

◆ PTEST_FCB

◆ TEST_CONTEXT

◆ TEST_FCB

Function Documentation

◆ AcquireForLazyWrite()

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

Definition at line 101 of file CcMapData_drv.c.

104{
105 return TRUE;
106}
#define TRUE
Definition: types.h:120

◆ AcquireForReadAhead()

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

Definition at line 118 of file CcMapData_drv.c.

121{
122 return TRUE;
123}

◆ CleanupTest()

static VOID CleanupTest ( ULONG  TestId,
PDEVICE_OBJECT  DeviceObject 
)
static

Definition at line 454 of file CcMapData_drv.c.

457{
459 CACHE_UNINITIALIZE_EVENT CacheUninitEvent;
460
462 ok_eq_ulong(TestTestId, TestId);
463
464 if (!skip(TestFileObject != NULL, "No test FO\n"))
465 {
467 {
468 KeInitializeEvent(&CacheUninitEvent.Event, NotificationEvent, FALSE);
469 CcUninitializeCacheMap(TestFileObject, &Zero, &CacheUninitEvent);
471 }
472
473 if (TestFileObject->FsContext != NULL)
474 {
475 ExFreePool(TestFileObject->FsContext);
476 TestFileObject->FsContext = NULL;
477 TestFileObject->SectionObjectPointer = NULL;
478 }
479
481 }
482
485 TestTestId = -1;
486}
static PDEVICE_OBJECT TestDeviceObject
Definition: CcMapData_drv.c:32
static PFILE_OBJECT TestFileObject
Definition: CcMapData_drv.c:31
static ULONG TestTestId
Definition: CcMapData_drv.c:30
#define ok_eq_pointer(value, expected)
Definition: apitest.h:59
#define ok_eq_ulong(value, expected)
Definition: apitest.h:63
#define skip(...)
Definition: atltest.h:64
#define CcIsFileCached(FO)
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#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 ExFreePool(addr)
Definition: env_spec_w32.h:352
IN PVCB IN VBO IN ULONG OUT PBCB OUT PVOID IN BOOLEAN IN BOOLEAN Zero
Definition: fatprocs.h:419
BOOLEAN NTAPI CcUninitializeCacheMap(IN PFILE_OBJECT FileObject, IN OPTIONAL PLARGE_INTEGER TruncateSize, IN OPTIONAL PCACHE_UNINITIALIZE_EVENT UninitializeEvent)
Definition: fssup.c:286
#define KernelMode
Definition: asm.h:34
#define RTL_CONSTANT_LARGE_INTEGER(quad_part)
Definition: rtltypes.h:418
@ NotificationEvent
#define LL
Definition: tui.h:167
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
@ Executive
Definition: ketypes.h:415
#define ObDereferenceObject
Definition: obfuncs.h:203

Referenced by TestMessageHandler().

◆ MapAndLockUserBuffer()

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

Definition at line 148 of file CcMapData_drv.c.

151{
152 PMDL Mdl;
153
154 if (Irp->MdlAddress == NULL)
155 {
156 Mdl = IoAllocateMdl(Irp->UserBuffer, BufferLength, FALSE, FALSE, Irp);
157 if (Mdl == NULL)
158 {
159 return NULL;
160 }
161
163 {
164 MmProbeAndLockPages(Mdl, Irp->RequestorMode, IoWriteAccess);
165 }
167 {
168 IoFreeMdl(Mdl);
169 Irp->MdlAddress = NULL;
170 _SEH2_YIELD(return NULL);
171 }
172 _SEH2_END;
173 }
174
176}
_In_ PIRP Irp
Definition: csq.h:116
#define IoFreeMdl
Definition: fxmdl.h:89
#define IoAllocateMdl
Definition: fxmdl.h:88
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
VOID NTAPI MmProbeAndLockPages(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN LOCK_OPERATION Operation)
Definition: mdlsup.c:931
@ NormalPagePriority
Definition: imports.h:54
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
#define _SEH2_END
Definition: pseh2_64.h:155
#define _SEH2_TRY
Definition: pseh2_64.h:55
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:168
_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:864
#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority)

Referenced by TestIrpHandler().

◆ MapInAnotherThread()

static VOID NTAPI MapInAnotherThread ( IN PVOID  Context)
static

Definition at line 181 of file CcMapData_drv.c.

182{
183 BOOLEAN Ret;
185 PVOID Bcb;
187 PTEST_CONTEXT TestContext;
188
189 ok(TestFileObject != NULL, "Called in invalid context!\n");
191
192 TestContext = Context;
193 ok(TestContext != NULL, "Called in invalid context!\n");
194 ok(TestContext->Bcb != NULL, "Called in invalid context!\n");
195 ok(TestContext->Buffer != NULL, "Called in invalid context!\n");
196 ok(TestContext->Length != 0, "Called in invalid context!\n");
197
198 Ret = FALSE;
199 Offset.QuadPart = 0x1000;
200 KmtStartSeh();
201 Ret = CcMapData(TestFileObject, &Offset, TestContext->Length, MAP_WAIT, &Bcb, (PVOID *)&Buffer);
203
204 if (!skip(Ret == TRUE, "CcMapData failed\n"))
205 {
206 ok_eq_pointer(Bcb, TestContext->Bcb);
207 ok_eq_pointer(Buffer, TestContext->Buffer);
208
210 }
211
212 KmtStartSeh();
213 Ret = CcPinRead(TestFileObject, &Offset, TestContext->Length, 0, &Bcb, (PVOID *)&Buffer);
215
216 if (!skip(Ret == TRUE, "CcPinRead failed\n"))
217 {
218 ok(Bcb != TestContext->Bcb, "Returned same BCB!\n");
219 ok_eq_pointer(Buffer, TestContext->Buffer);
220
222 }
223
224 KmtStartSeh();
225 Ret = CcPinRead(TestFileObject, &Offset, TestContext->Length, PIN_IF_BCB, &Bcb, (PVOID *)&Buffer);
227 ok(Ret == FALSE, "CcPinRead succeed\n");
228
229 if (Ret)
230 {
232 }
233
234 KmtStartSeh();
235 Ret = CcPinRead(TestFileObject, &Offset, TestContext->Length, PIN_EXCLUSIVE, &Bcb, (PVOID *)&Buffer);
237
238 if (!skip(Ret == TRUE, "CcPinRead failed\n"))
239 {
240 ok(Bcb != TestContext->Bcb, "Returned same BCB!\n");
241 ok_eq_pointer(Buffer, TestContext->Buffer);
242
244 }
245
246 Offset.QuadPart = 0x1500;
247 TestContext->Length -= 0x500;
248
249 KmtStartSeh();
250 Ret = CcMapData(TestFileObject, &Offset, TestContext->Length, MAP_WAIT, &Bcb, (PVOID *)&Buffer);
252
253 if (!skip(Ret == TRUE, "CcMapData failed\n"))
254 {
255 ok_eq_pointer(Bcb, TestContext->Bcb);
256 ok_eq_pointer(Buffer, (PVOID)((ULONG_PTR)TestContext->Buffer + 0x500));
257
259 }
260
261 return;
262}
unsigned char BOOLEAN
#define ok(value,...)
Definition: atltest.h:57
Definition: bufpool.h:45
IN PVCB IN VBO IN ULONG OUT PBCB * Bcb
Definition: fatprocs.h:415
#define KmtStartSeh()
Definition: kmt_test.h:282
#define KmtEndSeh(ExpectedStatus)
Definition: kmt_test.h:288
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define PIN_EXCLUSIVE
#define PIN_IF_BCB
#define MAP_WAIT
VOID NTAPI CcUnpinData(IN PVOID Bcb)
Definition: pinsup.c:955
BOOLEAN NTAPI CcPinRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG Flags, OUT PVOID *Bcb, OUT PVOID *Buffer)
Definition: pinsup.c:802
BOOLEAN NTAPI CcMapData(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG Flags, OUT PVOID *BcbResult, OUT PVOID *Buffer)
Definition: pinsup.c:694
#define STATUS_SUCCESS
Definition: shellext.h:65
uint32_t * PULONG
Definition: typedefs.h:59
uint32_t ULONG_PTR
Definition: typedefs.h:65

Referenced by PerformTest().

◆ PerformTest()

static VOID PerformTest ( ULONG  TestId,
PDEVICE_OBJECT  DeviceObject 
)
static

Definition at line 266 of file CcMapData_drv.c.

269{
270 PVOID Bcb;
271 BOOLEAN Ret;
275
279
281 TestTestId = TestId;
283 if (!skip(TestFileObject != NULL, "Failed to allocate FO\n"))
284 {
286 if (!skip(Fcb != NULL, "ExAllocatePool failed\n"))
287 {
288 RtlZeroMemory(Fcb, sizeof(TEST_FCB));
289 ExInitializeFastMutex(&Fcb->HeaderMutex);
290 FsRtlSetupAdvancedHeader(&Fcb->Header, &Fcb->HeaderMutex);
291
292 TestFileObject->FsContext = Fcb;
293 TestFileObject->SectionObjectPointer = &Fcb->SectionObjectPointers;
294
295 KmtStartSeh();
298
299 if (!skip(CcIsFileCached(TestFileObject) == TRUE, "CcInitializeCacheMap failed\n"))
300 {
301 if (TestId < 3)
302 {
303 Ret = FALSE;
304 Offset.QuadPart = TestId * 0x1000;
305 KmtStartSeh();
308
309 if (!skip(Ret == TRUE, "CcMapData failed\n"))
310 {
311 ok_eq_ulong(Buffer[(0x3000 - TestId * 0x1000) / sizeof(ULONG)], 0xDEADBABE);
312
314 }
315 }
316 else if (TestId == 3)
317 {
318 PTEST_CONTEXT TestContext;
319
320 TestContext = ExAllocatePool(NonPagedPool, sizeof(TEST_CONTEXT));
321 if (!skip(TestContext != NULL, "ExAllocatePool failed\n"))
322 {
323 Ret = FALSE;
324 Offset.QuadPart = 0x1000;
325 KmtStartSeh();
326 Ret = CcMapData(TestFileObject, &Offset, FileSizes.FileSize.QuadPart - Offset.QuadPart, MAP_WAIT, &TestContext->Bcb, &TestContext->Buffer);
328
329 if (!skip(Ret == TRUE, "CcMapData failed\n"))
330 {
331 PKTHREAD ThreadHandle;
332
333 /* That's a bit rough but should do the job */
334#ifdef _X86_
335 if (Memory >= 2 * 1024)
336 {
337 ok((TestContext->Buffer >= (PVOID)0xC1000000 && TestContext->Buffer < (PVOID)0xE0FFFFFF) ||
338 (TestContext->Buffer >= (PVOID)0xA4000000 && TestContext->Buffer < (PVOID)0xBFFFFFFF),
339 "Buffer %p not mapped in system space\n", TestContext->Buffer);
340 }
341 else if (TS)
342 {
343 ok(TestContext->Buffer >= (PVOID)0xC1000000 && TestContext->Buffer < (PVOID)0xDCFFFFFF,
344 "Buffer %p not mapped in system space\n", TestContext->Buffer);
345 }
346 else
347 {
348 ok(TestContext->Buffer >= (PVOID)0xC1000000 && TestContext->Buffer < (PVOID)0xDBFFFFFF,
349 "Buffer %p not mapped in system space\n", TestContext->Buffer);
350 }
351#elif defined(_M_AMD64)
352 ok(TestContext->Buffer >= (PVOID)0xFFFFF98000000000 && TestContext->Buffer < (PVOID)0xFFFFFA8000000000,
353 "Buffer %p not mapped in system space\n", TestContext->Buffer);
354#else
355 skip(FALSE, "System space mapping not defined\n");
356#endif
357
358 TestContext->Length = FileSizes.FileSize.QuadPart - Offset.QuadPart;
359 ThreadHandle = KmtStartThread(MapInAnotherThread, TestContext);
360 KmtFinishThread(ThreadHandle, NULL);
361
362 TestContext->Length = FileSizes.FileSize.QuadPart - 2 * Offset.QuadPart;
363 ThreadHandle = KmtStartThread(MapInAnotherThread, TestContext);
364 KmtFinishThread(ThreadHandle, NULL);
365
366 CcUnpinData(TestContext->Bcb);
367 }
368
369 ExFreePool(TestContext);
370 }
371 }
372 else if (TestId == 4)
373 {
376
377 /* Map after EOF */
378 Ret = FALSE;
379 Offset.QuadPart = FileSizes.FileSize.QuadPart + 0x1000;
380
381 KmtStartSeh();
382 Ret = CcMapData(TestFileObject, &Offset, 0x1000, MAP_WAIT, &Bcb, (PVOID *)&Buffer);
384 ok(Ret == TRUE, "CcMapData failed\n");
385
386 if (Ret)
387 {
389 }
390
391 /* Map a VACB after EOF. */
392 Ret = FALSE;
394
395 KmtStartSeh();
396 Ret = CcMapData(TestFileObject, &Offset, 0x1000, MAP_WAIT, &Bcb, (PVOID *)&Buffer);
398 ok(Ret == TRUE, "CcMapData failed\n");
399
400 if (Ret)
401 {
403 }
404
405 /* Map after Allocation */
406 Ret = FALSE;
407 Offset.QuadPart = FileSizes.AllocationSize.QuadPart + 0x1000;
408
409 KmtStartSeh();
410 Ret = CcMapData(TestFileObject, &Offset, 0x1000, MAP_WAIT, &Bcb, (PVOID *)&Buffer);
412 ok(Ret == TRUE, "CcMapData failed\n");
413
414 if (Ret)
415 {
417 }
418
419 Ret = FALSE;
421
422 KmtStartSeh();
423 Ret = CcMapData(TestFileObject, &Offset, 0x1000, MAP_WAIT, &Bcb, (PVOID *)&Buffer);
425 ok(Ret == TRUE, "CcMapData failed\n");
426
427 if (Ret)
428 {
430 }
431
432 /* Map more than a VACB */
433 Ret = FALSE;
434 Offset.QuadPart = 0x0;
435
436 KmtStartSeh();
439 ok(Ret == TRUE, "CcMapData failed\n");
440
441 if (Ret)
442 {
444 }
445 }
446 }
447 }
448 }
449}
static BOOLEAN TS
Definition: CcMapData_drv.c:36
static CC_FILE_SIZES FileSizes
static VOID NTAPI MapInAnotherThread(IN PVOID Context)
static CACHE_MANAGER_CALLBACKS Callbacks
_In_ PFCB Fcb
Definition: cdprocs.h:159
#define NonPagedPool
Definition: env_spec_w32.h:307
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
VOID NTAPI CcSetFileSizes(IN PFILE_OBJECT FileObject, IN PCC_FILE_SIZES FileSizes)
Definition: fssup.c:356
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
PKTHREAD KmtStartThread(IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext OPTIONAL)
VOID KmtFinishThread(IN PKTHREAD Thread OPTIONAL, IN PKEVENT Event OPTIONAL)
PFILE_OBJECT NTAPI IoCreateStreamFileObject(IN PFILE_OBJECT FileObject, IN PDEVICE_OBJECT DeviceObject)
Definition: file.c:3187
LARGE_INTEGER FileSize
Definition: cctypes.h:16
LARGE_INTEGER AllocationSize
Definition: cctypes.h:15
SECTION_OBJECT_POINTERS SectionObjectPointers
Definition: ntfs.h:518
FSRTL_ADVANCED_FCB_HEADER Header
Definition: cdstruc.h:925
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
LONGLONG QuadPart
Definition: typedefs.h:114
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _Strict_type_match_ POOL_TYPE _In_opt_ ULONG _In_ _Out_ WDFMEMORY * Memory
Definition: wdfmemory.h:169
#define VACB_MAPPING_GRANULARITY
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274

Referenced by TestMessageHandler().

◆ ReleaseFromLazyWrite()

VOID NTAPI ReleaseFromLazyWrite ( _In_ PVOID  Context)

Definition at line 110 of file CcMapData_drv.c.

112{
113 return;
114}

◆ ReleaseFromReadAhead()

VOID NTAPI ReleaseFromReadAhead ( _In_ PVOID  Context)

Definition at line 127 of file CcMapData_drv.c.

129{
130 return;
131}

◆ TestEntry()

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

Definition at line 39 of file CcMapData_drv.c.

44{
49
50 PAGED_CODE();
51
53
54 *DeviceName = L"CcMapData";
55 *Flags = TESTENTRY_NO_EXCLUSIVE_DEVICE |
56 TESTENTRY_BUFFERED_IO_DEVICE |
57 TESTENTRY_NO_READONLY_DEVICE;
58
61
63 &SBI,
64 sizeof(SBI),
65 &Length);
66 if (NT_SUCCESS(Status))
67 {
68 Memory = (SBI.NumberOfPhysicalPages * SBI.PageSize) / 1024 / 1024;
69 }
70 else
71 {
73 }
74
77 if (NT_SUCCESS(Status))
78 {
81 }
82 else
83 {
85 }
86
87 trace("System with %I64dMb RAM and terminal services %S\n", Memory, (TS ? L"enabled" : L"disabled"));
88
89 return Status;
90}
#define PAGED_CODE()
static KMT_MESSAGE_HANDLER TestMessageHandler
Definition: CcMapData_drv.c:34
static KMT_IRP_HANDLER TestIrpHandler
Definition: CcMapData_drv.c:33
#define trace
Definition: atltest.h:70
LONG NTSTATUS
Definition: precomp.h:26
OSVERSIONINFOW VersionInfo
Definition: wkssvc.c:40
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
NTSTATUS NTAPI RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
Definition: version.c:158
#define BooleanFlagOn(F, SF)
Definition: ext2fs.h:183
NTSYSAPI NTSTATUS NTAPI ZwQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
@ SystemBasicInformation
Definition: ntddk_ex.h:11
Status
Definition: gdiplustypes.h:25
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)
#define VER_SUITE_TERMINAL
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
#define VER_SUITE_SINGLEUSERTS
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define L(x)
Definition: ntvdm.h:50
#define IRP_MJ_READ
Definition: rdpdr.c:46
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:246
_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_ ULONG Flags
Definition: wsk.h:170

◆ TestIrpHandler()

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

Definition at line 526 of file CcMapData_drv.c.

530{
532
533 PAGED_CODE();
534
535 DPRINT("IRP %x/%x\n", IoStack->MajorFunction, IoStack->MinorFunction);
536 ASSERT(IoStack->MajorFunction == IRP_MJ_READ);
537
539
541 Irp->IoStatus.Information = 0;
542
543 if (IoStack->MajorFunction == IRP_MJ_READ)
544 {
545 PMDL Mdl;
549
550 Offset = IoStack->Parameters.Read.ByteOffset;
551 Length = IoStack->Parameters.Read.Length;
552
554 ok_eq_pointer(IoStack->FileObject, TestFileObject);
555
556 ok(FlagOn(Irp->Flags, IRP_NOCACHE), "Not coming from Cc\n");
557
558 ok_irql(APC_LEVEL);
559 ok((Offset.QuadPart % PAGE_SIZE == 0 || Offset.QuadPart == 0), "Offset is not aligned: %I64i\n", Offset.QuadPart);
560 ok(Length % PAGE_SIZE == 0, "Length is not aligned: %I64i\n", Length);
561
562 ok(Irp->AssociatedIrp.SystemBuffer == NULL, "A SystemBuffer was allocated!\n");
564 ok(Buffer != NULL, "Null pointer!\n");
566
568 if (Offset.QuadPart <= 0x3000 && Offset.QuadPart + Length > 0x3000)
569 {
570 *(PULONG)((ULONG_PTR)Buffer + (ULONG_PTR)(0x3000 - Offset.QuadPart)) = 0xDEADBABE;
571 }
572
573 Mdl = Irp->MdlAddress;
574 ok(Mdl != NULL, "Null pointer for MDL!\n");
575 ok((Mdl->MdlFlags & MDL_PAGES_LOCKED) != 0, "MDL not locked\n");
576 ok((Mdl->MdlFlags & MDL_SOURCE_IS_NONPAGED_POOL) == 0, "MDL from non paged\n");
577 ok((Mdl->MdlFlags & MDL_IO_PAGE_READ) != 0, "Non paging IO\n");
578 ok((Irp->Flags & IRP_PAGING_IO) != 0, "Non paging IO\n");
579
580 Irp->IoStatus.Information = Length;
581 }
582
583 if (Status == STATUS_PENDING)
584 {
588 }
589 else
590 {
591 Irp->IoStatus.Status = Status;
593 }
594
596
597 return Status;
598}
static PVOID MapAndLockUserBuffer(_In_ _Out_ PIRP Irp, _In_ ULONG BufferLength)
#define STATUS_PENDING
Definition: d3dkmdt.h:43
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
#define ULONG_PTR
Definition: config.h:101
#define APC_LEVEL
Definition: env_spec_w32.h:695
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:599
IoMarkIrpPending(Irp)
#define ASSERT(a)
Definition: mode.c:44
#define IoCompleteRequest
Definition: irp.c:1240
#define DPRINT
Definition: sndvol32.h:73
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define IRP_PAGING_IO
#define IRP_NOCACHE
#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

◆ TestMessageHandler()

static NTSTATUS TestMessageHandler ( _In_ PDEVICE_OBJECT  DeviceObject,
_In_ ULONG  ControlCode,
_In_opt_ PVOID Buffer  ,
_In_ SIZE_T  InLength,
_Inout_ PSIZE_T  OutLength 
)
static

Definition at line 491 of file CcMapData_drv.c.

497{
499
501
502 switch (ControlCode)
503 {
504 case IOCTL_START_TEST:
505 ok_eq_ulong((ULONG)InLength, sizeof(ULONG));
507 break;
508
510 ok_eq_ulong((ULONG)InLength, sizeof(ULONG));
512 break;
513
514 default:
516 break;
517 }
518
520
521 return Status;
522}
#define IOCTL_FINISH_TEST
Definition: CcMapData_drv.c:14
static VOID PerformTest(ULONG TestId, PDEVICE_OBJECT DeviceObject)
static VOID CleanupTest(ULONG TestId, PDEVICE_OBJECT DeviceObject)
#define IOCTL_START_TEST
Definition: CcMapData_drv.c:13
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
_IRQL_requires_same_ typedef _In_ ULONG ControlCode
Definition: wmitypes.h:55

◆ TestUnload()

VOID TestUnload ( _In_ PDRIVER_OBJECT  DriverObject)

Definition at line 93 of file CcMapData_drv.c.

95{
96 PAGED_CODE();
97}

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 133 of file CcMapData_drv.c.

Referenced by PerformTest().

◆ FileSizes

◆ Memory

ULONGLONG Memory = 0
static

Definition at line 35 of file CcMapData_drv.c.

◆ TestDeviceObject

PDEVICE_OBJECT TestDeviceObject
static

Definition at line 32 of file CcMapData_drv.c.

Referenced by CleanupTest(), PerformTest(), and TestIrpHandler().

◆ TestFileObject

PFILE_OBJECT TestFileObject
static

Definition at line 31 of file CcMapData_drv.c.

Referenced by CleanupTest(), MapInAnotherThread(), PerformTest(), and TestIrpHandler().

◆ TestIrpHandler

KMT_IRP_HANDLER TestIrpHandler
static

Definition at line 33 of file CcMapData_drv.c.

Referenced by TestEntry().

◆ TestMessageHandler

KMT_MESSAGE_HANDLER TestMessageHandler
static

Definition at line 34 of file CcMapData_drv.c.

Referenced by TestEntry().

◆ TestTestId

ULONG TestTestId = -1
static

Definition at line 30 of file CcMapData_drv.c.

Referenced by CleanupTest(), MapInAnotherThread(), and PerformTest().

◆ TS

BOOLEAN TS = FALSE
static

Definition at line 36 of file CcMapData_drv.c.

Referenced by PerformTest(), and TestEntry().