ReactOS 0.4.15-dev-5664-g3bf4ef6
objtype.c
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: Security object type list support routines
5 * COPYRIGHT: Copyright Timo Kreuzer <timo.kreuzer@reactos.org>
6 */
7
8/* INCLUDES *******************************************************************/
9
10#include <ntoskrnl.h>
11#define NDEBUG
12#include <debug.h>
13
14/* PRIVATE FUNCTIONS ***********************************************************/
15
40 _In_reads_opt_(ObjectTypeListLength) POBJECT_TYPE_LIST ObjectTypeList,
41 _In_ ULONG ObjectTypeListLength,
43 _Out_ POBJECT_TYPE_LIST *CapturedObjectTypeList)
44{
46
48 {
50 }
51
52 if (ObjectTypeListLength == 0)
53 {
54 *CapturedObjectTypeList = NULL;
55 return STATUS_SUCCESS;
56 }
57
58 if (ObjectTypeList == NULL)
59 {
61 }
62
63 /* Calculate the list size and check for integer overflow */
64 Size = ObjectTypeListLength * sizeof(OBJECT_TYPE_LIST);
65 if (Size == 0)
66 {
68 }
69
70 /* Allocate a new list */
71 *CapturedObjectTypeList = ExAllocatePoolWithTag(PagedPool, Size, TAG_SEPA);
72 if (*CapturedObjectTypeList == NULL)
73 {
75 }
76
78 {
79 ProbeForRead(ObjectTypeList, Size, sizeof(ULONG));
80 RtlCopyMemory(*CapturedObjectTypeList, ObjectTypeList, Size);
81 }
83 {
84 ExFreePoolWithTag(*CapturedObjectTypeList, TAG_SEPA);
85 *CapturedObjectTypeList = NULL;
87 }
89
90 return STATUS_SUCCESS;
91}
92
106VOID
108 _In_ _Post_invalid_ POBJECT_TYPE_LIST CapturedObjectTypeList,
110{
111 if ((PreviousMode != KernelMode) && (CapturedObjectTypeList != NULL))
112 ExFreePoolWithTag(CapturedObjectTypeList, TAG_SEPA);
113}
114
115/* EOF */
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
unsigned int ULONG
Definition: retypes.h:1
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define _Post_invalid_
Definition: ms_sal.h:695
#define _Out_
Definition: ms_sal.h:345
#define _In_reads_opt_(size)
Definition: ms_sal.h:320
#define _In_
Definition: ms_sal.h:308
#define KernelMode
Definition: asm.h:34
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
NTSTATUS SeCaptureObjectTypeList(_In_reads_opt_(ObjectTypeListLength) POBJECT_TYPE_LIST ObjectTypeList, _In_ ULONG ObjectTypeListLength, _In_ KPROCESSOR_MODE PreviousMode, _Out_ POBJECT_TYPE_LIST *CapturedObjectTypeList)
Captures a list of object types.
Definition: objtype.c:39
VOID SeReleaseObjectTypeList(_In_ _Post_invalid_ POBJECT_TYPE_LIST CapturedObjectTypeList, _In_ KPROCESSOR_MODE PreviousMode)
Releases a buffer list of object types.
Definition: objtype.c:107
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:159
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:162
#define STATUS_SUCCESS
Definition: shellext.h:65
#define TAG_SEPA
Definition: tag.h:156
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
_In_ KPROCESSOR_MODE PreviousMode
Definition: sefuncs.h:103
struct _OBJECT_TYPE_LIST OBJECT_TYPE_LIST