https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7790670dd80c5d4cf3c4b…
commit 7790670dd80c5d4cf3c4b68f8327fe97126c6229
Author: Serge Gautherie <reactos-git_serge_171003(a)gautherie.fr>
AuthorDate: Wed Sep 9 03:46:56 2020 +0200
Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org>
CommitDate: Sat Oct 17 15:00:19 2020 +0200
[NTOS:EX] ExUuidCreate(): Correctly fill Uuid->Data4
ROSTESTS-359
Co-authored-by: Nguyen Trung Khanh <nguyentrungkhanh97(a)gmail.com>
---
ntoskrnl/ex/uuid.c | 10 ++++++----
ntoskrnl/include/internal/ex.h | 13 ++++++++++---
2 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/ntoskrnl/ex/uuid.c b/ntoskrnl/ex/uuid.c
index 0d198fbe4fe..b69200b1a86 100644
--- a/ntoskrnl/ex/uuid.c
+++ b/ntoskrnl/ex/uuid.c
@@ -42,7 +42,7 @@ LARGE_INTEGER ExpUuidLastTimeAllocated;
ULONG ExpUuidSequenceNumber = 0;
BOOLEAN ExpUuidSequenceNumberValid;
BOOLEAN ExpUuidSequenceNumberNotSaved = FALSE;
-UUID_CACHED_VALUES_STRUCT ExpUuidCachedValues = {0ULL, 0xFFFFFFFF, 0, 0, { 0x80, 0x6E,
0x6F, 0x6E, 0x69, 0x63}};
+UUID_CACHED_VALUES_STRUCT ExpUuidCachedValues = {0ULL, 0xFFFFFFFF, {{0, 0, {0x80, 0x6E,
0x6F, 0x6E, 0x69, 0x63}}}};
BOOLEAN ExpUuidCacheValid = FALSE;
ULONG ExpLuidIncrement = 1;
LARGE_INTEGER ExpLuid = {{0x3e9, 0x0}};
@@ -400,9 +400,11 @@ ExUuidCreate(OUT UUID *Uuid)
{
Time.QuadPart = ExpUuidCachedValues.Time;
- RtlCopyMemory(&Uuid->Data4[0],
- &ExpUuidCachedValues.NodeId[0],
- SEED_BUFFER_SIZE);
+ C_ASSERT(sizeof(ExpUuidCachedValues.GuidInit) == sizeof(Uuid->Data4));
+ RtlCopyMemory(Uuid->Data4,
+ ExpUuidCachedValues.GuidInit,
+ sizeof(Uuid->Data4));
+
Valid = ExpUuidCacheValid;
AllocatedCount =
InterlockedDecrement(&ExpUuidCachedValues.AllocatedCount);
}
diff --git a/ntoskrnl/include/internal/ex.h b/ntoskrnl/include/internal/ex.h
index 52e58bffbef..0690b7b9801 100644
--- a/ntoskrnl/include/internal/ex.h
+++ b/ntoskrnl/include/internal/ex.h
@@ -171,9 +171,16 @@ typedef struct _UUID_CACHED_VALUES_STRUCT
{
ULONGLONG Time;
LONG AllocatedCount;
- UCHAR ClockSeqHiAndReserved;
- UCHAR ClockSeqLow;
- UCHAR NodeId [ 6 ] ;
+ union
+ {
+ struct
+ {
+ UCHAR ClockSeqHiAndReserved;
+ UCHAR ClockSeqLow;
+ UCHAR NodeId[6 /*SEED_BUFFER_SIZE*/];
+ };
+ UCHAR GuidInit[8]; /* Match GUID.Data4 */
+ };
} UUID_CACHED_VALUES_STRUCT, *PUUID_CACHED_VALUES_STRUCT;
/* INITIALIZATION FUNCTIONS *************************************************/