ReactOS  0.4.15-dev-4853-g3a72a52
probe.h
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Kernel
3  * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4  * PURPOSE: Internal header containing information class probing helpers
5  * COPYRIGHT: Copyright 2022 George BiČ™oc <george.bisoc@reactos.org>
6  */
7 
8 #pragma once
9 
10 #include <reactos/probe.h>
11 
67 static
68 __inline
72  _In_ const INFORMATION_CLASS_INFO *ClassList,
73  _In_ ULONG ClassListEntries,
77 {
79 
80  if (Class < ClassListEntries)
81  {
82  if (!(ClassList[Class].Flags & ICIF_SET))
83  {
85  }
86  else if (ClassList[Class].RequiredSizeSET > 0 &&
87  BufferLength != ClassList[Class].RequiredSizeSET)
88  {
89  if (!(ClassList[Class].Flags & ICIF_SET_SIZE_VARIABLE))
90  {
92  }
93  }
94 
95  if (NT_SUCCESS(Status))
96  {
97  if (PreviousMode != KernelMode)
98  {
99  _SEH2_TRY
100  {
102  BufferLength,
103  ClassList[Class].AlignmentSET);
104  }
106  {
108  }
109  _SEH2_END;
110  }
111  }
112  }
113  else
115 
116  return Status;
117 }
118 
216 static
217 __inline
218 NTSTATUS
220  _In_ ULONG Class,
221  _In_ const INFORMATION_CLASS_INFO *ClassList,
222  _In_ ULONG ClassListEntries,
223  _In_ ULONG Flags,
227  _In_opt_ PULONG_PTR ReturnLengthPtr,
229 {
231 
232  if (Class < ClassListEntries)
233  {
234  if (!(ClassList[Class].Flags & ICIF_QUERY))
235  {
237  }
238  else if (ClassList[Class].RequiredSizeQUERY > 0 &&
239  BufferLength != ClassList[Class].RequiredSizeQUERY)
240  {
241  if (!(ClassList[Class].Flags & ICIF_QUERY_SIZE_VARIABLE))
242  {
244  }
245  }
246 
247  if (NT_SUCCESS(Status))
248  {
249  if (PreviousMode != KernelMode)
250  {
251  _SEH2_TRY
252  {
253  if (Buffer != NULL)
254  {
255  if (Flags & ICIF_PROBE_READ)
256  {
258  BufferLength,
259  ClassList[Class].AlignmentQUERY);
260  }
261  else
262  {
264  BufferLength,
265  ClassList[Class].AlignmentQUERY);
266  }
267  }
268 
270  {
272  }
273 
274  if (ReturnLengthPtr != NULL)
275  {
276  ProbeForWrite(ReturnLengthPtr, sizeof(ULONG_PTR), sizeof(ULONG_PTR));
277  }
278  }
280  {
282  }
283  _SEH2_END;
284  }
285  }
286  }
287  else
289 
290  return Status;
291 }
#define ProbeForWriteUlong(Ptr)
Definition: probe.h:36
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:39
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3767
#define _In_opt_
Definition: ms_sal.h:309
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
LONG NTSTATUS
Definition: precomp.h:26
#define ICIF_SET_SIZE_VARIABLE
Definition: icif.h:21
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
_SEH2_TRY
Definition: create.c:4226
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define ICIF_SET
Definition: icif.h:19
#define _In_
Definition: ms_sal.h:308
Definition: bufpool.h:45
Status
Definition: gdiplustypes.h:24
static __inline NTSTATUS DefaultSetInfoBufferCheck(_In_ ULONG Class, _In_ const INFORMATION_CLASS_INFO *ClassList, _In_ ULONG ClassListEntries, _In_ PVOID Buffer, _In_ ULONG BufferLength, _In_ KPROCESSOR_MODE PreviousMode)
Probe helper that validates the provided parameters whenever a NtSet*** system call is invoked from u...
Definition: probe.h:70
_In_ KPROCESSOR_MODE PreviousMode
Definition: sefuncs.h:103
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
static __inline NTSTATUS DefaultQueryInfoBufferCheck(_In_ ULONG Class, _In_ const INFORMATION_CLASS_INFO *ClassList, _In_ ULONG ClassListEntries, _In_ ULONG Flags, _In_opt_ PVOID Buffer, _In_ ULONG BufferLength, _In_opt_ PULONG ReturnLength, _In_opt_ PULONG_PTR ReturnLengthPtr, _In_ KPROCESSOR_MODE PreviousMode)
Probe helper that validates the provided parameters whenever a NtQuery*** system call is invoked from...
Definition: probe.h:219
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
#define STATUS_INVALID_INFO_CLASS
Definition: ntstatus.h:240
#define ICIF_QUERY_SIZE_VARIABLE
Definition: icif.h:20
_SEH2_END
Definition: create.c:4400
#define ICIF_FORCE_RETURN_LENGTH_PROBE
Definition: icif.h:26
unsigned int * PULONG
Definition: retypes.h:1
#define NULL
Definition: types.h:112
#define ICIF_QUERY
Definition: icif.h:18
unsigned int ULONG
Definition: retypes.h:1
uint32_t * PULONG_PTR
Definition: typedefs.h:65
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
#define STATUS_SUCCESS
Definition: shellext.h:65
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define ICIF_PROBE_READ
Definition: icif.h:25