ReactOS  0.4.14-dev-554-g2f8d847
block.c File Reference
#include "ntifs.h"
#include "ffsdrv.h"
Include dependency graph for block.c:

Go to the source code of this file.

Classes

struct  _FFS_RW_CONTEXT
 

Typedefs

typedef struct _FFS_RW_CONTEXT FFS_RW_CONTEXT
 
typedef struct _FFS_RW_CONTEXTPFFS_RW_CONTEXT
 

Functions

NTSTATUS NTAPI FFSReadWriteBlockSyncCompletionRoutine (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
 
NTSTATUS NTAPI FFSReadWriteBlockAsyncCompletionRoutine (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
 
NTSTATUS NTAPI FFSMediaEjectControlCompletion (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Contxt)
 
NTSTATUS FFSLockUserBuffer (IN PIRP Irp, IN ULONG Length, IN LOCK_OPERATION Operation)
 
PVOID FFSGetUserBuffer (IN PIRP Irp)
 
NTSTATUS FFSReadWriteBlocks (IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN PFFS_BDL FFSBDL, IN ULONG Length, IN ULONG Count, IN BOOLEAN bVerify)
 
NTSTATUS FFSReadSync (IN PFFS_VCB Vcb, IN ULONGLONG Offset, IN ULONG Length, OUT PVOID Buffer, IN BOOLEAN bVerify)
 
NTSTATUS FFSReadDisk (IN PFFS_VCB Vcb, IN ULONGLONG Offset, IN ULONG Size, IN PVOID Buffer, IN BOOLEAN bVerify)
 
NTSTATUS FFSDiskIoControl (IN PDEVICE_OBJECT DeviceObject, IN ULONG IoctlCode, IN PVOID InputBuffer, IN ULONG InputBufferSize, IN OUT PVOID OutputBuffer, IN OUT PULONG OutputBufferSize)
 
__drv_mustHoldCriticalRegion VOID FFSMediaEjectControl (IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN BOOLEAN bPrevent)
 
NTSTATUS FFSDiskShutDown (PFFS_VCB Vcb)
 

Variables

PFFS_GLOBAL FFSGlobal
 

Typedef Documentation

◆ FFS_RW_CONTEXT

◆ PFFS_RW_CONTEXT

Function Documentation

◆ FFSDiskIoControl()

NTSTATUS FFSDiskIoControl ( IN PDEVICE_OBJECT  DeviceObject,
IN ULONG  IoctlCode,
IN PVOID  InputBuffer,
IN ULONG  InputBufferSize,
IN OUT PVOID  OutputBuffer,
IN OUT PULONG  OutputBufferSize 
)

Definition at line 500 of file block.c.

507 {
508  ULONG OutBufferSize = 0;
509  KEVENT Event;
510  PIRP Irp;
513 
514  PAGED_CODE();
515 
517 
518  if (OutputBufferSize)
519  {
520  OutBufferSize = *OutputBufferSize;
521  }
522 
524 
526  IoctlCode,
527  DeviceObject,
528  InputBuffer,
529  InputBufferSize,
530  OutputBuffer,
532  FALSE,
533  &Event,
534  &IoStatus);
535 
536  if (Irp == NULL)
537  {
538  FFSPrint((DBG_ERROR, "FFSDiskIoControl: Building IRQ error!\n"));
540  }
541 
543 
544  if (Status == STATUS_PENDING)
545  {
547  Status = IoStatus.Status;
548  }
549 
550  if (OutputBufferSize)
551  {
552  *OutputBufferSize = (ULONG) IoStatus.Information;
553  }
554 
555  return Status;
556 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
_In_ PIRP _In_ ULONG _In_ ULONG _In_ ULONG _In_ ULONG OutBufferSize
Definition: classpnp.h:429
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
CHAR InputBuffer[80]
Definition: conmgr.c:33
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
smooth NULL
Definition: ftsmooth.c:416
_Must_inspect_result_ __drv_aliasesMem _In_ PDEVICE_OBJECT _In_opt_ PVOID _In_ ULONG _Out_opt_ PVOID OutputBuffer
Definition: iofuncs.h:713
#define STATUS_PENDING
Definition: ntstatus.h:82
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define DBG_ERROR
Definition: ffsdrv.h:1031
Status
Definition: gdiplustypes.h:24
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
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
unsigned int ULONG
Definition: retypes.h:1

Referenced by FFSInitializeVcb(), FFSMountVolume(), and FFSVerifyVolume().

◆ FFSDiskShutDown()

NTSTATUS FFSDiskShutDown ( PFFS_VCB  Vcb)

Definition at line 648 of file block.c.

650 {
651  PIRP Irp;
652  KEVENT Event;
655 
656  PAGED_CODE();
657 
659 
661  Vcb->TargetDeviceObject,
662  NULL,
663  0,
664  NULL,
665  &Event,
666  &IoStatus);
667 
668  if (Irp)
669  {
670  Status = IoCallDriver(Vcb->TargetDeviceObject, Irp);
671 
672  if (Status == STATUS_PENDING)
673  {
675  Executive,
676  KernelMode,
677  FALSE,
678  NULL);
679 
680  Status = IoStatus.Status;
681  }
682  }
683  else
684  {
685  Status = IoStatus.Status;
686  }
687 
688  return Status;
689 }
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
LONG NTSTATUS
Definition: precomp.h:26
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
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
smooth NULL
Definition: ftsmooth.c:416
#define STATUS_PENDING
Definition: ntstatus.h:82
#define Vcb
Definition: cdprocs.h:1425
Status
Definition: gdiplustypes.h:24
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218

