Fix CsrProbeForRead and CsrProbeForWrite to actually access the memory, by using volatile. The compiler optimized the access away previously.

svn path=/trunk/; revision=53760
This commit is contained in:
Timo Kreuzer
2011-09-19 16:24:18 +00:00
parent a60242cfe7
commit cf0a380afd
+18 -17
View File
@@ -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)