29 _In_ PUNICODE_STRING VolumeName,
30 _In_ PUNICODE_STRING ParentPath,
31 _In_ PUNICODE_STRING FinalComponent,
37 _In_ PFILE_OBJECT Parent,
38 _In_ PUNICODE_STRING FinalComponent,
40 _In_ BOOLEAN Normalized,
66 #pragma alloc_text(PAGE, NcBuildMappingPath) 67 #pragma alloc_text(PAGE, NcBuildMappingPathFromFile) 68 #pragma alloc_text(PAGE, NcBuildMappingPathFromVolume) 69 #pragma alloc_text(PAGE, NcInitMappingPath) 70 #pragma alloc_text(PAGE, NcIsMappingPathZeroed) 71 #pragma alloc_text(PAGE, NcTeardownMappingPath) 72 #pragma alloc_text(PAGE, NcInitMappingEntry) 73 #pragma alloc_text(PAGE, NcIsMappingEntryZeroed) 74 #pragma alloc_text(PAGE, NcTeardownMappingEntry) 75 #pragma alloc_text(PAGE, NcInitMapping) 76 #pragma alloc_text(PAGE, NcIsMappingZeroed) 77 #pragma alloc_text(PAGE, NcTeardownMapping) 78 #pragma alloc_text(PAGE, NcBuildMapping) 92 if (Path->FullPath.Buffer !=
NULL ||
93 Path->FullPath.Length != 0 ||
94 Path->FullPath.MaximumLength != 0) {
99 if (Path->VolumePath.Buffer !=
NULL ||
100 Path->VolumePath.Length != 0 ||
101 Path->VolumePath.MaximumLength != 0) {
106 if (Path->ParentPath.Buffer !=
NULL ||
107 Path->ParentPath.Length != 0 ||
108 Path->ParentPath.MaximumLength != 0) {
113 if (Path->FinalComponentName.Buffer !=
NULL ||
114 Path->FinalComponentName.Length != 0 ||
115 Path->FinalComponentName.MaximumLength != 0) {
120 if (Path->VolumelessName.Buffer !=
NULL ||
121 Path->VolumelessName.Length != 0 ||
122 Path->VolumelessName.MaximumLength != 0) {
177 if (Path->FullPath.Buffer !=
NULL) {
193 _In_ PUNICODE_STRING VolumeName,
194 _In_ PUNICODE_STRING ParentPath,
195 _In_ PUNICODE_STRING FinalComponent,
221 NTSTATUS
Status = STATUS_SUCCESS;
223 PWCHAR NameBuffer =
NULL;
224 UNICODE_STRING NameString;
225 USHORT SeparatorLength;
244 ParentEnd = ParentPath->Buffer[(ParentPath->Length /
sizeof(WCHAR)) - 1];
248 SeparatorLength =
sizeof(WCHAR);
258 NameLength = VolumeName->Length + ParentPath->Length + SeparatorLength + FinalComponent->Length;
260 NameBuffer = ExAllocatePoolWithTag( PagedPool,
264 if (NameBuffer ==
NULL) {
266 Status = STATUS_INSUFFICIENT_RESOURCES;
267 goto NcBuildMappingPathCleanup;
274 NameString.Length = 0;
275 NameString.MaximumLength = NameLength;
276 NameString.Buffer = NameBuffer;
282 RtlCopyUnicodeString( &NameString, VolumeName );
288 RtlAppendUnicodeStringToString( &NameString,ParentPath );
294 if (SeparatorLength != 0) {
296 NameString.Buffer[NameString.Length/SeparatorLength] =
NC_SEPARATOR;
297 NameString.Length = NameString.Length + SeparatorLength;
298 FLT_ASSERT( NameString.Length <= NameString.MaximumLength );
305 RtlAppendUnicodeStringToString( &NameString, FinalComponent );
311 Path->FullPath.Buffer = NameString.Buffer;
312 Path->FullPath.Length = NameString.Length;
313 Path->FullPath.MaximumLength = NameString.MaximumLength;
315 Path->VolumePath.Buffer = NameString.Buffer;
316 Path->VolumePath.Length = VolumeName->Length;
317 Path->VolumePath.MaximumLength = VolumeName->Length;
319 Path->ParentPath.Buffer = NameString.Buffer;
320 Path->ParentPath.Length = SeparatorLength ==
sizeof(WCHAR) ?
321 VolumeName->Length+ParentPath->Length :
322 VolumeName->Length+ParentPath->Length-
sizeof(WCHAR);
323 Path->ParentPath.MaximumLength = SeparatorLength ==
sizeof(WCHAR) ?
324 VolumeName->Length+ParentPath->Length :
325 VolumeName->Length+ParentPath->Length-
sizeof(WCHAR);
327 Path->FinalComponentName.Buffer = (PWSTR)
Add2Ptr( NameString.Buffer,
328 VolumeName->Length+ParentPath->Length+SeparatorLength );
330 Path->FinalComponentName.Length = FinalComponent->Length;
331 Path->FinalComponentName.MaximumLength = FinalComponent->Length;
333 Path->VolumelessName.Buffer = (PWSTR)
Add2Ptr( NameString.Buffer, VolumeName->Length );
334 Path->VolumelessName.Length = NameString.Length - VolumeName->Length;
335 Path->VolumelessName.MaximumLength = Path->VolumelessName.Length;
337 Path->NumberComponentsInVolumePath = 0;
339 for (Index = 0; Index < Path->VolumePath.Length/
sizeof(WCHAR); Index++) {
340 if (Path->VolumePath.Buffer[Index] == L
'\\') {
341 Path->NumberComponentsInVolumePath++;
345 Path->NumberComponentsInFullPath = 0;
347 for (Index = 0; Index < Path->FullPath.Length/
sizeof(WCHAR); Index++) {
348 if (Path->FullPath.Buffer[Index] == L
'\\') {
349 Path->NumberComponentsInFullPath++;
353 FLT_ASSERT( Path->NumberComponentsInFullPath > Path->NumberComponentsInVolumePath );
359 Status = STATUS_SUCCESS;
361 NcBuildMappingPathCleanup:
363 if (!NT_SUCCESS( Status )) {
365 if (NameBuffer !=
NULL) {
377 _In_ PFLT_VOLUME CONST Volume,
378 _In_ PUNICODE_STRING ParentPath,
379 _In_ PUNICODE_STRING FinalComponentName,
405 ULONG VolumeNameLength;
406 PVOID VolumeNameBuffer =
NULL;
407 UNICODE_STRING VolumeNameString;
417 Status = FltGetVolumeName( Volume,
421 if (!NT_SUCCESS( Status ) && Status != STATUS_BUFFER_TOO_SMALL) {
423 goto NcBuildPathCleanup;
430 Status = STATUS_SUCCESS;
432 VolumeNameBuffer = ExAllocatePoolWithTag( PagedPool,
436 if (VolumeNameBuffer ==
NULL) {
438 Status = STATUS_INSUFFICIENT_RESOURCES;
439 goto NcBuildPathCleanup;
442 RtlInitEmptyUnicodeString( &VolumeNameString, VolumeNameBuffer, (USHORT) VolumeNameLength );
448 Status = FltGetVolumeName( Volume,
452 if (!NT_SUCCESS( Status )) {
454 goto NcBuildPathCleanup;
466 if (!NT_SUCCESS( Status )) {
468 goto NcBuildPathCleanup;
473 if (!NT_SUCCESS( Status )) {
478 if (VolumeNameBuffer !=
NULL) {
488 _In_ PFILE_OBJECT Parent,
489 _In_ PUNICODE_STRING FinalComponent,
491 _In_ BOOLEAN Normalized,
519 UNICODE_STRING ParentPath;
520 PFLT_FILE_NAME_INFORMATION ParentNameInfo =
NULL;
521 FLT_FILE_NAME_OPTIONS NameFlags;
529 NameFlags = FLT_FILE_NAME_NORMALIZED | FLT_FILE_NAME_QUERY_DEFAULT;
533 NameFlags = FLT_FILE_NAME_OPENED | FLT_FILE_NAME_QUERY_DEFAULT;
541 Status = NcGetFileNameInformation(
NULL,
547 if (!NT_SUCCESS( Status )) {
549 goto NcBuildMappingPathFromFileCleanup;
552 Status = FltParseFileNameInformation( ParentNameInfo );
554 if (!NT_SUCCESS( Status )) {
556 goto NcBuildMappingPathFromFileCleanup;
560 FLT_ASSERT( ParentNameInfo->Format == FLT_FILE_NAME_NORMALIZED ||
561 ParentNameInfo->Format == FLT_FILE_NAME_OPENED );
568 ParentPath.Buffer = ParentNameInfo->ParentDir.Buffer;
569 ParentPath.Length = ParentNameInfo->ParentDir.Length+ParentNameInfo->FinalComponent.Length;
570 ParentPath.MaximumLength = ParentPath.Length;
581 NcBuildMappingPathFromFileCleanup:
583 if (!NT_SUCCESS( Status )) {
588 if (ParentNameInfo !=
NULL) {
590 FltReleaseFileNameInformation( ParentNameInfo );
632 PWCHAR StrBuff = Path->LongNamePath.FullPath.Buffer;
638 if (StrBuff != Path->ShortNamePath.FullPath.Buffer) {
699 _In_ PFILE_OBJECT UserParent,
700 _In_ PFILE_OBJECT RealParent,
701 _In_ PUNICODE_STRING UserFinalComponentShortName,
702 _In_ PUNICODE_STRING UserFinalComponentLongName,
703 _In_ PUNICODE_STRING RealFinalComponentName,
742 RealFinalComponentName,
745 &Mapping->RealMapping.LongNamePath );
747 if (!NT_SUCCESS( Status )) {
749 goto NcBuildMappingCleanup;
758 Mapping->RealMapping.ShortNamePath =
759 Mapping->RealMapping.LongNamePath;
766 UserFinalComponentShortName,
769 &Mapping->UserMapping.ShortNamePath );
771 if (!NT_SUCCESS( Status )) {
773 goto NcBuildMappingCleanup;
781 UserFinalComponentLongName,
784 &Mapping->UserMapping.LongNamePath );
786 if (!NT_SUCCESS( Status )) {
788 goto NcBuildMappingCleanup;
791 NcBuildMappingCleanup:
VOID NcInitMappingEntry(_Inout_ PNC_MAPPING_ENTRY Entry)
NTSTATUS NcBuildMapping(_In_ PFILE_OBJECT UserParent, _In_ PFILE_OBJECT RealParent, _In_ PUNICODE_STRING UserFinalComponentShortName, _In_ PUNICODE_STRING UserFinalComponentLongName, _In_ PUNICODE_STRING RealFinalComponentName, _In_ PFLT_INSTANCE Instance, _Out_ PNC_MAPPING Mapping)
NTSTATUS NcBuildMappingPath(_In_ PUNICODE_STRING VolumeName, _In_ PUNICODE_STRING ParentPath, _In_ PUNICODE_STRING FinalComponent, _Inout_ PNC_MAPPING_PATH Path)
NC_MAPPING_ENTRY RealMapping
VOID NcTeardownMapping(_Inout_ PNC_MAPPING Mapping)
BOOLEAN NcIsMappingPathZeroed(_In_ PNC_MAPPING_PATH Path)
_In_opt_ PFILE_OBJECT _In_opt_ PFLT_INSTANCE Instance
NC_MAPPING_PATH ShortNamePath
NC_MAPPING_PATH LongNamePath
FLT_ASSERT(IS_MY_CONTROL_DEVICE_OBJECT(DeviceObject))
NTSTATUS NcBuildMappingPathFromFile(_In_ PFILE_OBJECT Parent, _In_ PUNICODE_STRING FinalComponent, _In_ PFLT_INSTANCE Instance, _In_ BOOLEAN Normalized, _Inout_ PNC_MAPPING_PATH Path)
VOID NcInitMapping(PNC_MAPPING Mapping)
NTSTATUS NcBuildMappingPathFromVolume(_In_ PFLT_VOLUME CONST Volume, _In_ PUNICODE_STRING ParentPath, _In_ PUNICODE_STRING FinalComponentName, _Inout_ PNC_MAPPING_PATH Entry)
NC_MAPPING_ENTRY UserMapping
VOID NcTeardownMappingPath(_Inout_ PNC_MAPPING_PATH Path)
BOOLEAN NcIsMappingZeroed(PNC_MAPPING Mapping)
NcLoadRegistryStringRetry NULL
VOID NcInitMappingPath(_Out_ PNC_MAPPING_PATH Path)
VOID NcTeardownMappingEntry(_Inout_ PNC_MAPPING_ENTRY Path)
BOOLEAN NcIsMappingEntryZeroed(PNC_MAPPING_ENTRY Entry)