2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: ntoskrnl/include/ob_x.h
5 * PURPOSE: Intenral Inlined Functions for the Object Manager
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
11 ObpEnterObjectTypeMutex(IN POBJECT_TYPE ObjectType
)
14 ASSERT(KeGetCurrentIrql() <= APC_LEVEL
);
16 /* Enter a critical region and acquire the resource */
17 KeEnterCriticalRegion();
18 ExAcquireResourceExclusiveLite(&ObjectType
->Mutex
, TRUE
);
23 ObpLeaveObjectTypeMutex(IN POBJECT_TYPE ObjectType
)
25 /* Enter a critical region and acquire the resource */
26 ExReleaseResourceLite(&ObjectType
->Mutex
);
27 KeLeaveCriticalRegion();
30 ASSERT(KeGetCurrentIrql() <= APC_LEVEL
);
35 ObpReleaseCapturedAttributes(IN POBJECT_CREATE_INFORMATION ObjectCreateInfo
)
37 /* Check if we have a security descriptor */
38 if (ObjectCreateInfo
->SecurityDescriptor
)
41 SeReleaseSecurityDescriptor(ObjectCreateInfo
->SecurityDescriptor
,
42 ObjectCreateInfo
->ProbeMode
,
44 ObjectCreateInfo
->SecurityDescriptor
= NULL
;
50 ObpAllocateCapturedAttributes(IN PP_NPAGED_LOOKASIDE_NUMBER Type
)
53 PNPAGED_LOOKASIDE_LIST List
;
54 PKPRCB Prcb
= KeGetCurrentPrcb();
56 /* Get the P list first */
57 List
= (PNPAGED_LOOKASIDE_LIST
)Prcb
->PPLookasideList
[Type
].P
;
59 /* Attempt allocation */
60 List
->L
.TotalAllocates
++;
61 Buffer
= (PVOID
)InterlockedPopEntrySList(&List
->L
.ListHead
);
64 /* Let the balancer know that the P list failed */
65 List
->L
.AllocateMisses
++;
68 List
= (PNPAGED_LOOKASIDE_LIST
)Prcb
->PPLookasideList
[Type
].L
;
69 List
->L
.TotalAllocates
++;
70 Buffer
= (PVOID
)InterlockedPopEntrySList(&List
->L
.ListHead
);
73 /* Let the balancer know the L list failed too */
74 List
->L
.AllocateMisses
++;
77 Buffer
= List
->L
.Allocate(List
->L
.Type
, List
->L
.Size
, List
->L
.Tag
);
87 ObpFreeCapturedAttributes(IN PVOID Buffer
,
88 IN PP_NPAGED_LOOKASIDE_NUMBER Type
)
90 PNPAGED_LOOKASIDE_LIST List
;
91 PKPRCB Prcb
= KeGetCurrentPrcb();
94 List
= (PNPAGED_LOOKASIDE_LIST
)Prcb
->PPLookasideList
[Type
].P
;
97 /* Check if the Free was within the Depth or not */
98 if (ExQueryDepthSList(&List
->L
.ListHead
) >= List
->L
.Depth
)
100 /* Let the balancer know */
101 List
->L
.FreeMisses
++;
104 List
= (PNPAGED_LOOKASIDE_LIST
)Prcb
->PPLookasideList
[Type
].L
;
105 List
->L
.TotalFrees
++;
107 /* Check if the Free was within the Depth or not */
108 if (ExQueryDepthSList(&List
->L
.ListHead
) >= List
->L
.Depth
)
110 /* All lists failed, use the pool */
111 List
->L
.FreeMisses
++;
112 List
->L
.Free(Buffer
);
117 /* The free was within the Depth */
118 InterlockedPushEntrySList(&List
->L
.ListHead
,
119 (PSINGLE_LIST_ENTRY
)Buffer
);
125 ObpReleaseCapturedName(IN PUNICODE_STRING Name
)
127 /* We know this is a pool-allocation if the size doesn't match */
128 if (Name
->MaximumLength
!= 248)
130 ExFreePool(Name
->Buffer
);
134 /* Otherwise, free from the lookaside */
135 ObpFreeCapturedAttributes(Name
, LookasideNameBufferList
);
141 ObpFreeAndReleaseCapturedAttributes(IN POBJECT_CREATE_INFORMATION ObjectCreateInfo
)
143 /* First release the attributes, then free them from the lookaside list */
144 ObpReleaseCapturedAttributes(ObjectCreateInfo
);
145 ObpFreeCapturedAttributes(ObjectCreateInfo
, LookasideCreateInfoList
);