Author: tkreuzer
Date: Mon Sep 19 16:24:18 2011
New Revision: 53760
URL:
http://svn.reactos.org/svn/reactos?rev=53760&view=rev
Log:
[NTDLL]
Fix CsrProbeForRead and CsrProbeForWrite to actually access the memory, by using volatile.
The compiler optimized the access away previously.
Modified:
trunk/reactos/dll/ntdll/csr/capture.c
Modified: trunk/reactos/dll/ntdll/csr/capture.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/csr/capture.c?re…
==============================================================================
--- trunk/reactos/dll/ntdll/csr/capture.c [iso-8859-1] (original)
+++ trunk/reactos/dll/ntdll/csr/capture.c [iso-8859-1] Mon Sep 19 16:24:18 2011
@@ -26,7 +26,7 @@
IN ULONG Length,
IN ULONG Alignment)
{
- PUCHAR Pointer;
+ volatile UCHAR *Pointer;
UCHAR Data;
/* Validate length */
@@ -39,10 +39,12 @@
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 @@
IN ULONG Length,
IN ULONG Alignment)
{
- PUCHAR Pointer;
- UCHAR Data;
+ volatile UCHAR *Pointer;
/* Validate length */
if (Length == 0) return;
@@ -69,13 +70,13 @@
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 @@
if (!String)
{
CapturedString->Length = 0;
- CapturedString->MaximumLength = MaximumLength;
+ CapturedString->MaximumLength = (USHORT)MaximumLength;
/* Allocate a pointer for it */
CsrAllocateMessagePointer(CaptureBuffer,
@@ -227,13 +228,13 @@
}
/* 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)