ReactOS  0.4.14-dev-49-gfb4591c
block.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYRIGHT.TXT
3  * PROJECT: Ext2 File System Driver for WinNT/2K/XP
4  * FILE: block.c
5  * PROGRAMMER: Matt Wu <mattwu@163.com>
6  * HOMEPAGE: http://www.ext2fsd.com
7  * UPDATE HISTORY:
8  */
9 
10 /* INCLUDES *****************************************************************/
11 
12 #include "ext2fs.h"
13 
14 /* GLOBALS ***************************************************************/
15 
17 
18 /* DEFINITIONS *************************************************************/
19 
23  IN PIRP Irp,
24  IN PVOID Context );
25 
29  IN PIRP Irp,
30  IN PVOID Context );
31 
32 
36  IN PIRP Irp,
37  IN PVOID Contxt );
38 
39 #ifdef ALLOC_PRAGMA
40 #pragma alloc_text(PAGE, Ext2LockUserBuffer)
41 #pragma alloc_text(PAGE, Ext2ReadSync)
42 #pragma alloc_text(PAGE, Ext2ReadDisk)
43 #pragma alloc_text(PAGE, Ext2DiskIoControl)
44 #pragma alloc_text(PAGE, Ext2MediaEjectControl)
45 #pragma alloc_text(PAGE, Ext2DiskShutDown)
46 #endif
47 
48 
49 /* FUNCTIONS ***************************************************************/
50 
51 PMDL
53  IN PVOID Buffer,
54  IN ULONG Length,
56 )
57 {
59  PMDL Mdl = NULL;
60 
61  ASSERT (Buffer != NULL);
63  if (Mdl == NULL) {
65  } else {
66  _SEH2_TRY {
69  } else {
71  }
74  IoFreeMdl (Mdl);
75  Mdl = NULL;
76  DbgBreak();
78  } _SEH2_END;
79  }
80  return Mdl;
81 }
82 
83 
84 VOID
86 {
87  ASSERT (Mdl != NULL);
88  while (Mdl) {
89  PMDL Next;
90  Next = Mdl->Next;
91  Mdl->Next = NULL;
92  if (IsFlagOn(Mdl->MdlFlags, MDL_PAGES_LOCKED)) {
93  MmUnlockPages (Mdl);
94  }
95  IoFreeMdl (Mdl);
96  Mdl = Next;
97  }
98 }
99 
100 NTSTATUS
102  IN ULONG Length,
104 {
106  ASSERT(Irp != NULL);
107 
108  if (Irp->MdlAddress != NULL) {
109  return STATUS_SUCCESS;
110  }
111 
112  IoAllocateMdl(Irp->UserBuffer, Length, FALSE, FALSE, Irp);
113  if (Irp->MdlAddress == NULL) {
115  }
116 
117  _SEH2_TRY {
118 
119  MmProbeAndLockPages(Irp->MdlAddress, Irp->RequestorMode, Operation);
121 
123 
124  DbgBreak();
125  IoFreeMdl(Irp->MdlAddress);
126  Irp->MdlAddress = NULL;
128  } _SEH2_END;
129 
130  return Status;
131 }
132 
133 PVOID
135 {
136  ASSERT(Irp != NULL);
137 
138  if (Irp->MdlAddress) {
139 
140 #if (_WIN32_WINNT >= 0x0500)
142 #else
143  return MmGetSystemAddressForMdl(Irp->MdlAddress);
144 #endif
145  } else {
146 
147  return Irp->UserBuffer;
148  }
149 }
150 
154  IN PIRP Irp,
155  IN PVOID Context )
156 {
158 
159  if (Irp != pContext->MasterIrp) {
160 
161  if (!NT_SUCCESS(Irp->IoStatus.Status)) {
162  pContext->MasterIrp->IoStatus = Irp->IoStatus;
163  }
164 
165  IoFreeMdl(Irp->MdlAddress);
166  IoFreeIrp(Irp );
167  }
168 
169  if (InterlockedDecrement(&pContext->Blocks) == 0) {
170 
171  pContext->MasterIrp->IoStatus.Information = 0;
172  if (NT_SUCCESS(pContext->MasterIrp->IoStatus.Status)) {
173 
174  pContext->MasterIrp->IoStatus.Information =
175  pContext->Length;
176  }
177 
178  KeSetEvent(&pContext->Event, 0, FALSE);
179  }
180 
182 }
183 
187  IN PIRP Irp,
189 )
190 {
192  PIO_STACK_LOCATION iosp;
193 
194  ASSERT(FALSE == pContext->Wait);
195 
196  if (Irp != pContext->MasterIrp && !NT_SUCCESS(Irp->IoStatus.Status)) {
197  pContext->MasterIrp->IoStatus = Irp->IoStatus;
198  }
199 
200  if (InterlockedDecrement(&pContext->Blocks) == 0) {
201 
202  if (NT_SUCCESS(pContext->MasterIrp->IoStatus.Status)) {
203 
204  /* set written bytes to status information */
205  pContext->MasterIrp->IoStatus.Information = pContext->Length;
206 
207  if (pContext->FileObject != NULL && !IsFlagOn(pContext->MasterIrp->Flags, IRP_PAGING_IO)) {
208 
209  /* modify FileObject flags, skip this for volume direct access */
210  SetFlag( pContext->FileObject->Flags,
211  IsFlagOn(pContext->Flags, EXT2_RW_CONTEXT_WRITE) ?
213 
214  /* update Current Byteoffset */
215  if (IsFlagOn(pContext->FileObject->Flags, FO_SYNCHRONOUS_IO)) {
216  iosp = IoGetCurrentIrpStackLocation(pContext->MasterIrp);
217  pContext->FileObject->CurrentByteOffset.QuadPart =
218  iosp->Parameters.Read.ByteOffset.QuadPart + pContext->Length;
219  }
220  }
221 
222  } else {
223 
224  pContext->MasterIrp->IoStatus.Information = 0;
225  }
226 
227  /* release the locked resource acquired by the caller */
228  if (pContext->Resource) {
229  ExReleaseResourceForThread(pContext->Resource, pContext->ThreadId);
230  }
231 
232  Ext2FreePool(pContext, EXT2_RWC_MAGIC);
233  DEC_MEM_COUNT(PS_RW_CONTEXT, pContext, sizeof(EXT2_RW_CONTEXT));
234  }
235 
236  return STATUS_SUCCESS;
237 }
238 
239 NTSTATUS
241  IN PEXT2_IRP_CONTEXT IrpContext,
242  IN PEXT2_VCB Vcb,
243  IN PEXT2_EXTENT Chain,
244  IN ULONG Length
245  )
246 {
247  PIRP Irp;
248  PIRP MasterIrp = IrpContext->Irp;
250  PMDL Mdl;
251  PEXT2_RW_CONTEXT pContext = NULL;
253  KEVENT Wait;
255  BOOLEAN bMasterCompleted = FALSE;
256  BOOLEAN bBugCheck = FALSE;
257 
258  ASSERT(MasterIrp);
259 
260  _SEH2_TRY {
261 
263 
264  if (!pContext) {
265  DEBUG(DL_ERR, ( "Ex2ReadWriteBlocks: failed to allocate pContext.\n"));
267  _SEH2_LEAVE;
268  }
269 
270  INC_MEM_COUNT(PS_RW_CONTEXT, pContext, sizeof(EXT2_RW_CONTEXT));
271  RtlZeroMemory(pContext, sizeof(EXT2_RW_CONTEXT));
272  pContext->Wait = Ext2CanIWait();
273  pContext->MasterIrp = MasterIrp;
274  pContext->Length = Length;
275 
276  if (IrpContext->MajorFunction == IRP_MJ_WRITE) {
277  SetFlag(pContext->Flags, EXT2_RW_CONTEXT_WRITE);
278  }
279 
280  if (pContext->Wait) {
281 
283 
284  } else if (IrpContext->Fcb->Identifier.Type == EXT2FCB) {
285 
286  if (IsFlagOn(MasterIrp->Flags, IRP_PAGING_IO)) {
287  pContext->Resource = &IrpContext->Fcb->PagingIoResource;
288  } else {
289  pContext->Resource = &IrpContext->Fcb->MainResource;
290  }
291 
292  pContext->FileObject = IrpContext->FileObject;
293  pContext->ThreadId = ExGetCurrentResourceThread();
294  }
295 
296 
297  if (NULL == Chain->Next && 0 == Chain->Offset) {
298 
299  /* we get only 1 extent to dispatch, then don't bother allocating new irps */
300 
301  /* setup the Stack location to do a read from the disk driver. */
302  IrpSp = IoGetNextIrpStackLocation(MasterIrp);
303  IrpSp->MajorFunction = IrpContext->MajorFunction;
304  IrpSp->Parameters.Read.Length = Chain->Length;
305  IrpSp->Parameters.Read.ByteOffset.QuadPart = Chain->Lba;
306  if (IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WRITE_THROUGH)) {
308  }
309  if (IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_VERIFY_READ)) {
311  }
312 
314  MasterIrp,
315  Ext2CanIWait() ?
318  (PVOID) pContext,
319  TRUE,
320  TRUE,
321  TRUE );
322 
323  /* intialize context block */
324  Chain->Irp = MasterIrp;
325  pContext->Blocks = 1;
326 
327  } else {
328 
329  for (Extent = Chain; Extent != NULL; Extent = Extent->Next) {
330 
332  MasterIrp,
333  (CCHAR)(Vcb->TargetDeviceObject->StackSize + 1) );
334 
335  if (!Irp) {
337  _SEH2_LEAVE;
338  }
339 
340  Mdl = IoAllocateMdl( (PCHAR)MasterIrp->UserBuffer +
341  Extent->Offset,
342  Extent->Length,
343  FALSE,
344  FALSE,
345  Irp );
346 
347  if (!Mdl) {
349  _SEH2_LEAVE;
350  }
351 
352  IoBuildPartialMdl( MasterIrp->MdlAddress,
353  Mdl,
354  (PCHAR)MasterIrp->UserBuffer+Extent->Offset,
355  Extent->Length );
356 
359 
360  IrpSp->MajorFunction = IrpContext->MajorFunction;
361  IrpSp->Parameters.Read.Length = Extent->Length;
362  IrpSp->Parameters.Read.ByteOffset.QuadPart = Extent->Lba;
363 
365  Irp,
366  Ext2CanIWait() ?
369  (PVOID) pContext,
370  TRUE,
371  TRUE,
372  TRUE );
373 
375 
376  IrpSp->MajorFunction = IrpContext->MajorFunction;
377  IrpSp->Parameters.Read.Length =Extent->Length;
378  IrpSp->Parameters.Read.ByteOffset.QuadPart = Extent->Lba;
379 
380  /* set write through flag */
381  if (IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WRITE_THROUGH)) {
383  }
384 
385  /* set verify flag */
386  if (IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_VERIFY_READ)) {
388  }
389 
390  Extent->Irp = Irp;
391  pContext->Blocks += 1;
392  }
393 
394  MasterIrp->AssociatedIrp.IrpCount = pContext->Blocks;
395  if (Ext2CanIWait()) {
396  MasterIrp->AssociatedIrp.IrpCount += 1;
397  }
398  }
399  if (!Ext2CanIWait()) {
400  /* mark MasterIrp pending */
401  IoMarkIrpPending(pContext->MasterIrp);
402  }
403 
404  bBugCheck = TRUE;
405 
406  for (Extent = Chain; Extent != NULL; Extent = Extent->Next) {
407  Status = IoCallDriver ( Vcb->TargetDeviceObject,
408  Extent->Irp);
409  Extent->Irp = NULL;
410  }
411 
412  if (Ext2CanIWait()) {
413  KeWaitForSingleObject( &(pContext->Event),
415  KeClearEvent( &(pContext->Event) );
416  } else {
417  bMasterCompleted = TRUE;
418  }
419 
420  } _SEH2_FINALLY {
421 
422  for (Extent = Chain; Extent != NULL; Extent = Extent->Next) {
423  if (Extent->Irp != NULL ) {
424  if (Extent->Irp->MdlAddress != NULL) {
425  IoFreeMdl(Extent->Irp->MdlAddress );
426  }
427  IoFreeIrp(Extent->Irp);
428  }
429  }
430 
431  if (IrpContext->ExceptionInProgress) {
432 
433  if (bBugCheck) {
435  }
436 
437  } else {
438 
439  if (Ext2CanIWait()) {
440  if (MasterIrp) {
441  Status = MasterIrp->IoStatus.Status;
442  }
443  if (pContext) {
444  Ext2FreePool(pContext, EXT2_RWC_MAGIC);
445  DEC_MEM_COUNT(PS_RW_CONTEXT, pContext, sizeof(EXT2_RW_CONTEXT));
446  }
447  } else {
448  if (bMasterCompleted) {
449  IrpContext->Irp = NULL;
451  }
452  }
453  }
454  } _SEH2_END;
455 
456  return Status;
457 }
458 
459 NTSTATUS
461  IN PEXT2_VCB Vcb,
463  IN ULONG Length,
464  OUT PVOID Buffer,
466 )
467 {
468  PKEVENT Event = NULL;
469 
470  PIRP Irp;
473 
474 
475  ASSERT(Vcb != NULL);
476  ASSERT(Vcb->TargetDeviceObject != NULL);
477  ASSERT(Buffer != NULL);
478 
479  _SEH2_TRY {
480 
481  Event = Ext2AllocatePool(NonPagedPool, sizeof(KEVENT), 'EK2E');
482 
483  if (NULL == Event) {
484  DEBUG(DL_ERR, ( "Ex2ReadSync: failed to allocate Event.\n"));
485  _SEH2_LEAVE;
486  }
487 
489 
491 
493  IRP_MJ_READ,
494  Vcb->TargetDeviceObject,
495  Buffer,
496  Length,
498  Event,
499  &IoStatus
500  );
501 
502  if (!Irp) {
504  _SEH2_LEAVE;
505  }
506 
507  if (bVerify) {
510  }
511 
512  Status = IoCallDriver(Vcb->TargetDeviceObject, Irp);
513 
514  if (Status == STATUS_PENDING) {
516  Event,
517  Suspended,
518  KernelMode,
519  FALSE,
520  NULL
521  );
522 
523  Status = IoStatus.Status;
524  }
525 
526  } _SEH2_FINALLY {
527 
528  if (Event) {
529  Ext2FreePool(Event, 'EK2E');
531  }
532  } _SEH2_END;
533 
534  return Status;
535 }
536 
537 
538 NTSTATUS
540  IN PEXT2_VCB Vcb,
542  IN ULONG Size,
543  IN PVOID Buffer,
544  IN BOOLEAN bVerify )
545 {
547  PUCHAR Buf;
548  ULONG Length;
549  ULONGLONG Lba;
550 
551  Lba = Offset & (~((ULONGLONG)SECTOR_SIZE - 1));
552  Length = (ULONG)(Size + Offset + SECTOR_SIZE - 1 - Lba) &
553  (~((ULONG)SECTOR_SIZE - 1));
554 
556  if (!Buf) {
557  DEBUG(DL_ERR, ( "Ext2ReadDisk: failed to allocate Buffer.\n"));
559 
560  goto errorout;
561  }
563 
565  Lba,
566  Length,
567  Buf,
568  FALSE );
569 
570  if (!NT_SUCCESS(Status)) {
571  DEBUG(DL_ERR, ("Ext2ReadDisk: disk i/o error: %xh.\n", Status));
572  goto errorout;
573  }
574 
575  RtlCopyMemory(Buffer, &Buf[Offset - Lba], Size);
576 
577 errorout:
578 
579  if (Buf) {
582  }
583 
584  return Status;
585 }
586 
587 
588 NTSTATUS
591  IN ULONG IoctlCode,
593  IN ULONG InputBufferSize,
595  IN OUT PULONG OutputBufferSize)
596 {
597  ULONG OutBufferSize = 0;
598  KEVENT Event;
599  PIRP Irp;
602 
604 
605  if (OutputBufferSize)
606  {
607  OutBufferSize = *OutputBufferSize;
608  }
609 
611 
613  IoctlCode,
614  DeviceObject,
615  InputBuffer,
616  InputBufferSize,
617  OutputBuffer,
619  FALSE,
620  &Event,
621  &IoStatus
622  );
623 
624  if (Irp == NULL) {
625  DEBUG(DL_ERR, ( "Ext2DiskIoControl: failed to build Irp!\n"));
627  }
628 
630 
631  if (Status == STATUS_PENDING) {
633  Status = IoStatus.Status;
634  }
635 
636  if (OutputBufferSize) {
637  *OutputBufferSize = (ULONG)(IoStatus.Information);
638  }
639 
640  return Status;
641 }
642 
643 
647  IN PIRP Irp,
648  IN PVOID Contxt
649 )
650 {
651  PKEVENT Event = (PKEVENT)Contxt;
652 
653  KeSetEvent( Event, 0, FALSE );
654 
656 
657  return STATUS_SUCCESS;
658 }
659 
660 VOID
662  IN PEXT2_IRP_CONTEXT IrpContext,
663  IN PEXT2_VCB Vcb,
664  IN BOOLEAN bPrevent
665 )
666 {
667  PIRP Irp;
668  KEVENT Event;
670  PREVENT_MEDIA_REMOVAL Prevent;
672 
673 
675  &Vcb->MainResource,
676  TRUE );
677 
678  if (bPrevent != IsFlagOn(Vcb->Flags, VCB_REMOVAL_PREVENTED)) {
679  if (bPrevent) {
681  } else {
683  }
684  }
685 
686  ExReleaseResourceLite(&Vcb->MainResource);
687 
688  Prevent.PreventMediaRemoval = bPrevent;
689 
691 
693  Vcb->TargetDeviceObject,
694  &Prevent,
695  sizeof(PREVENT_MEDIA_REMOVAL),
696  NULL,
697  0,
698  FALSE,
699  NULL,
700  &IoStatus );
701 
702  if (Irp != NULL) {
705  &Event,
706  TRUE,
707  TRUE,
708  TRUE );
709 
710  Status = IoCallDriver(Vcb->TargetDeviceObject, Irp);
711 
712  if (Status == STATUS_PENDING) {
714  Executive,
715  KernelMode,
716  FALSE,
717  NULL );
718  }
719  }
720 }
721 
722 
723 NTSTATUS
725 {
726  PIRP Irp;
727  KEVENT Event;
728 
731 
733 
735  Vcb->TargetDeviceObject,
736  NULL,
737  0,
738  NULL,
739  &Event,
740  &IoStatus);
741 
742  if (Irp) {
743  Status = IoCallDriver(Vcb->TargetDeviceObject, Irp);
744 
745  if (Status == STATUS_PENDING) {
747  Executive,
748  KernelMode,
749  FALSE,
750  NULL);
751 
752  Status = IoStatus.Status;
753  }
754  } else {
755  Status = IoStatus.Status;
756  }
757 
758  return Status;
759 }
signed char * PCHAR
Definition: retypes.h:7
#define IRP_CONTEXT_FLAG_VERIFY_READ
Definition: ext2fs.h:1083
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
#define IN
Definition: typedefs.h:38
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
struct _KEVENT * PKEVENT
PEXT2_GLOBAL Ext2Global
Definition: init.c:16
VOID Ext2MediaEjectControl(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN BOOLEAN bPrevent)
Definition: block.c:661
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define EXT2_RWC_MAGIC
Definition: ext2fs.h:301
#define DEC_MEM_COUNT(_i, _p, _s)
Definition: ext2fs.h:599
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:63
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
PIRP NTAPI IoBuildSynchronousFsdRequest(IN ULONG MajorFunction, IN PDEVICE_OBJECT DeviceObject, IN PVOID Buffer, IN ULONG Length, IN PLARGE_INTEGER StartingOffset, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:1069
#define IRP_MJ_SHUTDOWN
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define IRP_CONTEXT_FLAG_WRITE_THROUGH
Definition: ext2fs.h:1079
unsigned char * PUCHAR
Definition: retypes.h:3
VOID NTAPI MmBuildMdlForNonPagedPool(IN PMDL Mdl)
Definition: mdlsup.c:428
#define EXT2_BUGCHK_BLOCK
Definition: ext2fs.h:309
LONG NTSTATUS
Definition: precomp.h:26
PVOID Ext2GetUserBuffer(IN PIRP Irp)
Definition: block.c:134
_In_ PIRP _In_ ULONG _In_ ULONG _In_ ULONG _In_ ULONG OutBufferSize
Definition: classpnp.h:429
uint64 Length
Definition: DriveVolume.h:48
VOID NTAPI MmUnlockPages(IN PMDL Mdl)
Definition: mdlsup.c:1439
#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority)
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
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
ERESOURCE_THREAD ThreadId
Definition: ext2fs.h:3070
CHAR InputBuffer[80]
Definition: conmgr.c:33
_SEH2_TRY
Definition: create.c:4250
#define PS_RW_CONTEXT
Definition: common.h:22
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
#define FO_SYNCHRONOUS_IO
Definition: iotypes.h:1733
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
NTSTATUS Ext2DiskIoControl(IN PDEVICE_OBJECT DeviceObject, IN ULONG IoctlCode, IN PVOID InputBuffer, IN ULONG InputBufferSize, IN OUT PVOID OutputBuffer, IN OUT PULONG OutputBufferSize)
Definition: block.c:589
#define ExReleaseResourceForThread
Definition: exfuncs.h:350
NTSTATUS Ext2ReadDisk(IN PEXT2_VCB Vcb, IN ULONGLONG Offset, IN ULONG Size, IN PVOID Buffer, IN BOOLEAN bVerify)
Definition: block.c:539
VOID NTAPI IoBuildPartialMdl(IN PMDL SourceMdl, IN PMDL TargetMdl, IN PVOID VirtualAddress, IN ULONG Length)
Definition: iomdl.c:96
#define FO_FILE_MODIFIED
Definition: iotypes.h:1745
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
VOID Ext2DestroyMdl(IN PMDL Mdl)
Definition: block.c:85
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define FO_FILE_FAST_IO_READ
Definition: iotypes.h:1752
#define Ext2BugCheck(A, B, C, D)
Definition: ext2fs.h:335
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
#define STATUS_INVALID_USER_BUFFER
Definition: udferr_usr.h:166
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
unsigned char BOOLEAN
KEVENT Event
Definition: ext2fs.h:3066
smooth NULL
Definition: ftsmooth.c:416
#define INC_MEM_COUNT(_i, _p, _s)
Definition: ext2fs.h:598
#define SL_OVERRIDE_VERIFY_VOLUME
Definition: iotypes.h:1780
Definition: bufpool.h:45
_Must_inspect_result_ __drv_aliasesMem _In_ PDEVICE_OBJECT _In_opt_ PVOID _In_ ULONG _Out_opt_ PVOID OutputBuffer
Definition: iofuncs.h:713
PIRP NTAPI IoMakeAssociatedIrp(IN PIRP Irp, IN CCHAR StackSize)
Definition: irp.c:1925
#define PS_DISK_BUFFER
Definition: common.h:30
static BOOL bVerify
Definition: verify.c:27
BOOLEAN NTAPI MmIsNonPagedSystemAddressValid(IN PVOID VirtualAddress)
Definition: mmsup.c:204
#define EXT2_DATA_MAGIC
Definition: ext2fs.h:291
#define MDL_PAGES_LOCKED
Definition: mmtypes.h:19
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
char CCHAR
Definition: typedefs.h:50
uint64_t ULONGLONG
Definition: typedefs.h:65
#define Vcb
Definition: cdprocs.h:1425
NTSTATUS NTAPI Ext2ReadWriteBlockSyncCompletionRoutine(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: block.c:152
PERESOURCE Resource
Definition: ext2fs.h:3069
#define VCB_REMOVAL_PREVENTED
Definition: ext2fs.h:798
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
NTSTATUS NTAPI Ext2MediaEjectControlCompletion(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Contxt)
Definition: block.c:645
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
VOID NTAPI IoFreeMdl(PMDL Mdl)
Definition: iomdl.c:146
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
BOOLEAN PreventMediaRemoval
Definition: ntddstor.h:251
#define InterlockedDecrement
Definition: armddk.h:52
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
ClearFlag(Dirent->Flags, DIRENT_FLAG_NOT_PERSISTENT)
Status
Definition: gdiplustypes.h:24
#define DL_ERR
Definition: ext2fs.h:1397
PMDL NTAPI IoAllocateMdl(IN PVOID VirtualAddress, IN ULONG Length, IN BOOLEAN SecondaryBuffer, IN BOOLEAN ChargeQuota, IN PIRP Irp)
Definition: iomdl.c:22
NTSTATUS Ext2ReadSync(IN PEXT2_VCB Vcb, IN ULONGLONG Offset, IN ULONG Length, OUT PVOID Buffer, BOOLEAN bVerify)
Definition: block.c:460
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
BOOLEAN Wait
Definition: ext2fs.h:3073
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
_SEH2_END
Definition: create.c:4424
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
VOID NTAPI MmProbeAndLockPages(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN LOCK_OPERATION Operation)
Definition: mdlsup.c:935
enum _LOCK_OPERATION LOCK_OPERATION
NTSTATUS Ext2ReadWriteBlocks(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_EXTENT Chain, IN ULONG Length)
Definition: block.c:240
#define Ext2CanIWait()
Definition: ext2fs.h:1091
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
_SEH2_FINALLY
Definition: create.c:4395
unsigned int * PULONG
Definition: retypes.h:1
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IRP_PAGING_IO
#define SL_WRITE_THROUGH
Definition: iotypes.h:1781
PIRP NTAPI IoBuildDeviceIoControlRequest(IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:881
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define PS_DISK_EVENT
Definition: common.h:29
NTSTATUS Ext2LockUserBuffer(IN PIRP Irp, IN ULONG Length, IN LOCK_OPERATION Operation)
Definition: block.c:101
#define OUT
Definition: typedefs.h:39
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1666
unsigned int ULONG
Definition: retypes.h:1
#define MmGetSystemAddressForMdl(Mdl)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
_In_ FLT_SET_CONTEXT_OPERATION Operation
Definition: fltkernel.h:1468
#define DbgBreak()
Definition: ext2fs.h:46
VOID Ext2FreePool(IN PVOID P, IN ULONG Tag)
Definition: debug.c:2697
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
UINT op
Definition: effect.c:223
PFILE_OBJECT FileObject
Definition: ext2fs.h:3071
#define SECTOR_SIZE
Definition: fs.h:22
#define DEBUG(args)
Definition: rdesktop.h:129
PMDL Ext2CreateMdl(IN PVOID Buffer, IN ULONG Length, IN LOCK_OPERATION op)
Definition: block.c:52
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
NTSTATUS NTAPI Ext2ReadWriteBlockAsyncCompletionRoutine(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: block.c:185
#define IOCTL_DISK_MEDIA_REMOVAL
Definition: cdrw_usr.h:176
#define _SEH2_LEAVE
Definition: filesup.c:20
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
struct _EXT2_RW_CONTEXT * PEXT2_RW_CONTEXT
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
return STATUS_SUCCESS
Definition: btrfs.c:2966
IoMarkIrpPending(Irp)
PVOID Ext2AllocatePool(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag)
Definition: debug.c:2684
#define EXT2_RW_CONTEXT_WRITE
Definition: ext2fs.h:3077
FORCEINLINE VOID IoSetNextIrpStackLocation(_Inout_ PIRP Irp)
Definition: iofuncs.h:2632
IN BOOLEAN Wait
Definition: fatprocs.h:1529
NTSTATUS Ext2DiskShutDown(PEXT2_VCB Vcb)
Definition: block.c:724