https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1815aae8776019c53a7e2…
commit 1815aae8776019c53a7e23b6aec50605cb244688
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Wed Apr 15 15:53:47 2020 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Wed Apr 15 15:59:08 2020 +0200
[CSRSRV] Addendum to e3a70662: Fix build.
Since indeeed the memcpy/move type of functions usually don't operate on
pointers to 'volatile' data, don't make ClientCaptureBuffer volatile.
Instead when retrieving the values of its 'Size' and 'PointerCount'
members (see the SEH block), use the so-called technique of "volatile
glasses" [1], where the pointer will be explicitly casted to "volatile
TYPE*"
where needed.
[1]:
https://docs.microsoft.com/archive/blogs/itgoestoeleven/why-your-user-mode-…
---
subsystems/win32/csrsrv/api.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/subsystems/win32/csrsrv/api.c b/subsystems/win32/csrsrv/api.c
index 9120794b16e..62bb06b3eba 100644
--- a/subsystems/win32/csrsrv/api.c
+++ b/subsystems/win32/csrsrv/api.c
@@ -1120,8 +1120,7 @@ CsrCaptureArguments(IN PCSR_THREAD CsrThread,
IN PCSR_API_MESSAGE ApiMessage)
{
PCSR_PROCESS CsrProcess = CsrThread->Process;
- volatile CSR_CAPTURE_BUFFER* ClientCaptureBuffer;
- PCSR_CAPTURE_BUFFER ServerCaptureBuffer = NULL;
+ PCSR_CAPTURE_BUFFER ClientCaptureBuffer, ServerCaptureBuffer = NULL;
ULONG_PTR EndOfClientBuffer;
SIZE_T SizeOfBufferThroughOffsetsArray;
SIZE_T BufferDistance;
@@ -1151,7 +1150,7 @@ CsrCaptureArguments(IN PCSR_THREAD CsrThread,
}
/* Capture the buffer length */
- Length = ClientCaptureBuffer->Size;
+ Length = ((volatile CSR_CAPTURE_BUFFER*)ClientCaptureBuffer)->Size;
/*
* Now check if the remaining of the buffer is inside our mapped section.
@@ -1171,7 +1170,7 @@ CsrCaptureArguments(IN PCSR_THREAD CsrThread,
}
/* Capture the pointer count */
- PointerCount = ClientCaptureBuffer->PointerCount;
+ PointerCount = ((volatile
CSR_CAPTURE_BUFFER*)ClientCaptureBuffer)->PointerCount;
/*
* Check whether the total buffer size and the pointer count are consistent