diff --git a/reactos/sdk/include/reactos/probe.h b/reactos/sdk/include/reactos/probe.h index dfa8f8d8b79..0aac83f065f 100644 --- a/reactos/sdk/include/reactos/probe.h +++ b/reactos/sdk/include/reactos/probe.h @@ -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 */