Referenced by FFSShutDown().

◆ FFSGetUserBuffer()

PVOID FFSGetUserBuffer ( IN PIRP  Irp)

Definition at line 115 of file block.c.

117 {
118  PAGED_CODE();
119 
120  ASSERT(Irp != NULL);
121 
122  if (Irp->MdlAddress)
123  {
124 #if (_WIN32_WINNT >= 0x0500)
126 #else
127  return MmGetSystemAddressForMdl(Irp->MdlAddress);
128 #endif
129  }
130  else
131  {
132  return Irp->UserBuffer;
133  }
134 }
_In_ PIRP Irp
Definition: csq.h:116
#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority)
#define PAGED_CODE()
Definition: video.h:57
smooth NULL
Definition: ftsmooth.c:416
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define MmGetSystemAddressForMdl(Mdl)

Referenced by FFSQueryDirectory(), FFSReadFile(), FFSReadVolume(), FFSWriteFile(), and FFSWriteVolume().

◆ FFSLockUserBuffer()

NTSTATUS FFSLockUserBuffer ( IN PIRP  Irp,
IN ULONG  Length,
IN LOCK_OPERATION  Operation 
)

Definition at line 70 of file block.c.

74 {
76 
77  PAGED_CODE();
78 
79  ASSERT(Irp != NULL);
80 
81  if (Irp->MdlAddress != NULL)
82  {
83  return STATUS_SUCCESS;
84  }
85 
86  IoAllocateMdl(Irp->UserBuffer, Length, FALSE, FALSE, Irp);
87 
88  if (Irp->MdlAddress == NULL)
89  {
91  }
92 
93  _SEH2_TRY
94  {
95  MmProbeAndLockPages(Irp->MdlAddress, Irp->RequestorMode, Operation);
96 
98  }
100  {
101  IoFreeMdl(Irp->MdlAddress);
102 
103  Irp->MdlAddress = NULL;
104 
105  FFSBreakPoint();
106 
108  } _SEH2_END;
109 
110  return Status;
111 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
#define PAGED_CODE()
Definition: video.h:57
_SEH2_TRY
Definition: create.c:4250
#define FFSBreakPoint()
Definition: ffsdrv.h:43
#define STATUS_INVALID_USER_BUFFER
Definition: udferr_usr.h:166
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
VOID NTAPI IoFreeMdl(PMDL Mdl)
Definition: iomdl.c:146
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Status
Definition: gdiplustypes.h:24
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
_In_ FLT_SET_CONTEXT_OPERATION Operation
Definition: fltkernel.h:1468
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by FFSQueryDirectory(), FFSReadFile(), FFSReadVolume(), FFSWriteFile(), and FFSWriteVolume().

◆ FFSMediaEjectControl()

__drv_mustHoldCriticalRegion VOID FFSMediaEjectControl ( IN PFFS_IRP_CONTEXT  IrpContext,
IN PFFS_VCB  Vcb,
IN BOOLEAN  bPrevent 
)

Definition at line 577 of file block.c.

581 {
582  PIRP Irp;
583  KEVENT Event;
585  PREVENT_MEDIA_REMOVAL Prevent;
587 
588  PAGED_CODE();
589 
591  &Vcb->MainResource,
592  TRUE);
593 
594  if (bPrevent != IsFlagOn(Vcb->Flags, VCB_REMOVAL_PREVENTED))
595  {
596  if (bPrevent)
597  {
599  }
600  else
601  {
603  }
604  }
605 
607  &Vcb->MainResource,
609 
610  Prevent.PreventMediaRemoval = bPrevent;
611 
613 
615  Vcb->TargetDeviceObject,
616  &Prevent,
617  sizeof(PREVENT_MEDIA_REMOVAL),
618  NULL,
619  0,
620  FALSE,
621  NULL,
622  &IoStatus);
623 
624  if (Irp != NULL)
625  {
628  &Event,
629  TRUE,
630  TRUE,
631  TRUE);
632 
633  Status = IoCallDriver(Vcb->TargetDeviceObject, Irp);
634 
635  if (Status == STATUS_PENDING)
636  {
638  Executive,
639  KernelMode,
640  FALSE,
641  NULL);
642  }
643  }
644 }
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
#define TRUE
Definition: types.h:120
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
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
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
smooth NULL
Definition: ftsmooth.c:416
#define STATUS_PENDING
Definition: ntstatus.h:82
#define Vcb
Definition: cdprocs.h:1425
#define VCB_REMOVAL_PREVENTED
Definition: ext2fs.h:798
BOOLEAN PreventMediaRemoval
Definition: ntddstor.h:251
ClearFlag(Dirent->Flags, DIRENT_FLAG_NOT_PERSISTENT)
Status
Definition: gdiplustypes.h:24
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
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
NTSTATUS NTAPI FFSMediaEjectControlCompletion(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Contxt)
Definition: block.c:560
VOID NTAPI ExReleaseResourceForThreadLite(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread)
Definition: resource.c:1844
#define IOCTL_DISK_MEDIA_REMOVAL
Definition: cdrw_usr.h:176

