ReactOS  0.4.13-dev-651-g5dbc677
Volume.c File Reference
#include "fltmgr.h"
#include "fltmgrint.h"
#include <debug.h>
Include dependency graph for Volume.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS FLTAPI FltGetVolumeProperties (_In_ PFLT_VOLUME Volume, _Out_writes_bytes_to_opt_(VolumePropertiesLength, *LengthReturned) PFLT_VOLUME_PROPERTIES VolumeProperties, _In_ ULONG VolumePropertiesLength, _Out_ PULONG LengthReturned)
 
NTSTATUS FLTAPI FltEnumerateVolumes (_In_ PFLT_FILTER Filter, _Out_writes_to_opt_(VolumeListSize, *NumberVolumesReturned) PFLT_VOLUME *VolumeList, _In_ ULONG VolumeListSize, _Out_ PULONG NumberVolumesReturned)
 
NTSTATUS FLTAPI FltDetachVolume (_Inout_ PFLT_FILTER Filter, _Inout_ PFLT_VOLUME Volume, _In_opt_ PCUNICODE_STRING InstanceName)
 
NTSTATUS FLTAPI FltAttachVolume (_Inout_ PFLT_FILTER Filter, _Inout_ PFLT_VOLUME Volume, _In_opt_ PCUNICODE_STRING InstanceName, _Outptr_opt_result_maybenull_ PFLT_INSTANCE *RetInstance)
 
NTSTATUS FLTAPI FltGetVolumeName (_In_ PFLT_VOLUME Volume, _Inout_opt_ PUNICODE_STRING VolumeName, _Out_opt_ PULONG BufferSizeNeeded)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file Volume.c.

Function Documentation

◆ FltAttachVolume()

NTSTATUS FLTAPI FltAttachVolume ( _Inout_ PFLT_FILTER  Filter,
_Inout_ PFLT_VOLUME  Volume,
_In_opt_ PCUNICODE_STRING  InstanceName,
_Outptr_opt_result_maybenull_ PFLT_INSTANCE RetInstance 
)

Definition at line 195 of file Volume.c.

