3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/se/luid.c
6 * PURPOSE: Security manager
8 * PROGRAMMERS: No programmer listed.
11 /* INCLUDES *****************************************************************/
14 #include <internal/debug.h>
16 /* GLOBALS *******************************************************************/
18 static LARGE_INTEGER LuidIncrement
;
19 static LARGE_INTEGER LuidValue
;
21 /* FUNCTIONS *****************************************************************/
26 LUID DummyLuidValue
= SYSTEM_LUID
;
28 LuidValue
.u
.HighPart
= DummyLuidValue
.HighPart
;
29 LuidValue
.u
.LowPart
= DummyLuidValue
.LowPart
;
30 LuidIncrement
.QuadPart
= 1;
35 ExpAllocateLocallyUniqueId(OUT LUID
*LocallyUniqueId
)
37 LARGE_INTEGER NewLuid
, PrevLuid
;
39 /* atomically increment the luid */
42 PrevLuid
= (volatile LARGE_INTEGER
)LuidValue
;
43 NewLuid
= RtlLargeIntegerAdd(PrevLuid
,
45 } while(ExfInterlockedCompareExchange64(&LuidValue
.QuadPart
,
47 &PrevLuid
.QuadPart
) != PrevLuid
.QuadPart
);
49 LocallyUniqueId
->LowPart
= NewLuid
.u
.LowPart
;
50 LocallyUniqueId
->HighPart
= NewLuid
.u
.HighPart
;
52 return STATUS_SUCCESS
;
60 NtAllocateLocallyUniqueId(OUT LUID
*LocallyUniqueId
)
63 KPROCESSOR_MODE PreviousMode
;
64 NTSTATUS Status
= STATUS_SUCCESS
;
68 PreviousMode
= ExGetPreviousMode();
70 if(PreviousMode
!= KernelMode
)
74 ProbeForWrite(LocallyUniqueId
,
80 Status
= _SEH_GetExceptionCode();
84 if(!NT_SUCCESS(Status
))
90 Status
= ExpAllocateLocallyUniqueId(&NewLuid
);
94 *LocallyUniqueId
= NewLuid
;
98 Status
= _SEH_GetExceptionCode();