ReactOS  0.4.14-dev-376-gaedba84
NtCreateSection_drv.c File Reference
#include <kmt_test.h>
#include <debug.h>
Include dependency graph for NtCreateSection_drv.c:

Go to the source code of this file.

Classes

struct  _TEST_FCB
 

Macros

#define NDEBUG
 

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)
 
static BOOLEAN NTAPI FastIoQueryStandardInfo (_In_ PFILE_OBJECT FileObject, _In_ BOOLEAN Wait, _Out_ PFILE_STANDARD_INFORMATION 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 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 UNICODE_STRING InitOnCreate = RTL_CONSTANT_STRING(L"\\InitOnCreate")
 
static UNICODE_STRING InitOnRW = RTL_CONSTANT_STRING(L"\\InitOnRW")
 
static UNICODE_STRING InvalidInit = RTL_CONSTANT_STRING(L"\\InvalidInit")
 
static CACHE_MANAGER_CALLBACKS Callbacks
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 10 of file NtCreateSection_drv.c.

Typedef Documentation

◆ PTEST_FCB

◆ TEST_FCB

Function Documentation

◆ AcquireForLazyWrite()

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

Definition at line 120 of file NtCreateSection_drv.c.

123 {
124  return TRUE;
125 }
#define TRUE
Definition: types.h:120

◆ AcquireForReadAhead()

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

Definition at line 137 of file NtCreateSection_drv.c.

140 {
141  return TRUE;
142 }
#define TRUE
Definition: types.h:120

◆ FastIoQueryStandardInfo()

static BOOLEAN NTAPI FastIoQueryStandardInfo ( _In_ PFILE_OBJECT  FileObject,
_In_ BOOLEAN  Wait,
_Out_ PFILE_STANDARD_INFORMATION  Buffer,
_Out_ PIO_STATUS_BLOCK  IoStatus,
_In_ PDEVICE_OBJECT  DeviceObject 
)
static

Definition at line 66 of file NtCreateSection_drv.c.

72 {
74  return FALSE;
75 }
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409

Referenced by TestEntry().

◆ 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 32 of file NtCreateSection_drv.c.

41 {
43  return FALSE;
44 }
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409

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 49 of file NtCreateSection_drv.c.

58 {
60  return FALSE;
61 }
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409

Referenced by TestEntry().

◆ MapAndLockUserBuffer()

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

Definition at line 161 of file NtCreateSection_drv.c.

164 {
165  PMDL Mdl;
166 
167  if (Irp->MdlAddress == NULL)
168  {
169  Mdl = IoAllocateMdl(Irp->UserBuffer, BufferLength, FALSE, FALSE, Irp);
170  if (Mdl == NULL)
171  {
172  return NULL;
173  }
174 
175  _SEH2_TRY
176  {
177  MmProbeAndLockPages(Mdl, Irp->RequestorMode, IoWriteAccess);
178  }
180  {
181  IoFreeMdl(Mdl);
182  Irp->MdlAddress = NULL;
183  _SEH2_YIELD(return NULL);
184  }
185  _SEH2_END;
186  }
187 
189 }
_In_ PIRP Irp
Definition: csq.h:116
#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority)
_SEH2_TRY
Definition: create.c:4250
_In_ ULONG BufferLength
Definition: usbdlib.h:225
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
VOID NTAPI IoFreeMdl(PMDL Mdl)
Definition: iomdl.c:146
PMDL NTAPI IoAllocateMdl(IN PVOID VirtualAddress, IN ULONG Length, IN BOOLEAN SecondaryBuffer, IN BOOLEAN ChargeQuota, IN PIRP Irp)
Definition: iomdl.c:22
_SEH2_END
Definition: create.c:4424
VOID NTAPI MmProbeAndLockPages(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN LOCK_OPERATION Operation)
Definition: mdlsup.c:935
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6

Referenced by TestIrpHandler().

◆ ReleaseFromLazyWrite()

VOID NTAPI ReleaseFromLazyWrite ( _In_ PVOID  Context)

Definition at line 129 of file NtCreateSection_drv.c.

131 {
132  return;
133 }

◆ ReleaseFromReadAhead()

VOID NTAPI ReleaseFromReadAhead ( _In_ PVOID  Context)

Definition at line 146 of file NtCreateSection_drv.c.

148 {
149  return;
150 }

◆ TestEntry()

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

Definition at line 78 of file NtCreateSection_drv.c.

83 {
85 
86  PAGED_CODE();
87 
89 
90  *DeviceName = L"NtCreateSection";
91  *Flags = TESTENTRY_NO_EXCLUSIVE_DEVICE |
92  TESTENTRY_BUFFERED_IO_DEVICE |
93  TESTENTRY_NO_READONLY_DEVICE;
94 
101 
106 
107 
108  return Status;
109 }
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
LONG NTSTATUS
Definition: precomp.h:26
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
WCHAR DeviceName[]
Definition: adapter.cpp:21
#define PAGED_CODE()
Definition: video.h:57
static FAST_IO_DISPATCH TestFastIoDispatch
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
smooth NULL
Definition: ftsmooth.c:416
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
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 FastIoQueryStandardInfo(_In_ PFILE_OBJECT FileObject, _In_ BOOLEAN Wait, _Out_ PFILE_STANDARD_INFORMATION Buffer, _Out_ PIO_STATUS_BLOCK IoStatus, _In_ PDEVICE_OBJECT DeviceObject)
NTSTATUS KmtRegisterIrpHandler(IN UCHAR MajorFunction, IN PDEVICE_OBJECT DeviceObject OPTIONAL, IN PKMT_IRP_HANDLER IrpHandler)
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
PFAST_IO_READ FastIoRead
Definition: iotypes.h:1692
PFAST_IO_WRITE FastIoWrite
Definition: iotypes.h:1693
PFAST_IO_QUERY_STANDARD_INFO FastIoQueryStandardInfo
Definition: iotypes.h:1695
#define IRP_MJ_READ
Definition: rdpdr.c:46
struct _FAST_IO_DISPATCH * FastIoDispatch
Definition: iotypes.h:2177
#define IRP_MJ_CLEANUP
#define IRP_MJ_SET_INFORMATION
Definition: rdpdr.c:49
_In_ PUNICODE_STRING RegistryPath
Definition: wmip.h:27
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define IRP_MJ_QUERY_INFORMATION
Definition: rdpdr.c:48
return STATUS_SUCCESS
Definition: btrfs.c:2938

◆ TestIrpHandler()

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

Definition at line 194 of file NtCreateSection_drv.c.

198 {
200  PTEST_FCB Fcb;
201  CACHE_UNINITIALIZE_EVENT CacheUninitEvent;
202 
203  PAGED_CODE();
204 
205  DPRINT("IRP %x/%x\n", IoStack->MajorFunction, IoStack->MinorFunction);
206  ASSERT(IoStack->MajorFunction == IRP_MJ_CLEANUP ||
207  IoStack->MajorFunction == IRP_MJ_CREATE ||
208  IoStack->MajorFunction == IRP_MJ_READ ||
209  IoStack->MajorFunction == IRP_MJ_WRITE ||
210  IoStack->MajorFunction == IRP_MJ_QUERY_INFORMATION ||
211  IoStack->MajorFunction == IRP_MJ_SET_INFORMATION);
212 
214  Irp->IoStatus.Information = 0;
215 
216  if (IoStack->MajorFunction == IRP_MJ_CREATE)
217  {
218  ULONG RequestedDisposition = ((IoStack->Parameters.Create.Options >> 24) & 0xff);
219  ok(RequestedDisposition == FILE_CREATE || RequestedDisposition == FILE_OPEN, "Invalid disposition: %lu\n", RequestedDisposition);
220 
221  if (IoStack->FileObject->FileName.Length >= 2 * sizeof(WCHAR))
222  {
224  TestFileObject = IoStack->FileObject;
225  }
226  Fcb = ExAllocatePoolWithTag(NonPagedPool, sizeof(*Fcb), 'FwrI');
227  RtlZeroMemory(Fcb, sizeof(*Fcb));
228  ExInitializeFastMutex(&Fcb->HeaderMutex);
229  FsRtlSetupAdvancedHeader(&Fcb->Header, &Fcb->HeaderMutex);
230 
231  /* Consider file/dir doesn't exist */
232  if (RequestedDisposition == FILE_CREATE)
233  {
234  Fcb->Header.AllocationSize.QuadPart = 0;
235  Fcb->Header.FileSize.QuadPart = 0;
236  Fcb->Header.ValidDataLength.QuadPart = 0;
237  }
238  else
239  {
240  Fcb->Header.AllocationSize.QuadPart = 512;
241  Fcb->Header.FileSize.QuadPart = 512;
242  Fcb->Header.ValidDataLength.QuadPart = 512;
243  }
244  Fcb->Header.IsFastIoPossible = FastIoIsNotPossible;
245 
246  DPRINT1("File: %wZ\n", &IoStack->FileObject->FileName);
247 
248  IoStack->FileObject->FsContext = Fcb;
249  if (RtlCompareUnicodeString(&IoStack->FileObject->FileName, &InvalidInit, FALSE) != 0)
250  {
251  IoStack->FileObject->SectionObjectPointer = &Fcb->SectionObjectPointers;
252  }
253 
254  if (IoStack->FileObject->FileName.Length == 0 ||
255  RtlCompareUnicodeString(&IoStack->FileObject->FileName, &InitOnCreate, FALSE) == 0)
256  {
257  DPRINT1("Init\n");
258 
259  CcInitializeCacheMap(IoStack->FileObject,
260  (PCC_FILE_SIZES)&Fcb->Header.AllocationSize,
261  FALSE, &Callbacks, NULL);
262  }
263 
264  Irp->IoStatus.Information = (RequestedDisposition == FILE_CREATE) ? FILE_CREATED : FILE_OPENED;
266  }
267  else if (IoStack->MajorFunction == IRP_MJ_READ)
268  {
269  BOOLEAN Ret;
270  ULONG Length;
271  PVOID Buffer;
273 
274  Offset = IoStack->Parameters.Read.ByteOffset;
275  Length = IoStack->Parameters.Read.Length;
276  Fcb = IoStack->FileObject->FsContext;
277 
279  ok_eq_pointer(IoStack->FileObject, TestFileObject);
280 
281  if (Offset.QuadPart + Length > Fcb->Header.FileSize.QuadPart)
282  {
284  }
285  else if (Length == 0)
286  {
288  }
289  else
290  {
291  if (!FlagOn(Irp->Flags, IRP_NOCACHE))
292  {
293  Buffer = Irp->AssociatedIrp.SystemBuffer;
294  ok(Buffer != NULL, "Null pointer!\n");
295 
296  _SEH2_TRY
297  {
298  if (IoStack->FileObject->PrivateCacheMap == NULL)
299  {
300  DPRINT1("Init\n");
301  ok_eq_ulong(RtlCompareUnicodeString(&IoStack->FileObject->FileName, &InitOnRW, FALSE), 0);
302  CcInitializeCacheMap(IoStack->FileObject,
303  (PCC_FILE_SIZES)&Fcb->Header.AllocationSize,
304  FALSE, &Callbacks, Fcb);
305  }
306 
307  Ret = CcCopyRead(IoStack->FileObject, &Offset, Length, TRUE, Buffer,
308  &Irp->IoStatus);
309  ok_bool_true(Ret, "CcCopyRead");
310  }
312  {
313  Irp->IoStatus.Status = _SEH2_GetExceptionCode();
314  }
315  _SEH2_END;
316 
317  Status = Irp->IoStatus.Status;
318  }
319  else
320  {
321  ok(Irp->AssociatedIrp.SystemBuffer == NULL, "A SystemBuffer was allocated!\n");
323  ok(Buffer != NULL, "Null pointer!\n");
324  RtlFillMemory(Buffer, Length, 0xBA);
325 
327  }
328  }
329 
330  if (NT_SUCCESS(Status))
331  {
332  Irp->IoStatus.Information = Length;
333  IoStack->FileObject->CurrentByteOffset.QuadPart = Offset.QuadPart + Length;
334  }
335  }
336  else if (IoStack->MajorFunction == IRP_MJ_WRITE)
337  {
338  BOOLEAN Ret;
339  ULONG Length;
340  PVOID Buffer;
342 
343  Offset = IoStack->Parameters.Write.ByteOffset;
344  Length = IoStack->Parameters.Write.Length;
345  Fcb = IoStack->FileObject->FsContext;
346 
348  ok_eq_pointer(IoStack->FileObject, TestFileObject);
349 
350  if (Length == 0)
351  {
353  }
354  else
355  {
356  if (!FlagOn(Irp->Flags, IRP_NOCACHE))
357  {
358  Buffer = Irp->AssociatedIrp.SystemBuffer;
359  ok(Buffer != NULL, "Null pointer!\n");
360 
361  _SEH2_TRY
362  {
363  if (IoStack->FileObject->PrivateCacheMap == NULL)
364  {
365  ok_eq_ulong(RtlCompareUnicodeString(&IoStack->FileObject->FileName, &InitOnRW, FALSE), 0);
366  CcInitializeCacheMap(IoStack->FileObject,
367  (PCC_FILE_SIZES)&Fcb->Header.AllocationSize,
368  FALSE, &Callbacks, Fcb);
369  }
370 
371  Ret = CcCopyWrite(IoStack->FileObject, &Offset, Length, TRUE, Buffer);
372  ok_bool_true(Ret, "CcCopyWrite");
373  }
375  {
376  Irp->IoStatus.Status = _SEH2_GetExceptionCode();
377  }
378  _SEH2_END;
379 
380  Status = Irp->IoStatus.Status;
381  }
382  else
383  {
384  PMDL Mdl;
385 
386  Mdl = Irp->MdlAddress;
387  ok(Mdl != NULL, "Null pointer for MDL!\n");
388  ok((Mdl->MdlFlags & MDL_PAGES_LOCKED) != 0, "MDL not locked\n");
389  ok((Mdl->MdlFlags & MDL_SOURCE_IS_NONPAGED_POOL) == 0, "MDL from non paged\n");
390  ok((Mdl->MdlFlags & MDL_IO_PAGE_READ) == 0, "Paging IO for reading\n");
391  ok((Irp->Flags & IRP_PAGING_IO) != 0, "Non paging IO\n");
392 
394  }
395 
396  if (NT_SUCCESS(Status))
397  {
398  if (Length + Offset.QuadPart > Fcb->Header.FileSize.QuadPart)
399  {
400  Fcb->Header.AllocationSize.QuadPart = Length + Offset.QuadPart;
401  Fcb->Header.FileSize.QuadPart = Length + Offset.QuadPart;
402  Fcb->Header.ValidDataLength.QuadPart = Length + Offset.QuadPart;
403 
404  if (CcIsFileCached(IoStack->FileObject))
405  {
406  CcSetFileSizes(IoStack->FileObject, (PCC_FILE_SIZES)(&(Fcb->Header.AllocationSize)));
407  }
408  }
409  }
410  }
411  }
412  else if (IoStack->MajorFunction == IRP_MJ_CLEANUP)
413  {
414  Fcb = IoStack->FileObject->FsContext;
415  ok(Fcb != NULL, "Null pointer!\n");
416  if (IoStack->FileObject->SectionObjectPointer != NULL)
417  {
419 
420  if (CcIsFileCached(IoStack->FileObject))
421  {
424  }
425 
426  KeInitializeEvent(&CacheUninitEvent.Event, NotificationEvent, FALSE);
427  CcUninitializeCacheMap(IoStack->FileObject, &Zero, &CacheUninitEvent);
428  KeWaitForSingleObject(&CacheUninitEvent.Event, Executive, KernelMode, FALSE, NULL);
429  }
430  ExFreePoolWithTag(Fcb, 'FwrI');
431  IoStack->FileObject->FsContext = NULL;
433  }
434  else if (IoStack->MajorFunction == IRP_MJ_QUERY_INFORMATION)
435  {
436  Fcb = IoStack->FileObject->FsContext;
437 
439  ok_eq_pointer(IoStack->FileObject, TestFileObject);
440  ok_eq_ulong(IoStack->Parameters.QueryFile.FileInformationClass, FileStandardInformation);
441 
442  if (IoStack->Parameters.QueryFile.FileInformationClass == FileStandardInformation)
443  {
444  PFILE_STANDARD_INFORMATION StandardInfo = Irp->AssociatedIrp.SystemBuffer;
445  ULONG BufferLength = IoStack->Parameters.QueryFile.Length;
446 
448  {
450  }
451  else
452  {
453  ok(StandardInfo != NULL, "Null pointer!\n");
454  ok(Fcb != NULL, "Null pointer!\n");
455 
456  StandardInfo->AllocationSize = Fcb->Header.AllocationSize;
457  StandardInfo->EndOfFile = Fcb->Header.FileSize;
458  StandardInfo->Directory = FALSE;
459  StandardInfo->NumberOfLinks = 1;
460  StandardInfo->DeletePending = FALSE;
461 
462  Irp->IoStatus.Information = sizeof(FILE_STANDARD_INFORMATION);
464  }
465  }
466  else
467  {
469  }
470  }
471  else if (IoStack->MajorFunction == IRP_MJ_SET_INFORMATION)
472  {
473  Fcb = IoStack->FileObject->FsContext;
474 
476  ok_eq_pointer(IoStack->FileObject, TestFileObject);
477  ok_eq_ulong(IoStack->Parameters.SetFile.FileInformationClass, FileEndOfFileInformation);
478 
479  if (IoStack->Parameters.SetFile.FileInformationClass == FileEndOfFileInformation)
480  {
481  PFILE_END_OF_FILE_INFORMATION EOFInfo = Irp->AssociatedIrp.SystemBuffer;
482  ULONG BufferLength = IoStack->Parameters.SetFile.Length;
483 
485  {
487  }
488  else
489  {
490  ULONG TestSize = 0;
491 
492  ok(EOFInfo != NULL, "Null pointer!\n");
493  ok(Fcb != NULL, "Null pointer!\n");
494  ok_bool_false(IoStack->Parameters.SetFile.AdvanceOnly, "AdvanceOnly set!\n");
495  ok(EOFInfo->EndOfFile.QuadPart > Fcb->Header.AllocationSize.QuadPart, "New size smaller\n");
496 
497  if (Fcb->Header.AllocationSize.QuadPart != 0)
498  {
499  TestSize = 512;
500  }
501 
502  Fcb->Header.AllocationSize.QuadPart = EOFInfo->EndOfFile.QuadPart;
503  ok_eq_ulong(Fcb->Header.FileSize.QuadPart, TestSize);
504  ok_eq_ulong(Fcb->Header.ValidDataLength.QuadPart, TestSize);
505 
506  if (CcIsFileCached(IoStack->FileObject))
507  {
508  CcSetFileSizes(IoStack->FileObject, (PCC_FILE_SIZES)(&(Fcb->Header.AllocationSize)));
509  }
510 
511  ok_eq_ulong(Fcb->Header.FileSize.QuadPart, TestSize);
512  ok_eq_ulong(Fcb->Header.ValidDataLength.QuadPart, TestSize);
513 
515  }
516  }
517  else
518  {
520  }
521  }
522 
523  if (Status == STATUS_PENDING)
524  {
528  }
529  else
530  {
531  Irp->IoStatus.Status = Status;
533  }
534 
535  return Status;
536 }
#define MDL_IO_PAGE_READ
Definition: mmtypes.h:24
BOOLEAN NTAPI CcPurgeCacheSection(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN OPTIONAL PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN UninitializeCacheMaps)
Definition: fssup.c:384
#define ok_eq_ulong(value, expected)
#define TRUE
Definition: types.h:120
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define LL
Definition: tui.h:85
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
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
FSRTL_ADVANCED_FCB_HEADER Header
Definition: cdstruc.h:931
PFILE_OBJECT FileObject
Definition: ntfs.h:516
_In_ PIRP Irp
Definition: csq.h:116
static CACHE_MANAGER_CALLBACKS Callbacks
#define ok_eq_pointer(value, expected)
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_CREATE
Definition: from_kernel.h:55
#define FILE_OPENED
Definition: nt_native.h:769
#define IRP_NOCACHE
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define PAGED_CODE()
Definition: video.h:57
_SEH2_TRY
Definition: create.c:4250
#define STATUS_END_OF_FILE
Definition: shellext.h:67
#define ok_bool_false(value, desc)
Definition: kmt_test.h:257
static PVOID MapAndLockUserBuffer(_In_ _Out_ PIRP Irp, _In_ ULONG BufferLength)
#define ok_bool_true(value, desc)
Definition: kmt_test.h:256
#define RTL_CONSTANT_LARGE_INTEGER(quad_part)
Definition: rtltypes.h:414
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
_In_ ULONG BufferLength
Definition: usbdlib.h:225
#define CcIsFileCached(FO)
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define MDL_SOURCE_IS_NONPAGED_POOL
Definition: mmtypes.h:20
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
static UNICODE_STRING InitOnCreate
#define MDL_PAGES_LOCKED
Definition: mmtypes.h:19
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
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:193
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
LARGE_INTEGER AllocationSize
Definition: propsheet.cpp:54
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static PFILE_OBJECT TestFileObject
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
BOOLEAN NTAPI CcCopyRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus)
Definition: copysup.c:43
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
#define FILE_STANDARD_INFORMATION
Definition: disk.h:54
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
Status
Definition: gdiplustypes.h:24
#define FILE_OPEN
Definition: from_kernel.h:54
BOOLEAN NTAPI CcCopyWrite(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN PVOID Buffer)
Definition: copysup.c:129
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
_SEH2_END
Definition: create.c:4424
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
BOOLEAN NTAPI CcUninitializeCacheMap(IN PFILE_OBJECT FileObject, IN OPTIONAL PLARGE_INTEGER TruncateSize, IN OPTIONAL PCACHE_UNINITIALIZE_EVENT UninitializeEvent)
Definition: fssup.c:284
static UNICODE_STRING InvalidInit
VOID NTAPI CcSetFileSizes(IN PFILE_OBJECT FileObject, IN PCC_FILE_SIZES FileSizes)
Definition: fssup.c:354
#define ok(value,...)
Definition: atltest.h:57
static UNICODE_STRING InitOnRW
#define IRP_PAGING_IO
#define FILE_CREATED
Definition: nt_native.h:770
IN PVCB IN VBO IN ULONG OUT PBCB OUT PVOID IN BOOLEAN IN BOOLEAN Zero
Definition: fatprocs.h:402
#define DPRINT1
Definition: precomp.h:8
#define FileStandardInformation
Definition: propsheet.cpp:61
#define IRP_MJ_READ
Definition: rdpdr.c:46
static PDEVICE_OBJECT TestDeviceObject
#define IRP_MJ_CLEANUP
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
#define IRP_MJ_SET_INFORMATION
Definition: rdpdr.c:49
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define IRP_MJ_QUERY_INFORMATION
Definition: rdpdr.c:48
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
_In_ PFCB Fcb
Definition: cdprocs.h:151
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2938
IoMarkIrpPending(Irp)
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:593
SECTION_OBJECT_POINTERS SectionObjectPointers
Definition: ntfs.h:514
LONGLONG QuadPart
Definition: typedefs.h:112

