mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 16:36:33 +00:00
[INCLUDES] probe.h: use ExFreePoolWithTag for releasing unicode strings capture, and fully clear up said strings.
svn path=/trunk/; revision=71421
This commit is contained in:
parent
c9493245e5
commit
09084fe16a
1 changed files with 13 additions and 11 deletions
|
@ -53,9 +53,9 @@ static const LARGE_STRING __emptyLargeString = {0, 0, 0, NULL};
|
|||
|
||||
#define ProbeForReadGenericType(Ptr, Type, Default) \
|
||||
(((ULONG_PTR)(Ptr) + sizeof(Type) - 1 < (ULONG_PTR)(Ptr) || \
|
||||
(ULONG_PTR)(Ptr) + sizeof(Type) - 1 >= (ULONG_PTR)MmUserProbeAddress) ? \
|
||||
ExRaiseAccessViolation(), Default : \
|
||||
*(const volatile Type *)(Ptr))
|
||||
(ULONG_PTR)(Ptr) + sizeof(Type) - 1 >= (ULONG_PTR)MmUserProbeAddress) ? \
|
||||
ExRaiseAccessViolation(), Default : \
|
||||
*(const volatile Type *)(Ptr))
|
||||
|
||||
#define ProbeForReadBoolean(Ptr) ProbeForReadGenericType(Ptr, BOOLEAN, FALSE)
|
||||
#define ProbeForReadUchar(Ptr) ProbeForReadGenericType(Ptr, UCHAR, 0)
|
||||
|
@ -144,7 +144,7 @@ ProbeAndCaptureUnicodeString(OUT PUNICODE_STRING Dest,
|
|||
IN const UNICODE_STRING *UnsafeSrc)
|
||||
{
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
WCHAR *Buffer = NULL;
|
||||
PWCHAR Buffer = NULL;
|
||||
ASSERT(Dest != NULL);
|
||||
|
||||
/* Probe the structure and buffer*/
|
||||
|
@ -162,9 +162,7 @@ ProbeAndCaptureUnicodeString(OUT PUNICODE_STRING Dest,
|
|||
{
|
||||
if (Dest->Length != 0)
|
||||
{
|
||||
ProbeForRead(Dest->Buffer,
|
||||
Dest->Length,
|
||||
sizeof(WCHAR));
|
||||
ProbeForRead(Dest->Buffer, Dest->Length, sizeof(WCHAR));
|
||||
|
||||
/* Allocate space for the buffer */
|
||||
Buffer = (PWCHAR)ExAllocatePoolWithTag(PagedPool,
|
||||
|
@ -186,14 +184,14 @@ ProbeAndCaptureUnicodeString(OUT PUNICODE_STRING Dest,
|
|||
}
|
||||
else
|
||||
{
|
||||
/* sanitize structure */
|
||||
/* Sanitize structure */
|
||||
Dest->MaximumLength = 0;
|
||||
Dest->Buffer = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* sanitize structure */
|
||||
/* Sanitize structure */
|
||||
Dest->Length = 0;
|
||||
Dest->MaximumLength = 0;
|
||||
}
|
||||
|
@ -203,7 +201,7 @@ ProbeAndCaptureUnicodeString(OUT PUNICODE_STRING Dest,
|
|||
/* Free allocated resources and zero the destination string */
|
||||
if (Buffer != NULL)
|
||||
{
|
||||
ExFreePool(Buffer);
|
||||
ExFreePoolWithTag(Buffer, 'RTSU');
|
||||
}
|
||||
Dest->Length = 0;
|
||||
Dest->MaximumLength = 0;
|
||||
|
@ -232,8 +230,12 @@ ReleaseCapturedUnicodeString(IN PUNICODE_STRING CapturedString,
|
|||
{
|
||||
if(CurrentMode != KernelMode && CapturedString->Buffer != NULL)
|
||||
{
|
||||
ExFreePool(CapturedString->Buffer);
|
||||
ExFreePoolWithTag(CapturedString->Buffer, 'RTSU');
|
||||
}
|
||||
|
||||
CapturedString->Length = 0;
|
||||
CapturedString->MaximumLength = 0;
|
||||
CapturedString->Buffer = NULL;
|
||||
}
|
||||
|
||||
#endif /* INCLUDE_REACTOS_CAPTURE_H */
|
||||
|
|
Loading…
Reference in a new issue