mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-24 09:23:37 -05:00
sys: FspAlloc*(), FspFree*()
This commit is contained in:
parent
75471b2338
commit
138a10d232
@ -425,10 +425,10 @@ VOID FspFsvolCreateComplete(
|
||||
|
||||
if (ReparseFileName.Length > FileObject->FileName.MaximumLength)
|
||||
{
|
||||
PVOID Buffer = ExAllocatePoolWithTag(NonPagedPool, ReparseFileName.Length, FSP_TAG);
|
||||
PVOID Buffer = FspAllocExternal(ReparseFileName.Length);
|
||||
if (0 == Buffer)
|
||||
FSP_RETURN(Result = STATUS_INSUFFICIENT_RESOURCES);
|
||||
ExFreePool(FileObject->FileName.Buffer);
|
||||
FspFreeExternal(FileObject->FileName.Buffer);
|
||||
FileObject->FileName.MaximumLength = ReparseFileName.Length;
|
||||
FileObject->FileName.Buffer = Buffer;
|
||||
}
|
||||
|
@ -189,8 +189,7 @@ static NTSTATUS FspFsvrtDeviceInit(PDEVICE_OBJECT DeviceObject)
|
||||
|
||||
FspIoqInitialize(&FsvrtDeviceExtension->Ioq);
|
||||
|
||||
FsvrtDeviceExtension->SwapVpb = ExAllocatePoolWithTag(NonPagedPool,
|
||||
sizeof *FsvrtDeviceExtension->SwapVpb, FSP_TAG);
|
||||
FsvrtDeviceExtension->SwapVpb = FspAllocNonPagedExternal(sizeof *FsvrtDeviceExtension->SwapVpb);
|
||||
if (0 == FsvrtDeviceExtension->SwapVpb)
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
RtlZeroMemory(FsvrtDeviceExtension->SwapVpb, sizeof *FsvrtDeviceExtension->SwapVpb);
|
||||
@ -205,7 +204,7 @@ static VOID FspFsvrtDeviceFini(PDEVICE_OBJECT DeviceObject)
|
||||
FSP_FSVRT_DEVICE_EXTENSION *FsvrtDeviceExtension = FspFsvrtDeviceExtension(DeviceObject);
|
||||
|
||||
if (0 != FsvrtDeviceExtension->SwapVpb)
|
||||
ExFreePoolWithTag(FsvrtDeviceExtension->SwapVpb, FSP_TAG);
|
||||
FspFreeExternal(FsvrtDeviceExtension->SwapVpb);
|
||||
}
|
||||
|
||||
static NTSTATUS FspFsvolDeviceInit(PDEVICE_OBJECT DeviceObject)
|
||||
@ -405,9 +404,8 @@ NTSTATUS FspDeviceCopyList(
|
||||
DeviceObjects, sizeof *DeviceObjects * DeviceObjectCount, &DeviceObjectCount))
|
||||
{
|
||||
if (0 != DeviceObjects)
|
||||
ExFreePoolWithTag(DeviceObjects, FSP_TAG);
|
||||
DeviceObjects = ExAllocatePoolWithTag(NonPagedPool,
|
||||
sizeof *DeviceObjects * DeviceObjectCount, FSP_TAG);
|
||||
FspFree(DeviceObjects);
|
||||
DeviceObjects = FspAllocNonPaged(sizeof *DeviceObjects * DeviceObjectCount);
|
||||
if (0 == DeviceObjects)
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
RtlZeroMemory(DeviceObjects, sizeof *DeviceObjects * DeviceObjectCount);
|
||||
@ -427,7 +425,7 @@ VOID FspDeviceDeleteList(
|
||||
for (ULONG i = 0; DeviceObjectCount > i; i++)
|
||||
ObDereferenceObject(DeviceObjects[i]);
|
||||
|
||||
ExFreePoolWithTag(DeviceObjects, FSP_TAG);
|
||||
FspFree(DeviceObjects);
|
||||
}
|
||||
|
||||
VOID FspDeviceDeleteAll(VOID)
|
||||
|
@ -167,7 +167,8 @@
|
||||
} while (0,0)
|
||||
|
||||
/* misc macros */
|
||||
#define FSP_TAG ' psF'
|
||||
#define FSP_ALLOC_INTERNAL_TAG 'IpsF'
|
||||
#define FSP_ALLOC_EXTERNAL_TAG 'XpsF'
|
||||
#define FSP_IO_INCREMENT IO_NETWORK_INCREMENT
|
||||
|
||||
/* disable warnings */
|
||||
@ -430,6 +431,36 @@ VOID FspFileContextRelease(FSP_FILE_CONTEXT *Context)
|
||||
}
|
||||
|
||||
/* misc */
|
||||
static inline
|
||||
PVOID FspAlloc(SIZE_T Size)
|
||||
{
|
||||
return ExAllocatePoolWithTag(PagedPool, Size, FSP_ALLOC_INTERNAL_TAG);
|
||||
}
|
||||
static inline
|
||||
PVOID FspAllocNonPaged(SIZE_T Size)
|
||||
{
|
||||
return ExAllocatePoolWithTag(NonPagedPool, Size, FSP_ALLOC_INTERNAL_TAG);
|
||||
}
|
||||
static inline
|
||||
VOID FspFree(PVOID Pointer)
|
||||
{
|
||||
ExFreePoolWithTag(Pointer, FSP_ALLOC_INTERNAL_TAG);
|
||||
}
|
||||
static inline
|
||||
PVOID FspAllocExternal(SIZE_T Size)
|
||||
{
|
||||
return ExAllocatePoolWithTag(PagedPool, Size, FSP_ALLOC_EXTERNAL_TAG);
|
||||
}
|
||||
static inline
|
||||
PVOID FspAllocNonPagedExternal(SIZE_T Size)
|
||||
{
|
||||
return ExAllocatePoolWithTag(NonPagedPool, Size, FSP_ALLOC_EXTERNAL_TAG);
|
||||
}
|
||||
static inline
|
||||
VOID FspFreeExternal(PVOID Pointer)
|
||||
{
|
||||
ExFreePool(Pointer);
|
||||
}
|
||||
NTSTATUS FspCreateGuid(GUID *Guid);
|
||||
BOOLEAN FspValidRelativeSecurityDescriptor(
|
||||
PSECURITY_DESCRIPTOR SecurityDescriptor, ULONG SecurityDescriptorLength,
|
||||
|
@ -20,16 +20,14 @@ NTSTATUS FspFileContextCreate(ULONG ExtraSize, FSP_FILE_CONTEXT **PFsContext)
|
||||
|
||||
*PFsContext = 0;
|
||||
|
||||
FSP_FILE_CONTEXT_NONPAGED *NonPaged = ExAllocatePoolWithTag(NonPagedPool,
|
||||
sizeof *NonPaged, FSP_TAG);
|
||||
FSP_FILE_CONTEXT_NONPAGED *NonPaged = FspAllocNonPaged(sizeof *NonPaged);
|
||||
if (0 == NonPaged)
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
|
||||
FSP_FILE_CONTEXT *FsContext = ExAllocatePoolWithTag(PagedPool,
|
||||
sizeof *FsContext + ExtraSize, FSP_TAG);
|
||||
FSP_FILE_CONTEXT *FsContext = FspAlloc(sizeof *FsContext + ExtraSize);
|
||||
if (0 == FsContext)
|
||||
{
|
||||
ExFreePoolWithTag(NonPaged, FSP_TAG);
|
||||
FspFree(NonPaged);
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
@ -62,7 +60,7 @@ VOID FspFileContextDelete(FSP_FILE_CONTEXT *FsContext)
|
||||
|
||||
ExDeleteResourceLite(&FsContext->NonPaged->PagingIoResource);
|
||||
ExDeleteResourceLite(&FsContext->NonPaged->Resource);
|
||||
ExFreePoolWithTag(FsContext->NonPaged, FSP_TAG);
|
||||
FspFree(FsContext->NonPaged);
|
||||
|
||||
ExFreePoolWithTag(FsContext, FSP_TAG);
|
||||
FspFree(FsContext);
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ static NTSTATUS FspFsctlCreateVolume(
|
||||
return Result;
|
||||
|
||||
/* copy the security descriptor from the system buffer to a temporary one */
|
||||
SecurityDescriptorBuf = ExAllocatePoolWithTag(PagedPool, SecurityDescriptorSize, FSP_TAG);
|
||||
SecurityDescriptorBuf = FspAlloc(SecurityDescriptorSize);
|
||||
if (0 == SecurityDescriptorBuf)
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
RtlCopyMemory(SecurityDescriptorBuf, SecurityDescriptor, SecurityDescriptorSize);
|
||||
@ -176,7 +176,7 @@ static NTSTATUS FspFsctlCreateVolume(
|
||||
|
||||
/* free the temporary security descriptor */
|
||||
if (0 != SecurityDescriptorBuf)
|
||||
ExFreePoolWithTag(SecurityDescriptorBuf, FSP_TAG);
|
||||
FspFree(SecurityDescriptorBuf);
|
||||
|
||||
return Result;
|
||||
}
|
||||
@ -306,7 +306,7 @@ static NTSTATUS FspFsvrtDeleteVolume(
|
||||
}
|
||||
IoReleaseVpbSpinLock(Irql);
|
||||
if (FreeVpb)
|
||||
ExFreePool(OldVpb);
|
||||
FspFreeExternal(OldVpb);
|
||||
#pragma prefast(pop)
|
||||
|
||||
/* release the file system device and virtual volume objects */
|
||||
|
@ -51,8 +51,7 @@ NTSTATUS FspIopCreateRequestEx(
|
||||
if (FSP_FSCTL_TRANSACT_REQ_SIZEMAX < sizeof *Request + ExtraSize)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
||||
RequestHeader = ExAllocatePoolWithTag(PagedPool,
|
||||
sizeof *RequestHeader + sizeof *Request + ExtraSize, FSP_TAG);
|
||||
RequestHeader = FspAlloc(sizeof *RequestHeader + sizeof *Request + ExtraSize);
|
||||
if (0 == RequestHeader)
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
|
||||
@ -87,7 +86,7 @@ static VOID FspIopDeleteRequest(FSP_FSCTL_TRANSACT_REQ *Request)
|
||||
if (0 != RequestHeader->RequestFini)
|
||||
RequestHeader->RequestFini(RequestHeader->Context);
|
||||
|
||||
ExFreePoolWithTag(RequestHeader, FSP_TAG);
|
||||
FspFree(RequestHeader);
|
||||
}
|
||||
|
||||
PVOID *FspIopRequestContextAddress(FSP_FSCTL_TRANSACT_REQ *Request, ULONG I)
|
||||
|
Loading…
x
Reference in New Issue
Block a user