◆ FFSMediaEjectControlCompletion()

NTSTATUS NTAPI FFSMediaEjectControlCompletion ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PVOID  Contxt 
)

Definition at line 560 of file block.c.

564 {
565  PKEVENT Event = (PKEVENT)Contxt;
566 
567  KeSetEvent(Event, 0, FALSE);
568 
570 
571  return STATUS_SUCCESS;
572 }
struct _KEVENT * PKEVENT
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by FFSMediaEjectControl().

◆ FFSReadDisk()

NTSTATUS FFSReadDisk ( IN PFFS_VCB  Vcb,
IN ULONGLONG  Offset,
IN ULONG  Size,
IN PVOID  Buffer,
IN BOOLEAN  bVerify 
)

Definition at line 448 of file block.c.

454 {
456  PUCHAR Buf;
457  ULONG Length;
458  ULONGLONG Lba;
459 
460  PAGED_CODE();
461 
462  Lba = Offset & (~((ULONGLONG)SECTOR_SIZE - 1));
463  Length = (ULONG)(Size + Offset + SECTOR_SIZE - 1 - Lba) &
464  (~((ULONG)SECTOR_SIZE - 1));
465 
467  if (!Buf)
468  {
469  FFSPrint((DBG_ERROR, "FFSReadDisk: no enough memory.\n"));
471 
472  goto errorout;
473  }
474 
476  Lba,
477  Length,
478  Buf,
479  FALSE);
480 
481  if (!NT_SUCCESS(Status))
482  {
483  FFSPrint((DBG_ERROR, "FFSReadDisk: Read Block Device error.\n"));
484 
485  goto errorout;
486  }
487 
488  RtlCopyMemory(Buffer, &Buf[Offset - Lba], Size);
489 
490 errorout:
491 
492  if (Buf)
493  ExFreePool(Buf);
494 
495  return Status;
496 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
unsigned char * PUCHAR
Definition: retypes.h:3
NTSTATUS FFSReadSync(IN PFFS_VCB Vcb, IN ULONGLONG Offset, IN ULONG Length, OUT PVOID Buffer, IN BOOLEAN bVerify)
Definition: block.c:389
LONG NTSTATUS
Definition: precomp.h:26
#define PAGED_CODE()
Definition: video.h:57
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
Definition: bufpool.h:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
uint64_t ULONGLONG
Definition: typedefs.h:65
#define Vcb
Definition: cdprocs.h:1425
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define DBG_ERROR
Definition: ffsdrv.h:1031
#define FFS_POOL_TAG
Definition: ffsdrv.h:817
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
Status
Definition: gdiplustypes.h:24
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
unsigned int ULONG
Definition: retypes.h:1
#define SECTOR_SIZE
Definition: fs.h:22
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by FFSLoadDiskLabel(), and FFSLoadSuper().

