ReactOS  r74405
cdfs.h File Reference
#include <ntifs.h>
#include <ntddcdrm.h>
#include <pseh/pseh2.h>
#include <pshpack1.h>
#include <poppack.h>
Include dependency graph for cdfs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _DIR_RECORD
 
struct  _VD_HEADER
 
struct  _PVD
 
struct  _SVD
 
struct  _CDINFO
 
struct  DEVICE_EXTENSION
 
struct  _CDFS_SHORT_NAME
 
struct  _FCB
 
struct  _CCB
 
struct  _CDFS_GLOBAL_DATA
 
struct  _CDFS_IRP_CONTEXT
 

Macros

#define INIT_SECTION   /* Done via alloc_text for MSC */
 
#define CDFS_BASIC_SECTOR   2048
 
#define CDFS_PRIMARY_DESCRIPTOR_LOCATION   16
 
#define BLOCKSIZE   CDFS_BASIC_SECTOR
 
#define CDFS_MAX_NAME_LEN   256
 
#define BOOT_VOLUME_DESCRIPTOR_TYPE   0
 
#define PRIMARY_VOLUME_DESCRIPTOR_TYPE   1
 
#define SUPPLEMENTARY_VOLUME_DESCRIPTOR_TYPE   2
 
#define VOLUME_PARTITION_DESCRIPTOR_TYPE   3
 
#define VOLUME_DESCRIPTOR_SET_TERMINATOR   255
 
#define FILE_FLAG_HIDDEN   0x01
 
#define FILE_FLAG_DIRECTORY   0x02
 
#define FILE_FLAG_SYSTEM   0x04
 
#define FILE_FLAG_READONLY   0x10
 
#define FCB_CACHE_INITIALIZED   0x0001
 
#define FCB_IS_VOLUME_STREAM   0x0002
 
#define FCB_IS_VOLUME   0x0004
 
#define MAX_PATH   260
 
#define CDFS_TAG   'sfdC'
 
#define CDFS_CCB_TAG   'ccdC'
 
#define CDFS_NONPAGED_FCB_TAG   'nfdC'
 
#define CDFS_SHORT_NAME_TAG   'sgdC'
 
#define CDFS_SEARCH_PATTERN_TAG   'eedC'
 
#define CDFS_FILENAME_TAG   'nFdC'
 
#define IRPCONTEXT_CANWAIT   0x1
 
#define IRPCONTEXT_COMPLETE   0x2
 
#define IRPCONTEXT_QUEUE   0x4
 

Typedefs

typedef struct _DIR_RECORD DIR_RECORD
 
typedef struct _DIR_RECORDPDIR_RECORD
 
typedef struct _VD_HEADER VD_HEADER
 
typedef struct _VD_HEADERPVD_HEADER
 
typedef struct _PVD PVD
 
typedef struct _PVDPPVD
 
typedef struct _SVD SVD
 
typedef struct _SVDPSVD
 
typedef struct _CDINFO CDINFO
 
typedef struct _CDINFOPCDINFO
 
typedef struct DEVICE_EXTENSIONPDEVICE_EXTENSION
 
typedef struct DEVICE_EXTENSION VCB
 
typedef struct DEVICE_EXTENSIONPVCB
 
typedef struct _CDFS_SHORT_NAME CDFS_SHORT_NAME
 
typedef struct _CDFS_SHORT_NAMEPCDFS_SHORT_NAME
 
typedef struct _FCB FCB
 
typedef struct _FCBPFCB
 
typedef struct _CCB CCB
 
typedef struct _CCBPCCB
 
typedef struct _CDFS_GLOBAL_DATA CDFS_GLOBAL_DATA
 
typedef struct _CDFS_GLOBAL_DATAPCDFS_GLOBAL_DATA
 
typedef struct _CDFS_IRP_CONTEXT CDFS_IRP_CONTEXT
 
typedef struct _CDFS_IRP_CONTEXTPCDFS_IRP_CONTEXT
 

Functions

NTSTATUS NTAPI DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
 
NTSTATUS NTAPI CdfsCleanup (PCDFS_IRP_CONTEXT IrpContext)
 
NTSTATUS NTAPI CdfsClose (PCDFS_IRP_CONTEXT IrpContext)
 
NTSTATUS CdfsCloseFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject)
 
NTSTATUS CdfsReadSectors (IN PDEVICE_OBJECT DeviceObject, IN ULONG DiskSector, IN ULONG SectorCount, IN OUT PUCHAR Buffer, IN BOOLEAN Override)
 
NTSTATUS CdfsDeviceIoControl (IN PDEVICE_OBJECT DeviceObject, IN ULONG CtlCode, IN PVOID InputBuffer, IN ULONG InputBufferSize, IN OUT PVOID OutputBuffer, IN OUT PULONG pOutputBufferSize, IN BOOLEAN Override)
 
NTSTATUS NTAPI CdfsCreate (PCDFS_IRP_CONTEXT IrpContext)
 
NTSTATUS NTAPI CdfsDeviceControl (PCDFS_IRP_CONTEXT IrpContext)
 
NTSTATUS NTAPI CdfsDirectoryControl (PCDFS_IRP_CONTEXT IrpContext)
 
