ReactOS 0.4.16-dev-287-g2d3f3a1
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{
203}
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42

◆ 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{
191}

◆ 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 PAGED_CODE()
VOID FLTAPI FltObjectDereference(_Inout_ PVOID Object)
Definition: Object.c:53
NTSTATUS FLTAPI FltObjectReference(_Inout_ PVOID Object)
Definition: Object.c:41
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define ExAcquireResourceSharedLite(res, wait)
Definition: env_spec_w32.h:621
_Must_inspect_result_ _In_ ULONG VolumeListSize
Definition: fltkernel.h:1792
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1801
_Must_inspect_result_ _In_ ULONG _Out_ PULONG NumberVolumesReturned
Definition: fltkernel.h:1793
Status
Definition: gdiplustypes.h:25
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define KeLeaveCriticalRegion()
Definition: ke_x.h:119
#define KeEnterCriticalRegion()
Definition: ke_x.h:88
UNICODE_STRING Volume
Definition: fltkernel.h:1172
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2451
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1822
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
FLT_RESOURCE_LIST_HEAD AttachedVolumes
Definition: fltmgrint.h:80
PFLTP_FRAME Frame
Definition: fltmgrint.h:99
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59

◆ 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 {
245 }
246
247 return Status;
248}
_Must_inspect_result_ _Inout_opt_ PUNICODE_STRING VolumeName
Definition: fltkernel.h:1117
_Must_inspect_result_ _Inout_opt_ PUNICODE_STRING _Out_opt_ PULONG BufferSizeNeeded
Definition: fltkernel.h:1118
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135

◆ 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}
_In_ ULONG VolumePropertiesLength
Definition: fltkernel.h:1734
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ FILE_INFORMATION_CLASS _Out_opt_ PULONG LengthReturned
Definition: fltkernel.h:1308
struct _FLT_VOLUME_PROPERTIES FLT_VOLUME_PROPERTIES
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
if(dx< 0)
Definition: linetemp.h:194
#define PCHAR
Definition: match.c:90
WCHAR * PWCH
Definition: ntbasedef.h:418
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
char * PCHAR
Definition: typedefs.h:51
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesWritten
Definition: wdfiotarget.h:960

Referenced by FilterInstanceSetup().