◆ FFSReadSync()

NTSTATUS FFSReadSync ( IN PFFS_VCB  Vcb,
IN ULONGLONG  Offset,
IN ULONG  Length,
OUT PVOID  Buffer,
IN BOOLEAN  bVerify 
)

Definition at line 389 of file block.c.

395 {
396  KEVENT Event;
397  PIRP Irp;
400 
401  PAGED_CODE();
402 
403  ASSERT(Vcb != NULL);
404  ASSERT(Vcb->TargetDeviceObject != NULL);
405  ASSERT(Buffer != NULL);
406 
408 
410  IRP_MJ_READ,
411  Vcb->TargetDeviceObject,
412  Buffer,
413  Length,
415  &Event,
416  &IoStatus);
417 
418  if (!Irp)
419  {
421  }
422 
423  if (bVerify)
424  {
427  }
428 
429  Status = IoCallDriver(Vcb->TargetDeviceObject, Irp);
430 
431  if (Status == STATUS_PENDING)
432  {
434  &Event,
435  Suspended,
436  KernelMode,
437  FALSE,
438  NULL);
439 
440  Status = IoStatus.Status;
441  }
442 
443  return Status;
444 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
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
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
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
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
smooth NULL
Definition: ftsmooth.c:416
#define SL_OVERRIDE_VERIFY_VOLUME
Definition: iotypes.h:1780
Definition: bufpool.h:45
static BOOL bVerify
Definition: verify.c:27
#define STATUS_PENDING
Definition: ntstatus.h:82
#define Vcb
Definition: cdprocs.h:1425
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
Status
Definition: gdiplustypes.h:24
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IRP_MJ_READ
Definition: rdpdr.c:46

Referenced by FFSReadDisk().

◆ FFSReadWriteBlockAsyncCompletionRoutine()

NTSTATUS NTAPI FFSReadWriteBlockAsyncCompletionRoutine ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PVOID  Context 
)

Definition at line 173 of file block.c.

177 {
179 
180  if (!NT_SUCCESS(Irp->IoStatus.Status))
181  {
182  pContext->MasterIrp->IoStatus = Irp->IoStatus;
183  }
184 
185  if (InterlockedDecrement(&pContext->Blocks) == 0)
186  {
187  pContext->MasterIrp->IoStatus.Information = 0;
188 
189  if (NT_SUCCESS(pContext->MasterIrp->IoStatus.Status))
190  {
191  pContext->MasterIrp->IoStatus.Information =
192  pContext->Length;
193  }
194 
195  IoMarkIrpPending(pContext->MasterIrp);
196 
197  ExFreePool(pContext);
198  }
199 
201 
202  return STATUS_SUCCESS;
203 
204 }
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
PIRP MasterIrp
Definition: block.c:25
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
struct _FFS_RW_CONTEXT * PFFS_RW_CONTEXT
#define InterlockedDecrement
Definition: armddk.h:52
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
return STATUS_SUCCESS
Definition: btrfs.c:2938
IoMarkIrpPending(Irp)
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
ULONG Length
Definition: block.c:29
LONG Blocks
Definition: block.c:28

Referenced by FFSReadWriteBlocks().

◆ FFSReadWriteBlocks()

NTSTATUS FFSReadWriteBlocks ( IN PFFS_IRP_CONTEXT  IrpContext,
IN PFFS_VCB  Vcb,
IN PFFS_BDL  FFSBDL,
IN ULONG  Length,
IN ULONG  Count,
IN BOOLEAN  bVerify 
)

Definition at line 207 of file block.c.

