ReactOS 0.4.15-dev-8417-gb6b82fe
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
67static
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 {
98 {
100 {
103 ClassList[Class].AlignmentSET);
104 }
106 {
108 }
109 _SEH2_END;
110 }
111 }
112 }
113 else
115
116 return Status;
117}
118
216static
217__inline
221 _In_ const INFORMATION_CLASS_INFO *ClassList,
222 _In_ ULONG ClassListEntries,
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 {
250 {
252 {
253 if (Buffer != NULL)
254 {
256 {
259 ClassList[Class].AlignmentQUERY);
260 }
261 else
262 {
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}
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:43
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
Status
Definition: gdiplustypes.h:25
#define ICIF_QUERY_SIZE_VARIABLE
Definition: icif.h:20
#define ICIF_QUERY
Definition: icif.h:18
#define ICIF_SET
Definition: icif.h:19
#define ICIF_SET_SIZE_VARIABLE
Definition: icif.h:21
#define ICIF_PROBE_READ
Definition: icif.h:25
#define ICIF_FORCE_RETURN_LENGTH_PROBE
Definition: icif.h:26
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define _In_
Definition: ms_sal.h:308
#define _In_opt_
Definition: ms_sal.h:309
#define KernelMode
Definition: asm.h:34
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
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
#define STATUS_INVALID_INFO_CLASS
Definition: ntstatus.h:240
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
#define ProbeForWriteUlong(Ptr)
Definition: probe.h:36
#define STATUS_SUCCESS
Definition: shellext.h:65
uint32_t * PULONG_PTR
Definition: typedefs.h:65
uint32_t * PULONG
Definition: typedefs.h:59
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
_In_ KPROCESSOR_MODE PreviousMode
Definition: sefuncs.h:103