ReactOS  0.4.14-dev-376-gaedba84
devctl.c File Reference
#include "ext2fs.h"
Include dependency graph for devctl.c:

Go to the source code of this file.

Functions

NTSTATUS NTAPI Ext2DeviceControlCompletion (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
 
NTSTATUS Ext2DeviceControlNormal (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2ProcessGlobalProperty (IN PDEVICE_OBJECT DeviceObject, IN PEXT2_VOLUME_PROPERTY3 Property3, IN ULONG Length)
 
NTSTATUS Ext2ProcessVolumeProperty (IN PEXT2_VCB Vcb, IN PEXT2_VOLUME_PROPERTY3 Property3, IN ULONG Length)
 
NTSTATUS Ext2ProcessUserProperty (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VOLUME_PROPERTY3 Property, IN ULONG Length)
 
NTSTATUS Ex2ProcessUserPerfStat (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_QUERY_PERFSTAT QueryPerf, IN ULONG Length)
 
NTSTATUS Ex2ProcessMountPoint (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_MOUNT_POINT MountPoint, IN ULONG Length)
 
NTSTATUS Ext2DeviceControl (IN PEXT2_IRP_CONTEXT IrpContext)
 

Variables

PEXT2_GLOBAL Ext2Global
 
CHAR gVersion []
 
CHAR gTime []
 
CHAR gDate []
 

Function Documentation

◆ Ex2ProcessMountPoint()

NTSTATUS Ex2ProcessMountPoint ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_MOUNT_POINT  MountPoint,
IN ULONG  Length 
)

Definition at line 699 of file devctl.c.

704 {
707  WCHAR Buffer[] = L"\\DosDevices\\Global\\Z:";
709 
711 
712  _SEH2_TRY {
713 
714  ASSERT(IrpContext != NULL);
715  ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
716  (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
717 
718  DeviceObject = IrpContext->DeviceObject;
721  _SEH2_LEAVE;
722  }
723 
724  if (Length != sizeof(EXT2_MOUNT_POINT) ||
725  MountPoint->Magic != EXT2_APP_MOUNTPOINT_MAGIC) {
727  _SEH2_LEAVE;
728  }
729 
731  Buffer[12] = MountPoint->Link[0];
732 
733  switch (MountPoint->Command) {
734 
736  RtlInitUnicodeString(&Target, &MountPoint->Name[0]);
738  break;
739 
742  break;
743 
744  default:
746  }
747 
748  } _SEH2_FINALLY {
749 
750  if (!IrpContext->ExceptionInProgress) {
751  Ext2CompleteIrpContext(IrpContext, status);
752  }
753  } _SEH2_END;
754 
755  return status;
756 }
#define APP_CMD_DEL_DOS_SYMLINK
Definition: common.h:258
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
static int Link(const char **args)
Definition: vfdcmd.c:2414
_SEH2_TRY
Definition: create.c:4250
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
_Must_inspect_result_ typedef _In_ ULONG _In_ BOOLEAN Target
Definition: iotypes.h:1068
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static const WCHAR L[]
Definition: oid.c:1250
#define EXT2_APP_MOUNTPOINT_MAGIC
Definition: common.h:247
NTSTATUS Ext2CompleteIrpContext(IN PEXT2_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:32
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
_SEH2_END
Definition: create.c:4424
_SEH2_FINALLY
Definition: create.c:4395
#define APP_CMD_ADD_DOS_SYMLINK
Definition: common.h:257
#define IsExt2FsDevice(DO)
Definition: ext2fs.h:607
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define _SEH2_LEAVE
Definition: filesup.c:20
return STATUS_SUCCESS
Definition: btrfs.c:2938
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by Ext2DeviceControl().

◆ Ex2ProcessUserPerfStat()

NTSTATUS Ex2ProcessUserPerfStat ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_QUERY_PERFSTAT  QueryPerf,
IN ULONG  Length 
)

Definition at line 616 of file devctl.c.

621 {
622 
623 #ifndef __REACTOS__
624  PEXT2_VCB Vcb = NULL;
625 #endif
627 
628  BOOLEAN GlobalDataResourceAcquired = FALSE;
630 
631  _SEH2_TRY {
632 
633  ASSERT(IrpContext != NULL);
634  ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
635  (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
636 
637  DeviceObject = IrpContext->DeviceObject;
639 
640  if (QueryPerf->Magic != EXT2_QUERY_PERFSTAT_MAGIC) {
642  _SEH2_LEAVE;
643  }
644 
645  if (QueryPerf->Command != IOCTL_APP_QUERY_PERFSTAT) {
647  _SEH2_LEAVE;
648  }
649 
653  _SEH2_LEAVE;
654  }
655 
657  GlobalDataResourceAcquired = TRUE;
658 
660  QueryPerf->Flags = EXT2_QUERY_PERFSTAT_VER2;
661  QueryPerf->PerfStatV2 = Ext2Global->PerfStat;
662  } else {
663  memcpy(&QueryPerf->PerfStatV1.Irps[0], &Ext2Global->PerfStat.Irps[0],
665  memcpy(&QueryPerf->PerfStatV1.Unit, &Ext2Global->PerfStat.Unit,
666  sizeof(EXT2_STAT_ARRAY_V1));
667  memcpy(&QueryPerf->PerfStatV1.Current, &Ext2Global->PerfStat.Current,
668  sizeof(EXT2_STAT_ARRAY_V1));
669  memcpy(&QueryPerf->PerfStatV1.Size, &Ext2Global->PerfStat.Size,
670  sizeof(EXT2_STAT_ARRAY_V1));
671  memcpy(&QueryPerf->PerfStatV1.Total, &Ext2Global->PerfStat.Total,
672  sizeof(EXT2_STAT_ARRAY_V1));
673  }
674 
675  } else {
677  _SEH2_LEAVE;
678  }
679 
680  if (NT_SUCCESS(Status)) {
681  IrpContext->Irp->IoStatus.Information = Length;
682  }
683 
684  } _SEH2_FINALLY {
685 
686  if (GlobalDataResourceAcquired) {
688  }
689 
690  if (!IrpContext->ExceptionInProgress) {
691  Ext2CompleteIrpContext(IrpContext, Status);
692  }
693  } _SEH2_END
694 
695  return Status;
696 }
#define TRUE
Definition: types.h:120
Unit
Definition: gdiplusenums.h:25
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
ERESOURCE Resource
Definition: ext2fs.h:510
EXT2_STAT_ARRAY_V2 Size
Definition: common.h:137
LONG NTSTATUS
Definition: precomp.h:26
EXT2_PERF_STATISTICS_V2 PerfStat
Definition: ext2fs.h:573
_SEH2_TRY
Definition: create.c:4250
#define IOCTL_APP_QUERY_PERFSTAT
Definition: common.h:8
PEXT2_GLOBAL Ext2Global
Definition: init.c:16
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define EXT2_QUERY_PERFSTAT_SZV1
Definition: common.h:243
EXT2_STAT_ARRAY_V2 Total
Definition: common.h:140
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define Vcb
Definition: cdprocs.h:1425
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
#define EXT2_QUERY_PERFSTAT_MAGIC
Definition: common.h:230
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
NTSTATUS Ext2CompleteIrpContext(IN PEXT2_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:32
#define EXT2_QUERY_PERFSTAT_VER2
Definition: common.h:231
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
struct _EXT2_PERF_STATISTICS_V2::@667 Irps[IRP_MJ_MAXIMUM_FUNCTION+1]
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
_SEH2_END
Definition: create.c:4424
#define EXT2_QUERY_PERFSTAT_SZV2
Definition: common.h:244
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
_SEH2_FINALLY
Definition: create.c:4395
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
#define IsExt2FsDevice(DO)
Definition: ext2fs.h:607
#define _SEH2_LEAVE
Definition: filesup.c:20
return STATUS_SUCCESS
Definition: btrfs.c:2938
EXT2_STAT_ARRAY_V2 Unit
Definition: common.h:131

Referenced by Ext2DeviceControl().

◆ Ext2DeviceControl()

NTSTATUS Ext2DeviceControl ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 759 of file devctl.c.

760 {
761  PIRP Irp;
763  ULONG code;
764  ULONG length;
766 
767  ASSERT(IrpContext);
768 
769  ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
770  (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
771 
772  Irp = IrpContext->Irp;
773 
775 
776  code = irpSp->Parameters.DeviceIoControl.IoControlCode;
777  length = irpSp->Parameters.DeviceIoControl.OutputBufferLength;
778 
779  switch (code) {
780 
783  IrpContext,
784  Irp->AssociatedIrp.SystemBuffer,
785  length
786  );
787  break;
788 
791  IrpContext,
792  Irp->AssociatedIrp.SystemBuffer,
793  length
794  );
795  break;
796 
799  IrpContext,
800  Irp->AssociatedIrp.SystemBuffer,
801  length
802  );
803  break;
804 
805 #if EXT2_UNLOAD
806  case IOCTL_PREPARE_TO_UNLOAD:
807  Status = Ext2PrepareToUnload(IrpContext);
808  break;
809 #endif
810  default:
811  Status = Ext2DeviceControlNormal(IrpContext);
812  }
813 
814  return Status;
815 }
#define IOCTL_APP_MOUNT_POINT
Definition: common.h:11
NTSTATUS Ex2ProcessMountPoint(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_MOUNT_POINT MountPoint, IN ULONG Length)
Definition: devctl.c:699
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
#define IOCTL_APP_VOLUME_PROPERTY
Definition: common.h:5
#define IOCTL_APP_QUERY_PERFSTAT
Definition: common.h:8
NTSTATUS Ex2ProcessUserPerfStat(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_QUERY_PERFSTAT QueryPerf, IN ULONG Length)
Definition: devctl.c:616
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
irpSp
Definition: iofuncs.h:2671
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
NTSTATUS Ext2ProcessUserProperty(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VOLUME_PROPERTY3 Property, IN ULONG Length)
Definition: devctl.c:567
int code
Definition: i386-dis.c:3591
Status
Definition: gdiplustypes.h:24
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
NTSTATUS Ext2DeviceControlNormal(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: devctl.c:57
NTSTATUS Ext2PrepareToUnload(IN PEXT2_IRP_CONTEXT IrpContext)
unsigned int ULONG
Definition: retypes.h:1

Referenced by Ext2DispatchRequest().

◆ Ext2DeviceControlCompletion()

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

Definition at line 42 of file devctl.c.

47 {
48  if (Irp->PendingReturned) {
50  }
51 
52  return STATUS_SUCCESS;
53 }
_In_ PIRP Irp
Definition: csq.h:116
return STATUS_SUCCESS
Definition: btrfs.c:2938
IoMarkIrpPending(Irp)

Referenced by Ext2DeviceControlNormal().

◆ Ext2DeviceControlNormal()

NTSTATUS Ext2DeviceControlNormal ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 57 of file devctl.c.

58 {
62 
63  PEXT2_VCB Vcb;
64 
65  PIRP Irp;
67  PIO_STACK_LOCATION NextIrpSp;
68 
70 
71  _SEH2_TRY {
72 
73  ASSERT(IrpContext != NULL);
74 
75  ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
76  (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
77 
79 
80  DeviceObject = IrpContext->DeviceObject;
81 
85  }
86 
87  Irp = IrpContext->Irp;
89 
90  Vcb = (PEXT2_VCB) IrpSp->FileObject->FsContext;
91 
92  if (!((Vcb) && (Vcb->Identifier.Type == EXT2VCB) &&
93  (Vcb->Identifier.Size == sizeof(EXT2_VCB)))) {
96  }
97 
98  TargetDeviceObject = Vcb->TargetDeviceObject;
99 
100  //
101  // Pass on the IOCTL to the driver below
102  //
103 
105 
106  NextIrpSp = IoGetNextIrpStackLocation( Irp );
107  *NextIrpSp = *IrpSp;
108 
110  Irp,
112  NULL,
113  FALSE,
114  TRUE,
115  TRUE );
116 
118 
119  } _SEH2_FINALLY {
120 
121  if (!IrpContext->ExceptionInProgress) {
122  if (IrpContext) {
123  if (!CompleteRequest) {
124  IrpContext->Irp = NULL;
125  }
126 
127  Ext2CompleteIrpContext(IrpContext, Status);
128  }
129  }
130  } _SEH2_END;
131 
132  return Status;
133 }
#define TRUE
Definition: types.h:120
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
_SEH2_TRY
Definition: create.c:4250
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define Vcb
Definition: cdprocs.h:1425
NTSTATUS NTAPI Ext2DeviceControlCompletion(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: devctl.c:42
NTSTATUS NTAPI CompleteRequest(IN PIRP Irp, IN NTSTATUS Status, IN ULONG_PTR Information)
Definition: dispatch.c:19
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
NTSTATUS Ext2CompleteIrpContext(IN PEXT2_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:32
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2813
_SEH2_END
Definition: create.c:4424
_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
#define IsExt2FsDevice(DO)
Definition: ext2fs.h:607
struct _EXT2_VCB * PEXT2_VCB
#define _SEH2_LEAVE
Definition: filesup.c:20
IN OUT PVCB IN PDEVICE_OBJECT TargetDeviceObject
Definition: fatprocs.h:1664

Referenced by Ext2DeviceControl().

◆ Ext2ProcessGlobalProperty()

NTSTATUS Ext2ProcessGlobalProperty ( IN PDEVICE_OBJECT  DeviceObject,
IN PEXT2_VOLUME_PROPERTY3  Property3,
IN ULONG  Length 
)

Definition at line 232 of file devctl.c.

237 {
238  PEXT2_VOLUME_PROPERTY3 Property2 = (PVOID)Property3;
239  PEXT2_VOLUME_PROPERTY Property = (PVOID)Property3;
240  struct nls_table * PageTable = NULL;
241 
243  BOOLEAN GlobalDataResourceAcquired = FALSE;
244 
245  _SEH2_TRY {
246 
247  if (Length < 8 || !IsFlagOn(Property->Flags, EXT2_FLAG_VP_SET_GLOBAL)) {
249  _SEH2_LEAVE;
250  }
251 
252  /* query Ext2Fsd's version and built date/time*/
253  if (Property->Command == APP_CMD_QUERY_VERSION) {
256 
257  if (Length < sizeof(EXT2_VOLUME_PROPERTY_VERSION)) {
259  _SEH2_LEAVE;
260  }
261 
262  RtlZeroMemory(&PVPV->Date[0], 0x20);
263  RtlZeroMemory(&PVPV->Time[0], 0x20);
264  RtlZeroMemory(&PVPV->Version[0],0x1C);
265  strncpy(&PVPV->Version[0], gVersion, 0x1B);
266  strncpy(&PVPV->Date[0], gDate, 0x1F);
267  strncpy(&PVPV->Time[0], gTime, 0x1F);
268  _SEH2_LEAVE;
269  }
270 
271  /* must be property query/set commands */
272  if (Property->Command == APP_CMD_SET_PROPERTY) {
273  if (Length < sizeof(EXT2_VOLUME_PROPERTY)) {
275  _SEH2_LEAVE;
276  }
277  } else if (Property->Command == APP_CMD_SET_PROPERTY2) {
278  if (Length < sizeof(EXT2_VOLUME_PROPERTY2)) {
280  _SEH2_LEAVE;
281  }
282  } else if (Property->Command == APP_CMD_SET_PROPERTY3) {
283  if (Length < sizeof(EXT2_VOLUME_PROPERTY3)) {
285  _SEH2_LEAVE;
286  }
287  } else {
289  _SEH2_LEAVE;
290  }
291 
293  GlobalDataResourceAcquired = TRUE;
294 
295 
296  switch (Property->Command) {
297 
299 
300  if (Property3->Flags2 & EXT2_VPROP3_AUTOMOUNT) {
301  if (Property3->AutoMount)
303  else
305  }
306 
308 
310  if ((Ext2Global->bHidingPrefix = Property2->bHidingPrefix)) {
312  Property2->sHidingPrefix,
313  HIDINGPAT_LEN - 1);
314  }
316  if ((Ext2Global->bHidingSuffix = Property2->bHidingSuffix)) {
318  Property2->sHidingSuffix,
319  HIDINGPAT_LEN - 1);
320  }
321 
323 
324  if (Property->bReadonly) {
327  } else {
329  if (Property->bExt3Writable) {
331  } else {
333  }
334  }
335 
336  PageTable = load_nls(Property->Codepage);
337  if (PageTable) {
338  memcpy(Ext2Global->Codepage.AnsiName, Property->Codepage, CODEPAGE_MAXLEN);
339  Ext2Global->Codepage.PageTable = PageTable;
340  }
341 
342  break;
343 
344  default:
345  break;
346  }
347 
348  } _SEH2_FINALLY {
349 
350  if (GlobalDataResourceAcquired) {
352  }
353  } _SEH2_END;
354 
355  return Status;
356 }
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define HIDINGPAT_LEN
Definition: common.h:160
static PMEM_HOOK PageTable[TOTAL_PAGES]
Definition: memory.c:40
#define APP_CMD_SET_PROPERTY2
Definition: common.h:155
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
ERESOURCE Resource
Definition: ext2fs.h:510
LONG NTSTATUS
Definition: precomp.h:26
CHAR gDate[]
Definition: init.c:24
_SEH2_TRY
Definition: create.c:4250
CHAR gTime[]
Definition: init.c:23
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
CHAR sHidingPrefix[HIDINGPAT_LEN]
Definition: ext2fs.h:563
PEXT2_GLOBAL Ext2Global
Definition: init.c:16
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define ClearLongFlag(_F, _SF)
Definition: ext2fs.h:254
void * PVOID
Definition: retypes.h:9
#define CODEPAGE_MAXLEN
Definition: common.h:159
struct _EXT2_GLOBAL::@670 Codepage
BOOLEAN bHidingPrefix
Definition: ext2fs.h:562
#define EXT2_SUPPORT_WRITING
Definition: ext2fs.h:582
#define EXT2_AUTO_MOUNT
Definition: ext2fs.h:585
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define EXT3_FORCE_WRITING
Definition: ext2fs.h:583
Status
Definition: gdiplustypes.h:24
BOOLEAN bHidingSuffix
Definition: ext2fs.h:564
_SEH2_END
Definition: create.c:4424
#define SetLongFlag(_F, _SF)
Definition: ext2fs.h:253
_SEH2_FINALLY
Definition: create.c:4395
#define EXT2_VPROP3_AUTOMOUNT
Definition: common.h:199
#define APP_CMD_SET_PROPERTY
Definition: common.h:153
#define APP_CMD_QUERY_VERSION
Definition: common.h:150
#define APP_CMD_SET_PROPERTY3
Definition: common.h:157
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define _SEH2_LEAVE
Definition: filesup.c:20
CHAR sHidingSuffix[HIDINGPAT_LEN]
Definition: ext2fs.h:565
return STATUS_SUCCESS
Definition: btrfs.c:2938
struct nls_table * load_nls(char *)
Definition: nls_base.c:218
#define EXT2_FLAG_VP_SET_GLOBAL
Definition: common.h:148
CHAR gVersion[]
Definition: init.c:22
ULONG Flags
Definition: ext2fs.h:514
struct _EXT2_VOLUME_PROPERTY_VERSION * PEXT2_VOLUME_PROPERTY_VERSION

