ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
March 2019
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
36 participants
217 discussions
Start a n
N
ew thread
[reactos] 01/01: [NTOSKRNL] Fix MSVC2010 build
by Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1114b89952ab6d92d7c61…
commit 1114b89952ab6d92d7c6156f6c8f0fba2f32e334 Author: Pierre Schweitzer <pierre(a)reactos.org> AuthorDate: Sat Mar 2 11:10:37 2019 +0100 Commit: Pierre Schweitzer <pierre(a)reactos.org> CommitDate: Sat Mar 2 11:10:37 2019 +0100 [NTOSKRNL] Fix MSVC2010 build --- ntoskrnl/ex/uuid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ntoskrnl/ex/uuid.c b/ntoskrnl/ex/uuid.c index 8c8270a3db..fdda755214 100644 --- a/ntoskrnl/ex/uuid.c +++ b/ntoskrnl/ex/uuid.c @@ -45,7 +45,7 @@ BOOLEAN ExpUuidSequenceNumberNotSaved = FALSE; UUID_CACHED_VALUES_STRUCT ExpUuidCachedValues = {0ULL, 0xFFFFFFFF, 0, 0, { 0x80, 0x6E, 0x6F, 0x6E, 0x69, 0x63}}; BOOLEAN ExpUuidCacheValid = FALSE; ULONG ExpLuidIncrement = 1; -LARGE_INTEGER ExpLuid = {.LowPart = 0x3e9, .HighPart = 0x0}; +LARGE_INTEGER ExpLuid = {{0x3e9, 0x0}}; /* FUNCTIONS ****************************************************************/
5 years, 9 months
1
0
0
0
[reactos] 01/01: [NTOSKRNL] Fix ClockDiff aka fix MSVC build
by Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c2b6c3a69ff133c3370a1…
commit c2b6c3a69ff133c3370a118a1abaa48dee91122a Author: Pierre Schweitzer <pierre(a)reactos.org> AuthorDate: Sat Mar 2 10:45:34 2019 +0100 Commit: Pierre Schweitzer <pierre(a)reactos.org> CommitDate: Sat Mar 2 10:45:34 2019 +0100 [NTOSKRNL] Fix ClockDiff aka fix MSVC build --- ntoskrnl/ex/uuid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ntoskrnl/ex/uuid.c b/ntoskrnl/ex/uuid.c index 1f41bdb122..8c8270a3db 100644 --- a/ntoskrnl/ex/uuid.c +++ b/ntoskrnl/ex/uuid.c @@ -261,7 +261,7 @@ ExpAllocateUuids(PULARGE_INTEGER Time, else { *Range = TIME_FRAME; - ClockDiff.QuadPart -= TIME_FRAME; + ClockDiff.QuadPart = TimeDiff.QuadPart - TIME_FRAME; --ClockDiff.HighPart; }
5 years, 9 months
1
0
0
0
[reactos] 01/01: [NTOSKRNL] Add a test for ExUuidCreate
by Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=bbfb3caa3609bb1716a14…
commit bbfb3caa3609bb1716a146efc5437dc4c6e4a910 Author: Pierre Schweitzer <pierre(a)reactos.org> AuthorDate: Sat Mar 2 10:29:26 2019 +0100 Commit: Pierre Schweitzer <pierre(a)reactos.org> CommitDate: Sat Mar 2 10:30:00 2019 +0100 [NTOSKRNL] Add a test for ExUuidCreate --- modules/rostests/kmtests/CMakeLists.txt | 1 + modules/rostests/kmtests/kmtest_drv/testlist.c | 2 ++ modules/rostests/kmtests/ntos_ex/ExUuid.c | 21 +++++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/modules/rostests/kmtests/CMakeLists.txt b/modules/rostests/kmtests/CMakeLists.txt index feb522be36..8d56d61b2d 100644 --- a/modules/rostests/kmtests/CMakeLists.txt +++ b/modules/rostests/kmtests/CMakeLists.txt @@ -54,6 +54,7 @@ list(APPEND KMTEST_DRV_SOURCE ntos_ex/ExSequencedList.c ntos_ex/ExSingleList.c ntos_ex/ExTimer.c + ntos_ex/ExUuid.c ntos_fsrtl/FsRtlDissect.c ntos_fsrtl/FsRtlExpression.c ntos_fsrtl/FsRtlLegal.c diff --git a/modules/rostests/kmtests/kmtest_drv/testlist.c b/modules/rostests/kmtests/kmtest_drv/testlist.c index fea8708b4f..11d63bbad2 100644 --- a/modules/rostests/kmtests/kmtest_drv/testlist.c +++ b/modules/rostests/kmtests/kmtest_drv/testlist.c @@ -19,6 +19,7 @@ KMT_TESTFUNC Test_ExResource; KMT_TESTFUNC Test_ExSequencedList; KMT_TESTFUNC Test_ExSingleList; KMT_TESTFUNC Test_ExTimer; +KMT_TESTFUNC Test_ExUuid; KMT_TESTFUNC Test_FsRtlDissect; KMT_TESTFUNC Test_FsRtlExpression; KMT_TESTFUNC Test_FsRtlLegal; @@ -90,6 +91,7 @@ const KMT_TEST TestList[] = { "ExSequencedList", Test_ExSequencedList }, { "ExSingleList", Test_ExSingleList }, { "-ExTimer", Test_ExTimer }, + { "ExUuid", Test_ExUuid }, { "Example", Test_Example }, { "FsRtlDissect", Test_FsRtlDissect }, { "FsRtlExpression", Test_FsRtlExpression }, diff --git a/modules/rostests/kmtests/ntos_ex/ExUuid.c b/modules/rostests/kmtests/ntos_ex/ExUuid.c new file mode 100644 index 0000000000..2fb0bba8dc --- /dev/null +++ b/modules/rostests/kmtests/ntos_ex/ExUuid.c @@ -0,0 +1,21 @@ +/* + * PROJECT: ReactOS kernel-mode tests + * LICENSE: LGPLv2+ - See COPYING.LIB in the top level directory + * PURPOSE: Kernel-Mode Test Suite UUIDs test + * PROGRAMMER: Pierre Schweitzer <pierre(a)reactos.org> + */ + +#include <kmt_test.h> + +#define NDEBUG +#include <debug.h> + +START_TEST(ExUuid) +{ + UUID Uuid; + NTSTATUS Status; + + Status = ExUuidCreate(&Uuid); + ok(Status == STATUS_SUCCESS, "ExUuidCreate returned unexpected status: %lx\n", Status); + ok((Uuid.Data3 & 0x1000) == 0x1000, "Invalid UUID version: %x\n", (Uuid.Data3 & 0xF000)); +}
5 years, 9 months
1
0
0
0
[reactos] 01/01: [SNDVOL32] In record mode, rename the 'Mute' autocheckbox to 'Select', turn it into a checkbox and make it behave like a radiobutton.
by Eric Kohl
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=28309096df136f9c15fe5…
commit 28309096df136f9c15fe53d4225fe87dd0331dd4 Author: Eric Kohl <eric.kohl(a)reactos.org> AuthorDate: Fri Mar 1 22:01:14 2019 +0100 Commit: Eric Kohl <eric.kohl(a)reactos.org> CommitDate: Fri Mar 1 22:01:14 2019 +0100 [SNDVOL32] In record mode, rename the 'Mute' autocheckbox to 'Select', turn it into a checkbox and make it behave like a radiobutton. --- base/applications/sndvol32/dialog.c | 17 ++++++++++++++++- base/applications/sndvol32/sndvol32.c | 28 ++++++++++++++++++++-------- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/base/applications/sndvol32/dialog.c b/base/applications/sndvol32/dialog.c index 781a59ea44..5a52272ed8 100644 --- a/base/applications/sndvol32/dialog.c +++ b/base/applications/sndvol32/dialog.c @@ -674,6 +674,7 @@ VOID LoadDialogCtrls( PPREFERENCES_CONTEXT PrefContext) { + WCHAR szBuffer[64]; HWND hDlgCtrl; RECT statusRect; UINT i; @@ -720,9 +721,23 @@ LoadDialogCtrls( SWP_NOZORDER); } - /* Resize the vertical line separators */ + if (PrefContext->MixerWindow->MixerId == RECORD_MIXER) + LoadStringW(hAppInstance, IDS_SELECT, szBuffer, ARRAYSIZE(szBuffer)); + for (i = 0; i < PrefContext->MixerWindow->DialogCount; i++) { + if (PrefContext->MixerWindow->MixerId == RECORD_MIXER) + { + hDlgCtrl = GetDlgItem(PrefContext->MixerWindow->hWnd, (i + 1) * IDC_LINE_SWITCH); + + /* Turn the autocheckbox into a checkbox */ + SetWindowLongPtr(hDlgCtrl, GWL_STYLE, (GetWindowLongPtr(hDlgCtrl, GWL_STYLE) & ~BS_AUTOCHECKBOX) | BS_CHECKBOX); + + /* Change text from 'Mute' to 'Select' */ + SetWindowTextW(hDlgCtrl, szBuffer); + } + + /* Resize the vertical line separator */ hDlgCtrl = GetDlgItem(PrefContext->MixerWindow->hWnd, (i + 1) * IDC_LINE_SEP); if (hDlgCtrl != NULL) { diff --git a/base/applications/sndvol32/sndvol32.c b/base/applications/sndvol32/sndvol32.c index 9a5578dc96..64ce3ac556 100644 --- a/base/applications/sndvol32/sndvol32.c +++ b/base/applications/sndvol32/sndvol32.c @@ -1000,16 +1000,28 @@ MainWindowProc(HWND hwnd, /* compute window id of line name static control */ CtrlID = LineOffset * IDC_LINE_NAME; - /* get line name */ - if (GetDlgItemTextW(hwnd, CtrlID, Context.LineName, MIXER_LONG_NAME_CHARS) != 0) + if (Preferences.MixerWindow->Mixer->MixerId == PLAY_MIXER) + { + /* get line name */ + if (GetDlgItemTextW(hwnd, CtrlID, Context.LineName, MIXER_LONG_NAME_CHARS) != 0) + { + /* setup context */ + Context.SliderPos = SendMessage((HWND)lParam, BM_GETCHECK, 0, 0); + Context.bVertical = FALSE; + Context.bSwitch = TRUE; + + /* set volume */ + SndMixerEnumConnections(Preferences.MixerWindow->Mixer, Preferences.SelectedLine, SetVolumeCallback, (LPVOID)&Context); + } + } + else if (Preferences.MixerWindow->Mixer->MixerId == RECORD_MIXER) { - /* setup context */ - Context.SliderPos = SendMessage((HWND)lParam, BM_GETCHECK, 0, 0); - Context.bVertical = FALSE; - Context.bSwitch = TRUE; + UINT i; - /* set volume */ - SndMixerEnumConnections(Preferences.MixerWindow->Mixer, Preferences.SelectedLine, SetVolumeCallback, (LPVOID)&Context); + for (i = 0; i < Preferences.MixerWindow->DialogCount; i++) + { + SendDlgItemMessageW(hwnd, (i + 1) * IDC_LINE_SWITCH, BM_SETCHECK, (WPARAM)((i + 1) == LineOffset), 0); + } } } else if (CtrlID % IDC_LINE_ADVANCED == 0)
5 years, 9 months
1
0
0
0
[reactos] 03/03: [NTOSKRNL] Rewrite/fix our UUID generation implementation So that it matches Windows behavior Also implement ExUuidCreate that will generate UUID version 1
by Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=eb8b481cd4f32472788c6…
commit eb8b481cd4f32472788c6e43c6a3a62a7d396d3b Author: Pierre Schweitzer <pierre(a)reactos.org> AuthorDate: Wed Feb 27 21:12:32 2019 +0100 Commit: Pierre Schweitzer <pierre(a)reactos.org> CommitDate: Fri Mar 1 08:22:48 2019 +0100 [NTOSKRNL] Rewrite/fix our UUID generation implementation So that it matches Windows behavior Also implement ExUuidCreate that will generate UUID version 1 The implementation is based on the RFC 4122 --- ntoskrnl/ex/init.c | 6 +- ntoskrnl/ex/uuid.c | 458 +++++++++++++++++++++++++++-------------- ntoskrnl/include/internal/ex.h | 9 +- ntoskrnl/include/internal/se.h | 5 - ntoskrnl/se/semgr.c | 2 +- 5 files changed, 321 insertions(+), 159 deletions(-) diff --git a/ntoskrnl/ex/init.c b/ntoskrnl/ex/init.c index 10be805374..1e31003af6 100644 --- a/ntoskrnl/ex/init.c +++ b/ntoskrnl/ex/init.c @@ -711,7 +711,11 @@ ExpInitSystemPhase1(VOID) } /* Initialize UUIDs */ - ExpInitUuids(); + if (ExpUuidInitialization() == FALSE) + { + DPRINT1("Executive: Uuid initialization failed\n"); + return FALSE; + } /* Initialize keyed events */ if (ExpInitializeKeyedEventImplementation() == FALSE) diff --git a/ntoskrnl/ex/uuid.c b/ntoskrnl/ex/uuid.c index 459b957270..1f41bdb122 100644 --- a/ntoskrnl/ex/uuid.c +++ b/ntoskrnl/ex/uuid.c @@ -5,6 +5,7 @@ * PURPOSE: UUID generator * PROGRAMMERS: Eric Kohl * Thomas Weidenmueller + * Pierre Schweitzer */ /* INCLUDES *****************************************************************/ @@ -25,75 +26,81 @@ #define SECS_15_OCT_1582_TO_1601 ((17 + 30 + 31 + 365 * 18 + 5) * SECSPERDAY) #define TICKS_15_OCT_1582_TO_1601 ((ULONGLONG)SECS_15_OCT_1582_TO_1601 * TICKSPERSEC) +/* 10000 in 100-ns model = 0,1 microsecond */ +#define TIME_FRAME 10000 + #if defined (ALLOC_PRAGMA) -#pragma alloc_text(INIT, ExpInitUuids) +#pragma alloc_text(INIT, ExpUuidInitialization) +#pragma alloc_text(INIT, ExLuidInitialization) #endif /* GLOBALS ****************************************************************/ -static FAST_MUTEX ExpUuidLock; -static ULARGE_INTEGER UuidLastTime; -static ULONG UuidSequence; -static BOOLEAN UuidSequenceInitialized = FALSE; -static BOOLEAN UuidSequenceChanged = FALSE; -static UCHAR UuidSeed[SEED_BUFFER_SIZE]; -static ULONG UuidCount; -static LARGE_INTEGER LuidIncrement; -static LARGE_INTEGER LuidValue; -UUID_CACHED_VALUES_STRUCT ExpUuidCachedValues = { 0ULL, 0xFFFFFFFF, 0, 0, { 0x80, 0x6E, 0x6F, 0x6E, 0x69, 0x63 } }; +FAST_MUTEX ExpUuidLock; +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}}; +BOOLEAN ExpUuidCacheValid = FALSE; +ULONG ExpLuidIncrement = 1; +LARGE_INTEGER ExpLuid = {.LowPart = 0x3e9, .HighPart = 0x0}; /* FUNCTIONS ****************************************************************/ -VOID +/* + * @implemented + */ +BOOLEAN INIT_FUNCTION NTAPI -ExpInitUuids(VOID) +ExpUuidInitialization(VOID) { ExInitializeFastMutex(&ExpUuidLock); - KeQuerySystemTime((PLARGE_INTEGER)&UuidLastTime); - UuidLastTime.QuadPart += TICKS_15_OCT_1582_TO_1601; + ExpUuidSequenceNumberValid = FALSE; + KeQuerySystemTime(&ExpUuidLastTimeAllocated); - UuidCount = TICKS_PER_CLOCK_TICK; - RtlZeroMemory(UuidSeed, SEED_BUFFER_SIZE); + return TRUE; } -#define VALUE_BUFFER_SIZE 256 - +/* + * @implemented + */ +#define VALUE_BUFFER_SIZE 20 static NTSTATUS -ExpLoadUuidSequence(PULONG Sequence) +ExpUuidLoadSequenceNumber(PULONG Sequence) { UCHAR ValueBuffer[VALUE_BUFFER_SIZE]; PKEY_VALUE_PARTIAL_INFORMATION ValueInfo; OBJECT_ATTRIBUTES ObjectAttributes; - UNICODE_STRING Name; + UNICODE_STRING KeyName, ValueName; HANDLE KeyHandle; ULONG ValueLength; NTSTATUS Status; - RtlInitUnicodeString(&Name, - L"\\Registry\\Machine\\Software\\Microsoft\\Rpc"); + PAGED_CODE(); + + RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\Microsoft\\Rpc"); + RtlInitUnicodeString(&ValueName, L"UuidSequenceNumber"); + InitializeObjectAttributes(&ObjectAttributes, - &Name, - OBJ_CASE_INSENSITIVE, + &KeyName, + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL); - Status = ZwOpenKey(&KeyHandle, - KEY_QUERY_VALUE, - &ObjectAttributes); + Status = ZwOpenKey(&KeyHandle, GENERIC_READ, &ObjectAttributes); if (!NT_SUCCESS(Status)) { DPRINT("ZwOpenKey() failed (Status %lx)\n", Status); return Status; } - RtlInitUnicodeString(&Name, L"UuidSequenceNumber"); - ValueInfo = (PKEY_VALUE_PARTIAL_INFORMATION)ValueBuffer; Status = ZwQueryValueKey(KeyHandle, - &Name, + &ValueName, KeyValuePartialInformation, ValueBuffer, VALUE_BUFFER_SIZE, @@ -105,6 +112,11 @@ ExpLoadUuidSequence(PULONG Sequence) return Status; } + if (ValueInfo->Type != REG_DWORD || ValueInfo->DataLength != sizeof(DWORD)) + { + return STATUS_UNSUCCESSFUL; + } + *Sequence = *((PULONG)ValueInfo->Data); DPRINT("Loaded sequence %lx\n", *Sequence); @@ -113,24 +125,29 @@ ExpLoadUuidSequence(PULONG Sequence) } #undef VALUE_BUFFER_SIZE - +/* + * @implemented + */ static NTSTATUS -ExpSaveUuidSequence(PULONG Sequence) +ExpUuidSaveSequenceNumber(PULONG Sequence) { OBJECT_ATTRIBUTES ObjectAttributes; - UNICODE_STRING Name; + UNICODE_STRING KeyName, ValueName; HANDLE KeyHandle; NTSTATUS Status; - RtlInitUnicodeString(&Name, - L"\\Registry\\Machine\\Software\\Microsoft\\Rpc"); + PAGED_CODE(); + + RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\Microsoft\\Rpc"); + RtlInitUnicodeString(&ValueName, L"UuidSequenceNumber"); + InitializeObjectAttributes(&ObjectAttributes, - &Name, - OBJ_CASE_INSENSITIVE, + &KeyName, + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL); Status = ZwOpenKey(&KeyHandle, - KEY_SET_VALUE, + GENERIC_READ | GENERIC_WRITE, &ObjectAttributes); if (!NT_SUCCESS(Status)) { @@ -138,9 +155,8 @@ ExpSaveUuidSequence(PULONG Sequence) return Status; } - RtlInitUnicodeString(&Name, L"UuidSequenceNumber"); Status = ZwSetValueKey(KeyHandle, - &Name, + &ValueName, 0, REG_DWORD, Sequence, @@ -154,98 +170,196 @@ ExpSaveUuidSequence(PULONG Sequence) return Status; } - +/* + * @implemented + * Warning! This function must be called + * with ExpUuidLock held! + */ static VOID -ExpGetRandomUuidSequence(PULONG Sequence) +ExpUuidSaveSequenceNumberIf(VOID) { - LARGE_INTEGER Counter; - LARGE_INTEGER Frequency; - ULONG Value; - - Counter = KeQueryPerformanceCounter(&Frequency); - Value = Counter.u.LowPart ^ Counter.u.HighPart; + NTSTATUS Status; - *Sequence = *Sequence ^ Value; + PAGED_CODE(); - DPRINT("Sequence %lx\n", *Sequence); + /* Only save sequence if it has to */ + if (ExpUuidSequenceNumberNotSaved == TRUE) + { + Status = ExpUuidSaveSequenceNumber(&ExpUuidSequenceNumber); + if (NT_SUCCESS(Status)) + { + ExpUuidSequenceNumberNotSaved = FALSE; + } + } } - +/* + * @implemented + * Warning! This function must be called + * with ExpUuidLock held! + */ static NTSTATUS -ExpCreateUuids(PULARGE_INTEGER Time, - PULONG Range, - PULONG Sequence) +ExpAllocateUuids(PULARGE_INTEGER Time, + PULONG Range, + PULONG Sequence) { - /* - * Generate time element of the UUID. Account for going faster - * than our clock as well as the clock going backwards. - */ - while (1) - { - KeQuerySystemTime((PLARGE_INTEGER)Time); - Time->QuadPart += TICKS_15_OCT_1582_TO_1601; + NTSTATUS Status; + LARGE_INTEGER Counter, Frequency, CurrentTime, TimeDiff, ClockDiff; - if (Time->QuadPart > UuidLastTime.QuadPart) - { - UuidCount = 0; - break; - } + PAGED_CODE(); - if (Time->QuadPart < UuidLastTime.QuadPart) + /* Initialize sequence number */ + if (!ExpUuidSequenceNumberValid) + { + /* Try to load sequence number */ + Status = ExpUuidLoadSequenceNumber(&ExpUuidSequenceNumber); + if (NT_SUCCESS(Status)) { - (*Sequence)++; - UuidSequenceChanged = TRUE; - UuidCount = 0; - break; + ++ExpUuidSequenceNumber; } - - if (UuidCount < TICKS_PER_CLOCK_TICK) + else { - UuidCount++; - break; + /* If we cannot, generate a "true" random */ + Counter = KeQueryPerformanceCounter(&Frequency); + ExpUuidSequenceNumber ^= (ULONG_PTR)&Status ^ (ULONG_PTR)Sequence ^ Counter.LowPart ^ Counter.HighPart; } + + /* It's valid and to be saved */ + ExpUuidSequenceNumberValid = TRUE; + ExpUuidSequenceNumberNotSaved = TRUE; + } + + KeQuerySystemTime(&CurrentTime); + TimeDiff.QuadPart = CurrentTime.QuadPart - ExpUuidLastTimeAllocated.QuadPart; + /* If time went backwards, change sequence (see RFC example) */ + if (TimeDiff.QuadPart < 0) + { + ++ExpUuidSequenceNumber; + TimeDiff.QuadPart = 2 * TIME_FRAME; + + /* It's to be saved */ + ExpUuidSequenceNumberNotSaved = TRUE; + ExpUuidLastTimeAllocated.QuadPart = CurrentTime.QuadPart - 2 * TIME_FRAME; + } + + if (TimeDiff.QuadPart == 0) + { + return STATUS_RETRY; } - UuidLastTime.QuadPart = Time->QuadPart; - Time->QuadPart += UuidCount; + /* If time diff > 0,1ms, squash it to reduce it to keep our clock resolution */ + if (TimeDiff.HighPart > 0 || TimeDiff.QuadPart > TICKS_PER_CLOCK_TICK * TIME_FRAME) + { + TimeDiff.QuadPart = TICKS_PER_CLOCK_TICK * TIME_FRAME; + } + + if (TimeDiff.HighPart < 0 || TimeDiff.QuadPart <= TIME_FRAME) + { + *Range = TimeDiff.QuadPart; + ClockDiff.QuadPart = 0LL; + } + else + { + *Range = TIME_FRAME; + ClockDiff.QuadPart -= TIME_FRAME; + --ClockDiff.HighPart; + } - *Range = 10000; /* What does this mean? Ticks per millisecond?*/ + Time->QuadPart = CurrentTime.QuadPart - *Range - ClockDiff.QuadPart; + ExpUuidLastTimeAllocated.QuadPart = CurrentTime.QuadPart - ClockDiff.QuadPart; + *Sequence = ExpUuidSequenceNumber; return STATUS_SUCCESS; } -VOID -INIT_FUNCTION -NTAPI -ExpInitLuid(VOID) +/* + * @implemented + * Warning! This function must be called + * with ExpUuidLock held! + */ +static NTSTATUS +ExpUuidGetValues(PUUID_CACHED_VALUES_STRUCT CachedValues) { - LUID DummyLuidValue = SYSTEM_LUID; + NTSTATUS Status; + ULARGE_INTEGER Time; + ULONG Range; + ULONG Sequence; + + PAGED_CODE(); - LuidValue.u.HighPart = DummyLuidValue.HighPart; - LuidValue.u.LowPart = DummyLuidValue.LowPart; - LuidIncrement.QuadPart = 1; + /* Allocate UUIDs */ + Status = ExpAllocateUuids(&Time, &Range, &Sequence); + if (Status == STATUS_RETRY) + { + return Status; + } + + if (!NT_SUCCESS(Status)) + { + return STATUS_NO_MEMORY; + } + + /* We need at least one UUID */ + ASSERT(Range != 0); + + /* Set up our internal cache + * See format_uuid_v1 in RFC4122 for magic values + */ + CachedValues->ClockSeqLow = Sequence; + CachedValues->ClockSeqHiAndReserved = (Sequence & 0x3F00) >> 8; + CachedValues->ClockSeqHiAndReserved |= 0x80; + CachedValues->AllocatedCount = Range; + + /* + * Time is relative to UUID time + * And we set last time range for all the possibly + * returnable UUID + */ + Time.QuadPart += TICKS_15_OCT_1582_TO_1601; + CachedValues->Time = Time.QuadPart + (Range - 1); + + return STATUS_SUCCESS; } +/* + * @implemented + */ +BOOLEAN +INIT_FUNCTION +NTAPI +ExLuidInitialization(VOID) +{ + return TRUE; +} +/* + * @implemented + */ VOID NTAPI ExAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId) { - LARGE_INTEGER NewLuid, PrevLuid; + LARGE_INTEGER PrevLuid; + LONGLONG NewLuid, CompLuid; - /* atomically increment the luid */ - do + /* Atomically increment the luid */ + PrevLuid.QuadPart = ExpLuid.QuadPart; + for (NewLuid = ExpLuid.QuadPart + ExpLuidIncrement; ; + NewLuid = PrevLuid.QuadPart + ExpLuidIncrement) { - PrevLuid = LuidValue; - NewLuid = RtlLargeIntegerAdd(PrevLuid, - LuidIncrement); - } while(ExInterlockedCompareExchange64(&LuidValue.QuadPart, - &NewLuid.QuadPart, - &PrevLuid.QuadPart, - NULL) != PrevLuid.QuadPart); - - LocallyUniqueId->LowPart = NewLuid.u.LowPart; - LocallyUniqueId->HighPart = NewLuid.u.HighPart; + CompLuid = InterlockedCompareExchange64(&ExpLuid.QuadPart, + NewLuid, + PrevLuid.QuadPart); + if (CompLuid == PrevLuid.QuadPart) + { + break; + } + + PrevLuid.QuadPart = CompLuid; + } + + LocallyUniqueId->LowPart = PrevLuid.LowPart; + LocallyUniqueId->HighPart = PrevLuid.HighPart; } @@ -256,9 +370,7 @@ NTSTATUS NTAPI NtAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId) { - LUID NewLuid; KPROCESSOR_MODE PreviousMode; - NTSTATUS Status; PAGED_CODE(); /* Probe if user mode */ @@ -279,35 +391,91 @@ NtAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId) } /* Do the allocation */ - ExAllocateLocallyUniqueId(&NewLuid); - Status = STATUS_SUCCESS; - - /* Write back LUID to caller */ - _SEH2_TRY - { - *LocallyUniqueId = NewLuid; - } - _SEH2_EXCEPT(ExSystemExceptionFilter()) - { - Status = _SEH2_GetExceptionCode(); - } - _SEH2_END; - return Status; + ExAllocateLocallyUniqueId(LocallyUniqueId); + return STATUS_SUCCESS; } /* - * @unimplemented + * @implemented */ NTSTATUS NTAPI ExUuidCreate(OUT UUID *Uuid) { - UNIMPLEMENTED; - return FALSE; + NTSTATUS Status; + LONG AllocatedCount; + LARGE_INTEGER Time; + BOOLEAN Valid; + + PAGED_CODE(); + + Status = STATUS_SUCCESS; + /* Loop until we have an UUID to return */ + while (TRUE) + { + /* Try to gather node values */ + do + { + Time.QuadPart = ExpUuidCachedValues.Time; + + RtlCopyMemory(&Uuid->Data4[0], + &ExpUuidCachedValues.NodeId[0], + SEED_BUFFER_SIZE); + Valid = ExpUuidCacheValid; + AllocatedCount = InterlockedDecrement(&ExpUuidCachedValues.AllocatedCount); + } + /* Loop till we can do it without being disturbed */ + while (Time.QuadPart != ExpUuidCachedValues.Time); + + /* We have more than an allocated UUID left, that's OK to return! */ + if (AllocatedCount >= 0) + { + break; + } + + /* + * Here, we're out of UUIDs, we need to allocate more + * We need to be alone to do it, so lock the mutex + */ + ExAcquireFastMutex(&ExpUuidLock); + if (Time.QuadPart == ExpUuidCachedValues.Time) + { + /* If allocation fails, bail out! */ + Status = ExpUuidGetValues(&ExpUuidCachedValues); + if (Status != STATUS_SUCCESS) + { + ExReleaseFastMutex(&ExpUuidLock); + return Status; + } + + /* Save our current sequence if changed */ + ExpUuidSaveSequenceNumberIf(); + } + ExReleaseFastMutex(&ExpUuidLock); + } + + /* + * Once here, we've got an UUID to return + * But, if our init wasn't sane, then, make + * sure it's only used locally + */ + if (!Valid) + { + Status = RPC_NT_UUID_LOCAL_ONLY; + } + + /* Set our timestamp - see RFC4211 */ + Time.QuadPart -= AllocatedCount; + Uuid->Data1 = Time.LowPart; + Uuid->Data2 = Time.HighPart; + /* We also set the bit for GUIDv1 */ + Uuid->Data3 = ((Time.HighPart >> 16) & 0x0FFF) | 0x1000; + + return Status; } /* - * @unimplemented + * @implemented */ NTSTATUS NTAPI @@ -317,7 +485,7 @@ NtAllocateUuids(OUT PULARGE_INTEGER Time, OUT PUCHAR Seed) { ULARGE_INTEGER IntTime; - ULONG IntRange; + ULONG IntRange, IntSequence; NTSTATUS Status; KPROCESSOR_MODE PreviousMode; @@ -352,40 +520,22 @@ NtAllocateUuids(OUT PULARGE_INTEGER Time, _SEH2_END; } + /* During allocation we must be alone */ ExAcquireFastMutex(&ExpUuidLock); - if (!UuidSequenceInitialized) - { - Status = ExpLoadUuidSequence(&UuidSequence); - if (NT_SUCCESS(Status)) - { - UuidSequence++; - } - else - { - ExpGetRandomUuidSequence(&UuidSequence); - } - - UuidSequenceInitialized = TRUE; - UuidSequenceChanged = TRUE; - } - - Status = ExpCreateUuids(&IntTime, - &IntRange, - &UuidSequence); + Status = ExpAllocateUuids(&IntTime, + &IntRange, + &IntSequence); if (!NT_SUCCESS(Status)) { ExReleaseFastMutex(&ExpUuidLock); return Status; } - if (UuidSequenceChanged) - { - Status = ExpSaveUuidSequence(&UuidSequence); - if (NT_SUCCESS(Status)) - UuidSequenceChanged = FALSE; - } + /* If sequence number was changed, save it */ + ExpUuidSaveSequenceNumberIf(); + /* Allocation done, so we can release */ ExReleaseFastMutex(&ExpUuidLock); /* Write back UUIDs to caller */ @@ -393,10 +543,10 @@ NtAllocateUuids(OUT PULARGE_INTEGER Time, { Time->QuadPart = IntTime.QuadPart; *Range = IntRange; - *Sequence = UuidSequence; + *Sequence = IntSequence; RtlCopyMemory(Seed, - UuidSeed, + &ExpUuidCachedValues.NodeId[0], SEED_BUFFER_SIZE); Status = STATUS_SUCCESS; @@ -453,7 +603,15 @@ NtSetUuidSeed(IN PUCHAR Seed) /* Check for buffer validity and then copy it to our seed */ ProbeForRead(Seed, SEED_BUFFER_SIZE, sizeof(UCHAR)); - RtlCopyMemory(UuidSeed, Seed, SEED_BUFFER_SIZE); + RtlCopyMemory(&ExpUuidCachedValues.NodeId[0], Seed, SEED_BUFFER_SIZE); + + /* + * According to RFC 4122, UUID seed is based on MAC addresses + * If it is randomly set, then, it must have its multicast be set + * to be valid and avoid collisions + * Reflect it here + */ + ExpUuidCacheValid = ~(*Seed >> 7) & 1; Status = STATUS_SUCCESS; } diff --git a/ntoskrnl/include/internal/ex.h b/ntoskrnl/include/internal/ex.h index 2072a6a31c..52e58bffbe 100644 --- a/ntoskrnl/include/internal/ex.h +++ b/ntoskrnl/include/internal/ex.h @@ -236,9 +236,14 @@ NTAPI ExpInitializeCallbacks(VOID); INIT_FUNCTION -VOID +BOOLEAN +NTAPI +ExpUuidInitialization(VOID); + +INIT_FUNCTION +BOOLEAN NTAPI -ExpInitUuids(VOID); +ExLuidInitialization(VOID); INIT_FUNCTION VOID diff --git a/ntoskrnl/include/internal/se.h b/ntoskrnl/include/internal/se.h index e2285fd29d..aec259cdb7 100644 --- a/ntoskrnl/include/internal/se.h +++ b/ntoskrnl/include/internal/se.h @@ -248,11 +248,6 @@ BOOLEAN NTAPI SeInitSystem(VOID); -INIT_FUNCTION -VOID -NTAPI -ExpInitLuid(VOID); - INIT_FUNCTION VOID NTAPI diff --git a/ntoskrnl/se/semgr.c b/ntoskrnl/se/semgr.c index 3156e64227..18768c75ff 100644 --- a/ntoskrnl/se/semgr.c +++ b/ntoskrnl/se/semgr.c @@ -97,7 +97,7 @@ SepInitializationPhase0(VOID) { PAGED_CODE(); - ExpInitLuid(); + if (!ExLuidInitialization()) return FALSE; if (!SepInitSecurityIDs()) return FALSE; if (!SepInitDACLs()) return FALSE; if (!SepInitSDs()) return FALSE;
5 years, 9 months
1
0
0
0
[reactos] 02/03: [NTOSKRNL] Introduce the UUID_CACHED_VALUES_STRUCT structure
by Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2d9673c68fd6ce9d8749a…
commit 2d9673c68fd6ce9d8749aac0ed3c6bf04c1ba32a Author: Pierre Schweitzer <pierre(a)reactos.org> AuthorDate: Wed Feb 27 09:02:30 2019 +0100 Commit: Pierre Schweitzer <pierre(a)reactos.org> CommitDate: Fri Mar 1 08:22:47 2019 +0100 [NTOSKRNL] Introduce the UUID_CACHED_VALUES_STRUCT structure Source:
https://blog.48bits.com/el-codigo-ntoskvinci/
--- ntoskrnl/ex/uuid.c | 1 + ntoskrnl/include/internal/ex.h | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/ntoskrnl/ex/uuid.c b/ntoskrnl/ex/uuid.c index 60103f04b4..459b957270 100644 --- a/ntoskrnl/ex/uuid.c +++ b/ntoskrnl/ex/uuid.c @@ -41,6 +41,7 @@ static UCHAR UuidSeed[SEED_BUFFER_SIZE]; static ULONG UuidCount; static LARGE_INTEGER LuidIncrement; static LARGE_INTEGER LuidValue; +UUID_CACHED_VALUES_STRUCT ExpUuidCachedValues = { 0ULL, 0xFFFFFFFF, 0, 0, { 0x80, 0x6E, 0x6F, 0x6E, 0x69, 0x63 } }; /* FUNCTIONS ****************************************************************/ diff --git a/ntoskrnl/include/internal/ex.h b/ntoskrnl/include/internal/ex.h index 2eaf8d2da0..2072a6a31c 100644 --- a/ntoskrnl/include/internal/ex.h +++ b/ntoskrnl/include/internal/ex.h @@ -167,6 +167,15 @@ ExGetPoolTagInfo( IN OUT PULONG ReturnLength OPTIONAL ); +typedef struct _UUID_CACHED_VALUES_STRUCT +{ + ULONGLONG Time; + LONG AllocatedCount; + UCHAR ClockSeqHiAndReserved; + UCHAR ClockSeqLow; + UCHAR NodeId [ 6 ] ; +} UUID_CACHED_VALUES_STRUCT, *PUUID_CACHED_VALUES_STRUCT; + /* INITIALIZATION FUNCTIONS *************************************************/ INIT_FUNCTION
5 years, 9 months
1
0
0
0
[reactos] 01/03: [NTOSKRNL] UuidMutex -> ExpUuidLock
by Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=81c88c1029b3569a560b1…
commit 81c88c1029b3569a560b1d32736a03bf0cb05ff5 Author: Pierre Schweitzer <pierre(a)reactos.org> AuthorDate: Wed Feb 27 08:54:48 2019 +0100 Commit: Pierre Schweitzer <pierre(a)reactos.org> CommitDate: Fri Mar 1 08:22:47 2019 +0100 [NTOSKRNL] UuidMutex -> ExpUuidLock --- ntoskrnl/ex/uuid.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ntoskrnl/ex/uuid.c b/ntoskrnl/ex/uuid.c index cae12d7bd1..60103f04b4 100644 --- a/ntoskrnl/ex/uuid.c +++ b/ntoskrnl/ex/uuid.c @@ -32,7 +32,7 @@ /* GLOBALS ****************************************************************/ -static FAST_MUTEX UuidMutex; +static FAST_MUTEX ExpUuidLock; static ULARGE_INTEGER UuidLastTime; static ULONG UuidSequence; static BOOLEAN UuidSequenceInitialized = FALSE; @@ -49,7 +49,7 @@ INIT_FUNCTION NTAPI ExpInitUuids(VOID) { - ExInitializeFastMutex(&UuidMutex); + ExInitializeFastMutex(&ExpUuidLock); KeQuerySystemTime((PLARGE_INTEGER)&UuidLastTime); UuidLastTime.QuadPart += TICKS_15_OCT_1582_TO_1601; @@ -351,7 +351,7 @@ NtAllocateUuids(OUT PULARGE_INTEGER Time, _SEH2_END; } - ExAcquireFastMutex(&UuidMutex); + ExAcquireFastMutex(&ExpUuidLock); if (!UuidSequenceInitialized) { @@ -374,7 +374,7 @@ NtAllocateUuids(OUT PULARGE_INTEGER Time, &UuidSequence); if (!NT_SUCCESS(Status)) { - ExReleaseFastMutex(&UuidMutex); + ExReleaseFastMutex(&ExpUuidLock); return Status; } @@ -385,7 +385,7 @@ NtAllocateUuids(OUT PULARGE_INTEGER Time, UuidSequenceChanged = FALSE; } - ExReleaseFastMutex(&UuidMutex); + ExReleaseFastMutex(&ExpUuidLock); /* Write back UUIDs to caller */ _SEH2_TRY
5 years, 9 months
1
0
0
0
← Newer
1
...
19
20
21
22
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Results per page:
10
25
50
100
200