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 *****************************************************************/
28 LUID DummyLuidValue
= SYSTEM_LUID
;
30 LuidValue
.u
.HighPart
= DummyLuidValue
.HighPart
;
31 LuidValue
.u
.LowPart
= DummyLuidValue
.LowPart
;
32 LuidIncrement
.QuadPart
= 1;
38 ExpAllocateLocallyUniqueId(OUT LUID
*LocallyUniqueId
)
40 LARGE_INTEGER NewLuid
, PrevLuid
;
42 /* atomically increment the luid */
46 NewLuid
= RtlLargeIntegerAdd(PrevLuid
,
48 } while(ExfInterlockedCompareExchange64(&LuidValue
.QuadPart
,
50 &PrevLuid
.QuadPart
) != PrevLuid
.QuadPart
);
52 LocallyUniqueId
->LowPart
= NewLuid
.u
.LowPart
;
53 LocallyUniqueId
->HighPart
= NewLuid
.u
.HighPart
;
55 return STATUS_SUCCESS
;
63 NtAllocateLocallyUniqueId(OUT LUID
*LocallyUniqueId
)
66 KPROCESSOR_MODE PreviousMode
;
67 NTSTATUS Status
= STATUS_SUCCESS
;
71 PreviousMode
= ExGetPreviousMode();
73 if(PreviousMode
!= KernelMode
)
77 ProbeForWrite(LocallyUniqueId
,
83 Status
= _SEH_GetExceptionCode();
87 if(!NT_SUCCESS(Status
))
93 Status
= ExpAllocateLocallyUniqueId(&NewLuid
);
97 *LocallyUniqueId
= NewLuid
;
101 Status
= _SEH_GetExceptionCode();