Referenced by Ext2ProcessUserProperty().

◆ Ext2ProcessUserProperty()

NTSTATUS Ext2ProcessUserProperty ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VOLUME_PROPERTY3  Property,
IN ULONG  Length 
)

Definition at line 567 of file devctl.c.

572 {
574  PEXT2_VCB Vcb = NULL;
576 
577  _SEH2_TRY {
578 
579  ASSERT(IrpContext != NULL);
580  ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
581  (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
582 
583  if (Property->Magic != EXT2_VOLUME_PROPERTY_MAGIC) {
585  _SEH2_LEAVE;
586  }
587 
588  DeviceObject = IrpContext->DeviceObject;
591  } else {
593  if (!((Vcb) && (Vcb->Identifier.Type == EXT2VCB) &&
594  (Vcb->Identifier.Size == sizeof(EXT2_VCB)))) {
596  _SEH2_LEAVE;
597  }
599  }
600 
601  if (NT_SUCCESS(Status)) {
602  IrpContext->Irp->IoStatus.Information = Length;
603  }
604 
605  } _SEH2_FINALLY {
606 
607  if (!IrpContext->ExceptionInProgress) {
608  Ext2CompleteIrpContext(IrpContext, Status);
609  }
610  } _SEH2_END;
611 
612  return Status;
613 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS Ext2ProcessVolumeProperty(IN PEXT2_VCB Vcb, IN PEXT2_VOLUME_PROPERTY3 Property3, IN ULONG Length)
Definition: devctl.c:360
_SEH2_TRY
Definition: create.c:4250
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define Vcb
Definition: cdprocs.h:1425
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
NTSTATUS Ext2CompleteIrpContext(IN PEXT2_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:32
#define EXT2_VOLUME_PROPERTY_MAGIC
Definition: common.h:146
NTSTATUS Ext2ProcessGlobalProperty(IN PDEVICE_OBJECT DeviceObject, IN PEXT2_VOLUME_PROPERTY3 Property3, IN ULONG Length)
Definition: devctl.c:232
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
_SEH2_END
Definition: create.c:4424
_SEH2_FINALLY
Definition: create.c:4395
#define IsExt2FsDevice(DO)
Definition: ext2fs.h:607
struct _EXT2_VCB * PEXT2_VCB
#define _SEH2_LEAVE
Definition: filesup.c:20
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by Ext2DeviceControl().

◆ Ext2ProcessVolumeProperty()

NTSTATUS Ext2ProcessVolumeProperty ( IN PEXT2_VCB  Vcb,
IN PEXT2_VOLUME_PROPERTY3  Property3,
IN ULONG  Length 
)

Definition at line 360 of file devctl.c.

365 {
366  struct nls_table * PageTable = NULL;
367  PEXT2_VOLUME_PROPERTY2 Property2 = (PVOID)Property3;
368  PEXT2_VOLUME_PROPERTY Property = (PVOID)Property3;
370  BOOLEAN VcbResourceAcquired = FALSE;
371 
372  _SEH2_TRY {
373 
374  ExAcquireResourceExclusiveLite(&Vcb->MainResource, TRUE);
375  VcbResourceAcquired = TRUE;
376 
377  if (Property->Command == APP_CMD_SET_PROPERTY ||
378  Property->Command == APP_CMD_QUERY_PROPERTY) {
379  if (Length < sizeof(EXT2_VOLUME_PROPERTY)) {
381  _SEH2_LEAVE;
382  }
383  } else if (Property->Command == APP_CMD_SET_PROPERTY2 ||
384  Property->Command == APP_CMD_QUERY_PROPERTY2) {
385  if (Length < sizeof(EXT2_VOLUME_PROPERTY2)) {
387  _SEH2_LEAVE;
388  }
389  } else if (Property->Command == APP_CMD_SET_PROPERTY3 ||
390  Property->Command == APP_CMD_QUERY_PROPERTY3) {
391  if (Length < sizeof(EXT2_VOLUME_PROPERTY3)) {
393  _SEH2_LEAVE;
394  }
395  }
396 
397  switch (Property->Command) {
398 
400 
401  if (Property3->Flags2 & EXT2_VPROP3_AUTOMOUNT) {
402  if (Property3->AutoMount)
404  else
406  }
407  if (Property3->Flags2 & EXT2_VPROP3_USERIDS) {
408  SetFlag(Vcb->Flags, VCB_USER_IDS);
409  Vcb->uid = Property3->uid;
410  Vcb->gid = Property3->gid;
411  if (Property3->EIDS) {
412  Vcb->euid = Property3->euid;
413  Vcb->egid = Property3->egid;
414  SetFlag(Vcb->Flags, VCB_USER_EIDS);
415  } else {
416  Vcb->euid = Vcb->egid = 0;
417  ClearFlag(Vcb->Flags, VCB_USER_EIDS);
418  }
419  } else {
420  ClearFlag(Vcb->Flags, VCB_USER_IDS);
421  ClearFlag(Vcb->Flags, VCB_USER_EIDS);
422  Vcb->uid = Vcb->gid = 0;
423  Vcb->euid = Vcb->egid = 0;
424  }
425 
427 
428  RtlZeroMemory(Vcb->sHidingPrefix, HIDINGPAT_LEN);
429  if (Vcb->bHidingPrefix == Property2->bHidingPrefix) {
430  RtlCopyMemory( Vcb->sHidingPrefix,
431  Property2->sHidingPrefix,
432  HIDINGPAT_LEN - 1);
433  }
434 
435  RtlZeroMemory(Vcb->sHidingSuffix, HIDINGPAT_LEN);
436  if (Vcb->bHidingSuffix == Property2->bHidingSuffix) {
437  RtlCopyMemory( Vcb->sHidingSuffix,
438  Property2->sHidingSuffix,
439  HIDINGPAT_LEN - 1);
440  }
441  Vcb->DrvLetter = Property2->DrvLetter;
442 
444 
445  if (Property->bReadonly) {
446  if (IsFlagOn(Vcb->Flags, VCB_INITIALIZED)) {
449  }
450  SetLongFlag(Vcb->Flags, VCB_READ_ONLY);
451 
452  } else {
453 
454  if (Property->bExt3Writable) {
456  }
457 
458  if (!Vcb->IsExt3fs) {
460  } else if (!Property->bExt3Writable) {
461  SetLongFlag(Vcb->Flags, VCB_READ_ONLY);
462  } else if (IsFlagOn(Vcb->Flags, VCB_JOURNAL_RECOVER)) {
465  if (IsFlagOn(Vcb->Flags, VCB_JOURNAL_RECOVER)) {
466  SetLongFlag(Vcb->Flags, VCB_READ_ONLY);
467  } else {
469  }
470  } else {
472  }
473  }
474 
475  PageTable = load_nls(Property->Codepage);
476  memcpy(Vcb->Codepage.AnsiName, Property->Codepage, CODEPAGE_MAXLEN);
477  Vcb->Codepage.PageTable = PageTable;
478  if (Vcb->Codepage.PageTable) {
479  Ext2InitializeLabel(Vcb, Vcb->SuperBlock);
480  }
481 
482  break;
483 
485 
487  SetFlag(Property3->Flags2, EXT2_VPROP3_AUTOMOUNT);
488  Property3->AutoMount = TRUE;
489  } else {
490  ClearFlag(Property3->Flags2, EXT2_VPROP3_AUTOMOUNT);
491  Property3->AutoMount = FALSE;
492  }
493 
494  if (IsFlagOn(Vcb->Flags, VCB_USER_IDS)) {
495  SetFlag(Property3->Flags2, EXT2_VPROP3_USERIDS);
496  Property3->uid = Vcb->uid;
497  Property3->gid = Vcb->gid;
498  if (IsFlagOn(Vcb->Flags, VCB_USER_EIDS)) {
499  Property3->EIDS = TRUE;
500  Property3->euid = Vcb->euid;
501  Property3->egid = Vcb->egid;
502  } else {
503  Property3->EIDS = FALSE;
504  }
505  } else {
506  ClearFlag(Property3->Flags2, EXT2_VPROP3_USERIDS);
507  }
508 
510 
511  RtlCopyMemory(Property2->UUID, Vcb->SuperBlock->s_uuid, 16);
512  Property2->DrvLetter = Vcb->DrvLetter;
513 
514  if (Property2->bHidingPrefix == Vcb->bHidingPrefix) {
515  RtlCopyMemory( Property2->sHidingPrefix,
516  Vcb->sHidingPrefix,
517  HIDINGPAT_LEN);
518  } else {
519  RtlZeroMemory( Property2->sHidingPrefix,
520  HIDINGPAT_LEN);
521  }
522 
523  if (Property2->bHidingSuffix == Vcb->bHidingSuffix) {
524  RtlCopyMemory( Property2->sHidingSuffix,
525  Vcb->sHidingSuffix,
526  HIDINGPAT_LEN);
527  } else {
528  RtlZeroMemory( Property2->sHidingSuffix,
529  HIDINGPAT_LEN);
530  }
531 
533 
534  Property->bExt2 = TRUE;
535  Property->bExt3 = Vcb->IsExt3fs;
536  Property->bReadonly = IsFlagOn(Vcb->Flags, VCB_READ_ONLY);
537  if (!Property->bReadonly && Vcb->IsExt3fs) {
538  Property->bExt3Writable = TRUE;
539  } else {
540  Property->bExt3Writable = FALSE;
541  }
542 
544  if (Vcb->Codepage.PageTable) {
545  strncpy(Property->Codepage, Vcb->Codepage.PageTable->charset, CODEPAGE_MAXLEN);
546  } else {
547  strncpy(Property->Codepage, "default", CODEPAGE_MAXLEN);
548  }
549  break;
550 
551  default:
553  break;
554  }
555 
556  } _SEH2_FINALLY {
557 
558  if (VcbResourceAcquired) {
559  ExReleaseResourceLite(&Vcb->MainResource);
560  }
561  } _SEH2_END;
562 
563  return Status;
564 }
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define HIDINGPAT_LEN
Definition: common.h:160
static PMEM_HOOK PageTable[TOTAL_PAGES]
Definition: memory.c:40
#define APP_CMD_SET_PROPERTY2
Definition: common.h:155
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
#define VCB_JOURNAL_RECOVER
Definition: ext2fs.h:792
LONG NTSTATUS
Definition: precomp.h:26
#define APP_CMD_QUERY_PROPERTY3
Definition: common.h:156
NTSTATUS Ext2FlushVolume(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN BOOLEAN bShutDown)
Definition: flush.c:39
#define VCB_USER_IDS
Definition: ext2fs.h:785
_SEH2_TRY
Definition: create.c:4250
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
BOOLEAN bHidingSuffix
Definition: common.h:193
PEXT2_GLOBAL Ext2Global
Definition: init.c:16
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
CHAR sHidingPrefix[HIDINGPAT_LEN]
Definition: common.h:194
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define ClearLongFlag(_F, _SF)
Definition: ext2fs.h:254
void * PVOID
Definition: retypes.h:9
CHAR sHidingSuffix[HIDINGPAT_LEN]
Definition: common.h:195
#define CODEPAGE_MAXLEN
Definition: common.h:159
#define Vcb
Definition: cdprocs.h:1425
#define EXT2_VPROP3_USERIDS
Definition: common.h:200
#define APP_CMD_QUERY_PROPERTY2
Definition: common.h:154
#define EXT2_AUTO_MOUNT
Definition: ext2fs.h:585
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
NTSTATUS Ext2InitializeLabel(IN PEXT2_VCB Vcb, IN PEXT2_SUPER_BLOCK Sb)
Definition: memory.c:2241
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
#define VCB_FORCE_WRITING
Definition: ext2fs.h:790
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define VCB_USER_EIDS
Definition: ext2fs.h:786
#define VCB_READ_ONLY
Definition: ext2fs.h:795
ClearFlag(Dirent->Flags, DIRENT_FLAG_NOT_PERSISTENT)
Status
Definition: gdiplustypes.h:24
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
_SEH2_END
Definition: create.c:4424
BOOLEAN bHidingPrefix
Definition: common.h:192
NTSTATUS Ext2FlushFiles(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN BOOLEAN bShutDown)
Definition: flush.c:108
#define SetLongFlag(_F, _SF)
Definition: ext2fs.h:253
_SEH2_FINALLY
Definition: create.c:4395
#define EXT2_VPROP3_AUTOMOUNT
Definition: common.h:199
#define APP_CMD_SET_PROPERTY
Definition: common.h:153
#define APP_CMD_SET_PROPERTY3
Definition: common.h:157
INT Ext2RecoverJournal(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb)
Definition: recover.c:95
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define APP_CMD_QUERY_PROPERTY
Definition: common.h:152
#define VCB_INITIALIZED
Definition: ext2fs.h:779
#define _SEH2_LEAVE
Definition: filesup.c:20
return STATUS_SUCCESS
Definition: btrfs.c:2938
struct nls_table * load_nls(char *)
Definition: nls_base.c:218
ULONG Flags
Definition: ext2fs.h:514

Referenced by Ext2PerformRegistryVolumeParams(), and Ext2ProcessUserProperty().

Variable Documentation

◆ Ext2Global

PEXT2_GLOBAL Ext2Global

◆ gDate

CHAR gDate[]

Definition at line 24 of file init.c.

Referenced by Ext2ProcessGlobalProperty().

◆ gTime

CHAR gTime[]

Definition at line 23 of file init.c.

Referenced by Ext2ProcessGlobalProperty().

◆ gVersion

CHAR gVersion[]

Definition at line 22 of file init.c.

Referenced by Ext2ProcessGlobalProperty(), kbd_c(), kbd_h(), and kbd_rc().