ReactOS 0.4.15-dev-8021-g7ce96fd
Volume.c
Go to the documentation of this file.
1/*
2* PROJECT: Filesystem Filter Manager
3* LICENSE: GPL - See COPYING in the top level directory
4* FILE: drivers/filters/fltmgr/Context.c
5* PURPOSE: Contains routines for the volume
6* PROGRAMMERS: Ged Murphy (gedmurphy@reactos.org)
7*/
8
9/* INCLUDES ******************************************************************/
10
11#include "fltmgr.h"
12#include "fltmgrint.h"
13
14#define NDEBUG
15#include <debug.h>
16
17
18/* DATA *********************************************************************/
19
20
21
22/* EXPORTED FUNCTIONS ******************************************************/
23
25FLTAPI
31)
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}
108
109
111FLTAPI
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}
181
183FLTAPI
188{
191}
192
194FLTAPI
200{
203}
204
206FLTAPI
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}
249
250
251/* INTERNAL FUNCTIONS ******************************************************/
#define PAGED_CODE()
VOID FLTAPI FltObjectDereference(_Inout_ PVOID Object)
Definition: Object.c:53
NTSTATUS FLTAPI FltObjectReference(_Inout_ PVOID Object)
Definition: Object.c:41
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: Volume.c:26
NTSTATUS FLTAPI FltDetachVolume(_Inout_ PFLT_FILTER Filter, _Inout_ PFLT_VOLUME Volume, _In_opt_ PCUNICODE_STRING InstanceName)
Definition: Volume.c:184
NTSTATUS FLTAPI FltAttachVolume(_Inout_ PFLT_FILTER Filter, _Inout_ PFLT_VOLUME Volume, _In_opt_ PCUNICODE_STRING InstanceName, _Outptr_opt_result_maybenull_ PFLT_INSTANCE *RetInstance)
Definition: Volume.c:195
NTSTATUS FLTAPI FltEnumerateVolumes(_In_ PFLT_FILTER Filter, _Out_writes_to_opt_(VolumeListSize, *NumberVolumesReturned) PFLT_VOLUME *VolumeList, _In_ ULONG VolumeListSize, _Out_ PULONG NumberVolumesReturned)
Definition: Volume.c:112
NTSTATUS FLTAPI FltGetVolumeName(_In_ PFLT_VOLUME Volume, _Inout_opt_ PUNICODE_STRING VolumeName, _Out_opt_ PULONG BufferSizeNeeded)
Definition: Volume.c:207
LONG NTSTATUS
Definition: precomp.h:26
#define UNIMPLEMENTED
Definition: debug.h:115
#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_ _Inout_opt_ PUNICODE_STRING VolumeName
Definition: fltkernel.h:1117
_Must_inspect_result_ _In_ ULONG VolumeListSize
Definition: fltkernel.h:1792
_Must_inspect_result_ _Inout_ PFLT_VOLUME _In_opt_ PCUNICODE_STRING InstanceName
Definition: fltkernel.h:1163
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1801
_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
_Must_inspect_result_ _Inout_opt_ PUNICODE_STRING _Out_opt_ PULONG BufferSizeNeeded
Definition: fltkernel.h:1118
_Must_inspect_result_ _Inout_ PFLT_VOLUME _In_opt_ PCUNICODE_STRING _Outptr_opt_result_maybenull_ PFLT_INSTANCE * RetInstance
Definition: fltkernel.h:1164
_Must_inspect_result_ _In_ ULONG _Out_ PULONG NumberVolumesReturned
Definition: fltkernel.h:1793
struct _FLT_VOLUME_PROPERTIES FLT_VOLUME_PROPERTIES
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
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
if(dx< 0)
Definition: linetemp.h:194
#define PCHAR
Definition: match.c:90
UNICODE_STRING Volume
Definition: fltkernel.h:1172
#define _Out_opt_
Definition: ms_sal.h:346
#define _Inout_
Definition: ms_sal.h:378
#define _Outptr_opt_result_maybenull_
Definition: ms_sal.h:430
#define _Inout_opt_
Definition: ms_sal.h:379
#define _Out_
Definition: ms_sal.h:345
#define _Out_writes_to_opt_(size, count)
Definition: ms_sal.h:356
#define _Out_writes_bytes_to_opt_(size, count)
Definition: ms_sal.h:361
#define _In_
Definition: ms_sal.h:308
#define _In_opt_
Definition: ms_sal.h:309
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2439
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
WCHAR * PWCH
Definition: ntbasedef.h:410
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1822
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
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
USHORT MaximumLength
Definition: env_spec_w32.h:370
uint32_t * PULONG
Definition: typedefs.h:59
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_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