214 {
215  PMDL Mdl;
216  PIRP Irp;
217  PIRP MasterIrp = IrpContext->Irp;
220  PFFS_RW_CONTEXT pContext = NULL;
221  ULONG i;
222  BOOLEAN bBugCheck = FALSE;
223 
224  PAGED_CODE();
225 
226  ASSERT(MasterIrp);
227 
228  _SEH2_TRY
229  {
230 
232 
233  if (!pContext)
234  {
236  _SEH2_LEAVE;
237  }
238 
239  RtlZeroMemory(pContext, sizeof(FFS_RW_CONTEXT));
240 
241  pContext->Wait = IrpContext->IsSynchronous;
242  pContext->MasterIrp = MasterIrp;
243  pContext->Blocks = Count;
244  pContext->Length = 0;
245 
246  if (pContext->Wait)
247  {
249  }
250 
251  for (i = 0; i < Count; i++)
252  {
253 
254  Irp = IoMakeAssociatedIrp(MasterIrp,
255  (CCHAR)(Vcb->TargetDeviceObject->StackSize + 1));
256  if (!Irp)
257  {
258 #ifdef __REACTOS__
259  ExFreePoolWithTag(pContext, FFS_POOL_TAG);
260  pContext = NULL;
261 #endif
263  _SEH2_LEAVE;
264  }
265 
266  Mdl = IoAllocateMdl((PCHAR)MasterIrp->UserBuffer +
267  FFSBDL[i].Offset,
268  FFSBDL[i].Length,
269  FALSE,
270  FALSE,
271  Irp);
272 
273  if (!Mdl)
274  {
275 #ifdef __REACTOS__
276  ExFreePoolWithTag(pContext, FFS_POOL_TAG);
277  pContext = NULL;
278 #endif
280  _SEH2_LEAVE;
281  }
282 
283  IoBuildPartialMdl(MasterIrp->MdlAddress,
284  Mdl,
285  (PCHAR)MasterIrp->UserBuffer + FFSBDL[i].Offset,
286  FFSBDL[i].Length);
287 
290 
291 
292  IrpSp->MajorFunction = IrpContext->MajorFunction;
293  IrpSp->Parameters.Read.Length = FFSBDL[i].Length;
294  IrpSp->Parameters.Read.ByteOffset.QuadPart = FFSBDL[i].Lba;
295 
297  IrpContext->IsSynchronous ?
300  (PVOID) pContext,
301  TRUE,
302  TRUE,
303  TRUE);
304 
306 
307  IrpSp->MajorFunction = IrpContext->MajorFunction;
308  IrpSp->Parameters.Read.Length = FFSBDL[i].Length;
309  IrpSp->Parameters.Read.ByteOffset.QuadPart = FFSBDL[i].Lba;
310 
311  if (bVerify)
312  {
314  }
315 
316  FFSBDL[i].Irp = Irp;
317  }
318 
319  MasterIrp->AssociatedIrp.IrpCount = Count;
320 
321  if (IrpContext->IsSynchronous)
322  {
323  MasterIrp->AssociatedIrp.IrpCount += 1;
324  }
325 
326  pContext->Length = Length;
327 
328  bBugCheck = TRUE;
329 
330  for (i = 0; i < Count; i++)
331  {
332  Status = IoCallDriver(Vcb->TargetDeviceObject,
333  FFSBDL[i].Irp);
334  }
335 
336  if (IrpContext->IsSynchronous)
337  {
338  KeWaitForSingleObject(&(pContext->Event),
340 
341  KeClearEvent(&(pContext->Event));
342  }
343  }
344 
346  {
347  if (IrpContext->IsSynchronous)
348  {
349  if (MasterIrp)
350  Status = MasterIrp->IoStatus.Status;
351 
352  if (pContext)
353  ExFreePool(pContext);
354 
355  }
356  else
357  {
358  IrpContext->Irp = NULL;
360  }
361 
363  {
364  if (bBugCheck)
365  {
366  FFSBugCheck(FFS_BUGCHK_BLOCK, 0, 0, 0);
367  }
368 
369  for (i = 0; i < Count; i++)
370  {
371  if (FFSBDL[i].Irp != NULL)
372  {
373  if (FFSBDL[i].Irp->MdlAddress != NULL)
374  {
375  IoFreeMdl(FFSBDL[i].Irp->MdlAddress);
376  }
377 
378  IoFreeIrp(FFSBDL[i].Irp);
379  }
380  }
381  }
382  } _SEH2_END;
383 
384  return Status;
385 }
signed char * PCHAR
Definition: retypes.h:7
NTSTATUS NTAPI FFSReadWriteBlockAsyncCompletionRoutine(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: block.c:173
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
#define FFSBugCheck(A, B, C, D)
Definition: ffsdrv.h:194
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
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 IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
VOID NTAPI IoBuildPartialMdl(IN PMDL SourceMdl, IN PMDL TargetMdl, IN PVOID VirtualAddress, IN ULONG Length)
Definition: iomdl.c:96
PIRP MasterIrp
Definition: block.c:25
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
BOOLEAN Wait
Definition: block.c:27
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define _SEH2_AbnormalTermination()
Definition: pseh2_64.h:13
#define SL_OVERRIDE_VERIFY_VOLUME
Definition: iotypes.h:1780
PIRP NTAPI IoMakeAssociatedIrp(IN PIRP Irp, IN CCHAR StackSize)
Definition: irp.c:1925
static BOOL bVerify
Definition: verify.c:27
#define FFS_BUGCHK_BLOCK
Definition: ffsdrv.h:168
#define STATUS_PENDING
Definition: ntstatus.h:82
char CCHAR
Definition: typedefs.h:50
#define Vcb
Definition: cdprocs.h:1425
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
VOID NTAPI IoFreeMdl(PMDL Mdl)
Definition: iomdl.c:146
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define FFS_POOL_TAG
Definition: ffsdrv.h:817
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
KEVENT Event
Definition: block.c:26
Status
Definition: gdiplustypes.h:24
PMDL NTAPI IoAllocateMdl(IN PVOID VirtualAddress, IN ULONG Length, IN BOOLEAN SecondaryBuffer, IN BOOLEAN ChargeQuota, IN PIRP Irp)
Definition: iomdl.c:22
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
#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
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
_SEH2_FINALLY
Definition: create.c:4395
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1666
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
NTSTATUS NTAPI FFSReadWriteBlockSyncCompletionRoutine(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: block.c:138
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define _SEH2_LEAVE
Definition: filesup.c:20
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
return STATUS_SUCCESS
Definition: btrfs.c:2938
FORCEINLINE VOID IoSetNextIrpStackLocation(_Inout_ PIRP Irp)
Definition: iofuncs.h:2632
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
ULONG Length
Definition: block.c:29
LONG Blocks
Definition: block.c:28

Referenced by FFSReadVolume(), FFSv1ReadInode(), FFSv1WriteInode(), FFSv2ReadInode(), and FFSWriteVolume().

◆ FFSReadWriteBlockSyncCompletionRoutine()

NTSTATUS NTAPI FFSReadWriteBlockSyncCompletionRoutine ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PVOID  Context 
)

Definition at line 138 of file block.c.

142 {
144 
145  if (!NT_SUCCESS(Irp->IoStatus.Status))
146  {
147 
148  pContext->MasterIrp->IoStatus = Irp->IoStatus;
149  }
150 
151  IoFreeMdl(Irp->MdlAddress);
152  IoFreeIrp(Irp);
153 
154  if (InterlockedDecrement(&pContext->Blocks) == 0)
155  {
156  pContext->MasterIrp->IoStatus.Information = 0;
157 
158  if (NT_SUCCESS(pContext->MasterIrp->IoStatus.Status))
159  {
160  pContext->MasterIrp->IoStatus.Information =
161  pContext->Length;
162  }
163 
164  KeSetEvent(&pContext->Event, 0, FALSE);
165  }
166 
168 
170 }
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:68
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
PIRP MasterIrp
Definition: block.c:25
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
struct _FFS_RW_CONTEXT * PFFS_RW_CONTEXT
VOID NTAPI IoFreeMdl(PMDL Mdl)
Definition: iomdl.c:146
#define InterlockedDecrement
Definition: armddk.h:52
KEVENT Event
Definition: block.c:26
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1666
ULONG Length
Definition: block.c:29
LONG Blocks
Definition: block.c:28

Referenced by FFSReadWriteBlocks().

Variable Documentation

◆ FFSGlobal

PFFS_GLOBAL FFSGlobal

Definition at line 22 of file init.c.