◆ TestUnload()

VOID TestUnload ( _In_ PDRIVER_OBJECT  DriverObject)

Definition at line 112 of file NtCreateSection_drv.c.

114 {
115  PAGED_CODE();
116 }
#define PAGED_CODE()
Definition: video.h:57

Variable Documentation

◆ Callbacks

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

Definition at line 152 of file NtCreateSection_drv.c.

Referenced by TestIrpHandler().

◆ InitOnCreate

UNICODE_STRING InitOnCreate = RTL_CONSTANT_STRING(L"\\InitOnCreate")
static

Definition at line 25 of file NtCreateSection_drv.c.

Referenced by START_TEST(), and TestIrpHandler().

◆ InitOnRW

UNICODE_STRING InitOnRW = RTL_CONSTANT_STRING(L"\\InitOnRW")
static

Definition at line 26 of file NtCreateSection_drv.c.

Referenced by START_TEST(), and TestIrpHandler().

◆ InvalidInit

UNICODE_STRING InvalidInit = RTL_CONSTANT_STRING(L"\\InvalidInit")
static

Definition at line 27 of file NtCreateSection_drv.c.

Referenced by START_TEST(), and TestIrpHandler().

◆ TestDeviceObject

PDEVICE_OBJECT TestDeviceObject
static

Definition at line 21 of file NtCreateSection_drv.c.

Referenced by TestIrpHandler().

◆ TestFastIoDispatch

FAST_IO_DISPATCH TestFastIoDispatch
static

Definition at line 23 of file NtCreateSection_drv.c.

Referenced by TestEntry().

◆ TestFileObject

PFILE_OBJECT TestFileObject
static

Definition at line 20 of file NtCreateSection_drv.c.

Referenced by TestIrpHandler().

◆ TestIrpHandler

KMT_IRP_HANDLER TestIrpHandler
static

Definition at line 22 of file NtCreateSection_drv.c.

Referenced by TestEntry().