ReactOS  0.4.13-dev-551-gf37fb1f
dirctl.c File Reference
#include "ntifs.h"
#include "ffsdrv.h"
Include dependency graph for dirctl.c:

Go to the source code of this file.

Functions

ULONG FFSGetInfoLength (IN FILE_INFORMATION_CLASS FileInformationClass)
 
ULONG FFSProcessDirEntry (IN PFFS_VCB Vcb, IN FILE_INFORMATION_CLASS FileInformationClass, IN ULONG in, IN PVOID Buffer, IN ULONG UsedLength, IN ULONG Length, IN ULONG FileIndex, IN PUNICODE_STRING pName, IN BOOLEAN Single)
 
__drv_mustHoldCriticalRegion NTSTATUS FFSQueryDirectory (IN PFFS_IRP_CONTEXT IrpContext)
 
__drv_mustHoldCriticalRegion NTSTATUS FFSNotifyChangeDirectory (IN PFFS_IRP_CONTEXT IrpContext)
 
VOID FFSNotifyReportChange (IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN PFFS_FCB Fcb, IN ULONG Filter, IN ULONG Action)
 
__drv_mustHoldCriticalRegion NTSTATUS FFSDirectoryControl (IN PFFS_IRP_CONTEXT IrpContext)
 
BOOLEAN FFSIsDirectoryEmpty (PFFS_VCB Vcb, PFFS_FCB Dcb)
 

Variables

PFFS_GLOBAL FFSGlobal
 

Function Documentation

◆ FFSDirectoryControl()

__drv_mustHoldCriticalRegion NTSTATUS FFSDirectoryControl ( IN PFFS_IRP_CONTEXT  IrpContext)

Definition at line 1243 of file dirctl.c.

1245 {
1246  NTSTATUS Status;
1247 
1248  PAGED_CODE();
1249 
1250  ASSERT(IrpContext);
1251 
1252  ASSERT((IrpContext->Identifier.Type == FFSICX) &&
1253  (IrpContext->Identifier.Size == sizeof(FFS_IRP_CONTEXT)));
1254 
1255  switch (IrpContext->MinorFunction)
1256  {
1258  Status = FFSQueryDirectory(IrpContext);
1259  break;
1260 
1262  Status = FFSNotifyChangeDirectory(IrpContext);
1263  break;
1264 
1265  default:
1267  FFSCompleteIrpContext(IrpContext, Status);
1268  }
1269 
1270  return Status;
1271 }
#define IRP_MN_NOTIFY_CHANGE_DIRECTORY
Definition: rdpdr.c:56
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define IRP_MN_QUERY_DIRECTORY
Definition: rdpdr.c:55
Definition: ffsdrv.h:283
#define PAGED_CODE()
Definition: video.h:57
__drv_mustHoldCriticalRegion NTSTATUS FFSNotifyChangeDirectory(IN PFFS_IRP_CONTEXT IrpContext)
Definition: dirctl.c:999
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
__drv_mustHoldCriticalRegion NTSTATUS FFSCompleteIrpContext(IN PFFS_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:53
Status
Definition: gdiplustypes.h:24
__drv_mustHoldCriticalRegion NTSTATUS FFSQueryDirectory(IN PFFS_IRP_CONTEXT IrpContext)
Definition: dirctl.c:323

Referenced by FFSDispatchRequest().

◆ FFSGetInfoLength()

ULONG FFSGetInfoLength ( IN FILE_INFORMATION_CLASS  FileInformationClass)

Definition at line 34 of file dirctl.c.

36 {
37  PAGED_CODE();
38 
39  switch (FileInformationClass)
40  {
42  return sizeof(FILE_DIRECTORY_INFORMATION);
43  break;
44 
46  return sizeof(FILE_FULL_DIR_INFORMATION);
47  break;
48 
50  return sizeof(FILE_BOTH_DIR_INFORMATION);
51  break;
52 
54  return sizeof(FILE_NAMES_INFORMATION);
55  break;
56 
57  default:
58  break;
59  }
60 
61  return 0;
62 }
struct _FILE_FULL_DIRECTORY_INFORMATION FILE_FULL_DIR_INFORMATION
static OUT PIO_STATUS_BLOCK OUT PVOID IN ULONG IN FILE_INFORMATION_CLASS FileInformationClass
Definition: pipe.c:75
#define PAGED_CODE()
Definition: video.h:57
struct _FILE_BOTH_DIR_INFORMATION FILE_BOTH_DIR_INFORMATION
struct _FILE_NAMES_INFORMATION FILE_NAMES_INFORMATION
struct _FILE_DIRECTORY_INFORMATION FILE_DIRECTORY_INFORMATION

Referenced by FFSProcessDirEntry().

◆ FFSIsDirectoryEmpty()

BOOLEAN FFSIsDirectoryEmpty ( PFFS_VCB  Vcb,
PFFS_FCB  Dcb 
)

Definition at line 1275 of file dirctl.c.

1278 {
1280 
1281  PFFS_DIR_ENTRY pTarget = NULL;
1282 
1283  ULONG dwBytes = 0;
1284  ULONG dwRet;
1285 
1286  BOOLEAN bRet = TRUE;
1287 
1288  PAGED_CODE();
1289 
1290  if (!IsFlagOn(Dcb->FFSMcb->FileAttr, FILE_ATTRIBUTE_DIRECTORY))
1291  return TRUE;
1292 
1293  _SEH2_TRY
1294  {
1297  if (!pTarget)
1298  {
1300  _SEH2_LEAVE;
1301  }
1302 
1303  dwBytes = 0;
1304 
1305 
1306  while ((LONGLONG)dwBytes < Dcb->Header.AllocationSize.QuadPart)
1307  {
1309 
1310  if (FS_VERSION == 1)
1311  {
1313  NULL,
1314  Vcb,
1315  Dcb->dinode1,
1316  dwBytes,
1317  (PVOID)pTarget,
1319  &dwRet);
1320  }
1321  else
1322  {
1324  NULL,
1325  Vcb,
1326  Dcb->dinode2,
1327  dwBytes,
1328  (PVOID)pTarget,
1330  &dwRet);
1331  }
1332 
1333  if (!NT_SUCCESS(Status))
1334  {
1335  FFSPrint((DBG_ERROR, "FFSRemoveEntry: Reading Directory Content error.\n"));
1336  _SEH2_LEAVE;
1337  }
1338 
1339  if (pTarget->d_ino)
1340  {
1341  if (pTarget->d_namlen == 1 && pTarget->d_name[0] == '.')
1342  {
1343  }
1344  else if (pTarget->d_namlen == 2 && pTarget->d_name[0] == '.' &&
1345  pTarget->d_name[1] == '.')
1346  {
1347  }
1348  else
1349  {
1350  bRet = FALSE;
1351  break;
1352  }
1353  }
1354  else
1355  {
1356  break;
1357  }
1358 
1359  dwBytes += pTarget->d_reclen;
1360  }
1361  }
1362 
1364  {
1365  if (pTarget != NULL)
1366  {
1367  ExFreePool(pTarget);
1368  }
1369  } _SEH2_END;
1370 
1371  return bRet;
1372 }
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
Definition: dir.h:83
#define FS_VERSION
Definition: ffsdrv.h:81
NTSTATUS FFSv1ReadInode(IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN PFFSv1_INODE dinode1, IN ULONGLONG offset, IN PVOID Buffer, IN ULONG size, OUT PULONG dwRet)
Definition: read.c:496
#define FFS_NAME_LEN
Definition: ffsdrv.h:202
LONG NTSTATUS
Definition: precomp.h:26
#define FFS_DIR_REC_LEN(name_len)
Definition: ffsdrv.h:214
#define PAGED_CODE()
Definition: video.h:57
_SEH2_TRY
Definition: create.c:4250
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
u_int32_t d_ino
Definition: dir.h:84
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
char d_name[MAXNAMLEN+1]
Definition: dir.h:88
int64_t LONGLONG
Definition: typedefs.h:66
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define Vcb
Definition: cdprocs.h:1425
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#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
u_int16_t d_reclen
Definition: dir.h:85
Status
Definition: gdiplustypes.h:24
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
_SEH2_END
Definition: create.c:4424
_SEH2_FINALLY
Definition: create.c:4395
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
NTSTATUS FFSv2ReadInode(IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN PFFSv2_INODE dinode2, IN ULONGLONG offset, IN PVOID Buffer, IN ULONG size, OUT PULONG dwRet)
Definition: read.c:585
#define _SEH2_LEAVE
Definition: filesup.c:20
struct direct * PFFS_DIR_ENTRY
Definition: ffsdrv.h:265
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB * Dcb
Definition: create.c:4157
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
u_int8_t d_namlen
Definition: dir.h:87