200 {
202  return STATUS_NOT_IMPLEMENTED;
203 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define UNIMPLEMENTED
Definition: debug.h:114

◆ FltDetachVolume()

NTSTATUS FLTAPI FltDetachVolume ( _Inout_ PFLT_FILTER  Filter,
_Inout_ PFLT_VOLUME  Volume,
_In_opt_ PCUNICODE_STRING  InstanceName 
)

Definition at line 184 of file Volume.c.

188 {
190  return STATUS_NOT_IMPLEMENTED;
191 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define UNIMPLEMENTED
Definition: debug.h:114

◆ FltEnumerateVolumes()

NTSTATUS FLTAPI FltEnumerateVolumes ( _In_ PFLT_FILTER  Filter,
_Out_writes_to_opt_(VolumeListSize, *NumberVolumesReturned) PFLT_VOLUME VolumeList,
_In_ ULONG  VolumeListSize,
_Out_ PULONG  NumberVolumesReturned 
)

Definition at line 112 of file Volume.c.

117 {
118  ULONG i;
119  PFLTP_FRAME Frame;
121  PLIST_ENTRY ListEntry;
122  ULONG NumberOfVolumes = 0;
124 
125  PAGED_CODE();
126 
127  Frame = Filter->Frame;
128 
129  /* Lock the attached volumes list */
132 
133  /* If it's not empty */
134  if (!IsListEmpty(&Frame->AttachedVolumes.rList))
135  {
136  /* Browse every entry */
137  for (ListEntry = Frame->AttachedVolumes.rList.Flink;
138  ListEntry != &Frame->AttachedVolumes.rList;
139  ListEntry = ListEntry->Flink)
140  {
141  /* Get the volume */
142  Volume = CONTAINING_RECORD(ListEntry, FLT_VOLUME, Base.PrimaryLink);
143 
144  /* If there's still room in the output buffer */
145  if (NumberOfVolumes < VolumeListSize)
146  {
147  /* Reference the volume and return it */
149  VolumeList[NumberOfVolumes] = Volume;
150  }
151 
152  /* We returned one more volume */
153  ++NumberOfVolumes;
154  }
155  }
156 
157  /* Release the list */
160 
161  /* If we want to return more volumes than we can */
162  if (NumberOfVolumes > VolumeListSize)
163  {
164  /* We will clear output */
165  for (i = 0; i < VolumeListSize; ++i)
166  {
167  FltObjectDereference(VolumeList[i]);
168  VolumeList[i] = NULL;
169  }
170 
171  /* And set failure status */
173  }
174 
175  /* Always return the max amount of volumes we want to return */
176  *NumberVolumesReturned = NumberOfVolumes;
177 
178  /* Done */
179  return Status;
180 }
#define TRUE
Definition: types.h:120
VOID FLTAPI FltObjectDereference(_Inout_ PVOID Object)
Definition: Object.c:53
LONG NTSTATUS
Definition: precomp.h:26
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2343
_Must_inspect_result_ _In_ ULONG _Out_ PULONG NumberVolumesReturned
Definition: fltkernel.h:1793
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define PAGED_CODE()
Definition: video.h:57
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1802
FLT_RESOURCE_LIST_HEAD AttachedVolumes
Definition: fltmgrint.h:80
smooth NULL
Definition: ftsmooth.c:416
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
PFLTP_FRAME Frame
Definition: fltmgrint.h:99
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
#define KeEnterCriticalRegion()
Definition: ke_x.h:83
Definition: typedefs.h:117
Status
Definition: gdiplustypes.h:24
#define KeLeaveCriticalRegion()
Definition: ke_x.h:114
NTSTATUS FLTAPI FltObjectReference(_Inout_ PVOID Object)
Definition: Object.c:41
_Must_inspect_result_ _In_ ULONG VolumeListSize
Definition: fltkernel.h:1793
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2777

◆ FltGetVolumeName()

NTSTATUS FLTAPI FltGetVolumeName ( _In_ PFLT_VOLUME  Volume,
_Inout_opt_ PUNICODE_STRING  VolumeName,
_Out_opt_ PULONG  BufferSizeNeeded 
)

Definition at line 207 of file Volume.c.

211 {
213 
214  /* Check if caller just probes for size */
215  if (VolumeName == NULL)
216  {
217  /* Totally broken call */
218  if (BufferSizeNeeded == NULL)
219  {
221  }
222 
223  /* Return the appropriate size and quit */
224  *BufferSizeNeeded = Volume->DeviceName.Length;
226  }
227 
228  /* We have an output buffer! Assume it's too small */
230 
231  /* If we have output size, fill it */
232  if (BufferSizeNeeded != NULL)
233  {
234  *BufferSizeNeeded = Volume->DeviceName.Length;
235  }
236 
237  /* Init that we didn't return a thing */
238  VolumeName->Length = 0;
239 
240  /* If we have enough room, copy and return success */
241  if (VolumeName->MaximumLength >= Volume->DeviceName.Length)
242  {
243  RtlCopyUnicodeString(VolumeName, &Volume->DeviceName);
245  }
246 
247  return Status;
248 }
_Must_inspect_result_ _Inout_opt_ PUNICODE_STRING _Out_opt_ PULONG BufferSizeNeeded
Definition: fltkernel.h:1117
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
smooth NULL
Definition: ftsmooth.c:416
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _Inout_opt_ PUNICODE_STRING VolumeName
Definition: fltkernel.h:1117
return STATUS_SUCCESS
Definition: btrfs.c:2777

◆ FltGetVolumeProperties()

NTSTATUS FLTAPI FltGetVolumeProperties ( _In_ PFLT_VOLUME  Volume,
_Out_writes_bytes_to_opt_(VolumePropertiesLength, *LengthReturned) PFLT_VOLUME_PROPERTIES  VolumeProperties,
_In_ ULONG  VolumePropertiesLength,
_Out_ PULONG  LengthReturned 
)

Definition at line 26 of file Volume.c.

32 {
33  ULONG BufferRequired;
35  PCHAR Ptr;
37 
38  /* Calculate the required buffer size */
39  BufferRequired = sizeof(FLT_VOLUME_PROPERTIES) +
40  Volume->CDODriverName.Length +
41  Volume->DeviceName.Length +
42  Volume->CDODeviceName.Length;
43 
44  /* If we don't have enough buffer to fill in the fixed struct, return with the required size */
46  {
47  *LengthReturned = BufferRequired;
49  }
50 
51  /* Clear out the buffer */
52  RtlZeroMemory(VolumeProperties, sizeof(FLT_VOLUME_PROPERTIES));
53 
54  /* Fill in the fixed data */
55  VolumeProperties->DeviceType = Volume->DeviceObject->DeviceType;
56  VolumeProperties->DeviceObjectFlags = Volume->DeviceObject->Flags;
57  VolumeProperties->AlignmentRequirement = Volume->DeviceObject->AlignmentRequirement;
58  VolumeProperties->SectorSize = Volume->DeviceObject->SectorSize;
59  if (Volume->DiskDeviceObject)
60  {
61  VolumeProperties->DeviceCharacteristics = Volume->DiskDeviceObject->Characteristics;
62  }
63  else
64  {
65  VolumeProperties->DeviceCharacteristics = Volume->DeviceObject->Characteristics;
66  }
67 
68  /* So far we've written the fixed struct data */
70  Ptr = (PCHAR)(VolumeProperties + 1);
71 
72  /* Make sure we have enough room to add the dynamic data */
73  if (VolumePropertiesLength >= BufferRequired)
74  {
75  /* Add the FS device name */
76  VolumeProperties->FileSystemDeviceName.Length = 0;
77  VolumeProperties->FileSystemDeviceName.MaximumLength = Volume->CDODeviceName.Length;
78  VolumeProperties->FileSystemDeviceName.Buffer = (PWCH)Ptr;
79  RtlCopyUnicodeString(&VolumeProperties->FileSystemDeviceName, &Volume->CDODeviceName);
80  Ptr += VolumeProperties->FileSystemDeviceName.Length;
81 
82  /* Add the driver name */
83  VolumeProperties->FileSystemDriverName.Length = 0;
84  VolumeProperties->FileSystemDriverName.MaximumLength = Volume->CDODriverName.Length;
85  VolumeProperties->FileSystemDriverName.Buffer = (PWCH)Ptr;
86  RtlCopyUnicodeString(&VolumeProperties->FileSystemDriverName, &Volume->CDODriverName);
87  Ptr += VolumeProperties->FileSystemDriverName.Length;
88 
89  /* Add the volume name */
90  VolumeProperties->RealDeviceName.Length = 0;
91  VolumeProperties->RealDeviceName.MaximumLength = Volume->DeviceName.Length;
92  VolumeProperties->RealDeviceName.Buffer = (PWCH)Ptr;
93  RtlCopyUnicodeString(&VolumeProperties->RealDeviceName, &Volume->DeviceName);
94 
95  BytesWritten = BufferRequired;
96 
98  }
99  else
100  {
102  }
103 
104  /* Set the number of bytes we wrote and return */
106  return Status;
107 }
signed char * PCHAR
Definition: retypes.h:7
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesWritten
Definition: fltkernel.h:1293
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
LONG NTSTATUS
Definition: precomp.h:26
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
_In_ ULONG VolumePropertiesLength
Definition: fltkernel.h:1735
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ FILE_INFORMATION_CLASS _Out_opt_ PULONG LengthReturned
Definition: fltkernel.h:1306
#define PCHAR
Definition: match.c:90
if(!(yy_init))
Definition: macro.lex.yy.c:714
WCHAR * PWCH
Definition: ntbasedef.h:417
Status
Definition: gdiplustypes.h:24
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
return STATUS_SUCCESS
Definition: btrfs.c:2777
struct _FLT_VOLUME_PROPERTIES FLT_VOLUME_PROPERTIES

Referenced by FilterInstanceSetup().