From e4748fe448e3e8b04d8082c7ca5e250706a4a8d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Tue, 4 Jun 2024 17:18:13 +0200 Subject: [PATCH] [NTOS:IO] IoVolumeDeviceToDosName(): Add SAL2 annotations, fix pool tag (#6989) The DEV2DOS tag value is from the official Windows pooltag.txt file. --- ntoskrnl/include/internal/tag.h | 1 + ntoskrnl/io/iomgr/volume.c | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ntoskrnl/include/internal/tag.h b/ntoskrnl/include/internal/tag.h index 4c71be47240..6febe9d6e51 100644 --- a/ntoskrnl/include/internal/tag.h +++ b/ntoskrnl/include/internal/tag.h @@ -94,6 +94,7 @@ #define TAG_VPB ' BPV' #define TAG_RTLREGISTRY 'vrqR' #define TAG_PNP_DEVACTION 'aDpP' +#define TAG_DEV2DOS ' d2D' /* Loader Related Tags */ #define TAG_MODULE_OBJECT 'omlk' /* klmo - kernel ldr module object */ diff --git a/ntoskrnl/io/iomgr/volume.c b/ntoskrnl/io/iomgr/volume.c index 600d899ce48..3f614e27c98 100644 --- a/ntoskrnl/io/iomgr/volume.c +++ b/ntoskrnl/io/iomgr/volume.c @@ -1276,8 +1276,10 @@ IoSetSystemPartition(IN PUNICODE_STRING VolumeNameString) */ NTSTATUS NTAPI -IoVolumeDeviceToDosName(IN PVOID VolumeDeviceObject, - OUT PUNICODE_STRING DosName) +IoVolumeDeviceToDosName( + _In_ PVOID VolumeDeviceObject, + _Out_ _When_(return==0, _At_(DosName->Buffer, __drv_allocatesMem(Mem))) + PUNICODE_STRING DosName) { NTSTATUS Status; ULONG Length; @@ -1373,7 +1375,7 @@ IoVolumeDeviceToDosName(IN PVOID VolumeDeviceObject, /* Reallocate the memory, even in case of success, because * that's the buffer that will be returned to the caller */ - VolumePathPtr = ExAllocatePoolWithTag(PagedPool, Length, 'D2d '); + VolumePathPtr = ExAllocatePoolWithTag(PagedPool, Length, TAG_DEV2DOS); if (!VolumePathPtr) { Status = STATUS_INSUFFICIENT_RESOURCES; @@ -1418,7 +1420,7 @@ IoVolumeDeviceToDosName(IN PVOID VolumeDeviceObject, goto Quit; ReleaseMemory: - ExFreePoolWithTag(VolumePathPtr, 'D2d '); + ExFreePoolWithTag(VolumePathPtr, TAG_DEV2DOS); Quit: ObDereferenceObject(FileObject);