Referenced by FFSDeleteFile(), and FFSSetDispositionInfo().

◆ FFSNotifyChangeDirectory()

__drv_mustHoldCriticalRegion NTSTATUS FFSNotifyChangeDirectory ( IN PFFS_IRP_CONTEXT  IrpContext)

Definition at line 999 of file dirctl.c.

1001 {
1005  PFFS_VCB Vcb;
1007  PFFS_FCB Fcb = 0;
1008  PIRP Irp;
1012 
1013  BOOLEAN bFcbAcquired = FALSE;
1014 
1016 
1017  PAGED_CODE();
1018 
1019  _SEH2_TRY
1020  {
1021  ASSERT(IrpContext);
1022 
1023  ASSERT((IrpContext->Identifier.Type == FFSICX) &&
1024  (IrpContext->Identifier.Size == sizeof(FFS_IRP_CONTEXT)));
1025 
1026  //
1027  // Always set the wait flag in the Irp context for the original request.
1028  //
1029 
1030  SetFlag(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT);
1031 
1032  DeviceObject = IrpContext->DeviceObject;
1033 
1035  {
1038  _SEH2_LEAVE;
1039  }
1040 
1042 
1043  ASSERT(Vcb != NULL);
1044 
1045  ASSERT((Vcb->Identifier.Type == FFSVCB) &&
1046  (Vcb->Identifier.Size == sizeof(FFS_VCB)));
1047 
1048  ASSERT(IsMounted(Vcb));
1049 
1050  FileObject = IrpContext->FileObject;
1051 
1052  Fcb = (PFFS_FCB)FileObject->FsContext;
1053 
1054  ASSERT(Fcb);
1055 
1056  if (Fcb->Identifier.Type == FFSVCB)
1057  {
1058  FFSBreakPoint();
1061  _SEH2_LEAVE;
1062  }
1063 
1064  ASSERT((Fcb->Identifier.Type == FFSFCB) &&
1065  (Fcb->Identifier.Size == sizeof(FFS_FCB)));
1066 
1067  if (!IsDirectory(Fcb))
1068  {
1069  FFSBreakPoint();
1072  _SEH2_LEAVE;
1073  }
1074 
1076  &Fcb->MainResource,
1077  TRUE))
1078  {
1079  bFcbAcquired = TRUE;
1080  }
1081  else
1082  {
1084  _SEH2_LEAVE;
1085  }
1086 
1087  Irp = IrpContext->Irp;
1088 
1090 
1091 #if !defined(_GNU_NTIFS_) || defined(__REACTOS__)
1092 
1094  IrpSp->Parameters.NotifyDirectory.CompletionFilter;
1095 
1096 #else // _GNU_NTIFS_
1097 
1099  IrpSp)->Parameters.NotifyDirectory.CompletionFilter;
1100 
1101 #endif // _GNU_NTIFS_
1102 
1104 
1106  {
1108  _SEH2_LEAVE;
1109  }
1110 
1111  FullName = &Fcb->LongName;
1112 
1113  if (FullName->Buffer == NULL)
1114  {
1115  if (!FFSGetFullFileName(Fcb->FFSMcb, FullName))
1116  {
1118  _SEH2_LEAVE;
1119  }
1120  }
1121 
1122  FsRtlNotifyFullChangeDirectory(Vcb->NotifySync,
1123  &Vcb->NotifyList,
1124  FileObject->FsContext2,
1125  (PSTRING)FullName,
1126  WatchTree,
1127  FALSE,
1129  Irp,
1130  NULL,
1131  NULL);
1132 
1134 
1136 
1137  /*
1138  Currently the driver is read-only but here is an example on how to use the
1139  FsRtl-functions to report a change:
1140 
1141  ANSI_STRING TestString;
1142  USHORT FileNamePartLength;
1143 
1144  RtlInitAnsiString(&TestString, "\\ntifs.h");
1145 
1146  FileNamePartLength = 7;
1147 
1148  FsRtlNotifyReportChange(
1149  Vcb->NotifySync, // PNOTIFY_SYNC NotifySync
1150  &Vcb->NotifyList, // PLIST_ENTRY NotifyList
1151  &TestString, // PSTRING FullTargetName
1152  &FileNamePartLength, // PUSHORT FileNamePartLength
1153  FILE_NOTIFY_CHANGE_NAME // ULONG FilterMatch
1154  );
1155 
1156  or
1157 
1158  ANSI_STRING TestString;
1159 
1160  RtlInitAnsiString(&TestString, "\\ntifs.h");
1161 
1162  FsRtlNotifyFullReportChange(
1163  Vcb->NotifySync, // PNOTIFY_SYNC NotifySync
1164  &Vcb->NotifyList, // PLIST_ENTRY NotifyList
1165  &TestString, // PSTRING FullTargetName
1166  1, // USHORT TargetNameOffset
1167  NULL, // PSTRING StreamName OPTIONAL
1168  NULL, // PSTRING NormalizedParentName OPTIONAL
1169  FILE_NOTIFY_CHANGE_NAME, // ULONG FilterMatch
1170  0, // ULONG Action
1171  NULL // PVOID TargetContext
1172  );
1173  */
1174 
1175  }
1177  {
1178  if (bFcbAcquired)
1179  {
1181  &Fcb->MainResource,
1183  }
1184 
1185  if (!IrpContext->ExceptionInProgress)
1186  {
1187  if (!CompleteRequest)
1188  {
1189  IrpContext->Irp = NULL;
1190  }
1191 
1192  FFSCompleteIrpContext(IrpContext, Status);
1193  }
1194  } _SEH2_END;
1195 
1196  return Status;
1197 }
PFFS_GLOBAL FFSGlobal
Definition: init.c:22
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
Definition: ffsdrv.h:281
#define STATUS_DELETE_PENDING
Definition: ntstatus.h:308
#define IsMounted(Vcb)
Definition: ext2fs.h:803
#define TRUE
Definition: types.h:120
#define IRP_CONTEXT_FLAG_WAIT
Definition: cdstruc.h:1221
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
VOID NTAPI FsRtlNotifyFullChangeDirectory(IN PNOTIFY_SYNC NotifySync, IN PLIST_ENTRY NotifyList, IN PVOID FsContext, IN PSTRING FullDirectoryName, IN BOOLEAN WatchTree, IN BOOLEAN IgnoreBuffer, IN ULONG CompletionFilter, IN PIRP NotifyIrp, IN PCHECK_FOR_TRAVERSE_ACCESS TraverseCallback OPTIONAL, IN PSECURITY_SUBJECT_CONTEXT SubjectContext OPTIONAL)
Definition: notify.c:1458
_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
_Inout_ PLIST_ENTRY _In_ PVOID _In_ PSTRING _In_ BOOLEAN WatchTree
Definition: fltkernel.h:2239
Definition: ffsdrv.h:283
struct _FFS_FCB * PFFS_FCB
#define FCB_DELETE_PENDING
Definition: ext2fs.h:879
PDEVICE_OBJECT DeviceObject
Definition: ffsdrv.h:371
#define PAGED_CODE()
Definition: video.h:57
_SEH2_TRY
Definition: create.c:4250
#define FFSBreakPoint()
Definition: ffsdrv.h:43
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
NTFSIDENTIFIER Identifier
Definition: ntfs.h:499
void * Buffer
Definition: sprintf.c:453
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
struct _FFS_VCB * PFFS_VCB
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define STATUS_PENDING
Definition: ntstatus.h:82
#define Vcb
Definition: cdprocs.h:1425
_In_ PSTRING FullName
Definition: rtlfuncs.h:1649
* PFILE_OBJECT
Definition: iotypes.h:1954
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
ULONG Flags
Definition: ntfs.h:520
__drv_mustHoldCriticalRegion NTSTATUS FFSCompleteIrpContext(IN PFFS_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:53
_Must_inspect_result_ _In_ PFLT_INSTANCE _Out_ PBOOLEAN IsDirectory
Definition: fltkernel.h:1139
ULONG Type
Definition: ntfs.h:95
#define SL_WATCH_TREE
Definition: iotypes.h:1795
Definition: ffsdrv.h:280
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
ERESOURCE MainResource
Definition: ntfs.h:512
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
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
_SEH2_END
Definition: create.c:4424
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
_SEH2_FINALLY
Definition: create.c:4395
_Inout_ PLIST_ENTRY _In_ PVOID _In_ PSTRING _In_ BOOLEAN _In_ BOOLEAN _In_ ULONG CompletionFilter
Definition: fltkernel.h:2239
unsigned int ULONG
Definition: retypes.h:1
VOID NTAPI ExReleaseResourceForThreadLite(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread)
Definition: resource.c:1844
IO_STACK_LOCATION * PEXTENDED_IO_STACK_LOCATION
Definition: ext2fs.h:174
#define _SEH2_LEAVE
Definition: filesup.c:20
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
_In_ PFCB Fcb
Definition: cdprocs.h:151
union _FCB::@692 LongName
ULONG Size
Definition: ntfs.h:96
BOOLEAN FFSGetFullFileName(PFFS_MCB Mcb, PUNICODE_STRING FileName)
Definition: memory.c:1134

Referenced by FFSDirectoryControl().

◆ FFSNotifyReportChange()

VOID FFSNotifyReportChange ( IN PFFS_IRP_CONTEXT  IrpContext,
IN PFFS_VCB  Vcb,
IN PFFS_FCB  Fcb,
IN ULONG  Filter,
IN ULONG  Action 
)

Definition at line 1201 of file dirctl.c.

1207 {
1209  USHORT Offset;
1210 
1211  FullName = &Fcb->LongName;
1212 
1213  // ASSERT(KeGetCurrentIrql() < DISPATCH_LEVEL);
1214 
1215  if (FullName->Buffer == NULL)
1216  {
1217  if (!FFSGetFullFileName(Fcb->FFSMcb, FullName))
1218  {
1219  /*Status = STATUS_INSUFFICIENT_RESOURCES;*/
1220  return;
1221  }
1222  }
1223 
1224  Offset = (USHORT)(FullName->Length -
1225  Fcb->FFSMcb->ShortName.Length);
1226 
1227  FsRtlNotifyFullReportChange(Vcb->NotifySync,
1228  &(Vcb->NotifyList),
1229  (PSTRING)(FullName),
1230  (USHORT)Offset,
1231  (PSTRING)NULL,
1232  (PSTRING)NULL,
1233  (ULONG)Filter,
1234  (ULONG)Action,
1235  (PVOID)NULL);
1236 
1237  // ASSERT(KeGetCurrentIrql() < DISPATCH_LEVEL);
1238 }
unsigned short Length
Definition: sprintf.c:451
VOID NTAPI FsRtlNotifyFullReportChange(IN PNOTIFY_SYNC NotifySync, IN PLIST_ENTRY NotifyList, IN PSTRING FullTargetName, IN USHORT TargetNameOffset, IN PSTRING StreamName OPTIONAL, IN PSTRING NormalizedParentName OPTIONAL, IN ULONG FilterMatch, IN ULONG Action, IN PVOID TargetContext)
Definition: notify.c:1523
void * Buffer
Definition: sprintf.c:453
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1802
smooth NULL
Definition: ftsmooth.c:416
_In_ PLIST_ENTRY _In_ PSTRING _In_ USHORT _In_opt_ PSTRING _In_opt_ PSTRING _In_ ULONG _In_ ULONG Action
Definition: fsrtlfuncs.h:738
#define Vcb
Definition: cdprocs.h:1425
_In_ PSTRING FullName
Definition: rtlfuncs.h:1649
unsigned short USHORT
Definition: pedump.c:61
unsigned int ULONG
Definition: retypes.h:1
_In_ PFCB Fcb
Definition: cdprocs.h:151
union _FCB::@692 LongName
FILE_NAME_NODE ShortName
Definition: fatstruc.h:1111
BOOLEAN FFSGetFullFileName(PFFS_MCB Mcb, PUNICODE_STRING FileName)
Definition: memory.c:1134

Referenced by FFSCleanup(), FFSCreateFile(), FFSSetInformation(), FFSSetRenameInfo(), and FFSWriteFile().

◆ FFSProcessDirEntry()

ULONG FFSProcessDirEntry ( IN PFFS_VCB  Vcb,
IN FILE_INFORMATION_CLASS  FileInformationClass,
IN ULONG  in,
IN PVOID  Buffer,
IN ULONG  UsedLength,
IN ULONG  Length,
IN ULONG  FileIndex,
IN PUNICODE_STRING  pName,
IN BOOLEAN  Single 
)

Definition at line 66 of file dirctl.c.

76 {
77  FFSv1_INODE dinode1;
78  FFSv2_INODE dinode2;
83 
84  ULONG InfoLength = 0;
85  ULONG NameLength = 0;
86  ULONG dwBytes = 0;
87 
88  PAGED_CODE();
89 
90  NameLength = pName->Length;
91 
92  if (!in)
93  {
94  FFSPrint((DBG_ERROR, "FFSPricessDirEntry: ffs_dir_entry is empty.\n"));
95  return 0;
96  }
97 
99 
100  if (!InfoLength || InfoLength + NameLength - sizeof(WCHAR) > Length)
101  {
102  FFSPrint((DBG_INFO, "FFSPricessDirEntry: Buffer is not enough.\n"));
103  return 0;
104  }
105 
106  if (FS_VERSION == 1)
107  {
108  if(!FFSv1LoadInode(Vcb, in, &dinode1))
109  {
110  FFSPrint((DBG_ERROR, "FFSPricessDirEntry: Loading inode %xh error.\n", in));
111 
112  FFSBreakPoint();
113 
114  return 0;
115  }
116  }
117  else
118  {
119  if(!FFSv2LoadInode(Vcb, in, &dinode2))
120  {
121  FFSPrint((DBG_ERROR, "FFSPricessDirEntry: Loading inode %xh error.\n", in));
122 
123  FFSBreakPoint();
124 
125  return 0;
126  }
127  }
128 
129  switch(FileInformationClass)
130  {
132  FDI = (PFILE_DIRECTORY_INFORMATION) ((PUCHAR)Buffer + UsedLength);
133  if (!Single)
134  FDI->NextEntryOffset = InfoLength + NameLength - sizeof(WCHAR);
135  else
136  FDI->NextEntryOffset = 0;
137  FDI->FileIndex = FileIndex;
138 
139  if (FS_VERSION == 1)
140  {
141  FDI->CreationTime = FFSSysTime(dinode1.di_ctime);
142  FDI->LastAccessTime = FFSSysTime(dinode1.di_atime);
143  FDI->LastWriteTime = FFSSysTime(dinode1.di_mtime);
144  FDI->ChangeTime = FFSSysTime(dinode1.di_mtime);
145  FDI->EndOfFile.QuadPart = dinode1.di_size;
146  FDI->AllocationSize.QuadPart = dinode1.di_size;
148 
149  if (FlagOn(Vcb->Flags, VCB_READ_ONLY) || FFSIsReadOnly(dinode1.di_mode))
150  {
152  }
153 
154  if ((dinode1.di_mode & IFMT) == IFDIR)
156 
157  FDI->FileNameLength = NameLength;
158  RtlCopyMemory(FDI->FileName, pName->Buffer, NameLength);
159  dwBytes = InfoLength + NameLength - sizeof(WCHAR);
160  break;
161  }
162  else
163  {
164  FDI->CreationTime = FFSSysTime((ULONG)dinode2.di_ctime);
165  FDI->LastAccessTime = FFSSysTime((ULONG)dinode2.di_atime);
166  FDI->LastWriteTime = FFSSysTime((ULONG)dinode2.di_mtime);
167  FDI->ChangeTime = FFSSysTime((ULONG)dinode2.di_mtime);
168  FDI->EndOfFile.QuadPart = dinode2.di_size;
169  FDI->AllocationSize.QuadPart = dinode2.di_size;
171 
172  if (FlagOn(Vcb->Flags, VCB_READ_ONLY) || FFSIsReadOnly(dinode2.di_mode))
173  {
175  }
176 
177  if ((dinode2.di_mode & IFMT) == IFDIR)
179 
180  FDI->FileNameLength = NameLength;
181  RtlCopyMemory(FDI->FileName, pName->Buffer, NameLength);
182  dwBytes = InfoLength + NameLength - sizeof(WCHAR);
183  break;
184  }
185 
187  FFI = (PFILE_FULL_DIR_INFORMATION) ((PUCHAR)Buffer + UsedLength);
188  if (!Single)
189  FFI->NextEntryOffset = InfoLength + NameLength - sizeof(WCHAR);
190  else
191  FFI->NextEntryOffset = 0;
192  FFI->FileIndex = FileIndex;
193 
194  if (FS_VERSION == 1)
195  {
196  FFI->CreationTime = FFSSysTime(dinode1.di_ctime);
197  FFI->LastAccessTime = FFSSysTime(dinode1.di_atime);
198  FFI->LastWriteTime = FFSSysTime(dinode1.di_mtime);
199  FFI->ChangeTime = FFSSysTime(dinode1.di_mtime);
200  FFI->EndOfFile.QuadPart = dinode1.di_size;
201  FFI->AllocationSize.QuadPart = dinode1.di_size;
203 
204  if (IsFlagOn(Vcb->Flags, VCB_READ_ONLY) || FFSIsReadOnly(dinode1.di_mode))
205  {
207  }
208 
209  if ((dinode1.di_mode & IFMT) == IFDIR)
211 
212  FFI->FileNameLength = NameLength;
213  RtlCopyMemory(FFI->FileName, pName->Buffer, NameLength);
214  dwBytes = InfoLength + NameLength - sizeof(WCHAR);
215 
216  break;
217  }
218  else
219  {
220  FFI->CreationTime = FFSSysTime((ULONG)dinode2.di_ctime);
221  FFI->LastAccessTime = FFSSysTime((ULONG)dinode2.di_atime);
222  FFI->LastWriteTime = FFSSysTime((ULONG)dinode2.di_mtime);
223  FFI->ChangeTime = FFSSysTime((ULONG)dinode2.di_mtime);
224  FFI->EndOfFile.QuadPart = dinode2.di_size;
225  FFI->AllocationSize.QuadPart = dinode2.di_size;
227 
228  if (IsFlagOn(Vcb->Flags, VCB_READ_ONLY) || FFSIsReadOnly(dinode2.di_mode))
229  {
231  }
232 
233  if ((dinode2.di_mode & IFMT) == IFDIR)
235 
236  FFI->FileNameLength = NameLength;
237  RtlCopyMemory(FFI->FileName, pName->Buffer, NameLength);
238  dwBytes = InfoLength + NameLength - sizeof(WCHAR);
239 
240  break;
241  }
242 
244  FBI = (PFILE_BOTH_DIR_INFORMATION) ((PUCHAR)Buffer + UsedLength);
245  if (!Single)
246  FBI->NextEntryOffset = InfoLength + NameLength - sizeof(WCHAR);
247  else
248  FBI->NextEntryOffset = 0;
249 
250  if (FS_VERSION == 1)
251  {
252  FBI->CreationTime = FFSSysTime(dinode1.di_ctime);
253  FBI->LastAccessTime = FFSSysTime(dinode1.di_atime);
254  FBI->LastWriteTime = FFSSysTime(dinode1.di_mtime);
255  FBI->ChangeTime = FFSSysTime(dinode1.di_mtime);
256 
257  FBI->FileIndex = FileIndex;
258  FBI->EndOfFile.QuadPart = dinode1.di_size;
259  FBI->AllocationSize.QuadPart = dinode1.di_size;
261 
262  if (FlagOn(Vcb->Flags, VCB_READ_ONLY) || FFSIsReadOnly(dinode1.di_mode))
263  {
265  }
266 
267  if ((dinode1.di_mode & IFMT) == IFDIR)
269  FBI->FileNameLength = NameLength;
270  RtlCopyMemory(FBI->FileName, pName->Buffer, NameLength);
271  dwBytes = InfoLength + NameLength - sizeof(WCHAR);
272 
273  break;
274  }
275  else
276  {
277  FBI->CreationTime = FFSSysTime((ULONG)dinode2.di_ctime);
278  FBI->LastAccessTime = FFSSysTime((ULONG)dinode2.di_atime);
279  FBI->LastWriteTime = FFSSysTime((ULONG)dinode2.di_mtime);
280  FBI->ChangeTime = FFSSysTime((ULONG)dinode2.di_mtime);
281 
282  FBI->FileIndex = FileIndex;
283  FBI->EndOfFile.QuadPart = dinode2.di_size;
284  FBI->AllocationSize.QuadPart = dinode2.di_size;
286 
287  if (FlagOn(Vcb->Flags, VCB_READ_ONLY) || FFSIsReadOnly(dinode2.di_mode))
288  {
290  }
291 
292  if ((dinode2.di_mode & IFMT) == IFDIR)
294  FBI->FileNameLength = NameLength;
295  RtlCopyMemory(FBI->FileName, pName->Buffer, NameLength);
296  dwBytes = InfoLength + NameLength - sizeof(WCHAR);
297 
298  break;
299  }
300 
302  FNI = (PFILE_NAMES_INFORMATION) ((PUCHAR)Buffer + UsedLength);
303  if (!Single)
304  FNI->NextEntryOffset = InfoLength + NameLength - sizeof(WCHAR);
305  else
306  FNI->NextEntryOffset = 0;
307  FNI->FileNameLength = NameLength;
308  RtlCopyMemory(FNI->FileName, pName->Buffer, NameLength);
309  dwBytes = InfoLength + NameLength - sizeof(WCHAR);
310 
311  break;
312 
313  default:
314  break;
315  }
316 
317  return dwBytes;
318 }
LARGE_INTEGER LastAccessTime
Definition: winternl.h:517
int32_t di_mtime
Definition: dinode.h:90
u_int16_t di_mode
Definition: dinode.h:81
struct _FILE_BOTH_DIR_INFORMATION * PFILE_BOTH_DIR_INFORMATION
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define FFSIsReadOnly(m)
Definition: ffsdrv.h:254
Definition: halp.h:205
#define FS_VERSION
Definition: ffsdrv.h:81
unsigned char * PUCHAR
Definition: retypes.h:3
BOOLEAN FFSv2LoadInode(IN PFFS_VCB Vcb, IN ULONG inode, IN PFFSv2_INODE dinode2)
Definition: ffs.c:336
int32_t di_atime
Definition: dinode.h:88
struct _FILE_DIRECTORY_INFORMATION * PFILE_DIRECTORY_INFORMATION
static OUT PIO_STATUS_BLOCK OUT PVOID IN ULONG IN FILE_INFORMATION_CLASS FileInformationClass
Definition: pipe.c:75
struct _FILE_FULL_DIRECTORY_INFORMATION * PFILE_FULL_DIR_INFORMATION
#define PAGED_CODE()
Definition: video.h:57
#define FFSBreakPoint()
Definition: ffsdrv.h:43
LARGE_INTEGER ChangeTime
Definition: winternl.h:519
LARGE_INTEGER LastWriteTime
Definition: from_kernel.h:143
LARGE_INTEGER EndOfFile
Definition: winternl.h:520
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
LARGE_INTEGER AllocationSize
Definition: from_kernel.h:146
LARGE_INTEGER FFSSysTime(IN ULONG i_time)
Definition: misc.c:53
struct _FILE_NAMES_INFORMATION * PFILE_NAMES_INFORMATION
Definition: bufpool.h:45
BOOLEAN FFSv1LoadInode(IN PFFS_VCB Vcb, IN ULONG inode, IN PFFSv1_INODE dinode1)
Definition: ffs.c:302
ULONG FFSGetInfoLength(IN FILE_INFORMATION_CLASS FileInformationClass)
Definition: dirctl.c:34
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
u_int64_t di_size
Definition: dinode.h:110
static LPSTR pName
Definition: security.c:75
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define IFDIR
Definition: dinode.h:166
#define Vcb
Definition: cdprocs.h:1425
LARGE_INTEGER LastWriteTime
Definition: winternl.h:518
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
int64_t di_mtime
Definition: dinode.h:113
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define DBG_ERROR
Definition: ffsdrv.h:1031
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
#define VCB_READ_ONLY
Definition: ext2fs.h:795
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
#define IFMT
Definition: dinode.h:163
int32_t di_ctime
Definition: dinode.h:92
GLuint in
Definition: glext.h:9616
LARGE_INTEGER CreationTime
Definition: winternl.h:516
int64_t di_ctime
Definition: dinode.h:114
LARGE_INTEGER CreationTime
Definition: from_kernel.h:141
u_int16_t di_mode
Definition: dinode.h:105
int64_t di_atime
Definition: dinode.h:112
unsigned int ULONG
Definition: retypes.h:1
#define DBG_INFO
Definition: ffsdrv.h:1034
LARGE_INTEGER LastAccessTime
Definition: from_kernel.h:142
u_int64_t di_size
Definition: dinode.h:87
WCHAR FileName[ANYSIZE_ARRAY]
Definition: winternl.h:524
LARGE_INTEGER AllocationSize
Definition: winternl.h:521
LONGLONG QuadPart
Definition: typedefs.h:112
WCHAR FileName[ANYSIZE_ARRAY]
Definition: winternl.h:539

Referenced by FFSQueryDirectory().

◆ FFSQueryDirectory()

__drv_mustHoldCriticalRegion NTSTATUS FFSQueryDirectory ( IN PFFS_IRP_CONTEXT  IrpContext)

Definition at line 323 of file dirctl.c.

325 {
328  PFFS_VCB Vcb = 0;
330  PFFS_FCB Fcb = 0;
331  PFFS_CCB Ccb;
332  PIRP Irp;
333  PIO_STACK_LOCATION IoStackLocation;
335  ULONG Length;
337  ULONG FileIndex;
340  BOOLEAN IndexSpecified;
341  PUCHAR Buffer;
342  BOOLEAN FirstQuery;
343  PFFSv1_INODE dinode1 = NULL;
344  PFFSv2_INODE dinode2 = NULL;
345  BOOLEAN FcbResourceAcquired = FALSE;
346  ULONG UsedLength = 0;
347  USHORT InodeFileNameLength;
348  UNICODE_STRING InodeFileName;
349  PFFS_DIR_ENTRY pDir = NULL;
350  ULONG dwBytes;
351  ULONG dwTemp = 0;
352  ULONG dwSize = 0;
353  ULONG dwReturn = 0;
354  BOOLEAN bRun = TRUE;
356 
357  PAGED_CODE();
358 
359  InodeFileName.Buffer = NULL;
360 
361  _SEH2_TRY
362  {
363  ASSERT(IrpContext);
364 
365  ASSERT((IrpContext->Identifier.Type == FFSICX) &&
366  (IrpContext->Identifier.Size == sizeof(FFS_IRP_CONTEXT)));
367 
368  DeviceObject = IrpContext->DeviceObject;
369 
370  //
371  // This request is not allowed on the main device object
372  //
374  {
376  _SEH2_LEAVE;
377  }
378 
380 
381  ASSERT(Vcb != NULL);
382 
383  ASSERT((Vcb->Identifier.Type == FFSVCB) &&
384  (Vcb->Identifier.Size == sizeof(FFS_VCB)));
385 
386  ASSERT(IsMounted(Vcb));
387 
388  FileObject = IrpContext->FileObject;
389 
390  Fcb = (PFFS_FCB)FileObject->FsContext;
391 
392  ASSERT(Fcb);
393 
394  //
395  // This request is not allowed on volumes
396  //
397  if (Fcb->Identifier.Type == FFSVCB)
398  {
400  _SEH2_LEAVE;
401  }
402 
403  ASSERT((Fcb->Identifier.Type == FFSFCB) &&
404  (Fcb->Identifier.Size == sizeof(FFS_FCB)));
405 
406  if (!IsDirectory(Fcb))
407  {
409  _SEH2_LEAVE;
410  }
411 
412  Ccb = (PFFS_CCB)FileObject->FsContext2;
413 
414  ASSERT(Ccb);
415 
416  ASSERT((Ccb->Identifier.Type == FFSCCB) &&
417  (Ccb->Identifier.Size == sizeof(FFS_CCB)));
418 
419  Irp = IrpContext->Irp;
420 
421  IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
422 
423 #if !defined(_GNU_NTIFS_) || defined(__REACTOS__)
424 
426  IoStackLocation->Parameters.QueryDirectory.FileInformationClass;
427 
428  Length = IoStackLocation->Parameters.QueryDirectory.Length;
429 
430  FileName = IoStackLocation->Parameters.QueryDirectory.FileName;
431 
432  FileIndex = IoStackLocation->Parameters.QueryDirectory.FileIndex;
433 
434 #else // _GNU_NTIFS_
435 
437  IoStackLocation)->Parameters.QueryDirectory.FileInformationClass;
438 
440  IoStackLocation)->Parameters.QueryDirectory.Length;
441 
443  IoStackLocation)->Parameters.QueryDirectory.FileName;
444 
445  FileIndex = ((PEXTENDED_IO_STACK_LOCATION)
446  IoStackLocation)->Parameters.QueryDirectory.FileIndex;
447 
448 #endif // _GNU_NTIFS_
449 
450  RestartScan = FlagOn(IoStackLocation->Flags, SL_RESTART_SCAN);
452  IndexSpecified = FlagOn(IoStackLocation->Flags, SL_INDEX_SPECIFIED);
453  /*
454  if (!Irp->MdlAddress && Irp->UserBuffer)
455  {
456  ProbeForWrite(Irp->UserBuffer, Length, 1);
457  }
458  */
460 
461  if (Buffer == NULL)
462  {
463  FFSBreakPoint();
465  _SEH2_LEAVE;
466  }
467 
468  if (!IrpContext->IsSynchronous)
469  {
471  _SEH2_LEAVE;
472  }
473 
475  &Fcb->MainResource,
476  IrpContext->IsSynchronous))
477  {
479  _SEH2_LEAVE;
480  }
481 
482  FcbResourceAcquired = TRUE;
483 
484  if (FileName != NULL)
485  {
486  if (Ccb->DirectorySearchPattern.Buffer != NULL)
487  {
488  FirstQuery = FALSE;
489  }
490  else
491  {
492  FirstQuery = TRUE;
493 
494  Ccb->DirectorySearchPattern.Length =
495  Ccb->DirectorySearchPattern.MaximumLength =
496  FileName->Length;
497 
498  Ccb->DirectorySearchPattern.Buffer =
500 
501  if (Ccb->DirectorySearchPattern.Buffer == NULL)
502  {
504  _SEH2_LEAVE;
505  }
506 
508  &(Ccb->DirectorySearchPattern),
509  FileName,
510  FALSE);
511 
512  if (!NT_SUCCESS(Status))
513  _SEH2_LEAVE;
514  }
515  }
516  else if (Ccb->DirectorySearchPattern.Buffer != NULL)
517  {
518  FirstQuery = FALSE;
519  FileName = &Ccb->DirectorySearchPattern;
520  }
521  else
522  {
523  FirstQuery = TRUE;
524 
525  Ccb->DirectorySearchPattern.Length =
526  Ccb->DirectorySearchPattern.MaximumLength = 2;
527 
528  Ccb->DirectorySearchPattern.Buffer =
530 
531  if (Ccb->DirectorySearchPattern.Buffer == NULL)
532  {
534  _SEH2_LEAVE;
535  }
536 
538  Ccb->DirectorySearchPattern.Buffer,
539  L"*\0", 2);
540  }
541 
542  if (!IndexSpecified)
543  {
544  if (RestartScan || FirstQuery)
545  {
546  FileIndex = Fcb->FFSMcb->DeOffset = 0;
547  }
548  else
549  {
550  FileIndex = Ccb->CurrentByteOffset;
551  }
552  }
553 
554  if (FS_VERSION == 1)
555  {
557  PagedPool,
559 
560  if (dinode1 == NULL)
561  {
563  _SEH2_LEAVE;
564  }
565 
567 
568  if (Fcb->dinode1->di_size <= FileIndex)
569  {
571  _SEH2_LEAVE;
572  }
573  }
574  else
575  {
577  PagedPool,
579 
580  if (dinode2 == NULL)
581  {
583  _SEH2_LEAVE;
584  }
585 
587 
588  if (Fcb->dinode2->di_size <= FileIndex)
589  {
591  _SEH2_LEAVE;
592  }
593  }
594 
596  sizeof(FFS_DIR_ENTRY), FFS_POOL_TAG);
597  if (!pDir)
598  {
600  _SEH2_LEAVE;
601  }
602 
603 
604  if (FS_VERSION == 1)
605  {
606  dwBytes = 0;
607  dwSize = (ULONG)Fcb->dinode1->di_size - FileIndex -
608  (sizeof(FFS_DIR_ENTRY) - FFS_NAME_LEN + 1);
609 
610  ByteOffset = FileIndex;
611 
612  dwTemp = 0;
613 
614  while (bRun && UsedLength < Length && dwBytes < dwSize)
615  {
617 
618  RtlZeroMemory(pDir, sizeof(FFS_DIR_ENTRY));
619 
621  NULL,
622  Vcb,
623  Fcb->dinode1,
624  ByteOffset,
625  (PVOID)pDir,
626  sizeof(FFS_DIR_ENTRY),
627  &dwReturn);
628 
629  if (!NT_SUCCESS(Status))
630  {
631  _SEH2_LEAVE;
632  }
633 
634  if (!pDir->d_ino)
635  {
636  if (pDir->d_reclen == 0)
637  {
638  FFSBreakPoint();
639  _SEH2_LEAVE;
640  }
641 
642  goto ProcessNextEntryv1;
643  }
644 
645  OemName.Buffer = pDir->d_name;
646  OemName.Length = (pDir->d_namlen & 0xff);
647  OemName.MaximumLength = OemName.Length;
648 
649 #if 0
650 /*
651  //
652  // We could not filter the files: "." and ".."
653  //
654 
655  if ((OemName.Length >) 1 && OemName.Buffer[0] == '.')
656  {
657  if ( OemName.Length == 2 && OemName.Buffer[1] == '.')
658  {
659  }
660  else
661  {
662  goto ProcessNextEntry1;
663  }
664  }
665 */
666 #endif
667 
668  InodeFileNameLength = (USHORT)
670 
671  InodeFileName.Length = 0;
672  InodeFileName.MaximumLength = InodeFileNameLength + 2;
673 
674  if (InodeFileNameLength <= 0)
675  {
676  break;
677  }
678 
679  InodeFileName.Buffer = ExAllocatePoolWithTag(
680  PagedPool,
681  InodeFileNameLength + 2, FFS_POOL_TAG);
682 
683  if (!InodeFileName.Buffer)
684  {
686  _SEH2_LEAVE;
687  }
688 
690  InodeFileName.Buffer,
691  InodeFileNameLength + 2);
692 
693  Status = FFSOEMToUnicode(&InodeFileName,
694  &OemName);
695 
696  if (!NT_SUCCESS(Status))
697  {
698  _SEH2_LEAVE;
699  }
700 
702  &(Ccb->DirectorySearchPattern)) ?
704  &(Ccb->DirectorySearchPattern),
705  &InodeFileName,
706  TRUE,
707  NULL) :
709  &(Ccb->DirectorySearchPattern),
710  &InodeFileName,
711  TRUE))
712  {
713  dwReturn = FFSProcessDirEntry(
715  pDir->d_ino,
716  Buffer,
717  UsedLength,
718  Length - UsedLength,
719  (FileIndex + dwBytes),
720  &InodeFileName,
722 
723  if (dwReturn <= 0)
724  {
725  bRun = FALSE;
726  }
727  else
728  {
729  dwTemp = UsedLength;
730  UsedLength += dwReturn;
731  }
732  }
733 
734  if (InodeFileName.Buffer != NULL)
735  {
736  ExFreePool(InodeFileName.Buffer);
737  InodeFileName.Buffer = NULL;
738  }
739 
740 ProcessNextEntryv1:
741 
742  if (bRun)
743  {
744  dwBytes +=pDir->d_reclen;
745  Ccb->CurrentByteOffset = FileIndex + dwBytes;
746  }
747 
748  if (UsedLength && ReturnSingleEntry)
749  {
751  _SEH2_LEAVE;
752  }
753 
754  ByteOffset = FileIndex + dwBytes;
755  }
756  }
757  else
758  {
759  dwBytes = 0;
760  dwSize = (ULONG)Fcb->dinode2->di_size - FileIndex -
761  (sizeof(FFS_DIR_ENTRY) - FFS_NAME_LEN + 1);
762 
763  ByteOffset = FileIndex;
764 
765  dwTemp = 0;
766 
767  while (bRun && UsedLength < Length && dwBytes < dwSize)
768  {
770 
771  RtlZeroMemory(pDir, sizeof(FFS_DIR_ENTRY));
772 
774  NULL,
775  Vcb,
776  Fcb->dinode2,
777  ByteOffset,
778  (PVOID)pDir,
779  sizeof(FFS_DIR_ENTRY),
780  &dwReturn);
781 
782  if (!NT_SUCCESS(Status))
783  {
784  _SEH2_LEAVE;
785  }
786 
787  if (!pDir->d_ino)
788  {
789  if (pDir->d_reclen == 0)
790  {
791  FFSBreakPoint();
792  _SEH2_LEAVE;
793  }
794 
795  goto ProcessNextEntryv2;
796  }
797 
798  OemName.Buffer = pDir->d_name;
799  OemName.Length = (pDir->d_namlen & 0xff);
800  OemName.MaximumLength = OemName.Length;
801 #if 0
802 /*
803  //
804  // We could not filter the files: "." and ".."
805  //
806 
807  if ((OemName.Length >) 1 && OemName.Buffer[0] == '.')
808  {
809  if ( OemName.Length == 2 && OemName.Buffer[1] == '.')
810  {
811  }
812  else
813  {
814  goto ProcessNextEntry2;
815  }
816  }
817 */
818 #endif
819 
820  InodeFileNameLength = (USHORT)
822 
823  InodeFileName.Length = 0;
824  InodeFileName.MaximumLength = InodeFileNameLength + 2;
825 
826  if (InodeFileNameLength <= 0)
827  {
828  break;
829  }
830 
831  InodeFileName.Buffer = ExAllocatePoolWithTag(
832  PagedPool,
833  InodeFileNameLength + 2, FFS_POOL_TAG);
834 
835  if (!InodeFileName.Buffer)
836  {
838  _SEH2_LEAVE;
839  }
840 
842  InodeFileName.Buffer,
843  InodeFileNameLength + 2);
844 
845  Status = FFSOEMToUnicode(&InodeFileName,
846  &OemName);
847 
848  if (!NT_SUCCESS(Status))
849  {
850  _SEH2_LEAVE;
851  }
852 
854  &(Ccb->DirectorySearchPattern)) ?
856  &(Ccb->DirectorySearchPattern),
857  &InodeFileName,
858  TRUE,
859  NULL) :
861  &(Ccb->DirectorySearchPattern),
862  &InodeFileName,
863  TRUE))
864  {
865  dwReturn = FFSProcessDirEntry(
867  pDir->d_ino,
868  Buffer,
869  UsedLength,
870  Length - UsedLength,
871  (FileIndex + dwBytes),
872  &InodeFileName,
874 
875  if (dwReturn <= 0)
876  {
877  bRun = FALSE;
878  }
879  else
880  {
881  dwTemp = UsedLength;
882  UsedLength += dwReturn;
883  }
884  }
885 
886  if (InodeFileName.Buffer != NULL)
887  {
888  ExFreePool(InodeFileName.Buffer);
889  InodeFileName.Buffer = NULL;
890  }
891 
892 ProcessNextEntryv2:
893 
894  if (bRun)
895  {
896  dwBytes +=pDir->d_reclen;
897  Ccb->CurrentByteOffset = FileIndex + dwBytes;
898  }
899 
900  if (UsedLength && ReturnSingleEntry)
901  {
903  _SEH2_LEAVE;
904  }
905 
906  ByteOffset = FileIndex + dwBytes;
907  }
908  }
909 
910  FileIndex += dwBytes;
911 
912  ((PULONG)((PUCHAR)Buffer + dwTemp)) [0] = 0;
913 
914  if (!UsedLength)
915  {
916  if (FirstQuery)
917  {
919  }
920  else
921  {
923  }
924  }
925  else
926  {
928  }
929  }
930 
932  {
933 
934  if (FcbResourceAcquired)
935  {
937  &Fcb->MainResource,
939  }
940 
941  if (FS_VERSION == 1)
942  {
943  if (dinode1 != NULL)
944  {
945  ExFreePool(dinode1);
946  }
947  }
948  else
949  {
950  if (dinode2 != NULL)
951  {
952  ExFreePool(dinode2);
953  }
954  }
955 
956  if (pDir != NULL)
957  {
958  ExFreePool(pDir);
959  pDir = NULL;
960  }
961 
962  if (InodeFileName.Buffer != NULL)
963  {
964  ExFreePool(InodeFileName.Buffer);
965  }
966 
967  if (!IrpContext->ExceptionInProgress)
968  {
969  if (Status == STATUS_PENDING)
970  {
972  IrpContext->Irp,
973  Length,
974  IoWriteAccess);
975 
976  if (NT_SUCCESS(Status))
977  {
978  Status = FFSQueueRequest(IrpContext);
979  }
980  else
981  {
982  FFSCompleteIrpContext(IrpContext, Status);
983  }
984  }
985  else
986  {
987  IrpContext->Irp->IoStatus.Information = UsedLength;
988  FFSCompleteIrpContext(IrpContext, Status);
989  }
990  }
991  } _SEH2_END;
992 
993  return Status;
994 }
PFFS_GLOBAL FFSGlobal
Definition: init.c:22
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
NTSTATUS FFSQueueRequest(IN PFFS_IRP_CONTEXT IrpContext)
Definition: dispatch.c:33
Definition: ffsdrv.h:281
#define IsMounted(Vcb)
Definition: ext2fs.h:803
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
NTSTATUS RtlUpcaseUnicodeString(PUNICODE_STRING dst, PUNICODE_STRING src, BOOLEAN Alloc)
Definition: string_lib.cpp:46
Definition: dir.h:83
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ BOOLEAN _In_ ULONG _In_opt_ PULONG _In_ BOOLEAN RestartScan
Definition: fltkernel.h:2298
#define FS_VERSION
Definition: ffsdrv.h:81
#define SL_INDEX_SPECIFIED
Definition: iotypes.h:1793
USHORT MaximumLength
Definition: env_spec_w32.h:370
NTSTATUS FFSv1ReadInode(IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN PFFSv1_INODE dinode1, IN ULONGLONG offset, IN PVOID Buffer, IN ULONG size, OUT PULONG dwRet)
Definition: read.c:496
#define FFS_NAME_LEN
Definition: ffsdrv.h:202
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
unsigned char * PUCHAR
Definition: retypes.h:3
ULONG FFSProcessDirEntry(IN PFFS_VCB Vcb, IN FILE_INFORMATION_CLASS FileInformationClass, IN ULONG in, IN PVOID Buffer, IN ULONG UsedLength, IN ULONG Length, IN ULONG FileIndex, IN PUNICODE_STRING pName, IN BOOLEAN Single)
Definition: dirctl.c:66
struct ufs1_dinode * PFFSv1_INODE
Definition: ffsdrv.h:262
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ BOOLEAN ReturnSingleEntry
Definition: fltkernel.h:2295
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
Definition: ffsdrv.h:283
NTSTATUS FFSLockUserBuffer(IN PIRP Irp, IN ULONG Length, IN LOCK_OPERATION Operation)
Definition: block.c:70
static OUT PIO_STATUS_BLOCK OUT PVOID IN ULONG IN FILE_INFORMATION_CLASS FileInformationClass
Definition: pipe.c:75
STRING OEM_STRING
Definition: umtypes.h:203
struct _FFS_FCB * PFFS_FCB
BOOLEAN NTAPI FsRtlDoesNameContainWildCards(IN PUNICODE_STRING Name)
Definition: name.c:464
BOOLEAN NTAPI FsRtlIsNameInExpression(IN PUNICODE_STRING Expression, IN PUNICODE_STRING Name, IN BOOLEAN IgnoreCase, IN PWCHAR UpcaseTable OPTIONAL)
Definition: name.c:514
PDEVICE_OBJECT DeviceObject
Definition: ffsdrv.h:371
struct ufs2_dinode * PFFSv2_INODE
Definition: ffsdrv.h:263
#define PAGED_CODE()
Definition: video.h:57
_SEH2_TRY
Definition: create.c:4250
#define FFSBreakPoint()
Definition: ffsdrv.h:43
NTFSIDENTIFIER Identifier
Definition: ntfs.h:499
#define STATUS_INVALID_USER_BUFFER
Definition: udferr_usr.h:166
PVOID FFSGetUserBuffer(IN PIRP Irp)
Definition: block.c:115
Definition: ffsdrv.h:282
u_int32_t d_ino
Definition: dir.h:84
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
struct _FFS_VCB * PFFS_VCB
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
char d_name[MAXNAMLEN+1]
Definition: dir.h:88
enum _FILE_INFORMATION_CLASS FILE_INFORMATION_CLASS
Definition: directory.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define STATUS_NO_MORE_FILES
Definition: udferr_usr.h:128
#define Vcb
Definition: cdprocs.h:1425
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
* PFILE_OBJECT
Definition: iotypes.h:1954
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
__drv_mustHoldCriticalRegion NTSTATUS FFSCompleteIrpContext(IN PFFS_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:53
static const WCHAR L[]
Definition: oid.c:1250
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
_Must_inspect_result_ _In_ PFLT_INSTANCE _Out_ PBOOLEAN IsDirectory
Definition: fltkernel.h:1139
ULONG Type
Definition: ntfs.h:95
Definition: ffsdrv.h:280
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:593
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
#define FFS_POOL_TAG
Definition: ffsdrv.h:817
u_int16_t d_reclen
Definition: dir.h:85
ERESOURCE MainResource
Definition: ntfs.h:512
Status
Definition: gdiplustypes.h:24
struct _FFS_CCB * PFFS_CCB
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
struct _FileName FileName
Definition: fatprocs.h:884
#define SL_RETURN_SINGLE_ENTRY
Definition: iotypes.h:1792
_SEH2_END
Definition: create.c:4424
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_NO_SUCH_FILE
Definition: udferr_usr.h:137
_SEH2_FINALLY
Definition: create.c:4395
unsigned int * PULONG
Definition: retypes.h:1
#define SL_RESTART_SCAN
Definition: iotypes.h:1791
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
NTSTATUS FFSOEMToUnicode(IN OUT PUNICODE_STRING Unicode, IN POEM_STRING Oem)
Definition: misc.c:80
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define DINODE2_SIZE
Definition: dinode.h:175
#define DINODE1_SIZE
Definition: dinode.h:174
VOID NTAPI ExReleaseResourceForThreadLite(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread)
Definition: resource.c:1844
NTSTATUS FFSv2ReadInode(IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN PFFSv2_INODE dinode2, IN ULONGLONG offset, IN PVOID Buffer, IN ULONG size, OUT PULONG dwRet)
Definition: read.c:585
IO_STACK_LOCATION * PEXTENDED_IO_STACK_LOCATION
Definition: ext2fs.h:174
#define _SEH2_LEAVE
Definition: filesup.c:20
IN PDCB IN POEM_STRING OemName
Definition: fatprocs.h:1294
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
_In_ PFCB Fcb
Definition: cdprocs.h:151
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2777
ULONG Size
Definition: ntfs.h:96
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
u_int8_t d_namlen
Definition: dir.h:87
IN PDCB IN PCCB IN VBO IN OUT PULONG OUT PDIRENT OUT PBCB OUT PVBO ByteOffset
Definition: fatprocs.h:716
NTSYSAPI UINT WINAPI RtlOemStringToUnicodeSize(const STRING *)

Referenced by FFSDirectoryControl().

Variable Documentation

◆ FFSGlobal

PFFS_GLOBAL FFSGlobal

Definition at line 22 of file init.c.

Referenced by FFSNotifyChangeDirectory(), and FFSQueryDirectory().