From cf0a380afd425f9495b8a33f426b37bcd6c88cc9 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 19 Sep 2011 16:24:18 +0000 Subject: [PATCH] [NTDLL] Fix CsrProbeForRead and CsrProbeForWrite to actually access the memory, by using volatile. The compiler optimized the access away previously. svn path=/trunk/; revision=53760 --- reactos/dll/ntdll/csr/capture.c | 35 +++++++++++++++++---------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/reactos/dll/ntdll/csr/capture.c b/reactos/dll/ntdll/csr/capture.c index d86133c2d19..b147dcf3f3b 100644 --- a/reactos/dll/ntdll/csr/capture.c +++ b/reactos/dll/ntdll/csr/capture.c @@ -26,7 +26,7 @@ CsrProbeForRead(IN PVOID Address, IN ULONG Length, IN ULONG Alignment) { - PUCHAR Pointer; + volatile UCHAR *Pointer; UCHAR Data; /* Validate length */ @@ -39,10 +39,12 @@ CsrProbeForRead(IN PVOID Address, RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT); } - /* Do the probe */ - Pointer = (PUCHAR)Address; + /* Probe first byte */ + Pointer = Address; Data = *Pointer; - Pointer = (PUCHAR)((ULONG)Address + Length -1); + + /* Probe last byte */ + Pointer = (PUCHAR)Address + Length - 1; Data = *Pointer; (void)Data; } @@ -56,8 +58,7 @@ CsrProbeForWrite(IN PVOID Address, IN ULONG Length, IN ULONG Alignment) { - PUCHAR Pointer; - UCHAR Data; + volatile UCHAR *Pointer; /* Validate length */ if (Length == 0) return; @@ -69,13 +70,13 @@ CsrProbeForWrite(IN PVOID Address, RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT); } - /* Do the probe */ - Pointer = (PUCHAR)Address; - Data = *Pointer; - *Pointer = Data; - Pointer = (PUCHAR)((ULONG)Address + Length -1); - Data = *Pointer; - *Pointer = Data; + /* Probe first byte */ + Pointer = Address; + *Pointer = *Pointer; + + /* Probe last byte */ + Pointer = (PUCHAR)Address + Length - 1; + *Pointer = *Pointer; } /* @@ -217,7 +218,7 @@ CsrCaptureMessageString(PCSR_CAPTURE_BUFFER CaptureBuffer, if (!String) { CapturedString->Length = 0; - CapturedString->MaximumLength = MaximumLength; + CapturedString->MaximumLength = (USHORT)MaximumLength; /* Allocate a pointer for it */ CsrAllocateMessagePointer(CaptureBuffer, @@ -227,13 +228,13 @@ CsrCaptureMessageString(PCSR_CAPTURE_BUFFER CaptureBuffer, } /* Initialize this string */ - CapturedString->Length = StringLength; - + CapturedString->Length = (USHORT)StringLength; + /* Allocate a buffer and get its size */ ReturnedLength = CsrAllocateMessagePointer(CaptureBuffer, MaximumLength, (PVOID*)&CapturedString->Buffer); - CapturedString->MaximumLength = ReturnedLength; + CapturedString->MaximumLength = (USHORT)ReturnedLength; /* If the string had data */ if (StringLength)