From fffe4f6385fed59082ea5e1fd3b91b99f848ef3d Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Thu, 12 Jul 2018 15:54:52 +0200 Subject: [PATCH 1/1] [NTOS:EX] Use InterlockedExchangeAdd64 instead of InterlockedCompareExchange64 loop in ExAllocateLocallyUniqueId --- ntoskrnl/ex/uuid.c | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/ntoskrnl/ex/uuid.c b/ntoskrnl/ex/uuid.c index 4d3c2932bce..8af4776d0b1 100644 --- a/ntoskrnl/ex/uuid.c +++ b/ntoskrnl/ex/uuid.c @@ -339,27 +339,9 @@ VOID NTAPI ExAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId) { - LARGE_INTEGER PrevLuid; - LONGLONG NewLuid, CompLuid; - /* Atomically increment the luid */ - PrevLuid.QuadPart = ExpLuid.QuadPart; - for (NewLuid = ExpLuid.QuadPart + ExpLuidIncrement; ; - NewLuid = PrevLuid.QuadPart + ExpLuidIncrement) - { - CompLuid = InterlockedCompareExchange64(&ExpLuid.QuadPart, - NewLuid, - PrevLuid.QuadPart); - if (CompLuid == PrevLuid.QuadPart) - { - break; - } - - PrevLuid.QuadPart = CompLuid; - } - - LocallyUniqueId->LowPart = PrevLuid.LowPart; - LocallyUniqueId->HighPart = PrevLuid.HighPart; + *(LONG64*)LocallyUniqueId = InterlockedExchangeAdd64(&ExpLuid.QuadPart, + ExpLuidIncrement); } -- 2.17.1