NTSTATUS NTAPI CdfsFsdDispatch (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
BOOLEAN NTAPI CdfsAcquireForLazyWrite (IN PVOID Context, IN BOOLEAN Wait)
 
VOID NTAPI CdfsReleaseFromLazyWrite (IN PVOID Context)
 
PFCB CdfsCreateFCB (PCWSTR FileName)
 
VOID CdfsDestroyFCB (PFCB Fcb)
 
BOOLEAN CdfsFCBIsDirectory (PFCB Fcb)
 
BOOLEAN CdfsFCBIsRoot (PFCB Fcb)
 
VOID CdfsGrabFCB (PDEVICE_EXTENSION Vcb, PFCB Fcb)
 
VOID CdfsReleaseFCB (PDEVICE_EXTENSION Vcb, PFCB Fcb)
 
VOID CdfsAddFCBToTable (PDEVICE_EXTENSION Vcb, PFCB Fcb)
 
PFCB CdfsGrabFCBFromTable (PDEVICE_EXTENSION Vcb, PUNICODE_STRING FileName)
 
NTSTATUS CdfsFCBInitializeCache (PVCB Vcb, PFCB Fcb)
 
PFCB CdfsMakeRootFCB (PDEVICE_EXTENSION Vcb)
 
PFCB CdfsOpenRootFCB (PDEVICE_EXTENSION Vcb)
 
NTSTATUS CdfsMakeFCBFromDirEntry (PVCB Vcb, PFCB DirectoryFCB, PWSTR LongName, PWSTR ShortName, PDIR_RECORD Record, ULONG DirectorySector, ULONG DirectoryOffset, PFCB *fileFCB)
 
NTSTATUS CdfsAttachFCBToFileObject (PDEVICE_EXTENSION Vcb, PFCB Fcb, PFILE_OBJECT FileObject)
 
NTSTATUS CdfsDirFindFile (PDEVICE_EXTENSION DeviceExt, PFCB DirectoryFcb, PUNICODE_STRING FileToFind, PFCB *FoundFCB)
 
NTSTATUS CdfsGetFCBForFile (PDEVICE_EXTENSION Vcb, PFCB *pParentFCB, PFCB *pFCB, PUNICODE_STRING FileName)
 
NTSTATUS NTAPI CdfsQueryInformation (PCDFS_IRP_CONTEXT IrpContext)
 
NTSTATUS NTAPI CdfsSetInformation (PCDFS_IRP_CONTEXT IrpContext)
 
NTSTATUS NTAPI CdfsFileSystemControl (PCDFS_IRP_CONTEXT IrpContext)
 
BOOLEAN CdfsIsIrpTopLevel (PIRP Irp)
 
PCDFS_IRP_CONTEXT CdfsAllocateIrpContext (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
VOID CdfsSwapString (PWCHAR Out, PUCHAR In, ULONG Count)
 
VOID CdfsDateTimeToSystemTime (PFCB Fcb, PLARGE_INTEGER SystemTime)
 
VOID CdfsFileFlagsToAttributes (PFCB Fcb, PULONG FileAttributes)
 
VOID CdfsShortNameCacheGet (PFCB DirectoryFcb, PLARGE_INTEGER StreamOffset, PUNICODE_STRING LongName, PUNICODE_STRING ShortName)
 
BOOLEAN CdfsIsRecordValid (IN PDEVICE_EXTENSION DeviceExt, IN PDIR_RECORD Record)
 
VOID CdfsGetDirEntryName (PDEVICE_EXTENSION DeviceExt, PDIR_RECORD Record, PWSTR Name)
 
NTSTATUS NTAPI CdfsRead (PCDFS_IRP_CONTEXT IrpContext)
 
NTSTATUS NTAPI CdfsWrite (PCDFS_IRP_CONTEXT IrpContext)
 
NTSTATUS NTAPI CdfsQueryVolumeInformation (PCDFS_IRP_CONTEXT IrpContext)
 
NTSTATUS NTAPI CdfsSetVolumeInformation (PCDFS_IRP_CONTEXT IrpContext)
 

Variables

PCDFS_GLOBAL_DATA CdfsGlobalData
 
DRIVER_DISPATCH CdfsFsdDispatch
 
FAST_IO_CHECK_IF_POSSIBLE CdfsFastIoCheckIfPossible
 
FAST_IO_READ CdfsFastIoRead
 
FAST_IO_WRITE CdfsFastIoWrite
 

Macro Definition Documentation

#define BLOCKSIZE   CDFS_BASIC_SECTOR

Definition at line 16 of file cdfs.h.

#define BOOT_VOLUME_DESCRIPTOR_TYPE   0

Definition at line 20 of file cdfs.h.

#define CDFS_BASIC_SECTOR   2048

Definition at line 14 of file cdfs.h.

Referenced by CdfsGetVolumeData().

#define CDFS_CCB_TAG   'ccdC'
#define CDFS_FILENAME_TAG   'nFdC'

Definition at line 246 of file cdfs.h.

Referenced by CdfsMakeAbsoluteFilename(), and CdfsOpenFile().

#define CDFS_MAX_NAME_LEN   256

Definition at line 17 of file cdfs.h.

#define CDFS_NONPAGED_FCB_TAG   'nfdC'

Definition at line 243 of file cdfs.h.

Referenced by CdfsCreateFCB(), CdfsDestroyFCB(), and CdfsMountVolume().

#define CDFS_PRIMARY_DESCRIPTOR_LOCATION   16

Definition at line 15 of file cdfs.h.

Referenced by CdfsGetVolumeData().

#define CDFS_SEARCH_PATTERN_TAG   'eedC'

Definition at line 245 of file cdfs.h.

Referenced by CdfsCloseFile(), and CdfsQueryDirectory().

#define CDFS_SHORT_NAME_TAG   'sgdC'

Definition at line 244 of file cdfs.h.

Referenced by CdfsDestroyFCB(), and CdfsShortNameCacheGet().

#define CDFS_TAG   'sfdC'

Definition at line 241 of file cdfs.h.

Referenced by CdfsGetVolumeData(), and CdfsReadFile().

#define FCB_IS_VOLUME_STREAM   0x0002

Definition at line 178 of file cdfs.h.

Referenced by CdfsMountVolume(), and NtfsMountVolume().

#define FILE_FLAG_DIRECTORY   0x02
#define FILE_FLAG_HIDDEN   0x01

Definition at line 54 of file cdfs.h.

Referenced by CdfsFileFlagsToAttributes().

#define FILE_FLAG_READONLY   0x10

Definition at line 57 of file cdfs.h.

Referenced by CdfsFileFlagsToAttributes().

#define FILE_FLAG_SYSTEM   0x04

Definition at line 56 of file cdfs.h.

Referenced by CdfsFileFlagsToAttributes().

#define INIT_SECTION   /* Done via alloc_text for MSC */

Definition at line 11 of file cdfs.h.

#define IRPCONTEXT_QUEUE   0x4
#define MAX_PATH   260

Definition at line 181 of file cdfs.h.

#define PRIMARY_VOLUME_DESCRIPTOR_TYPE   1

Definition at line 21 of file cdfs.h.

#define SUPPLEMENTARY_VOLUME_DESCRIPTOR_TYPE   2

Definition at line 22 of file cdfs.h.

#define VOLUME_DESCRIPTOR_SET_TERMINATOR   255

Definition at line 24 of file cdfs.h.

#define VOLUME_PARTITION_DESCRIPTOR_TYPE   3

Definition at line 23 of file cdfs.h.

Typedef Documentation

typedef struct _CCB CCB

Definition at line 51 of file cdfs.h.

typedef struct _FCB FCB
typedef struct _CCB * PCCB
typedef struct _CDINFO * PCDINFO

Definition at line 51 of file cdfs.h.

typedef struct _FCB * PFCB
typedef struct _PVD * PPVD

Definition at line 102 of file cdfs.h.

typedef struct _SVD * PSVD

Definition at line 135 of file cdfs.h.

typedef struct _PVD PVD

Definition at line 102 of file cdfs.h.

Definition at line 69 of file cdfs.h.

typedef struct _SVD SVD

Definition at line 135 of file cdfs.h.

Definition at line 69 of file cdfs.h.

Function Documentation

BOOLEAN NTAPI CdfsAcquireForLazyWrite ( IN PVOID  Context,
IN BOOLEAN  Wait 
)

Referenced by DriverEntry().

VOID CdfsAddFCBToTable ( PDEVICE_EXTENSION  Vcb,
PFCB  Fcb 
)

Definition at line 175 of file fcb.c.

Referenced by CdfsMakeFCBFromDirEntry(), and CdfsMakeRootFCB().

177 {
178  KIRQL oldIrql;
179 
180  KeAcquireSpinLock(&Vcb->FcbListLock, &oldIrql);
181  Fcb->DevExt = Vcb;
182  InsertTailList(&Vcb->FcbListHead, &Fcb->FcbListEntry);
183  KeReleaseSpinLock(&Vcb->FcbListLock, oldIrql);
184 }
LIST_ENTRY FcbListEntry
Definition: cdfs.h:208
#define InsertTailList(ListHead, Entry)
UCHAR KIRQL
Definition: env_spec_w32.h:591
PDEVICE_EXTENSION DevExt
Definition: cdfs.h:199
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define Vcb
PCDFS_IRP_CONTEXT CdfsAllocateIrpContext ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 69 of file misc.c.

Referenced by CdfsFsdDispatch().

72 {
73  PCDFS_IRP_CONTEXT IrpContext;
74 
75  DPRINT("CdfsAllocateIrpContext()\n");
76 
77  IrpContext = (PCDFS_IRP_CONTEXT)ExAllocateFromNPagedLookasideList(&CdfsGlobalData->IrpContextLookasideList);
78  if (IrpContext == NULL)
79  return NULL;
80 
81  RtlZeroMemory(IrpContext, sizeof(CDFS_IRP_CONTEXT));
82 
83 // IrpContext->Identifier.Type = NTFS_TYPE_IRP_CONTEST;
84 // IrpContext->Identifier.Size = sizeof(NTFS_IRP_CONTEXT);
85  IrpContext->Irp = Irp;
86  IrpContext->DeviceObject = DeviceObject;
87  IrpContext->Stack = IoGetCurrentIrpStackLocation(Irp);
88  IrpContext->MajorFunction = IrpContext->Stack->MajorFunction;
89  IrpContext->MinorFunction = IrpContext->Stack->MinorFunction;
90  IrpContext->FileObject = IrpContext->Stack->FileObject;
91  IrpContext->IsTopLevel = (IoGetTopLevelIrp() == Irp);
92  IrpContext->PriorityBoost = IO_NO_INCREMENT;
93  IrpContext->Flags = IRPCONTEXT_COMPLETE;
94 
95  if (IrpContext->MajorFunction == IRP_MJ_FILE_SYSTEM_CONTROL ||
96  IrpContext->MajorFunction == IRP_MJ_DEVICE_CONTROL ||
97  IrpContext->MajorFunction == IRP_MJ_SHUTDOWN ||
98  (IrpContext->MajorFunction != IRP_MJ_CLEANUP &&
99  IrpContext->MajorFunction != IRP_MJ_CLOSE &&
101  {
102  IrpContext->Flags |= IRPCONTEXT_CANWAIT;
103  }
104 
105  return IrpContext;
106 }
#define IRP_MJ_SHUTDOWN
_In_ PIRP Irp
Definition: csq.h:116
UCHAR MinorFunction
Definition: cdfs.h:268
BOOLEAN IsTopLevel
Definition: cdfs.h:271
_In_ PLARGE_INTEGER _In_ ULONG _In_ BOOLEAN _In_ ULONG _Out_ PVOID _Out_ PIO_STATUS_BLOCK _In_ PDEVICE_OBJECT DeviceObject
Definition: npfs.h:636
BOOLEAN NTAPI IoIsOperationSynchronous(IN PIRP Irp)
Definition: irp.c:1805
CCHAR PriorityBoost
Definition: cdfs.h:275
UCHAR MajorFunction
Definition: cdfs.h:267
smooth NULL
Definition: ftsmooth.c:464
void DPRINT(...)
Definition: polytest.cpp:61
#define IRPCONTEXT_CANWAIT
Definition: cdfs.h:258
#define IRP_MJ_FILE_SYSTEM_CONTROL
PIRP NTAPI IoGetTopLevelIrp(VOID)
Definition: irp.c:1766
#define IRPCONTEXT_COMPLETE
Definition: cdfs.h:259
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
ULONG Flags
Definition: cdfs.h:265
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2787
struct _CDFS_IRP_CONTEXT * PCDFS_IRP_CONTEXT
PDEVICE_OBJECT DeviceObject
Definition: cdfs.h:272
PCDFS_GLOBAL_DATA CdfsGlobalData
Definition: cdfs.c:41
NPAGED_LOOKASIDE_LIST IrpContextLookasideList
Definition: cdfs.h:255
#define IRP_MJ_CLEANUP
PIO_STACK_LOCATION Stack
Definition: cdfs.h:266
#define IO_NO_INCREMENT
Definition: iotypes.h:565
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
PFILE_OBJECT FileObject
Definition: cdfs.h:273
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
NTSTATUS CdfsAttachFCBToFileObject ( PDEVICE_EXTENSION  Vcb,
PFCB  Fcb,
PFILE_OBJECT  FileObject 
)

Definition at line 395 of file fcb.c.

Referenced by CdfsOpenFile().

398 {
399  PCCB newCCB;
400 
402  if (newCCB == NULL)
403  {
405  }
406  memset(newCCB, 0, sizeof(CCB));
407 
408  FileObject->ReadAccess = TRUE;
409  FileObject->WriteAccess = FALSE;
410  FileObject->DeleteAccess = FALSE;
411  FileObject->SectionObjectPointer = &Fcb->SectionObjectPointers;
412  FileObject->FsContext = Fcb;
413  FileObject->FsContext2 = newCCB;
414  newCCB->PtrFileObject = FileObject;
415  Fcb->DevExt = Vcb;
416 
417  if (CdfsFCBIsDirectory(Fcb))
418  {
419  _SEH2_TRY
420  {
423  FALSE,
425  Fcb);
426  }
428  {
429  FileObject->FsContext2 = NULL;
431  return _SEH2_GetExceptionCode();
432  }
433  _SEH2_END;
435  }
436 
437  DPRINT("file open: fcb:%p file size: %u\n", Fcb, Fcb->Entry.DataLengthL);
438 
439  return(STATUS_SUCCESS);
440 }
#define STATUS_SUCCESS
Definition: contextmenu.cpp:55
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define CDFS_CCB_TAG
Definition: cdfs.h:242
Definition: cdfs.h:227
#define TRUE
Definition: numbers.c:17
BOOLEAN CdfsFCBIsDirectory(PFCB Fcb)
Definition: fcb.c:122
CACHE_MANAGER_CALLBACKS CacheMgrCallbacks
Definition: cdfs.h:253
#define _SEH2_END
Definition: pseh2_64.h:7
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:464
_In_ PFILE_OBJECT FileObject
Definition: classpnp.h:1229
DIR_RECORD Entry
Definition: cdfs.h:219
void DPRINT(...)
Definition: polytest.cpp:61
#define FCB_CACHE_INITIALIZED
Definition: cdfs.h:177
FSRTL_COMMON_FCB_HEADER RFCB
Definition: cdfs.h:193
PFILE_OBJECT PtrFileObject
Definition: cdfs.h:230
PDEVICE_EXTENSION DevExt
Definition: cdfs.h:199
VOID NTAPI CcInitializeCacheMap(IN PFILE_OBJECT FileObject, IN PCC_FILE_SIZES FileSizes, IN BOOLEAN PinAccess, IN PCACHE_MANAGER_CALLBACKS Callbacks, IN PVOID LazyWriteContext)
Definition: fssup.c:193
ULONG Flags
Definition: cdfs.h:217
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
LARGE_INTEGER AllocationSize
Definition: env_spec_w32.h:755
PCDFS_GLOBAL_DATA CdfsGlobalData
Definition: cdfs.c:41
#define _SEH2_TRY
Definition: pseh2_64.h:5
#define Vcb
#define FALSE
Definition: numbers.c:16
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1097
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
ULONG DataLengthL
Definition: iso.h:29
#define memset(x, y, z)
Definition: compat.h:39
SECTION_OBJECT_POINTERS SectionObjectPointers
Definition: cdfs.h:194
NTSTATUS NTAPI CdfsCleanup ( PCDFS_IRP_CONTEXT  IrpContext)

Definition at line 82 of file cleanup.c.

Referenced by CdfsDispatch().

84 {
85  PIRP Irp;
87  PDEVICE_EXTENSION DeviceExtension;
88  PIO_STACK_LOCATION Stack;
91 
92  DPRINT("CdfsCleanup() called\n");
93 
94  ASSERT(IrpContext);
95 
96  Irp = IrpContext->Irp;
97  DeviceObject = IrpContext->DeviceObject;
98  Stack = IrpContext->Stack;
99 
100  if (DeviceObject == CdfsGlobalData->DeviceObject)
101  {
102  DPRINT("Closing file system\n");
103  Status = STATUS_SUCCESS;
104  goto ByeBye;
105  }
106 
107  FileObject = Stack->FileObject;
108  DeviceExtension = DeviceObject->DeviceExtension;
109 
111  ExAcquireResourceExclusiveLite(&DeviceExtension->DirResource, TRUE);
112 
113  Status = CdfsCleanupFile(IrpContext, FileObject);
114 
115  ExReleaseResourceLite(&DeviceExtension->DirResource);
117 
118 ByeBye:
119  Irp->IoStatus.Information = 0;
120 
121  return(Status);
122 }
#define STATUS_SUCCESS
Definition: contextmenu.cpp:55
_In_ PIRP Irp
Definition: csq.h:116
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
PDEVICE_OBJECT DeviceObject
Definition: cdfs.h:251
#define TRUE
Definition: numbers.c:17
_In_ PLARGE_INTEGER _In_ ULONG _In_ BOOLEAN _In_ ULONG _Out_ PVOID _Out_ PIO_STATUS_BLOCK _In_ PDEVICE_OBJECT DeviceObject
Definition: npfs.h:636
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
PVOID DeviceExtension
Definition: env_spec_w32.h:418
_In_ PFILE_OBJECT FileObject
Definition: classpnp.h:1229
void DPRINT(...)
Definition: polytest.cpp:61
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
* PFILE_OBJECT
Definition: iotypes.h:1949
static NTSTATUS CdfsCleanupFile(PCDFS_IRP_CONTEXT IrpContext, PFILE_OBJECT FileObject)
Definition: cleanup.c:38
#define KeEnterCriticalRegion()
Definition: ke_x.h:83
Status
Definition: gdiplustypes.h:24
PFILE_OBJECT FileObject
Definition: iotypes.h:2787
LONG NTSTATUS
Definition: DriverTester.h:11
#define KeLeaveCriticalRegion()
Definition: ke_x.h:114
PDEVICE_OBJECT DeviceObject
Definition: cdfs.h:272
PCDFS_GLOBAL_DATA CdfsGlobalData
Definition: cdfs.c:41
PIO_STACK_LOCATION Stack
Definition: cdfs.h:266
PVOID PIRP
Definition: usb.h:38
NTSTATUS NTAPI CdfsClose ( PCDFS_IRP_CONTEXT  IrpContext)

Definition at line 79 of file close.c.

Referenced by CdfsDispatch().

81 {
82  PIRP Irp;
84  PDEVICE_EXTENSION DeviceExtension;
85  PIO_STACK_LOCATION Stack;
88 
89  DPRINT("CdfsClose() called\n");
90 
91  ASSERT(IrpContext);
92 
93  Irp = IrpContext->Irp;
94  DeviceObject = IrpContext->DeviceObject;
95  Stack = IrpContext->Stack;
96 
97  if (DeviceObject == CdfsGlobalData->DeviceObject)
98  {
99  DPRINT("Closing file system\n");
100  Status = STATUS_SUCCESS;
101  goto ByeBye;
102  }
103 
104  FileObject = Stack->FileObject;
105  DeviceExtension = DeviceObject->DeviceExtension;
106 
107  Status = CdfsCloseFile(DeviceExtension,FileObject);
108 
109 ByeBye:
110  Irp->IoStatus.Information = 0;
111 
112  return(Status);
113 }
#define STATUS_SUCCESS
Definition: contextmenu.cpp:55
_In_ PIRP Irp
Definition: csq.h:116
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
PDEVICE_OBJECT DeviceObject
Definition: cdfs.h:251
_In_ PLARGE_INTEGER _In_ ULONG _In_ BOOLEAN _In_ ULONG _Out_ PVOID _Out_ PIO_STATUS_BLOCK _In_ PDEVICE_OBJECT DeviceObject
Definition: npfs.h:636
PVOID DeviceExtension
Definition: env_spec_w32.h:418
_In_ PFILE_OBJECT FileObject
Definition: classpnp.h:1229
void DPRINT(...)
Definition: polytest.cpp:61
NTSTATUS CdfsCloseFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject)
Definition: close.c:38
* PFILE_OBJECT
Definition: iotypes.h:1949
Status
Definition: gdiplustypes.h:24
PFILE_OBJECT FileObject
Definition: iotypes.h:2787
LONG NTSTATUS
Definition: DriverTester.h:11
PDEVICE_OBJECT DeviceObject
Definition: cdfs.h:272
PCDFS_GLOBAL_DATA CdfsGlobalData
Definition: cdfs.c:41
PIO_STACK_LOCATION Stack
Definition: cdfs.h:266
PVOID PIRP
Definition: usb.h:38
NTSTATUS CdfsCloseFile ( PDEVICE_EXTENSION  DeviceExt,
PFILE_OBJECT  FileObject 
)

Definition at line 38 of file close.c.

Referenced by CdfsClose(), and CdfsCreateFile().

43 {
44  PCCB Ccb;
45 
46  DPRINT("CdfsCloseFile(DeviceExt %p, FileObject %p)\n",
47  DeviceExt,
48  FileObject);
49 
50  Ccb = (PCCB)(FileObject->FsContext2);
51 
52  DPRINT("Ccb %p\n", Ccb);
53  if (Ccb == NULL)
54  {
55  return(STATUS_SUCCESS);
56  }
57 
58  FileObject->FsContext2 = NULL;
59 
60  if (FileObject->FileName.Buffer)
61  {
62  // This a FO, that was created outside from FSD.
63  // Some FO's are created with IoCreateStreamFileObject() insid from FSD.
64  // This FO's don't have a FileName.
65  CdfsReleaseFCB(DeviceExt, FileObject->FsContext);
66  }
67 
69  {
71  }
73 
74  return(STATUS_SUCCESS);
75 }
#define STATUS_SUCCESS
Definition: contextmenu.cpp:55
VOID CdfsReleaseFCB(PDEVICE_EXTENSION Vcb, PFCB Fcb)
Definition: fcb.c:153
#define CDFS_CCB_TAG
Definition: cdfs.h:242
Definition: cdfs.h:227
struct _CCB * PCCB
#define CDFS_SEARCH_PATTERN_TAG
Definition: cdfs.h:245
smooth NULL
Definition: ftsmooth.c:464
_In_ PFILE_OBJECT FileObject
Definition: classpnp.h:1229
void DPRINT(...)
Definition: polytest.cpp:61
UNICODE_STRING DirectorySearchPattern
Definition: cdfs.h:236
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1097
NTSTATUS NTAPI CdfsCreate ( PCDFS_IRP_CONTEXT  IrpContext)

Definition at line 257 of file create.c.

Referenced by CdfsDispatch().

259 {
261  PDEVICE_EXTENSION DeviceExt;
263 
264  DPRINT("CdfsCreate()\n");
265 
266  ASSERT(IrpContext);
267 
268  DeviceObject = IrpContext->DeviceObject;
269  if (DeviceObject == CdfsGlobalData->DeviceObject)
270  {
271  /* DeviceObject represents FileSystem instead of logical volume */
272  DPRINT("Opening file system\n");
273  IrpContext->Irp->IoStatus.Information = FILE_OPENED;
274  return STATUS_SUCCESS;
275  }
276 
277  DeviceExt = DeviceObject->DeviceExtension;
278 
280  ExAcquireResourceExclusiveLite(&DeviceExt->DirResource,
281  TRUE);
282  Status = CdfsCreateFile(DeviceObject,
283  IrpContext->Irp);
284  ExReleaseResourceLite(&DeviceExt->DirResource);
286 
287  return Status;
288 }
#define STATUS_SUCCESS
Definition: contextmenu.cpp:55
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
PDEVICE_OBJECT DeviceObject
Definition: cdfs.h:251
#define FILE_OPENED
Definition: nt_native.h:769
#define TRUE
Definition: numbers.c:17
_In_ PLARGE_INTEGER _In_ ULONG _In_ BOOLEAN _In_ ULONG _Out_ PVOID _Out_ PIO_STATUS_BLOCK _In_ PDEVICE_OBJECT DeviceObject
Definition: npfs.h:636
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
static NTSTATUS CdfsCreateFile(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: create.c:193
PVOID DeviceExtension
Definition: env_spec_w32.h:418
void DPRINT(...)
Definition: polytest.cpp:61
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
#define KeEnterCriticalRegion()
Definition: ke_x.h:83
Status
Definition: gdiplustypes.h:24
LONG NTSTATUS
Definition: DriverTester.h:11
#define KeLeaveCriticalRegion()
Definition: ke_x.h:114
PDEVICE_OBJECT DeviceObject
Definition: cdfs.h:272
PCDFS_GLOBAL_DATA CdfsGlobalData
Definition: cdfs.c:41
PFCB CdfsCreateFCB ( PCWSTR  FileName)

Definition at line 62 of file fcb.c.

Referenced by CdfsMakeFCBFromDirEntry(), CdfsMakeRootFCB(), and CdfsMountVolume().

63 {
64  PFCB Fcb;
65 
67  sizeof(FCB),
69  if(!Fcb) return NULL;
70 
71  RtlZeroMemory(Fcb, sizeof(FCB));
72  RtlInitEmptyUnicodeString(&Fcb->PathName, Fcb->PathNameBuffer, sizeof(Fcb->PathNameBuffer));
73 
74  if (FileName)
75  {
77  if (wcsrchr(Fcb->PathName.Buffer, '\\') != 0)
78  {
79  Fcb->ObjectName = wcsrchr(Fcb->PathName.Buffer, '\\');
80  }
81  else
82  {
83  Fcb->ObjectName = Fcb->PathName.Buffer;
84  }
85  }
86 
91  Fcb->RFCB.Resource = &Fcb->MainResource;
95 
96  return(Fcb);
97 }
FILE_LOCK FileLock
Definition: cdfs.h:223
LIST_ENTRY ShortNameList
Definition: cdfs.h:222
VOID NTAPI FsRtlInitializeFileLock(IN PFILE_LOCK FileLock, IN PCOMPLETE_LOCK_IRP_ROUTINE CompleteLockIrpRoutine OPTIONAL, IN PUNLOCK_ROUTINE UnlockRoutine OPTIONAL)
Definition: filelock.c:1261
Definition: cdfs.h:191
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
#define CDFS_NONPAGED_FCB_TAG
Definition: cdfs.h:243
ERESOURCE NameListResource
Definition: cdfs.h:221
UNICODE_STRING PathName
Definition: cdfs.h:204
WCHAR * ObjectName
Definition: cdfs.h:203
smooth NULL
Definition: ftsmooth.c:464
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcsrchr(_In_z_ const wchar_t *_Str, _In_ wchar_t _Ch)
FSRTL_COMMON_FCB_HEADER RFCB
Definition: cdfs.h:193
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
ERESOURCE MainResource
Definition: cdfs.h:195
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
WCHAR PathNameBuffer[MAX_PATH]
Definition: cdfs.h:205
ERESOURCE PagingIoResource
Definition: cdfs.h:196
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
VOID CdfsDateTimeToSystemTime ( PFCB  Fcb,
PLARGE_INTEGER  SystemTime 
)

Definition at line 135 of file misc.c.

Referenced by CdfsGetAllInformation(), CdfsGetBasicInformation(), CdfsGetBothDirectoryInformation(), CdfsGetDirectoryInformation(), CdfsGetFullDirectoryInformation(), and CdfsGetNetworkOpenInformation().

137 {
139  LARGE_INTEGER LocalTime;
140 
141  TimeFields.Milliseconds = 0;
142  TimeFields.Second = Fcb->Entry.Second;
143  TimeFields.Minute = Fcb->Entry.Minute;
144  TimeFields.Hour = Fcb->Entry.Hour;
145 
146  TimeFields.Day = Fcb->Entry.Day;
147  TimeFields.Month = Fcb->Entry.Month;
148  TimeFields.Year = Fcb->Entry.Year + 1900;
149 
150  RtlTimeFieldsToTime(&TimeFields,
151  &LocalTime);
152  ExLocalTimeToSystemTime(&LocalTime, SystemTime);
153 }
UCHAR Day
Definition: iso.h:33
UCHAR Month
Definition: iso.h:32
DIR_RECORD Entry
Definition: cdfs.h:219
USHORT Milliseconds
Definition: env_spec_w32.h:717
UCHAR Minute
Definition: iso.h:35
#define ExLocalTimeToSystemTime(LocTime, SysTime)
Definition: env_spec_w32.h:738
UCHAR Second
Definition: iso.h:36
UCHAR Hour
Definition: iso.h:34
BOOLEAN RtlTimeFieldsToTime(IN PTIME_FIELDS TimeFields, IN PLARGE_INTEGER Time)
static PTIME_FIELDS TimeFields
Definition: time.c:27
UCHAR Year
Definition: iso.h:31
VOID CdfsDestroyFCB ( PFCB  Fcb)

Definition at line 101 of file fcb.c.

Referenced by CdfsReleaseFCB().

102 {
104 
108 
109  while (!IsListEmpty(&Fcb->ShortNameList))
110  {
111  Entry = Fcb->ShortNameList.Flink;
112  RemoveEntryList(Entry);
114  }
115 
118 }
FILE_LOCK FileLock
Definition: cdfs.h:223
LIST_ENTRY ShortNameList
Definition: cdfs.h:222
struct _Entry Entry
Definition: kefuncs.h:640
VOID NTAPI FsRtlUninitializeFileLock(IN PFILE_LOCK FileLock)
Definition: filelock.c:1278
NTSTATUS NTAPI ExDeleteResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1456
#define CDFS_NONPAGED_FCB_TAG
Definition: cdfs.h:243
ERESOURCE NameListResource
Definition: cdfs.h:221
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
#define CDFS_SHORT_NAME_TAG
Definition: cdfs.h:244
struct _LIST_ENTRY * Flink
Definition: typedefs.h:120
Definition: typedefs.h:118
ERESOURCE MainResource
Definition: cdfs.h:195
ERESOURCE PagingIoResource
Definition: cdfs.h:196
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1097
NTSTATUS NTAPI CdfsDeviceControl ( PCDFS_IRP_CONTEXT  IrpContext)

Definition at line 20 of file devctrl.c.

Referenced by CdfsDispatch().

22 {
23  PIRP Irp;
25  PVCB Vcb = NULL;
27  PIO_STACK_LOCATION Stack;
28 
29  DPRINT("CdfsDeviceControl()\n");
30 
31  ASSERT(IrpContext);
32 
33  Irp = IrpContext->Irp;
34  Stack = IrpContext->Stack;
35  FileObject = Stack->FileObject;
36  Irp->IoStatus.Information = 0;
37 
38  /* FIXME: HACK, it means that CD has changed */
39  if (!FileObject)
40  {
41  DPRINT1("FIXME: CdfsDeviceControl called without FileObject!\n");
43  }
44 
45  /* Only support such operations on volume */
46  if (!(FileObject->RelatedFileObject == NULL || FileObject->RelatedFileObject->FsContext2 != NULL))
47  {
49  }
50 
51  if (Stack->Parameters.DeviceIoControl.IoControlCode == IOCTL_CDROM_DISK_TYPE)
52  {
53  /* We should handle this one, but we don't! */
54  Status = STATUS_NOT_IMPLEMENTED;
55  }
56  else
57  {
58  /* Pass it to storage driver */
60  Vcb = (PVCB)Stack->DeviceObject->DeviceExtension;
61 
62  /* Lower driver will complete - we don't have to */
63  IrpContext->Flags &= ~IRPCONTEXT_COMPLETE;
64 
65  Status = IoCallDriver(Vcb->StorageDevice, Irp);
66  }
67 
68  return Status;
69 }
struct _IO_STACK_LOCATION::@3189::@3203 DeviceIoControl
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
PDEVICE_OBJECT StorageDevice
Definition: cdfs.h:166
_In_ PIRP Irp
Definition: csq.h:116
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
union _IO_STACK_LOCATION::@3189 Parameters
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define IOCTL_CDROM_DISK_TYPE
Definition: ntddcdrm.h:67
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:464
_In_ PFILE_OBJECT FileObject
Definition: classpnp.h:1229
void DPRINT(...)
Definition: polytest.cpp:61
PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2841
* PFILE_OBJECT
Definition: iotypes.h:1949
#define IRPCONTEXT_COMPLETE
Definition: cdfs.h:259
ULONG Flags
Definition: cdfs.h:265
Status
Definition: gdiplustypes.h:24
PFILE_OBJECT FileObject
Definition: iotypes.h:2787
LONG NTSTATUS
Definition: DriverTester.h:11
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1155
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define DPRINT1
Definition: precomp.h:8
#define Vcb
PIO_STACK_LOCATION Stack
Definition: cdfs.h:266
PVOID PIRP
Definition: usb.h:38
struct DEVICE_EXTENSION * PVCB
NTSTATUS CdfsDeviceIoControl ( IN PDEVICE_OBJECT  DeviceObject,
IN ULONG  CtlCode,
IN PVOID  InputBuffer,
IN ULONG  InputBufferSize,
IN OUT PVOID  OutputBuffer,
IN OUT PULONG  pOutputBufferSize,
IN BOOLEAN  Override 
)

Definition at line 143 of file common.c.

Referenced by CdfsGetVolumeData(), and CdfsOpenFile().

150 {
151  PIO_STACK_LOCATION Stack;
153  KEVENT Event;
154  PIRP Irp;
156  BOOLEAN LastChance = FALSE;
157 
158  DPRINT("CdfsDeviceIoControl(DeviceObject %p, CtlCode %u, "
159  "InputBuffer %p, InputBufferSize %u, OutputBuffer %p, "
160  "POutputBufferSize %p (%x)\n", DeviceObject, CtlCode,
161  InputBuffer, InputBufferSize, OutputBuffer, OutputBufferSize,
162  OutputBufferSize ? *OutputBufferSize : 0);
163 
164 again:
166 
167  DPRINT("Building device I/O control request ...\n");
168  Irp = IoBuildDeviceIoControlRequest(CtlCode,
169  DeviceObject,
170  InputBuffer,
171  InputBufferSize,
172  OutputBuffer,
173  (OutputBufferSize != NULL) ? *OutputBufferSize : 0,
174  FALSE,
175  &Event,
176  &IoStatus);
177  if (Irp == NULL)
178  {
179  DPRINT("IoBuildDeviceIoControlRequest failed\n");
181  }
182 
183  if (Override)
184  {
185  Stack = IoGetNextIrpStackLocation(Irp);
187  }
188 
189  DPRINT ("Calling IO Driver... with irp %p\n", Irp);
190  Status = IoCallDriver(DeviceObject, Irp);
191 
192  DPRINT ("Waiting for IO Operation for %p\n", Irp);
193  if (Status == STATUS_PENDING)
194  {
195  DPRINT ("Operation pending\n");
197  DPRINT ("Getting IO Status... for %p\n", Irp);
198 
199  Status = IoStatus.Status;
200  }
201 
202  if (OutputBufferSize != NULL)
203  {
204  *OutputBufferSize = IoStatus.Information;
205  }
206 
207  if (Status == STATUS_VERIFY_REQUIRED)
208  {
209  PDEVICE_OBJECT DeviceToVerify;
210 
211  DeviceToVerify = IoGetDeviceToVerify(PsGetCurrentThread());
213 
214  if (DeviceToVerify)
215  {
216  Status = IoVerifyVolume(DeviceToVerify, FALSE);
217  DPRINT("IoVerifyVolume() returned (Status %lx)\n", Status);
218  }
219 
220  if (NT_SUCCESS(Status) && !LastChance)
221  {
222  DPRINT1("Volume verify succeeded; trying request again\n");
223  LastChance = TRUE;
224  goto again;
225  }
226  else if (NT_SUCCESS(Status))
227  {
228  DPRINT1("Failed to read after successful verify, aborting\n");
229  Status = STATUS_DEVICE_NOT_READY;
230  }
231  else
232  {
233  DPRINT1("IoVerifyVolume() failed (Status %lx)\n", Status);
234  }
235  }
236 
237  DPRINT("Returning Status %x\n", Status);
238 
239  return Status;
240 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
_In_ PIRP Irp
Definition: csq.h:116
#define TRUE
Definition: numbers.c:17
PDEVICE_OBJECT NTAPI IoGetDeviceToVerify(IN PETHREAD Thread)
Definition: util.c:304
_In_ PLARGE_INTEGER _In_ ULONG _In_ BOOLEAN _In_ ULONG _Out_ PVOID _Out_ PIO_STATUS_BLOCK _In_ PDEVICE_OBJECT DeviceObject
Definition: npfs.h:636
#define STATUS_VERIFY_REQUIRED
Definition: udferr_usr.h:130
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
CHAR InputBuffer[80]
Definition: conmgr.c:33
ACPI_EFI_EVENT Event
Definition: acefiex.h:607
smooth NULL
Definition: ftsmooth.c:464
#define SL_OVERRIDE_VERIFY_VOLUME
Definition: iotypes.h:1774
void DPRINT(...)
Definition: polytest.cpp:61
_Must_inspect_result_ __drv_aliasesMem _In_ PDEVICE_OBJECT _In_opt_ PVOID _In_ ULONG _Out_opt_ PVOID OutputBuffer
Definition: iofuncs.h:713
unsigned char BOOLEAN
#define STATUS_PENDING
Definition: ntstatus.h:82
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
Status
Definition: gdiplustypes.h:24
_In_ PLARGE_INTEGER _In_ ULONG _In_ BOOLEAN _In_ ULONG _Out_ PVOID _Out_ PIO_STATUS_BLOCK IoStatus
Definition: npfs.h:636
#define NT_SUCCESS(StatCode)
Definition: cmd.c:149
LONG NTSTATUS
Definition: DriverTester.h:11
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1155
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:818
#define DPRINT1
Definition: precomp.h:8
#define FALSE
Definition: numbers.c:16
PVOID PIRP
Definition: usb.h:38
NTSTATUS NTAPI IoVerifyVolume(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN AllowRawMount)
Definition: volume.c:874
VOID NTAPI IoSetDeviceToVerify(IN PETHREAD Thread, IN PDEVICE_OBJECT DeviceObject)
Definition: util.c:280
#define STATUS_DEVICE_NOT_READY
Definition: udferr_usr.h:162
NTSTATUS NTAPI CdfsDirectoryControl ( PCDFS_IRP_CONTEXT  IrpContext)

Definition at line 782 of file dirctl.c.

Referenced by CdfsDispatch().

784 {
785  PIRP Irp;
788 
789  DPRINT("CdfsDirectoryControl() called\n");
790 
791  ASSERT(IrpContext);
792 
793  Irp = IrpContext->Irp;
794  DeviceObject = IrpContext->DeviceObject;
795 
796  switch (IrpContext->MinorFunction)
797  {
799  Status = CdfsQueryDirectory(DeviceObject,
800  Irp);
801  break;
802 
804  Status = CdfsNotifyChangeDirectory(DeviceObject,
805  Irp, IrpContext);
806  break;
807 
808  default:
809  DPRINT1("CDFS: MinorFunction %u\n", IrpContext->MinorFunction);
811  break;
812  }
813 
814  if (Status != STATUS_PENDING)
815  {
816  Irp->IoStatus.Information = 0;
817  }
818 
819  return(Status);
820 }
#define IRP_MN_NOTIFY_CHANGE_DIRECTORY
Definition: rdpdr.c:56
_In_ PIRP Irp
Definition: csq.h:116
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
UCHAR MinorFunction
Definition: cdfs.h:268
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define IRP_MN_QUERY_DIRECTORY
Definition: rdpdr.c:55
_In_ PLARGE_INTEGER _In_ ULONG _In_ BOOLEAN _In_ ULONG _Out_ PVOID _Out_ PIO_STATUS_BLOCK _In_ PDEVICE_OBJECT DeviceObject
Definition: npfs.h:636
void DPRINT(...)
Definition: polytest.cpp:61
static NTSTATUS CdfsQueryDirectory(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: dirctl.c:545
static NTSTATUS CdfsNotifyChangeDirectory(PDEVICE_OBJECT DeviceObject, PIRP Irp, PCDFS_IRP_CONTEXT IrpContext)
Definition: dirctl.c:744
#define STATUS_PENDING
Definition: ntstatus.h:82
Status
Definition: gdiplustypes.h:24
LONG NTSTATUS
Definition: DriverTester.h:11
PDEVICE_OBJECT DeviceObject
Definition: cdfs.h:272
#define DPRINT1
Definition: precomp.h:8
PVOID PIRP
Definition: usb.h:38
NTSTATUS CdfsDirFindFile ( PDEVICE_EXTENSION  DeviceExt,
PFCB  DirectoryFcb,
PUNICODE_STRING  FileToFind,
PFCB FoundFCB 
)

Definition at line 444 of file fcb.c.

Referenced by CdfsGetFCBForFile().

448 {
449  UNICODE_STRING TempName;
450  WCHAR Name[256];
451  PVOID Block;
452  ULONG DirSize;
454  ULONG Offset;
457 
458  LARGE_INTEGER StreamOffset, OffsetOfEntry;
459  PVOID Context;
460 
461  WCHAR ShortNameBuffer[13];
464  UNICODE_STRING FileToFindUpcase;
465 
466  ASSERT(DeviceExt);
467  ASSERT(DirectoryFcb);
468  ASSERT(FileToFind);
469 
470  DPRINT("CdfsDirFindFile(VCB:%p, dirFCB:%p, File:%wZ)\n",
471  DeviceExt,
472  DirectoryFcb,
473  FileToFind);
474  DPRINT("Dir Path:%wZ\n", &DirectoryFcb->PathName);
475 
476  /* default to '.' if no filename specified */
477  if (FileToFind->Length == 0)
478  {
479  RtlInitUnicodeString(&TempName, L".");
480  FileToFind = &TempName;
481  }
482 
483  DirSize = DirectoryFcb->Entry.DataLengthL;
484  StreamOffset.QuadPart = (LONGLONG)DirectoryFcb->Entry.ExtentLocationL * (LONGLONG)BLOCKSIZE;
485 
486  _SEH2_TRY
487  {
488  CcMapData(DeviceExt->StreamFileObject, &StreamOffset, BLOCKSIZE, MAP_WAIT, &Context, &Block);
489  }
491  {
492  DPRINT("CcMapData() failed\n");
494  }
495  _SEH2_END;
496 
497  Offset = 0;
498  BlockOffset = 0;
499  Record = (PDIR_RECORD)Block;
500 
501  /* Upper case the expression for FsRtlIsNameInExpression */
502  Status = RtlUpcaseUnicodeString(&FileToFindUpcase, FileToFind, TRUE);
503  if (!NT_SUCCESS(Status))
504  {
505  return Status;
506  }
507 
508  while(TRUE)
509  {
510  if (Record->RecordLength == 0)
511  {
512  DPRINT("RecordLength == 0 Stopped!\n");
513  break;
514  }
515 
516  DPRINT("RecordLength %u ExtAttrRecordLength %u NameLength %u\n",
517  Record->RecordLength, Record->ExtAttrRecordLength, Record->FileIdLength);
518 
519  if (!CdfsIsRecordValid(DeviceExt, Record))
520  {
521  RtlFreeUnicodeString(&FileToFindUpcase);
522  CcUnpinData(Context);
524  }
525 
526  CdfsGetDirEntryName(DeviceExt, Record, Name);
527  DPRINT ("Name '%S'\n", Name);
528  DPRINT ("Sector %lu\n", DirectoryFcb->Entry.ExtentLocationL);
529  DPRINT ("Offset %lu\n", Offset);
530 
531  RtlInitUnicodeString(&LongName, Name);
532  RtlInitEmptyUnicodeString(&ShortName, ShortNameBuffer, sizeof(ShortNameBuffer));
533  RtlZeroMemory(ShortNameBuffer, sizeof(ShortNameBuffer));
534 
535  OffsetOfEntry.QuadPart = StreamOffset.QuadPart + Offset;
536  CdfsShortNameCacheGet(DirectoryFcb, &OffsetOfEntry, &LongName, &ShortName);
537 
538  DPRINT("ShortName '%wZ'\n", &ShortName);
539 
540  ASSERT(LongName.Length >= sizeof(WCHAR));
541  ASSERT(ShortName.Length >= sizeof(WCHAR));
542  if (FsRtlIsNameInExpression(&FileToFindUpcase, &LongName, TRUE, NULL) ||
543  FsRtlIsNameInExpression(&FileToFindUpcase, &ShortName, TRUE, NULL))
544  {
545  DPRINT("Match found, %S\n", Name);
546  Status = CdfsMakeFCBFromDirEntry(DeviceExt,
547  DirectoryFcb,
548  Name,
549  ShortNameBuffer,
550  Record,
551  DirectoryFcb->Entry.ExtentLocationL,
552  Offset,
553  FoundFCB);
554 
555  RtlFreeUnicodeString(&FileToFindUpcase);
556  CcUnpinData(Context);
557 
558  return(Status);
559  }
560 
561  Offset += Record->RecordLength;
562  BlockOffset += Record->RecordLength;
563  Record = (PDIR_RECORD)((ULONG_PTR)Block + BlockOffset);
564  if (BlockOffset >= BLOCKSIZE || Record->RecordLength == 0)
565  {
566  DPRINT("Map next sector\n");
567  CcUnpinData(Context);
568  StreamOffset.QuadPart += BLOCKSIZE;
569  Offset = ROUND_UP(Offset, BLOCKSIZE);
570  BlockOffset = 0;
571 
572  _SEH2_TRY
573  {
574  CcMapData(DeviceExt->StreamFileObject, &StreamOffset, BLOCKSIZE, MAP_WAIT, &Context, &Block);
575  }
577  {
578  DPRINT("CcMapData() failed\n");
579  RtlFreeUnicodeString(&FileToFindUpcase);
581  }
582  _SEH2_END;
583  Record = (PDIR_RECORD)((ULONG_PTR)Block + BlockOffset);
584  }
585 
586  if (Offset >= DirSize)
587  break;
588  }
589 
590  RtlFreeUnicodeString(&FileToFindUpcase);
591  CcUnpinData(Context);
592 
594 }
DWORD *typedef PVOID
Definition: winlogon.h:52
NTSTATUS RtlUpcaseUnicodeString(PUNICODE_STRING dst, PUNICODE_STRING src, BOOLEAN Alloc)
Definition: string_lib.cpp:46
BOOLEAN CdfsIsRecordValid(IN PDEVICE_EXTENSION DeviceExt, IN PDIR_RECORD Record)
Definition: misc.c:210
Definition: bidi.c:75
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define BLOCKSIZE
Definition: urlcache.c:40
UCHAR FileIdLength
Definition: iso.h:42
VOID NTAPI CcUnpinData(IN PVOID Bcb)
Definition: pinsup.c:955
#define TRUE
Definition: numbers.c:17
#define MAP_WAIT
NTSTATUS CdfsMakeFCBFromDirEntry(PVCB Vcb, PFCB DirectoryFCB, PWSTR LongName, PWSTR ShortName, PDIR_RECORD Record, ULONG DirectorySector, ULONG DirectoryOffset, PFCB *fileFCB)
Definition: fcb.c:326
BOOLEAN NTAPI FsRtlIsNameInExpression(IN PUNICODE_STRING Expression, IN PUNICODE_STRING Name, IN BOOLEAN IgnoreCase, IN PWCHAR UpcaseTable OPTIONAL)
Definition: name.c:492
VOID CdfsShortNameCacheGet(PFCB DirectoryFcb, PLARGE_INTEGER StreamOffset, PUNICODE_STRING LongName, PUNICODE_STRING ShortName)
Definition: misc.c:254
uint32_t ULONG_PTR
Definition: typedefs.h:64
static IN ULONG IN PWSTR OUT PCWSTR * ShortName
_In_ struct _KBUGCHECK_REASON_CALLBACK_RECORD * Record
Definition: ketypes.h:256
#define BlockOffset(V, L)
Definition: cdprocs.h:1437
UNICODE_STRING PathName
Definition: cdfs.h:204
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define _SEH2_END
Definition: pseh2_64.h:7
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:464
DIR_RECORD Entry
Definition: cdfs.h:219
void DPRINT(...)
Definition: polytest.cpp:61
struct _DIR_RECORD * PDIR_RECORD
Definition: iso.h:45
int64_t LONGLONG
Definition: typedefs.h:67
BOOLEAN NTAPI CcMapData(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG Flags, OUT PVOID *BcbResult, OUT PVOID *Buffer)
Definition: pinsup.c:694
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
VOID CdfsGetDirEntryName(PDEVICE_EXTENSION DeviceExt, PDIR_RECORD Record, PWSTR Name)
Definition: misc.c:344
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
UCHAR RecordLength
Definition: iso.h:25
Status
Definition: gdiplustypes.h:24
ULONG ExtentLocationL
Definition: iso.h:27
#define NT_SUCCESS(StatCode)
Definition: cmd.c:149
LONG NTSTATUS
Definition: DriverTester.h:11
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
UCHAR ExtAttrRecordLength
Definition: iso.h:26
_In_ ULONGLONG _In_ PUNICODE_STRING _In_ PUNICODE_STRING LongName
Definition: fsrtlfuncs.h:336
#define _SEH2_TRY
Definition: pseh2_64.h:5
#define STATUS_DISK_CORRUPT_ERROR
Definition: udferr_usr.h:147
#define ROUND_UP(N, S)
Definition: fcb.c:37
struct tagContext Context
Definition: acpixf.h:1013
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
ULONG DataLengthL
Definition: iso.h:29
LONGLONG QuadPart
Definition: typedefs.h:113
NTSTATUS CdfsFCBInitializeCache ( PVCB  Vcb,
PFCB  Fcb 
)

Definition at line 230 of file fcb.c.

Referenced by CdfsMakeFCBFromDirEntry(), and CdfsMakeRootFCB().

232 {
234  PCCB newCCB;
235 
236  FileObject = IoCreateStreamFileObject(NULL, Vcb->StorageDevice);
237 
239  if (newCCB == NULL)
240  {
242  }
243  RtlZeroMemory(newCCB,
244  sizeof(CCB));
245 
246  FileObject->ReadAccess = TRUE;
247  FileObject->WriteAccess = FALSE;
248  FileObject->DeleteAccess = FALSE;
249  FileObject->SectionObjectPointer = &Fcb->SectionObjectPointers;
250  FileObject->FsContext = Fcb;
251  FileObject->FsContext2 = newCCB;
252  newCCB->PtrFileObject = FileObject;
253  Fcb->FileObject = FileObject;
254  Fcb->DevExt = Vcb;
255 
256  _SEH2_TRY
257  {
258  CcInitializeCacheMap(FileObject,
260  FALSE,
262  Fcb);
263  }
265  {
266  FileObject->FsContext2 = NULL;
268  ObDereferenceObject(FileObject);
269  Fcb->FileObject = NULL;
270  return _SEH2_GetExceptionCode();
271  }
272  _SEH2_END;
273 
274  ObDereferenceObject(FileObject);
276 
277  return STATUS_SUCCESS;
278 }
#define STATUS_SUCCESS
Definition: contextmenu.cpp:55
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
PFILE_OBJECT FileObject
Definition: cdfs.h:198
PDEVICE_OBJECT StorageDevice
Definition: cdfs.h:166
#define CDFS_CCB_TAG
Definition: cdfs.h:242
Definition: cdfs.h:227
#define TRUE
Definition: numbers.c:17
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:267
CACHE_MANAGER_CALLBACKS CacheMgrCallbacks
Definition: cdfs.h:253
#define _SEH2_END
Definition: pseh2_64.h:7
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:464
_In_ PFILE_OBJECT FileObject
Definition: classpnp.h:1229
#define FCB_CACHE_INITIALIZED
Definition: cdfs.h:177
PFILE_OBJECT NTAPI IoCreateStreamFileObject(IN PFILE_OBJECT FileObject, IN PDEVICE_OBJECT DeviceObject)
Definition: file.c:2791
FSRTL_COMMON_FCB_HEADER RFCB
Definition: cdfs.h:193
PFILE_OBJECT PtrFileObject
Definition: cdfs.h:230
PDEVICE_EXTENSION DevExt
Definition: cdfs.h:199
VOID NTAPI CcInitializeCacheMap(IN PFILE_OBJECT FileObject, IN PCC_FILE_SIZES FileSizes, IN BOOLEAN PinAccess, IN PCACHE_MANAGER_CALLBACKS Callbacks, IN PVOID LazyWriteContext)
Definition: fssup.c:193
* PFILE_OBJECT
Definition: iotypes.h:1949
ULONG Flags
Definition: cdfs.h:217
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
LARGE_INTEGER AllocationSize
Definition: env_spec_w32.h:755
PCDFS_GLOBAL_DATA CdfsGlobalData
Definition: cdfs.c:41
#define _SEH2_TRY
Definition: pseh2_64.h:5
#define Vcb
#define FALSE
Definition: numbers.c:16
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1097
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
SECTION_OBJECT_POINTERS SectionObjectPointers
Definition: cdfs.h:194
BOOLEAN CdfsFCBIsRoot ( PFCB  Fcb)

Definition at line 129 of file fcb.c.

Referenced by CdfsMakeAbsoluteFilename(), and CdfsMakeFCBFromDirEntry().

130 {
131  return (Fcb->PathName.Length == sizeof(WCHAR) && Fcb->PathName.Buffer[0] == L'\\');
132 }
Definition: bidi.c:75
__wchar_t WCHAR
Definition: xmlstorage.h:180
UNICODE_STRING PathName
Definition: cdfs.h:204
VOID CdfsFileFlagsToAttributes ( PFCB  Fcb,
PULONG  FileAttributes 
)

Definition at line 157 of file misc.c.

Referenced by CdfsGetAllInformation(), CdfsGetBasicInformation(), CdfsGetBothDirectoryInformation(), CdfsGetDirectoryInformation(), CdfsGetFullDirectoryInformation(), and CdfsGetNetworkOpenInformation().

159 {
160  /* FIXME: Fix attributes */
161 
162  *FileAttributes = // FILE_ATTRIBUTE_READONLY |
167 }
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
UCHAR FileFlags
Definition: iso.h:38
#define FILE_FLAG_HIDDEN
Definition: cdfs.h:54
DIR_RECORD Entry
Definition: cdfs.h:219
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE _In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Out_ PIO_STATUS_BLOCK _In_opt_ PLARGE_INTEGER _In_ ULONG FileAttributes
Definition: fltkernel.h:1230
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define FILE_FLAG_SYSTEM
Definition: cdfs.h:56
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
#define FILE_FLAG_READONLY
Definition: cdfs.h:57
#define FILE_FLAG_DIRECTORY
Definition: cdfs.h:55
NTSTATUS NTAPI CdfsFileSystemControl ( PCDFS_IRP_CONTEXT  IrpContext)

Definition at line 566 of file fsctl.c.

Referenced by CdfsDispatch().

568 {
569  PIRP Irp;
571  PIO_STACK_LOCATION Stack;
573 
574  DPRINT("CdfsFileSystemControl() called\n");
575 
576  ASSERT(IrpContext);
577 
578  DeviceObject = IrpContext->DeviceObject;
579  Irp = IrpContext->Irp;
580  Stack = IrpContext->Stack;
581 
582  Irp->IoStatus.Information = 0;
583 
584  switch (IrpContext->MinorFunction)
585  {
586  case IRP_MN_KERNEL_CALL:
588  switch (Stack->Parameters.DeviceIoControl.IoControlCode)
589  {
591  DPRINT("CDFS: IRP_MN_USER_FS_REQUEST / FSCTL_SET_COMPRESSION\n");
592  Status = CdfsSetCompression(DeviceObject, Irp);
593  break;
594 
595  default:
596  DPRINT1("CDFS: IRP_MN_USER_FS_REQUEST / Unknown IoControlCode 0x%x\n",
597  Stack->Parameters.DeviceIoControl.IoControlCode);
599  }
600  break;
601 
602  case IRP_MN_MOUNT_VOLUME:
603  DPRINT("CDFS: IRP_MN_MOUNT_VOLUME\n");
604  Status = CdfsMountVolume(DeviceObject, Irp);
605  break;
606 
608  DPRINT1("CDFS: IRP_MN_VERIFY_VOLUME\n");
609  Status = CdfsVerifyVolume(DeviceObject, Irp);
610  break;
611 
612  default:
613  DPRINT1("CDFS FSC: MinorFunction %u\n", Stack->MinorFunction);
615  break;
616  }
617 
618  return Status;
619 }
struct _IO_STACK_LOCATION::@3189::@3203 DeviceIoControl
_In_ PIRP Irp
Definition: csq.h:116
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
UCHAR MinorFunction
Definition: cdfs.h:268
#define FSCTL_SET_COMPRESSION
Definition: nt_native.h:842
union _IO_STACK_LOCATION::@3189 Parameters
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
_In_ PLARGE_INTEGER _In_ ULONG _In_ BOOLEAN _In_ ULONG _Out_ PVOID _Out_ PIO_STATUS_BLOCK _In_ PDEVICE_OBJECT DeviceObject
Definition: npfs.h:636
#define IRP_MN_VERIFY_VOLUME
Definition: iotypes.h:4015
void DPRINT(...)
Definition: polytest.cpp:61
#define IRP_MN_MOUNT_VOLUME
Definition: iotypes.h:4014
#define IRP_MN_USER_FS_REQUEST
Definition: iotypes.h:4013
NTSTATUS NTAPI CdfsSetCompression(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fsctl.c:542
#define IRP_MN_KERNEL_CALL
Definition: iotypes.h:4018
Status
Definition: gdiplustypes.h:24
LONG NTSTATUS
Definition: DriverTester.h:11
PDEVICE_OBJECT DeviceObject
Definition: cdfs.h:272
static NTSTATUS CdfsMountVolume(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: fsctl.c:315
#define DPRINT1
Definition: precomp.h:8
PIO_STACK_LOCATION Stack
Definition: cdfs.h:266
PVOID PIRP
Definition: usb.h:38
static NTSTATUS CdfsVerifyVolume(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: fsctl.c:468
NTSTATUS NTAPI CdfsFsdDispatch ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 200 of file dispatch.c.

203 {
204  PCDFS_IRP_CONTEXT IrpContext = NULL;
206 
207  DPRINT("CdfsFsdDispatch()\n");
208 
209  IrpContext = CdfsAllocateIrpContext(DeviceObject, Irp);
210  if (IrpContext == NULL)
211  {
213  Irp->IoStatus.Status = Status;
215  }
216  else
217  {
218  Status = CdfsDispatch(IrpContext);
219  }
220 
221  return Status;
222 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
smooth NULL
Definition: ftsmooth.c:464
#define IoCompleteRequest
Definition: irp.c:1177
void DPRINT(...)
Definition: polytest.cpp:61
static NTSTATUS CdfsDispatch(PCDFS_IRP_CONTEXT IrpContext)
Definition: dispatch.c:86
Status
Definition: gdiplustypes.h:24
LONG NTSTATUS
Definition: DriverTester.h:11
PCDFS_IRP_CONTEXT CdfsAllocateIrpContext(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: misc.c:69
#define IO_NO_INCREMENT
Definition: iotypes.h:565
VOID CdfsGetDirEntryName ( PDEVICE_EXTENSION  DeviceExt,
PDIR_RECORD  Record,
PWSTR  Name 
)

Definition at line 344 of file misc.c.

Referenced by CdfsDirFindFile(), CdfsGetEntryName(), and CdfsMakeFCBFromDirEntry().

350 {
351  if (Record->FileIdLength == 1 && Record->FileId[0] == 0)
352  {
353  wcscpy(Name, L".");
354  }
355  else if (Record->FileIdLength == 1 && Record->FileId[0] == 1)
356  {
357  wcscpy(Name, L"..");
358  }
359  else
360  {
361  if (DeviceExt->CdInfo.JolietLevel == 0)
362  {
363  ULONG i;
364 
365  for (i = 0; i < Record->FileIdLength && Record->FileId[i] != ';'; i++)
366  Name[i] = (WCHAR)Record->FileId[i];
367  Name[i] = 0;
368  }
369  else
370  {
372  Record->FileId,
373  Record->FileIdLength);
374  }
375  }
376 
377  DPRINT("Name '%S'\n", Name);
378 }
UCHAR FileId[1]
Definition: iso.h:43
Definition: bidi.c:75
__wchar_t WCHAR
Definition: xmlstorage.h:180
VOID CdfsSwapString(PWCHAR Out, PUCHAR In, ULONG Count)
Definition: misc.c:110
UCHAR FileIdLength
Definition: iso.h:42
GLenum GLclampf GLint i
Definition: glfuncs.h:14
void DPRINT(...)
Definition: polytest.cpp:61
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS CdfsGetFCBForFile ( PDEVICE_EXTENSION  Vcb,
PFCB pParentFCB,
PFCB pFCB,
PUNICODE_STRING  FileName 
)

Definition at line 598 of file fcb.c.

Referenced by CdfsOpenFile().

602 {
603  UNICODE_STRING PathName;
604  UNICODE_STRING NextElement;
605  UNICODE_STRING CurrentElement;
607  PFCB FCB;
608  PFCB parentFCB;
609 
610  DPRINT("CdfsGetFCBForFile(%p, %p, %p, '%wZ')\n",
611  Vcb,
612  pParentFCB,
613  pFCB,
614  FileName);
615 
616  /* Trivial case, open of the root directory on volume */
617  if (FileName->Length == 0 ||
618  ((FileName->Buffer[0] == '\\') && (FileName->Length == sizeof(WCHAR))))
619  {
620  DPRINT("returning root FCB\n");
621 
622  FCB = CdfsOpenRootFCB(Vcb);
623  *pFCB = FCB;
624  *pParentFCB = NULL;
625 
626  return((FCB != NULL) ? STATUS_SUCCESS : STATUS_OBJECT_PATH_NOT_FOUND);
627  }
628  else
629  {
630  /* Start with empty path */
631  PathName = *FileName;
632  PathName.Length = 0;
633  CurrentElement = *FileName;
634 
635  FCB = CdfsOpenRootFCB (Vcb);
636  }
637  parentFCB = NULL;
638 
639  /* Parse filename and check each path element for existence and access */
640  while (CdfsGetNextPathElement(&CurrentElement, &NextElement))
641  {
642  /* Skip blank directory levels */
643  if (CurrentElement.Buffer[0] == L'\\')
644  {
645  CurrentElement.Buffer++;
646  CurrentElement.Length -= sizeof(WCHAR);
647  CurrentElement.MaximumLength -= sizeof(WCHAR);
648  continue;
649  }
650 
651  DPRINT("Parsing, currentElement:%wZ\n", &CurrentElement);
652  DPRINT(" parentFCB:%p FCB:%p\n", parentFCB, FCB);
653 
654  /* Descend to next directory level */
655  if (parentFCB)
656  {
657  CdfsReleaseFCB(Vcb, parentFCB);
658  parentFCB = NULL;
659  }
660 
661  /* fail if element in FCB is not a directory */
662  if (!CdfsFCBIsDirectory(FCB))
663  {
664  DPRINT("Element in requested path is not a directory\n");
665 
666  CdfsReleaseFCB(Vcb, FCB);
667  FCB = 0;
668  *pParentFCB = NULL;
669  *pFCB = NULL;
670 
672  }
673  parentFCB = FCB;
674 
675  /* Extract next directory level */
676  PathName.Length = (NextElement.Buffer - FileName->Buffer) * sizeof(WCHAR);
677  DPRINT(" PathName:%wZ\n", &PathName);
678 
679  FCB = CdfsGrabFCBFromTable(Vcb, &PathName);
680  if (FCB == NULL)
681  {
682  UNICODE_STRING ChildElement = CurrentElement;
683  ChildElement.Length = (NextElement.Buffer - CurrentElement.Buffer) * sizeof(WCHAR);
684 
685  Status = CdfsDirFindFile(Vcb,
686  parentFCB,
687  &ChildElement,
688  &FCB);
689  if (Status == STATUS_OBJECT_NAME_NOT_FOUND)
690  {
691  *pParentFCB = parentFCB;
692  *pFCB = NULL;
693 
694  if (NextElement.Length == 0)
695  {
697  }
698  else
699  {
701  }
702  }
703  else if (!NT_SUCCESS(Status))
704  {
705  CdfsReleaseFCB(Vcb, parentFCB);
706  *pParentFCB = NULL;
707  *pFCB = NULL;
708 
709  return(Status);
710  }
711  }
712  CurrentElement = NextElement;
713  }
714 
715  *pParentFCB = parentFCB;
716  *pFCB = FCB;
717 
718  return STATUS_SUCCESS;
719 }
#define STATUS_SUCCESS
Definition: contextmenu.cpp:55
struct _FCB FCB
USHORT MaximumLength
Definition: env_spec_w32.h:370
Definition: bidi.c:75
Definition: cdfs.h:191
__wchar_t WCHAR
Definition: xmlstorage.h:180
static BOOLEAN CdfsGetNextPathElement(PCUNICODE_STRING CurrentElement, PUNICODE_STRING NextElement)
Definition: fcb.c:43
PFCB CdfsGrabFCBFromTable(PDEVICE_EXTENSION Vcb, PUNICODE_STRING FileName)
Definition: fcb.c:188
#define WCHAR
Definition: msvc.h:43
BOOLEAN CdfsFCBIsDirectory(PFCB Fcb)
Definition: fcb.c:122
smooth NULL
Definition: ftsmooth.c:464
void DPRINT(...)
Definition: polytest.cpp:61
struct _FileName FileName
#define STATUS_OBJECT_PATH_NOT_FOUND
Definition: udferr_usr.h:151
PFCB CdfsOpenRootFCB(PDEVICE_EXTENSION Vcb)
Definition: fcb.c:307
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: cmd.c:149
LONG NTSTATUS
Definition: DriverTester.h:11
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
VOID CdfsReleaseFCB(PDEVICE_EXTENSION Vcb, PFCB Fcb)
Definition: fcb.c:153
NTSTATUS CdfsDirFindFile(PDEVICE_EXTENSION DeviceExt, PFCB DirectoryFcb, PUNICODE_STRING FileToFind, PFCB *FoundFCB)
Definition: fcb.c:444
VOID CdfsGrabFCB ( PDEVICE_EXTENSION  Vcb,
PFCB  Fcb 
)

Definition at line 136 of file fcb.c.

Referenced by CdfsMakeRootFCB().

138 {
139  KIRQL oldIrql;
140 
141  DPRINT("grabbing FCB at %p: %S, refCount:%d\n",
142  Fcb,
143  Fcb->PathName,
144  Fcb->RefCount);
145 
146  KeAcquireSpinLock(&Vcb->FcbListLock, &oldIrql);
147  Fcb->RefCount++;
148  KeReleaseSpinLock(&Vcb->FcbListLock, oldIrql);
149 }
UCHAR KIRQL
Definition: env_spec_w32.h:591
UNICODE_STRING PathName
Definition: cdfs.h:204
LONG RefCount
Definition: cdfs.h:216
void DPRINT(...)
Definition: polytest.cpp:61
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
PFCB CdfsGrabFCBFromTable ( PDEVICE_EXTENSION  Vcb,
PUNICODE_STRING  FileName 
)

Definition at line 188 of file fcb.c.

Referenced by CdfsGetFCBForFile(), CdfsOpenFile(), and CdfsOpenRootFCB().

190 {
191  KIRQL oldIrql;
192  PFCB Fcb;
193  PLIST_ENTRY current_entry;
194 
195  KeAcquireSpinLock(&Vcb->FcbListLock, &oldIrql);
196 
197  if (FileName == NULL || FileName->Length == 0 || FileName->Buffer[0] == 0)
198  {
199  DPRINT("Return FCB for stream file object\n");
200  Fcb = Vcb->StreamFileObject->FsContext;
201  Fcb->RefCount++;
202  KeReleaseSpinLock(&Vcb->FcbListLock, oldIrql);
203  return(Fcb);
204  }
205 
206  current_entry = Vcb->FcbListHead.Flink;
207  while (current_entry != &Vcb->FcbListHead)
208  {
209  Fcb = CONTAINING_RECORD(current_entry, FCB, FcbListEntry);
210 
211  DPRINT("Comparing '%wZ' and '%wZ'\n", FileName, &Fcb->PathName);
212  if (RtlCompareUnicodeString(FileName, &Fcb->PathName, TRUE) == 0)
213  {
214  Fcb->RefCount++;
215  KeReleaseSpinLock(&Vcb->FcbListLock, oldIrql);
216  return(Fcb);
217  }
218 
219  //FIXME: need to compare against short name in FCB here
220 
221  current_entry = current_entry->Flink;
222  }
223  KeReleaseSpinLock(&Vcb->FcbListLock, oldIrql);
224 
225  return(NULL);
226 }
Definition: cdfs.h:191
#define TRUE
Definition: numbers.c:17
UCHAR KIRQL
Definition: env_spec_w32.h:591
UNICODE_STRING PathName
Definition: cdfs.h:204
LONG RefCount
Definition: cdfs.h:216
smooth NULL
Definition: ftsmooth.c:464
void DPRINT(...)
Definition: polytest.cpp:61
struct _LIST_ENTRY * Flink
Definition: typedefs.h:120
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
Definition: typedefs.h:118
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
BOOLEAN CdfsIsIrpTopLevel ( PIRP  Irp)

Definition at line 44 of file misc.c.

Referenced by CdfsDispatch().

46 {
47  BOOLEAN ReturnCode = FALSE;
48 
49  DPRINT("CdfsIsIrpTopLevel()\n");
50 
51  if (IoGetTopLevelIrp() == NULL)
52  {
54  ReturnCode = TRUE;
55  }
56 
57  return ReturnCode;
58 }
_In_ PIRP Irp
Definition: csq.h:116
#define TRUE
Definition: numbers.c:17
smooth NULL
Definition: ftsmooth.c:464
void DPRINT(...)
Definition: polytest.cpp:61
unsigned char BOOLEAN
PIRP NTAPI IoGetTopLevelIrp(VOID)
Definition: irp.c:1766
VOID NTAPI IoSetTopLevelIrp(IN PIRP Irp)
Definition: irp.c:1923
#define FALSE
Definition: numbers.c:16
BOOLEAN CdfsIsRecordValid ( IN PDEVICE_EXTENSION  DeviceExt,
IN PDIR_RECORD  Record 
)

Definition at line 210 of file misc.c.

Referenced by CdfsDirFindFile(), and CdfsGetEntryName().

212 {
213  if (Record->RecordLength < Record->FileIdLength + FIELD_OFFSET(DIR_RECORD, FileId))
214  {
215  DPRINT1("Found corrupted entry! %u - %u\n", Record->RecordLength, Record->FileIdLength + FIELD_OFFSET(DIR_RECORD, FileId));
216  return FALSE;
217  }
218 
219  if (Record->FileIdLength == 0)
220  {
221  DPRINT1("Found corrupted entry (null size)!\n");
222  return FALSE;
223  }
224 
225  if (DeviceExt->CdInfo.JolietLevel == 0)
226  {
227  if (Record->FileId[0] == ANSI_NULL && Record->FileIdLength != 1)
228  {
229  DPRINT1("Found corrupted entry!\n");
230  return FALSE;
231  }
232  }
233  else
234  {
235  if (Record->FileIdLength & 1 && Record->FileIdLength != 1)
236  {
237  DPRINT1("Found corrupted entry! %u\n", Record->FileIdLength);
238  return FALSE;
239  }
240 
241  if (Record->FileIdLength == 1 && Record->FileId[0] != 0 && Record->FileId[0] != 1)
242  {
243  DPRINT1("Found corrupted entry! %c\n", Record->FileId[0]);
244  DPRINT1("%wc\n", ((PWSTR)Record->FileId)[0]);
245  return FALSE;
246  }
247  }
248 
249  return TRUE;
250 }
#define TRUE
Definition: numbers.c:17
PVOID *typedef PWSTR
Definition: winlogon.h:57
_In_ struct _KBUGCHECK_REASON_CALLBACK_RECORD * Record
Definition: ketypes.h:256
#define ANSI_NULL
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define DPRINT1
Definition: precomp.h:8
#define FALSE
Definition: numbers.c:16
NTSTATUS CdfsMakeFCBFromDirEntry ( PVCB  Vcb,
PFCB  DirectoryFCB,
PWSTR  LongName,
PWSTR  ShortName,
PDIR_RECORD  Record,
ULONG  DirectorySector,
ULONG  DirectoryOffset,
PFCB fileFCB 
)

Definition at line 326 of file fcb.c.

Referenced by CdfsDirFindFile().

334 {
335  WCHAR pathName[MAX_PATH];
336  PFCB rcFCB;
337  ULONG Size;
338 
339  /* Check if the full string would overflow the pathName buffer (the additional characters are for '\\' and '\0') */
340  if ((LongName[0] != 0) &&
341  ((DirectoryFCB->PathName.Length / sizeof(WCHAR)) + 1 + wcslen(LongName) + 1 > MAX_PATH))
342  {
344  }
345 
346  wcscpy(pathName, DirectoryFCB->PathName.Buffer);
347  if (!CdfsFCBIsRoot(DirectoryFCB))
348  {
349  wcscat(pathName, L"\\");
350  }
351 
352  if (LongName[0] != 0)
353  {
354  wcscat(pathName, LongName);
355  }
356  else
357  {
358  WCHAR entryName[MAX_PATH];
359 
360  CdfsGetDirEntryName(Vcb, Record, entryName);
361  wcscat(pathName, entryName);
362  }
363 
364  rcFCB = CdfsCreateFCB(pathName);
365  memcpy(&rcFCB->Entry, Record, sizeof(DIR_RECORD));
366 
367  /* Copy short name into FCB */
368  rcFCB->ShortNameU.Length = wcslen(ShortName) * sizeof(WCHAR);
369  rcFCB->ShortNameU.MaximumLength = rcFCB->ShortNameU.Length;
370  rcFCB->ShortNameU.Buffer = rcFCB->ShortNameBuffer;
372 
373  Size = rcFCB->Entry.DataLengthL;
374 
375  rcFCB->RFCB.FileSize.QuadPart = Size;
378  if (CdfsFCBIsDirectory(rcFCB))
379  {
380  CdfsFCBInitializeCache(Vcb, rcFCB);
381  }
382  rcFCB->IndexNumber.u.HighPart = DirectorySector;
383  rcFCB->IndexNumber.u.LowPart = DirectoryOffset;
384  rcFCB->RefCount++;
385  CdfsAddFCBToTable(Vcb, rcFCB);
386  *fileFCB = rcFCB;
387 
388  DPRINT("%S %u %I64d\n", LongName, Size, rcFCB->RFCB.AllocationSize.QuadPart);
389 
390  return(STATUS_SUCCESS);
391 }
#define STATUS_SUCCESS
Definition: contextmenu.cpp:55
USHORT MaximumLength
Definition: env_spec_w32.h:370
Definition: bidi.c:75
Definition: cdfs.h:191
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define BLOCKSIZE
Definition: urlcache.c:40
WCHAR ShortNameBuffer[13]
Definition: cdfs.h:206
struct _LARGE_INTEGER::@1855 u
#define WCHAR
Definition: msvc.h:43
static IN ULONG IN PWSTR OUT PCWSTR * ShortName
BOOLEAN CdfsFCBIsDirectory(PFCB Fcb)
Definition: fcb.c:122
UNICODE_STRING PathName
Definition: cdfs.h:204
BOOLEAN CdfsFCBIsRoot(PFCB Fcb)
Definition: fcb.c:129
LARGE_INTEGER IndexNumber
Definition: cdfs.h:213
LONG RefCount
Definition: cdfs.h:216
DIR_RECORD Entry
Definition: cdfs.h:219
void DPRINT(...)
Definition: polytest.cpp:61
FSRTL_COMMON_FCB_HEADER RFCB
Definition: cdfs.h:193
UINTN Size
Definition: acefiex.h:550
#define MAX_PATH
Definition: compat.h:26
VOID CdfsGetDirEntryName(PDEVICE_EXTENSION DeviceExt, PDIR_RECORD Record, PWSTR Name)
Definition: misc.c:344
VOID CdfsAddFCBToTable(PDEVICE_EXTENSION Vcb, PFCB Fcb)
Definition: fcb.c:175
UNICODE_STRING ShortNameU
Definition: cdfs.h:201
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
PFCB CdfsCreateFCB(PCWSTR FileName)
Definition: fcb.c:62
LARGE_INTEGER AllocationSize
Definition: env_spec_w32.h:755
NTSTATUS CdfsFCBInitializeCache(PVCB Vcb, PFCB Fcb)
Definition: fcb.c:230
_In_ ULONGLONG _In_ PUNICODE_STRING _In_ PUNICODE_STRING LongName
Definition: fsrtlfuncs.h:336
#define STATUS_OBJECT_NAME_INVALID
Definition: udferr_usr.h:148
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define ROUND_UP(N, S)
Definition: fcb.c:37
unsigned int ULONG
Definition: retypes.h:1
ULONG DataLengthL
Definition: iso.h:29
LARGE_INTEGER ValidDataLength
Definition: env_spec_w32.h:757
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
LONGLONG QuadPart
Definition: typedefs.h:113
PFCB CdfsMakeRootFCB ( PDEVICE_EXTENSION  Vcb)

Definition at line 282 of file fcb.c.

Referenced by CdfsOpenRootFCB().

283 {
284  PFCB Fcb;
285 
286  Fcb = CdfsCreateFCB(L"\\");
287 
288  Fcb->Entry.DataLengthL = Vcb->CdInfo.RootSize;
289  Fcb->Entry.ExtentLocationL = Vcb->CdInfo.RootStart;
291  Fcb->IndexNumber.QuadPart = 0LL;
292  Fcb->RefCount = 1;
293  Fcb->DirIndex = 0;
294  Fcb->RFCB.FileSize.QuadPart = Vcb->CdInfo.RootSize;
295  Fcb->RFCB.ValidDataLength.QuadPart = Vcb->CdInfo.RootSize;
296  Fcb->RFCB.AllocationSize.QuadPart = Vcb->CdInfo.RootSize;
297 
298  CdfsFCBInitializeCache(Vcb, Fcb);
299  CdfsAddFCBToTable(Vcb, Fcb);
300  CdfsGrabFCB(Vcb, Fcb);
301 
302  return(Fcb);
303 }
VOID CdfsGrabFCB(PDEVICE_EXTENSION Vcb, PFCB Fcb)
Definition: fcb.c:136
#define LL
Definition: tui.h:72
Definition: bidi.c:75
Definition: cdfs.h:191
ULONG DirIndex
Definition: cdfs.h:211
UCHAR FileFlags
Definition: iso.h:38
LARGE_INTEGER IndexNumber
Definition: cdfs.h:213
LONG RefCount
Definition: cdfs.h:216
DIR_RECORD Entry
Definition: cdfs.h:219
FSRTL_COMMON_FCB_HEADER RFCB
Definition: cdfs.h:193
VOID CdfsAddFCBToTable(PDEVICE_EXTENSION Vcb, PFCB Fcb)
Definition: fcb.c:175
PFCB CdfsCreateFCB(PCWSTR FileName)
Definition: fcb.c:62
LARGE_INTEGER AllocationSize
Definition: env_spec_w32.h:755
NTSTATUS CdfsFCBInitializeCache(PVCB Vcb, PFCB Fcb)
Definition: fcb.c:230
ULONG ExtentLocationL
Definition: iso.h:27
ULONG DataLengthL
Definition: iso.h:29
LARGE_INTEGER ValidDataLength
Definition: env_spec_w32.h:757
#define FILE_FLAG_DIRECTORY
Definition: cdfs.h:55
LONGLONG QuadPart
Definition: typedefs.h:113
PFCB CdfsOpenRootFCB ( PDEVICE_EXTENSION  Vcb)

Definition at line 307 of file fcb.c.

Referenced by CdfsGetFCBForFile().

308 {
310  PFCB Fcb;
311 
312  RtlInitUnicodeString(&FileName, L"\\");
313 
314  Fcb = CdfsGrabFCBFromTable(Vcb,
315  &FileName);
316  if (Fcb == NULL)
317  {
318  Fcb = CdfsMakeRootFCB(Vcb);
319  }
320 
321  return(Fcb);
322 }
Definition: bidi.c:75
Definition: cdfs.h:191
PFCB CdfsGrabFCBFromTable(PDEVICE_EXTENSION Vcb, PUNICODE_STRING FileName)
Definition: fcb.c:188
PFCB CdfsMakeRootFCB(PDEVICE_EXTENSION Vcb)
Definition: fcb.c:282
smooth NULL
Definition: ftsmooth.c:464
struct _FileName FileName
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSTATUS NTAPI CdfsQueryInformation ( PCDFS_IRP_CONTEXT  IrpContext)

Definition at line 337 of file finfo.c.

Referenced by CdfsDispatch().

339 {
340  PIRP Irp;
343  PIO_STACK_LOCATION Stack;
345  PFCB Fcb;
346  PVOID SystemBuffer;
348 
350 
351  DPRINT("CdfsQueryInformation() called\n");
352 
353  Irp = IrpContext->Irp;
354  DeviceObject = IrpContext->DeviceObject;
355  Stack = IrpContext->Stack;
356  FileInformationClass = Stack->Parameters.QueryFile.FileInformationClass;
357  FileObject = Stack->FileObject;
358  Fcb = FileObject->FsContext;
359 
360  SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
361  BufferLength = Stack->Parameters.QueryFile.Length;
362 
363  switch (FileInformationClass)
364  {
366  Status = CdfsGetStandardInformation(Fcb,
367  DeviceObject,
368  SystemBuffer,
369  &BufferLength);
370  break;
371 
373  Status = CdfsGetPositionInformation(FileObject,
374  SystemBuffer,
375  &BufferLength);
376  break;
377 
379  Status = CdfsGetBasicInformation(FileObject,
380  Fcb,
381  DeviceObject,
382  SystemBuffer,
383  &BufferLength);
384  break;
385 
386  case FileNameInformation:
387  Status = CdfsGetNameInformation(FileObject,
388  Fcb,
389  DeviceObject,
390  SystemBuffer,
391  &BufferLength);
392  break;
393 
395  Status = CdfsGetInternalInformation(Fcb,
396  SystemBuffer,
397  &BufferLength);
398  break;
399 
401  Status = CdfsGetNetworkOpenInformation(Fcb,
402  SystemBuffer,
403  &BufferLength);
404  break;
405 
406  case FileAllInformation:
407  Status = CdfsGetAllInformation(FileObject,
408  Fcb,
409  SystemBuffer,
410  &BufferLength);
411  break;
412 
414  Status = STATUS_NOT_IMPLEMENTED;
415  break;
416 
417  default:
418  DPRINT("Unimplemented information class %x\n", FileInformationClass);
419  Status = STATUS_INVALID_PARAMETER;
420  break;
421  }
422 
423  if (NT_SUCCESS(Status) || Status == STATUS_BUFFER_OVERFLOW)
424  Irp->IoStatus.Information =
425  Stack->Parameters.QueryFile.Length - BufferLength;
426  else
427  Irp->IoStatus.Information = 0;
428 
429  return(Status);
430 }
DWORD *typedef PVOID
Definition: winlogon.h:52
static NTSTATUS CdfsGetAllInformation(PFILE_OBJECT FileObject, PFCB Fcb, PFILE_ALL_INFORMATION Info, PULONG BufferLength)
Definition: finfo.c:261
#define STATUS_SUCCESS
Definition: contextmenu.cpp:55
static NTSTATUS CdfsGetInternalInformation(PFCB Fcb, PFILE_INTERNAL_INFORMATION InternalInfo, PULONG BufferLength)
Definition: finfo.c:196
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
_In_ PIRP Irp
Definition: csq.h:116
Definition: cdfs.h:191
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
union _IO_STACK_LOCATION::@3189 Parameters
static OUT PIO_STATUS_BLOCK OUT PVOID IN ULONG IN FILE_INFORMATION_CLASS FileInformationClass
Definition: pipe.c:75
_In_ PLARGE_INTEGER _In_ ULONG _In_ BOOLEAN _In_ ULONG _Out_ PVOID _Out_ PIO_STATUS_BLOCK _In_ PDEVICE_OBJECT DeviceObject
Definition: npfs.h:636
static NTSTATUS CdfsGetBasicInformation(PFILE_OBJECT FileObject, PFCB Fcb, PDEVICE_OBJECT DeviceObject, PFILE_BASIC_INFORMATION BasicInfo, PULONG BufferLength)
Definition: finfo.c:109
enum _FILE_INFORMATION_CLASS FILE_INFORMATION_CLASS
Definition: file.c:104
struct _IO_STACK_LOCATION::@3189::@3195 QueryFile
_In_ ULONG BufferLength
Definition: usbdlib.h:225
static NTSTATUS CdfsGetNetworkOpenInformation(PFCB Fcb, PFILE_NETWORK_OPEN_INFORMATION NetworkInfo, PULONG BufferLength)
Definition: finfo.c:220
_In_ PFILE_OBJECT FileObject
Definition: classpnp.h:1229
void DPRINT(...)
Definition: polytest.cpp:61
* PFILE_OBJECT
Definition: iotypes.h:1949
Status
Definition: gdiplustypes.h:24
static NTSTATUS CdfsGetPositionInformation(PFILE_OBJECT FileObject, PFILE_POSITION_INFORMATION PositionInfo, PULONG BufferLength)
Definition: finfo.c:85
#define NT_SUCCESS(StatCode)
Definition: cmd.c:149
PFILE_OBJECT FileObject
Definition: iotypes.h:2787
LONG NTSTATUS
Definition: DriverTester.h:11
PDEVICE_OBJECT DeviceObject
Definition: cdfs.h:272
static NTSTATUS CdfsGetNameInformation(PFILE_OBJECT FileObject, PFCB Fcb, PDEVICE_OBJECT DeviceObject, PFILE_NAME_INFORMATION NameInfo, PULONG BufferLength)
Definition: finfo.c:145
PIO_STACK_LOCATION Stack
Definition: cdfs.h:266
PVOID PIRP
Definition: usb.h:38
unsigned int ULONG
Definition: retypes.h:1
static NTSTATUS CdfsGetStandardInformation(PFCB Fcb, PDEVICE_OBJECT DeviceObject, PFILE_STANDARD_INFORMATION StandardInfo, PULONG BufferLength)
Definition: finfo.c:42
#define STATUS_BUFFER_OVERFLOW
Definition: udferr_usr.h:127
NTSTATUS NTAPI CdfsQueryVolumeInformation ( PCDFS_IRP_CONTEXT  IrpContext)

Definition at line 208 of file volinfo.c.

Referenced by CdfsDispatch().

210 {
211  PIRP Irp;
214  PIO_STACK_LOCATION Stack;
216  PVOID SystemBuffer;
218 
219  DPRINT("CdfsQueryVolumeInformation() called\n");
220 
221  ASSERT(IrpContext);
222 
223  Irp = IrpContext->Irp;
224  DeviceObject = IrpContext->DeviceObject;
225  Stack = IrpContext->Stack;
226  FsInformationClass = Stack->Parameters.QueryVolume.FsInformationClass;
227  BufferLength = Stack->Parameters.QueryVolume.Length;
228  SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
229 
230  DPRINT("FsInformationClass %d\n", FsInformationClass);
231  DPRINT("SystemBuffer %p\n", SystemBuffer);
232 
233  switch (FsInformationClass)
234  {
236  Status = CdfsGetFsVolumeInformation(DeviceObject,
237  SystemBuffer,
238  &BufferLength);
239  break;
240 
242  Status = CdfsGetFsAttributeInformation(DeviceObject->DeviceExtension,
243  SystemBuffer,
244  &BufferLength);
245  break;
246 
248  Status = CdfsGetFsSizeInformation(DeviceObject,
249  SystemBuffer,
250  &BufferLength);
251  break;
252 
254  Status = CdfsGetFsDeviceInformation(DeviceObject,
255  SystemBuffer,
256  &BufferLength);
257  break;
258 
260  Status = CdfsGetFsFullSizeInformation(DeviceObject,
261  SystemBuffer,
262  &BufferLength);
263  break;
264 
265  default:
266  Status = STATUS_NOT_SUPPORTED;
267  }
268 
269  if (NT_SUCCESS(Status))
270  Irp->IoStatus.Information =
271  Stack->Parameters.QueryVolume.Length - BufferLength;
272  else
273  Irp->IoStatus.Information = 0;
274 
275  return Status;
276 }
DWORD *typedef PVOID
Definition: winlogon.h:52
#define STATUS_SUCCESS
Definition: contextmenu.cpp:55
static NTSTATUS CdfsGetFsAttributeInformation(PDEVICE_EXTENSION DeviceExt, PFILE_FS_ATTRIBUTE_INFORMATION FsAttributeInfo, PULONG BufferLength)
Definition: volinfo.c:83
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ FS_INFORMATION_CLASS FsInformationClass
Definition: fltkernel.h:1329
struct _IO_STACK_LOCATION::@3189::@3199 QueryVolume
_In_ PIRP Irp
Definition: csq.h:116
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
union _IO_STACK_LOCATION::@3189 Parameters
#define FileFsFullSizeInformation
Definition: ntifs_ex.h:389
_In_ PLARGE_INTEGER _In_ ULONG _In_ BOOLEAN _In_ ULONG _Out_ PVOID _Out_ PIO_STATUS_BLOCK _In_ PDEVICE_OBJECT DeviceObject
Definition: npfs.h:636
static NTSTATUS CdfsGetFsFullSizeInformation(PDEVICE_OBJECT DeviceObject, PFILE_FS_FULL_SIZE_INFORMATION FsSizeInfo, PULONG BufferLength)
Definition: volinfo.c:176
_In_ ULONG BufferLength
Definition: usbdlib.h:225
static NTSTATUS CdfsGetFsSizeInformation(PDEVICE_OBJECT DeviceObject, PFILE_FS_SIZE_INFORMATION FsSizeInfo, PULONG BufferLength)
Definition: volinfo.c:118
PVOID DeviceExtension
Definition: env_spec_w32.h:418
static NTSTATUS CdfsGetFsVolumeInformation(PDEVICE_OBJECT DeviceObject, PFILE_FS_VOLUME_INFORMATION FsVolumeInfo, PULONG BufferLength)
Definition: volinfo.c:39
void DPRINT(...)
Definition: polytest.cpp:61
enum _FSINFOCLASS FS_INFORMATION_CLASS
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: cmd.c:149
LONG NTSTATUS
Definition: DriverTester.h:11
PDEVICE_OBJECT DeviceObject
Definition: cdfs.h:272
static NTSTATUS CdfsGetFsDeviceInformation(PDEVICE_OBJECT DeviceObject, PFILE_FS_DEVICE_INFORMATION FsDeviceInfo, PULONG BufferLength)
Definition: volinfo.c:149
PIO_STACK_LOCATION Stack
Definition: cdfs.h:266
PVOID PIRP
Definition: usb.h:38
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS NTAPI CdfsRead ( PCDFS_IRP_CONTEXT  IrpContext)

Definition at line 189 of file rw.c.

Referenced by CdfsDispatch().

191 {
192  PIRP Irp;
193  PIO_STACK_LOCATION Stack;
195  PVOID Buffer = NULL;
196  ULONG ReadLength;
197  LARGE_INTEGER ReadOffset;
198  ULONG ReturnedReadLength = 0;
200 
201  DPRINT("CdfsRead(%p)\n", IrpContext);
202 
203  ASSERT(IrpContext);
204 
205  Irp = IrpContext->Irp;
206  Stack = IrpContext->Stack;
207 
208  FileObject = Stack->FileObject;
209 
210  ReadLength = Stack->Parameters.Read.Length;
211  ReadOffset = Stack->Parameters.Read.ByteOffset;
212  if (ReadLength) Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
213 
214  Status = CdfsReadFile(IrpContext,
215  FileObject,
216  Buffer,
217  ReadLength,
218  ReadOffset.u.LowPart,
219  Irp->Flags,
220  &ReturnedReadLength);
221  if (NT_SUCCESS(Status))
222  {
223  if (FileObject->Flags & FO_SYNCHRONOUS_IO)
224  {
225  FileObject->CurrentByteOffset.QuadPart =
226  ReadOffset.QuadPart + ReturnedReadLength;
227  }
228  Irp->IoStatus.Information = ReturnedReadLength;
229  }
230  else
231  {
232  Irp->IoStatus.Information = 0;
233  }
234 
235  return(Status);
236 }
DWORD *typedef PVOID
Definition: winlogon.h:52
#define STATUS_SUCCESS
Definition: contextmenu.cpp:55
_In_ PIRP Irp
Definition: csq.h:116
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
union _IO_STACK_LOCATION::@3189 Parameters
struct _LARGE_INTEGER::@1855 u
#define FO_SYNCHRONOUS_IO
Definition: iotypes.h:1727
struct _IO_STACK_LOCATION::@3189::@3191 Read
smooth NULL
Definition: ftsmooth.c:464
_In_ PFILE_OBJECT FileObject
Definition: classpnp.h:1229
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
static NTSTATUS CdfsReadFile(PCDFS_IRP_CONTEXT IrpContext, PFILE_OBJECT FileObject, PUCHAR Buffer, ULONG Length, ULONG ReadOffset, ULONG IrpFlags, PULONG LengthRead)
Definition: rw.c:44
* PFILE_OBJECT
Definition: iotypes.h:1949
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: cmd.c:149
PFILE_OBJECT FileObject
Definition: iotypes.h:2787
LONG NTSTATUS
Definition: DriverTester.h:11
PIO_STACK_LOCATION Stack
Definition: cdfs.h:266
PVOID PIRP
Definition: usb.h:38
unsigned int ULONG
Definition: retypes.h:1
#define MmGetSystemAddressForMdl(Mdl)
LONGLONG QuadPart
Definition: typedefs.h:113
NTSTATUS CdfsReadSectors ( IN PDEVICE_OBJECT  DeviceObject,
IN ULONG  DiskSector,
IN ULONG  SectorCount,
IN OUT PUCHAR  Buffer,
IN BOOLEAN  Override 
)

Definition at line 38 of file common.c.

Referenced by CdfsGetVolumeData(), and CdfsReadFile().

43 {
44  PIO_STACK_LOCATION Stack;
47  ULONG BlockSize;
48  KEVENT Event;
49  PIRP Irp;
51  BOOLEAN LastChance = FALSE;
52 
53 again:
54  KeInitializeEvent(&Event,
56  FALSE);
57 
58  Offset.u.LowPart = DiskSector << 11;
59  Offset.u.HighPart = DiskSector >> 21;
60 
61  BlockSize = BLOCKSIZE * SectorCount;
62 
63  DPRINT("CdfsReadSectors(DeviceObject %p, DiskSector %u, Buffer %p)\n",
64  DeviceObject, DiskSector, Buffer);
65  DPRINT("Offset %I64x BlockSize %u\n",
66  Offset.QuadPart,
67  BlockSize);
68 
69  DPRINT("Building synchronous FSD Request...\n");
72  Buffer,
73  BlockSize,
74  &Offset,
75  &Event,
76  &IoStatus);
77  if (Irp == NULL)
78  {
79  DPRINT("IoBuildSynchronousFsdRequest failed\n");
81  }
82 
83  if (Override)
84  {
85  Stack = IoGetNextIrpStackLocation(Irp);
87  }
88 
89  DPRINT("Calling IO Driver... with irp %p\n", Irp);
90  Status = IoCallDriver(DeviceObject, Irp);
91 
92  DPRINT("Waiting for IO Operation for %p\n", Irp);
93  if (Status == STATUS_PENDING)
94  {
95  DPRINT("Operation pending\n");
97  DPRINT("Getting IO Status... for %p\n", Irp);
98  Status = IoStatus.Status;
99  }
100 
101  if (!NT_SUCCESS(Status))
102  {
103  if (Status == STATUS_VERIFY_REQUIRED)
104  {
105  PDEVICE_OBJECT DeviceToVerify;
106 
107  DeviceToVerify = IoGetDeviceToVerify(PsGetCurrentThread());
109 
110  Status = IoVerifyVolume(DeviceToVerify, FALSE);
111 
112  if (NT_SUCCESS(Status) && !LastChance)
113  {
114  DPRINT("Volume verify succeeded; trying request again\n");
115  LastChance = TRUE;
116  goto again;
117  }
118  else if (NT_SUCCESS(Status))
119  {
120  DPRINT1("Failed to read after successful verify, aborting\n");
121  Status = STATUS_DEVICE_NOT_READY;
122  }
123  else
124  {
125  DPRINT1("IoVerifyVolume() failed (Status %lx)\n", Status);
126  }
127  }
128 
129  DPRINT("CdfsReadSectors() failed (Status %x)\n", Status);
130  DPRINT("(DeviceObject %p, DiskSector %u, Buffer %p, Offset 0x%I64x)\n",
131  DeviceObject, DiskSector, Buffer,
132  Offset.QuadPart);
133  return(Status);
134  }
135 
136  DPRINT("Block request succeeded for %p\n", Irp);
137 
138  return(STATUS_SUCCESS);
139 }
#define STATUS_SUCCESS
Definition: contextmenu.cpp:55
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
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:1006
_In_ PIRP Irp
Definition: csq.h:116
#define BLOCKSIZE
Definition: urlcache.c:40
#define TRUE
Definition: numbers.c:17
struct _LARGE_INTEGER::@1855 u
PDEVICE_OBJECT NTAPI IoGetDeviceToVerify(IN PETHREAD Thread)
Definition: util.c:304
_In_ PLARGE_INTEGER _In_ ULONG _In_ BOOLEAN _In_ ULONG _Out_ PVOID _Out_ PIO_STATUS_BLOCK _In_ PDEVICE_OBJECT DeviceObject
Definition: npfs.h:636
#define STATUS_VERIFY_REQUIRED
Definition: udferr_usr.h:130
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
ACPI_EFI_EVENT Event
Definition: acefiex.h:607
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
smooth NULL
Definition: ftsmooth.c:464
#define SL_OVERRIDE_VERIFY_VOLUME
Definition: iotypes.h:1774
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
unsigned char BOOLEAN
#define STATUS_PENDING
Definition: ntstatus.h:82
ULONG SectorCount
Definition: part_xbox.c:32
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
Status
Definition: gdiplustypes.h:24
_In_ PLARGE_INTEGER _In_ ULONG _In_ BOOLEAN _In_ ULONG _Out_ PVOID _Out_ PIO_STATUS_BLOCK IoStatus
Definition: npfs.h:636
#define NT_SUCCESS(StatCode)
Definition: cmd.c:149
LONG NTSTATUS
Definition: DriverTester.h:11
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1155
#define DPRINT1
Definition: precomp.h:8
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define FALSE
Definition: numbers.c:16
PVOID PIRP
Definition: usb.h:38
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS NTAPI IoVerifyVolume(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN AllowRawMount)
Definition: volume.c:874
VOID NTAPI IoSetDeviceToVerify(IN PETHREAD Thread, IN PDEVICE_OBJECT DeviceObject)
Definition: util.c:280
LONGLONG QuadPart
Definition: typedefs.h:113
#define STATUS_DEVICE_NOT_READY
Definition: udferr_usr.h:162
VOID CdfsReleaseFCB ( PDEVICE_EXTENSION  Vcb,
PFCB  Fcb 
)

Definition at line 153 of file fcb.c.

Referenced by CdfsCloseFile(), CdfsGetFCBForFile(), and CdfsOpenFile().

155 {
156  KIRQL oldIrql;
157 
158  DPRINT("releasing FCB at %p: %wZ, refCount:%d\n",
159  Fcb,
160  &Fcb->PathName,
161  Fcb->RefCount);
162 
163  KeAcquireSpinLock(&Vcb->FcbListLock, &oldIrql);
164  Fcb->RefCount--;
165  if (Fcb->RefCount <= 0 && !CdfsFCBIsDirectory(Fcb))
166  {
168  CdfsDestroyFCB(Fcb);
169  }
170  KeReleaseSpinLock(&Vcb->FcbListLock, oldIrql);
171 }
LIST_ENTRY FcbListEntry
Definition: cdfs.h:208
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
UCHAR KIRQL
Definition: env_spec_w32.h:591
BOOLEAN CdfsFCBIsDirectory(PFCB Fcb)
Definition: fcb.c:122
UNICODE_STRING PathName
Definition: cdfs.h:204
LONG RefCount
Definition: cdfs.h:216
void DPRINT(...)
Definition: polytest.cpp:61
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
VOID CdfsDestroyFCB(PFCB Fcb)
Definition: fcb.c:101
VOID NTAPI CdfsReleaseFromLazyWrite ( IN PVOID  Context)

Referenced by DriverEntry().

NTSTATUS NTAPI CdfsSetInformation ( PCDFS_IRP_CONTEXT  IrpContext)

Definition at line 456 of file finfo.c.

Referenced by CdfsDispatch().

458 {
459  PIRP Irp;
461  PIO_STACK_LOCATION Stack;
463  PVOID SystemBuffer;
464 
466 
467  DPRINT("CdfsSetInformation() called\n");
468 
469  Irp = IrpContext->Irp;
470  Stack = IrpContext->Stack;
471  FileInformationClass = Stack->Parameters.SetFile.FileInformationClass;
472  FileObject = Stack->FileObject;
473 
474  SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
475 
476  switch (FileInformationClass)
477  {
479  Status = CdfsSetPositionInformation(FileObject,
480  SystemBuffer);
481  break;
482 
485  Status = STATUS_NOT_IMPLEMENTED;
486  break;
487 
488  default:
489  Status = STATUS_NOT_SUPPORTED;
490  break;
491  }
492 
493  Irp->IoStatus.Information = 0;
494 
495  return Status;
496 }
DWORD *typedef PVOID
Definition: winlogon.h:52
#define STATUS_SUCCESS
Definition: contextmenu.cpp:55
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
_In_ PIRP Irp
Definition: csq.h:116
union _IO_STACK_LOCATION::@3189 Parameters
static OUT PIO_STATUS_BLOCK OUT PVOID IN ULONG IN FILE_INFORMATION_CLASS FileInformationClass
Definition: pipe.c:75
enum _FILE_INFORMATION_CLASS FILE_INFORMATION_CLASS
Definition: file.c:104
_In_ PFILE_OBJECT FileObject
Definition: classpnp.h:1229
void DPRINT(...)
Definition: polytest.cpp:61
struct _IO_STACK_LOCATION::@3189::@3196 SetFile
* PFILE_OBJECT
Definition: iotypes.h:1949
Status
Definition: gdiplustypes.h:24
PFILE_OBJECT FileObject
Definition: iotypes.h:2787
LONG NTSTATUS
Definition: DriverTester.h:11
PIO_STACK_LOCATION Stack
Definition: cdfs.h:266
PVOID PIRP
Definition: usb.h:38
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
static NTSTATUS CdfsSetPositionInformation(PFILE_OBJECT FileObject, PFILE_POSITION_INFORMATION PositionInfo)
Definition: finfo.c:437
NTSTATUS NTAPI CdfsSetVolumeInformation ( PCDFS_IRP_CONTEXT  IrpContext)

Definition at line 281 of file volinfo.c.

Referenced by CdfsDispatch().

283 {
284  DPRINT("CdfsSetVolumeInformation() called\n");
285 
286  ASSERT(IrpContext);
287 
288  IrpContext->Irp->IoStatus.Information = 0;
289 
290  return STATUS_NOT_SUPPORTED;
291 }
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
void DPRINT(...)
Definition: polytest.cpp:61
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
VOID CdfsShortNameCacheGet ( PFCB  DirectoryFcb,
PLARGE_INTEGER  StreamOffset,
PUNICODE_STRING  LongName,
PUNICODE_STRING  ShortName 
)

Definition at line 254 of file misc.c.

Referenced by CdfsDirFindFile(), and CdfsFindFile().

258 {
260  PCDFS_SHORT_NAME ShortNameEntry;
262 
263  DPRINT("CdfsShortNameCacheGet(%I64d,%wZ)\n", StreamOffset->QuadPart, LongName);
264 
265  /* Get the name list resource */
267 
268  /* Try to find the name in our cache */
269  for (Entry = DirectoryFcb->ShortNameList.Flink;
270  Entry != &DirectoryFcb->ShortNameList;
271  Entry = Entry->Flink)
272  {
273  ShortNameEntry = CONTAINING_RECORD(Entry, CDFS_SHORT_NAME, Entry);
274  if (ShortNameEntry->StreamOffset.QuadPart == StreamOffset->QuadPart)
275  {
276  /* Cache hit */
277  RtlCopyUnicodeString(ShortName, &ShortNameEntry->Name);
278  ExReleaseResourceLite(&DirectoryFcb->NameListResource);
279  DPRINT("Yield short name %wZ from cache\n", ShortName);
280  return;
281  }
282  }
283 
284  /* Cache miss */
285  if (!CdfsIsNameLegalDOS8Dot3(*LongName))
286  {
287  RtlGenerate8dot3Name(LongName, FALSE, &Context, ShortName);
288  }
289  else
290  {
291  /* copy short name */
293  (ShortName,
294  LongName,
295  FALSE);
296  }
297 
298  DPRINT("Initial Guess %wZ\n", ShortName);
299 
300  /* Make it unique by scanning the cache and bumping */
301  /* Note that incrementing the ambiguous name is enough, since we add new
302  * entries at the tail. We'll scan over all collisions. */
303  /* XXX could perform better. */
304  for (Entry = DirectoryFcb->ShortNameList.Flink;
305  Entry != &DirectoryFcb->ShortNameList;
306  Entry = Entry->Flink)
307  {
308  ShortNameEntry = CONTAINING_RECORD(Entry, CDFS_SHORT_NAME, Entry);
310  (ShortName,
311  &ShortNameEntry->Name,
312  TRUE) == 0) /* Match */
313  {
314  RtlGenerate8dot3Name(LongName, FALSE, &Context, ShortName);
315  DPRINT("Collide; try %wZ\n", ShortName);
316  }
317  }
318 
319  /* We've scanned over all entries and now have a unique one. Cache it. */
320  ShortNameEntry = ExAllocatePoolWithTag(PagedPool,
321  sizeof(CDFS_SHORT_NAME),
323  if (!ShortNameEntry)
324  {
325  /* We couldn't cache it, but we can return it. We run the risk of
326  * generating a non-unique name later. */
327  ExReleaseResourceLite(&DirectoryFcb->NameListResource);
328  DPRINT1("Couldn't cache potentially clashing 8.3 name %wZ\n", ShortName);
329  return;
330  }
331 
332  ShortNameEntry->StreamOffset = *StreamOffset;
333  RtlInitEmptyUnicodeString(&ShortNameEntry->Name,
334  ShortNameEntry->NameBuffer,
335  sizeof(ShortNameEntry->NameBuffer));
336  RtlCopyUnicodeString(&ShortNameEntry->Name, ShortName);
337  InsertTailList(&DirectoryFcb->ShortNameList, &ShortNameEntry->Entry);
338  ExReleaseResourceLite(&DirectoryFcb->NameListResource);
339 
340  DPRINT("Returning short name %wZ for long name %wZ\n", ShortName, LongName);
341 }
LIST_ENTRY ShortNameList
Definition: cdfs.h:222
NTSTATUS RtlUpcaseUnicodeString(PUNICODE_STRING dst, PUNICODE_STRING src, BOOLEAN Alloc)
Definition: string_lib.cpp:46
struct _Entry Entry
Definition: kefuncs.h:640
UNICODE_STRING Name
Definition: cdfs.h:187
BOOLEAN CdfsIsNameLegalDOS8Dot3(IN UNICODE_STRING FileName)
Definition: misc.c:170
#define TRUE
Definition: numbers.c:17
WCHAR NameBuffer[13]
Definition: cdfs.h:188
ERESOURCE NameListResource
Definition: cdfs.h:221
#define InsertTailList(ListHead, Entry)
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
#define CDFS_SHORT_NAME_TAG
Definition: cdfs.h:244
void DPRINT(...)
Definition: polytest.cpp:61
struct _LIST_ENTRY * Flink
Definition: typedefs.h:120
LARGE_INTEGER StreamOffset
Definition: cdfs.h:186
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
Definition: typedefs.h:118
NTSYSAPI VOID NTAPI RtlGenerate8dot3Name(_In_ PCUNICODE_STRING Name, _In_ BOOLEAN AllowExtendedCharacters, _Inout_ PGENERATE_NAME_CONTEXT Context, _Inout_ PUNICODE_STRING Name8dot3)
#define DPRINT1
Definition: precomp.h:8
#define FALSE
Definition: numbers.c:16
LIST_ENTRY Entry
Definition: cdfs.h:185
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
LONGLONG QuadPart
Definition: typedefs.h:113
VOID CdfsSwapString ( PWCHAR  Out,
PUCHAR  In,
ULONG  Count 
)

Definition at line 110 of file misc.c.

Referenced by CdfsGetDirEntryName().

113 {
114  PUCHAR t = (PUCHAR)Out;
115  ULONG i;
116 
117  for (i = 0; i < Count; i += 2)
118  {
119  t[i] = In[i+1];
120  t[i+1] = In[i];
121  if (t[i+1] == 0 && t[i] == ';')
122  break;
123  }
124  if ((i>2)&&(t[i-2] == '.'))
125  {
126  t[i-2] = 0;
127  t[i-1] = 0;
128  }
129  t[i] = 0;
130  t[i+1] = 0;
131 }
unsigned char * PUCHAR
Definition: retypes.h:3
GLdouble GLdouble t
Definition: gl.h:2047
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
GLenum GLclampf GLint i
Definition: glfuncs.h:14
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS NTAPI CdfsWrite ( PCDFS_IRP_CONTEXT  IrpContext)

Definition at line 240 of file rw.c.

Referenced by CdfsDispatch().

242 {
243  DPRINT("CdfsWrite(%p)\n", IrpContext);
244 
245  ASSERT(IrpContext);
246 
247  IrpContext->Irp->IoStatus.Information = 0;
248  return(STATUS_NOT_SUPPORTED);
249 }
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
void DPRINT(...)
Definition: polytest.cpp:61
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
NTSTATUS NTAPI DriverEntry ( PDRIVER_OBJECT  DriverObject,
PUNICODE_STRING  RegistryPath 
)

Definition at line 16 of file battc.c.

18 {
19  DPRINT("Battery class driver initialized\n");
20 
21  return STATUS_SUCCESS;
22 }
#define STATUS_SUCCESS
Definition: contextmenu.cpp:55
void DPRINT(...)
Definition: polytest.cpp:61

Variable Documentation

FAST_IO_CHECK_IF_POSSIBLE CdfsFastIoCheckIfPossible

Definition at line 367 of file cdfs.h.

Referenced by DriverEntry().

FAST_IO_READ CdfsFastIoRead

Definition at line 368 of file cdfs.h.

Referenced by DriverEntry().

FAST_IO_WRITE CdfsFastIoWrite

Definition at line 369 of file cdfs.h.

Referenced by DriverEntry().

DRIVER_DISPATCH CdfsFsdDispatch

Definition at line 349 of file cdfs.h.

Referenced by DriverEntry().