[CONSRV]
[reactos.git] / win32ss / user / consrv / server.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Console Server DLL
4 * FILE: win32ss/user/consrv/init.c
5 * PURPOSE: Server APIs
6 * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca@sfr.fr)
7 */
8
9 #include "consrv.h"
10
11 #define NDEBUG
12 #include <debug.h>
13
14 #if 0
15 /* Ensure that a captured buffer is safe to access */
16 BOOL FASTCALL
17 Win32CsrValidateBuffer(PCSR_PROCESS ProcessData, PVOID Buffer,
18 SIZE_T NumElements, SIZE_T ElementSize)
19 {
20 /* Check that the following conditions are true:
21 * 1. The start of the buffer is somewhere within the process's
22 * shared memory section view.
23 * 2. The remaining space in the view is at least as large as the buffer.
24 * (NB: Please don't try to "optimize" this by using multiplication
25 * instead of division; remember that 2147483648 * 2 = 0.)
26 * 3. The buffer is DWORD-aligned.
27 */
28 ULONG_PTR Offset = (BYTE *)Buffer - (BYTE *)ProcessData->ClientViewBase;
29 if (Offset >= ProcessData->ClientViewBounds
30 || NumElements > (ProcessData->ClientViewBounds - Offset) / ElementSize
31 || (Offset & (sizeof(DWORD) - 1)) != 0)
32 {
33 DPRINT1("Invalid buffer %p(%u*%u); section view is %p(%u)\n",
34 Buffer, NumElements, ElementSize,
35 ProcessData->ClientViewBase, ProcessData->ClientViewBounds);
36 return FALSE;
37 }
38 return TRUE;
39 }
40 #endif
41
42 /* EOF */