Author: fireball Date: Thu May 18 16:06:28 2006 New Revision: 21930
URL: http://svn.reactos.ru/svn/reactos?rev=21930&view=rev Log: [AUDIT] ntoskrnl/ex (according to functions_list.txt in audited branch comments by Alex Ionescu, and uuid.c comments by me) - dbgctrl.c: Modified the function slightly for compatibility with some keys, still has nothing to do with Windows' - lookas.c: File is clean. I merely rewrote existing versions based on a GPLed IBM driver I found on google, OSR documentation and some DDK sample code. The implementation is trivial and only calls caller-defined functions which are the ones doing the work. - uuid.c: Added programmers, unified formatting, STDCALL->NTAPI change. Code doesn't look suspicious, plus stubbed functions - win32k.c: Alex Ionescu only changed the functions to call Win32K instead of having the code in ntoskrnl. It was a cut/paste job. Aleksey Bragin: The code looks very trivial and straightforward, certainly it's written based on clean sources of information - zone.c: Based on David Welch's code, which Alex Ionescu merely cleaned up, using clean development. He's not even sure if the Zone functions are still in Windows.
Modified: trunk/reactos/ntoskrnl/ex/dbgctrl.c (props changed) trunk/reactos/ntoskrnl/ex/lookas.c (props changed) trunk/reactos/ntoskrnl/ex/uuid.c (contents, props changed) trunk/reactos/ntoskrnl/ex/win32k.c (props changed) trunk/reactos/ntoskrnl/ex/zone.c (props changed)
Propchange: trunk/reactos/ntoskrnl/ex/dbgctrl.c ------------------------------------------------------------------------------ --- svn:needs-lock (original) +++ svn:needs-lock (removed) @@ -1,1 +1,0 @@ -*
Propchange: trunk/reactos/ntoskrnl/ex/lookas.c ------------------------------------------------------------------------------ --- svn:needs-lock (original) +++ svn:needs-lock (removed) @@ -1,1 +1,0 @@ -*
Modified: trunk/reactos/ntoskrnl/ex/uuid.c URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/ex/uuid.c?rev=21930... ============================================================================== --- trunk/reactos/ntoskrnl/ex/uuid.c (original) +++ trunk/reactos/ntoskrnl/ex/uuid.c Thu May 18 16:06:28 2006 @@ -5,7 +5,8 @@ * FILE: ntoskrnl/ex/uuid.c * PURPOSE: UUID generator * - * PROGRAMMERS: No programmer listed. + * PROGRAMMERS: Eric Kohl + Thomas Weidenmueller */
/* INCLUDES *****************************************************************/ @@ -47,16 +48,16 @@
VOID INIT_FUNCTION -STDCALL +NTAPI ExpInitUuids(VOID) { - ExInitializeFastMutex(&UuidMutex); - - KeQuerySystemTime((PLARGE_INTEGER)&UuidLastTime); - UuidLastTime.QuadPart += TICKS_15_OCT_1582_TO_1601; - - UuidCount = TICKS_PER_CLOCK_TICK; - RtlZeroMemory(UuidSeed, SEED_BUFFER_SIZE); + ExInitializeFastMutex(&UuidMutex); + + KeQuerySystemTime((PLARGE_INTEGER)&UuidLastTime); + UuidLastTime.QuadPart += TICKS_15_OCT_1582_TO_1601; + + UuidCount = TICKS_PER_CLOCK_TICK; + RtlZeroMemory(UuidSeed, SEED_BUFFER_SIZE); }
@@ -65,52 +66,51 @@ static NTSTATUS ExpLoadUuidSequence(PULONG Sequence) { - UCHAR ValueBuffer[VALUE_BUFFER_SIZE]; - PKEY_VALUE_PARTIAL_INFORMATION ValueInfo; - OBJECT_ATTRIBUTES ObjectAttributes; - UNICODE_STRING Name; - HANDLE KeyHandle; - ULONG ValueLength; - NTSTATUS Status; - - RtlInitUnicodeString(&Name, - L"\Registry\Machine\Software\Microsoft\Rpc"); - InitializeObjectAttributes(&ObjectAttributes, - &Name, - OBJ_CASE_INSENSITIVE, - NULL, - NULL); - Status = ZwOpenKey(&KeyHandle, - KEY_QUERY_VALUE, - &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, - KeyValuePartialInformation, - ValueBuffer, - VALUE_BUFFER_SIZE, - &ValueLength); - ZwClose(KeyHandle); - if (!NT_SUCCESS(Status)) - { - DPRINT("ZwQueryValueKey() failed (Status %lx)\n", Status); - return Status; - } - - *Sequence = *((PULONG)ValueInfo->Data); - - DPRINT("Loaded sequence %lx\n", *Sequence); - - return STATUS_SUCCESS; + UCHAR ValueBuffer[VALUE_BUFFER_SIZE]; + PKEY_VALUE_PARTIAL_INFORMATION ValueInfo; + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING Name; + HANDLE KeyHandle; + ULONG ValueLength; + NTSTATUS Status; + + RtlInitUnicodeString(&Name, + L"\Registry\Machine\Software\Microsoft\Rpc"); + InitializeObjectAttributes(&ObjectAttributes, + &Name, + OBJ_CASE_INSENSITIVE, + NULL, + NULL); + Status = ZwOpenKey(&KeyHandle, + KEY_QUERY_VALUE, + &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, + KeyValuePartialInformation, + ValueBuffer, + VALUE_BUFFER_SIZE, + &ValueLength); + ZwClose(KeyHandle); + if (!NT_SUCCESS(Status)) + { + DPRINT("ZwQueryValueKey() failed (Status %lx)\n", Status); + return Status; + } + + *Sequence = *((PULONG)ValueInfo->Data); + + DPRINT("Loaded sequence %lx\n", *Sequence); + + return STATUS_SUCCESS; } #undef VALUE_BUFFER_SIZE
@@ -118,192 +118,191 @@ static NTSTATUS ExpSaveUuidSequence(PULONG Sequence) { - OBJECT_ATTRIBUTES ObjectAttributes; - UNICODE_STRING Name; - HANDLE KeyHandle; - NTSTATUS Status; - - RtlInitUnicodeString(&Name, - L"\Registry\Machine\Software\Microsoft\Rpc"); - InitializeObjectAttributes(&ObjectAttributes, - &Name, - OBJ_CASE_INSENSITIVE, - NULL, - NULL); - Status = ZwOpenKey(&KeyHandle, - KEY_SET_VALUE, - &ObjectAttributes); - if (!NT_SUCCESS(Status)) - { - DPRINT("ZwOpenKey() failed (Status %lx)\n", Status); + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING Name; + HANDLE KeyHandle; + NTSTATUS Status; + + RtlInitUnicodeString(&Name, + L"\Registry\Machine\Software\Microsoft\Rpc"); + InitializeObjectAttributes(&ObjectAttributes, + &Name, + OBJ_CASE_INSENSITIVE, + NULL, + NULL); + Status = ZwOpenKey(&KeyHandle, + KEY_SET_VALUE, + &ObjectAttributes); + if (!NT_SUCCESS(Status)) + { + DPRINT("ZwOpenKey() failed (Status %lx)\n", Status); + return Status; + } + + RtlInitUnicodeString(&Name, L"UuidSequenceNumber"); + Status = ZwSetValueKey(KeyHandle, + &Name, + 0, + REG_DWORD, + Sequence, + sizeof(ULONG)); + ZwClose(KeyHandle); + if (!NT_SUCCESS(Status)) + { + DPRINT("ZwSetValueKey() failed (Status %lx)\n", Status); + } + return Status; - } - - RtlInitUnicodeString(&Name, - L"UuidSequenceNumber"); - Status = ZwSetValueKey(KeyHandle, - &Name, - 0, - REG_DWORD, - Sequence, - sizeof(ULONG)); - ZwClose(KeyHandle); - if (!NT_SUCCESS(Status)) - { - DPRINT("ZwSetValueKey() failed (Status %lx)\n", Status); - } - - return Status; }
static VOID ExpGetRandomUuidSequence(PULONG Sequence) { - LARGE_INTEGER Counter; - LARGE_INTEGER Frequency; - ULONG Value; - - Counter = KeQueryPerformanceCounter(&Frequency); - Value = Counter.u.LowPart ^ Counter.u.HighPart; - - *Sequence = *Sequence ^ Value; - - DPRINT("Sequence %lx\n", *Sequence); + LARGE_INTEGER Counter; + LARGE_INTEGER Frequency; + ULONG Value; + + Counter = KeQueryPerformanceCounter(&Frequency); + Value = Counter.u.LowPart ^ Counter.u.HighPart; + + *Sequence = *Sequence ^ Value; + + DPRINT("Sequence %lx\n", *Sequence); }
static NTSTATUS ExpCreateUuids(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; - - if (Time->QuadPart > UuidLastTime.QuadPart) - { - UuidCount = 0; - break; - } - - if (Time->QuadPart < UuidLastTime.QuadPart) - { - (*Sequence)++; - UuidSequenceChanged = TRUE; - UuidCount = 0; - break; - } - - if (UuidCount < TICKS_PER_CLOCK_TICK) - { - UuidCount++; - break; - } - } - - UuidLastTime.QuadPart = Time->QuadPart; - Time->QuadPart += UuidCount; - - *Range = 10000; /* What does this mean? Ticks per millisecond?*/ - - return STATUS_SUCCESS; + 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; + + if (Time->QuadPart > UuidLastTime.QuadPart) + { + UuidCount = 0; + break; + } + + if (Time->QuadPart < UuidLastTime.QuadPart) + { + (*Sequence)++; + UuidSequenceChanged = TRUE; + UuidCount = 0; + break; + } + + if (UuidCount < TICKS_PER_CLOCK_TICK) + { + UuidCount++; + break; + } + } + + UuidLastTime.QuadPart = Time->QuadPart; + Time->QuadPart += UuidCount; + + *Range = 10000; /* What does this mean? Ticks per millisecond?*/ + + return STATUS_SUCCESS; }
/* * @unimplemented */ NTSTATUS -STDCALL -ExUuidCreate( - OUT UUID *Uuid - ) -{ - UNIMPLEMENTED; - return FALSE; +NTAPI +ExUuidCreate(OUT UUID *Uuid) +{ + UNIMPLEMENTED; + return FALSE; }
/* * @unimplemented */ -NTSTATUS STDCALL +NTSTATUS +NTAPI NtAllocateUuids(OUT PULARGE_INTEGER Time, - OUT PULONG Range, - OUT PULONG Sequence, - OUT PUCHAR Seed) -{ - ULARGE_INTEGER IntTime; - ULONG IntRange; - NTSTATUS Status; - - PAGED_CODE(); - - ExAcquireFastMutex(&UuidMutex); - - if (!UuidSequenceInitialized) - { - Status = ExpLoadUuidSequence(&UuidSequence); - if (NT_SUCCESS(Status)) - { - UuidSequence++; - } - else - { - ExpGetRandomUuidSequence(&UuidSequence); - } - - UuidSequenceInitialized = TRUE; - UuidSequenceChanged = TRUE; - } - - Status = ExpCreateUuids(&IntTime, - &IntRange, - &UuidSequence); - if (!NT_SUCCESS(Status)) - { + OUT PULONG Range, + OUT PULONG Sequence, + OUT PUCHAR Seed) +{ + ULARGE_INTEGER IntTime; + ULONG IntRange; + NTSTATUS Status; + + PAGED_CODE(); + + ExAcquireFastMutex(&UuidMutex); + + if (!UuidSequenceInitialized) + { + Status = ExpLoadUuidSequence(&UuidSequence); + if (NT_SUCCESS(Status)) + { + UuidSequence++; + } + else + { + ExpGetRandomUuidSequence(&UuidSequence); + } + + UuidSequenceInitialized = TRUE; + UuidSequenceChanged = TRUE; + } + + Status = ExpCreateUuids(&IntTime, + &IntRange, + &UuidSequence); + if (!NT_SUCCESS(Status)) + { + ExReleaseFastMutex(&UuidMutex); + return Status; + } + + if (UuidSequenceChanged) + { + Status = ExpSaveUuidSequence(&UuidSequence); + if (NT_SUCCESS(Status)) + UuidSequenceChanged = FALSE; + } + ExReleaseFastMutex(&UuidMutex); - return Status; - } - - if (UuidSequenceChanged) - { - Status = ExpSaveUuidSequence(&UuidSequence); - if (NT_SUCCESS(Status)) - UuidSequenceChanged = FALSE; - } - - ExReleaseFastMutex(&UuidMutex); - - Time->QuadPart = IntTime.QuadPart; - *Range = IntRange; - *Sequence = UuidSequence; - - RtlCopyMemory(Seed, - UuidSeed, - SEED_BUFFER_SIZE); - - return STATUS_SUCCESS; + + Time->QuadPart = IntTime.QuadPart; + *Range = IntRange; + *Sequence = UuidSequence; + + RtlCopyMemory(Seed, + UuidSeed, + SEED_BUFFER_SIZE); + + return STATUS_SUCCESS; }
/* * @implemented */ -NTSTATUS STDCALL +NTSTATUS +NTAPI NtSetUuidSeed(IN PUCHAR Seed) { - PAGED_CODE(); - - RtlCopyMemory(UuidSeed, - Seed, - SEED_BUFFER_SIZE); - return STATUS_SUCCESS; + PAGED_CODE(); + + RtlCopyMemory(UuidSeed, + Seed, + SEED_BUFFER_SIZE); + return STATUS_SUCCESS; }
/* EOF */
Propchange: trunk/reactos/ntoskrnl/ex/uuid.c ------------------------------------------------------------------------------ --- svn:needs-lock (original) +++ svn:needs-lock (removed) @@ -1,1 +1,0 @@ -*
Propchange: trunk/reactos/ntoskrnl/ex/win32k.c ------------------------------------------------------------------------------ --- svn:needs-lock (original) +++ svn:needs-lock (removed) @@ -1,1 +1,0 @@ -*
Propchange: trunk/reactos/ntoskrnl/ex/zone.c ------------------------------------------------------------------------------ --- svn:needs-lock (original) +++ svn:needs-lock (removed) @@ -1,1 +1,0 @@ -*