Implemented RtlFindMessage().

Implemented Rtl[Query/Set]TimeZoneInformation().
Implemented RtlQueryRegistryValues() partially.

svn path=/trunk/; revision=1933
This commit is contained in:
Eric Kohl 2001-05-30 20:03:28 +00:00
parent 553aab4bb7
commit efe6366a22
13 changed files with 740 additions and 168 deletions

View file

@ -1,4 +1,4 @@
/* $Id: ntddk.h,v 1.21 2001/05/01 23:08:17 chorns Exp $
/* $Id: ntddk.h,v 1.22 2001/05/30 19:57:29 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -26,6 +26,7 @@ extern "C"
#define STATIC static
#include <ntos/types.h>
#include <ntos/time.h>
#include <ntos/disk.h>
#include <ntos/registry.h>
#include <ntos/port.h>

View file

@ -1,4 +1,4 @@
/* $Id: rtl.h,v 1.51 2001/05/27 11:09:35 ekohl Exp $
/* $Id: rtl.h,v 1.52 2001/05/30 19:57:29 ekohl Exp $
*
*/
@ -124,19 +124,38 @@ typedef struct _RTL_GENERIC_TABLE
} RTL_GENERIC_TABLE, *PRTL_GENERIC_TABLE;
typedef struct _RTL_MESSAGE_RESOURCE_ENTRY
{
USHORT Length;
USHORT Flags;
UCHAR Text[1];
} RTL_MESSAGE_RESOURCE_ENTRY, *PRTL_MESSAGE_RESOURCE_ENTRY;
typedef struct _RTL_MESSAGE_RESOURCE_BLOCK
{
ULONG LowId;
ULONG HighId;
ULONG OffsetToEntries;
} RTL_MESSAGE_RESOURCE_BLOCK, *PRTL_MESSAGE_RESOURCE_BLOCK;
typedef struct _RTL_MESSAGE_RESOURCE_DATA
{
ULONG NumberOfBlocks;
RTL_MESSAGE_RESOURCE_BLOCK Blocks[1];
} RTL_MESSAGE_RESOURCE_DATA, *PRTL_MESSAGE_RESOURCE_DATA;
/*
* PURPOSE: Flags for RtlQueryRegistryValues
*/
enum
{
RTL_QUERY_REGISTRY_SUBKEY,
RTL_QUERY_REGISTRY_TOPKEY,
RTL_QUERY_REGISTRY_REQUIRED,
RTL_QUERY_REGISTRY_NOVALUE,
RTL_QUERY_REGISTRY_NOEXPAND,
RTL_QUERY_REGISTRY_DIRECT,
RTL_QUERY_REGISTRY_DELETE,
};
#define RTL_QUERY_REGISTRY_SUBKEY (0x00000001)
#define RTL_QUERY_REGISTRY_TOPKEY (0x00000002)
#define RTL_QUERY_REGISTRY_REQUIRED (0x00000004)
#define RTL_QUERY_REGISTRY_NOVALUE (0x00000008)
#define RTL_QUERY_REGISTRY_NOEXPAND (0x00000010)
#define RTL_QUERY_REGISTRY_DIRECT (0x00000020)
#define RTL_QUERY_REGISTRY_DELETE (0x00000040)
typedef NTSTATUS (*PRTL_QUERY_REGISTRY_ROUTINE)(PWSTR ValueName,
ULONG ValueType,
@ -898,8 +917,13 @@ RtlExtendedMagicDivide (
CCHAR ShiftCount
);
VOID STDCALL
RtlFillMemory (PVOID Destination, ULONG Length, UCHAR Fill);
VOID
STDCALL
RtlFillMemory (
PVOID Destination,
ULONG Length,
UCHAR Fill
);
VOID
STDCALL
@ -953,6 +977,16 @@ RtlFindLongestRunSet (
PULONG StartingIndex
);
NTSTATUS
STDCALL
RtlFindMessage (
IN PVOID BaseAddress,
IN ULONG Type,
IN ULONG Language,
IN ULONG MessageId,
OUT PRTL_MESSAGE_RESOURCE_ENTRY *MessageResourceEntry
);
ULONG
STDCALL
RtlFindSetBits (
@ -1466,11 +1500,17 @@ RtlQueryAtomInAtomTable (
NTSTATUS
STDCALL
RtlQueryRegistryValues (
ULONG RelativeTo,
PWSTR Path,
PRTL_QUERY_REGISTRY_TABLE QueryTable,
PVOID Context,
PVOID Environment
IN ULONG RelativeTo,
IN PWSTR Path,
IN PRTL_QUERY_REGISTRY_TABLE QueryTable,
IN PVOID Context,
IN PVOID Environment
);
NTSTATUS
STDCALL
RtlQueryTimeZoneInformation (
IN OUT PTIME_ZONE_INFORMATION TimeZoneInformation
);
VOID
@ -1563,6 +1603,12 @@ RtlSetDaclSecurityDescriptor (
BOOLEAN DaclDefaulted
);
NTSTATUS
STDCALL
RtlSetTimeZoneInformation (
IN OUT PTIME_ZONE_INFORMATION TimeZoneInformation
);
DWORD
STDCALL
RtlSizeHeap (

View file

@ -2175,18 +2175,6 @@ extern "C" {
/* RegCreateKeyEx */
/* RegEnumValue */
#define REG_BINARY (3)
#define REG_DWORD (4)
#define REG_DWORD_LITTLE_ENDIAN (4)
#define REG_DWORD_BIG_ENDIAN (5)
#define REG_EXPAND_SZ (2)
#define REG_FULL_RESOURCE_DESCRIPTOR (9)
#define REG_LINK (6)
#define REG_MULTI_SZ (7)
#define REG_NONE (0)
#define REG_RESOURCE_LIST (8)
#define REG_RESOURCE_REQUIREMENTS_LIST (10)
#define REG_SZ (1)
/* RegisterHotKey */
#define MOD_ALT (1)

View file

@ -0,0 +1,6 @@
NTSTATUS
RtlpGetRegistryHandle(ULONG RelativeTo,
PWSTR Path,
BOOLEAN Create,
PHANDLE KeyHandle);

View file

@ -1,4 +1,4 @@
/* $Id: registry.h,v 1.1 2001/01/28 21:32:37 ekohl Exp $
/* $Id: registry.h,v 1.2 2001/05/30 19:58:48 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -10,8 +10,8 @@
* 25/01/2001: Created
*/
#ifndef __INCLUDE_REGISTRY_H
#define __INCLUDE_REGISTRY_H
#ifndef __INCLUDE_NTOS_REGISTRY_H
#define __INCLUDE_NTOS_REGISTRY_H
/* Key access rights */
#define KEY_QUERY_VALUE (1)
@ -34,4 +34,19 @@
#define REG_OPENED_EXISTING_KEY (0x2L)
#endif /* __INCLUDE_REGISTRY_H */
/* RegEnumValue */
#define REG_NONE (0)
#define REG_SZ (1)
#define REG_EXPAND_SZ (2)
#define REG_BINARY (3)
#define REG_DWORD (4)
#define REG_DWORD_LITTLE_ENDIAN (4)
#define REG_DWORD_BIG_ENDIAN (5)
#define REG_LINK (6)
#define REG_MULTI_SZ (7)
#define REG_RESOURCE_LIST (8)
#define REG_FULL_RESOURCE_DESCRIPTOR (9)
#define REG_RESOURCE_REQUIREMENTS_LIST (10)
#endif /* __INCLUDE_NTOS_REGISTRY_H */

View file

@ -9,30 +9,32 @@
*/
#ifndef __INCLUDE_TIME_H
#define __INCLUDE_TIME_H
#ifndef __INCLUDE_NTOS_TIME_H
#define __INCLUDE_NTOS_TIME_H
#include <ntos/types.h>
typedef struct _SYSTEMTIME {
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME, *LPSYSTEMTIME;
typedef struct _SYSTEMTIME
{
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME, *PSYSTEMTIME, *LPSYSTEMTIME;
typedef struct _TIME_ZONE_INFORMATION {
LONG Bias;
WCHAR StandardName[ 32 ];
SYSTEMTIME StandardDate;
LONG StandardBias;
WCHAR DaylightName[ 32 ];
SYSTEMTIME DaylightDate;
LONG DaylightBias;
} TIME_ZONE_INFORMATION, *LPTIME_ZONE_INFORMATION;
typedef struct _TIME_ZONE_INFORMATION
{
LONG Bias;
WCHAR StandardName[32];
SYSTEMTIME StandardDate;
LONG StandardBias;
WCHAR DaylightName[32];
SYSTEMTIME DaylightDate;
LONG DaylightBias;
} TIME_ZONE_INFORMATION, *PTIME_ZONE_INFORMATION, *LPTIME_ZONE_INFORMATION;
#endif /* __INCLUDE_TIME_H */
#endif /* __INCLUDE_NTOS_TIME_H */

View file

@ -1,4 +1,5 @@
/*
/* $Id: time.c,v 1.13 2001/05/30 20:03:28 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/kernel32/misc/time.c
@ -13,7 +14,9 @@
#include <ddk/ntddk.h>
#include <windows.h>
#include <string.h>
#include <napi/shared_data.h>
#include <kernel32/error.h>
//#include <string.h>
#define NDEBUG
#include <kernel32/kernel32.h>
@ -352,11 +355,9 @@ LocalFileTimeToFileTime(
return TRUE;
}
VOID
STDCALL
GetLocalTime(
LPSYSTEMTIME lpSystemTime
)
VOID STDCALL
GetLocalTime(LPSYSTEMTIME lpSystemTime)
{
FILETIME FileTime;
FILETIME LocalFileTime;
@ -366,11 +367,9 @@ GetLocalTime(
FileTimeToSystemTime (&LocalFileTime, lpSystemTime);
}
VOID
STDCALL
GetSystemTime(
LPSYSTEMTIME lpSystemTime
)
VOID STDCALL
GetSystemTime(LPSYSTEMTIME lpSystemTime)
{
FILETIME FileTime;
@ -378,11 +377,9 @@ GetSystemTime(
FileTimeToSystemTime (&FileTime, lpSystemTime);
}
WINBOOL
STDCALL
SetLocalTime(
CONST SYSTEMTIME *lpSystemTime
)
WINBOOL STDCALL
SetLocalTime(CONST SYSTEMTIME *lpSystemTime)
{
FILETIME LocalFileTime;
LARGE_INTEGER FileTime;
@ -396,11 +393,9 @@ SetLocalTime(
return TRUE;
}
WINBOOL
STDCALL
SetSystemTime(
CONST SYSTEMTIME *lpSystemTime
)
WINBOOL STDCALL
SetSystemTime(CONST SYSTEMTIME *lpSystemTime)
{
LARGE_INTEGER NewSystemTime;
NTSTATUS errCode;
@ -412,56 +407,74 @@ SetSystemTime(
return TRUE;
}
/*
typedef struct _TIME_ZONE_INFORMATION { // tzi
LONG Bias;
WCHAR StandardName[ 32 ];
SYSTEMTIME StandardDate;
LONG StandardBias;
WCHAR DaylightName[ 32 ];
SYSTEMTIME DaylightDate;
LONG DaylightBias;
} TIME_ZONE_INFORMATION;
TIME_ZONE_INFORMATION TimeZoneInformation = {60,"CET",;
*/
DWORD
STDCALL
GetTimeZoneInformation(
LPTIME_ZONE_INFORMATION lpTimeZoneInformation
)
DWORD STDCALL
GetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation)
{
// DPRINT("GetTimeZoneInformation()\n");
// memset(lpTimeZoneInformation, 0, sizeof(TIME_ZONE_INFORMATION));
return TIME_ZONE_ID_UNKNOWN;
TIME_ZONE_INFORMATION TimeZoneInformation;
NTSTATUS Status;
DPRINT("GetTimeZoneInformation()\n");
Status = NtQuerySystemInformation(SystemCurrentTimeZoneInformation,
&TimeZoneInformation,
sizeof(TIME_ZONE_INFORMATION),
NULL);
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
return TIME_ZONE_ID_INVALID;
}
memcpy(lpTimeZoneInformation,
&TimeZoneInformation,
sizeof(TIME_ZONE_INFORMATION));
return ((PKUSER_SHARED_DATA)USER_SHARED_DATA_BASE)->TimeZoneId;
}
BOOL
STDCALL
SetTimeZoneInformation(
CONST TIME_ZONE_INFORMATION *lpTimeZoneInformation
)
BOOL STDCALL
SetTimeZoneInformation(CONST TIME_ZONE_INFORMATION *lpTimeZoneInformation)
{
return FALSE;
TIME_ZONE_INFORMATION TimeZoneInformation;
NTSTATUS Status;
DPRINT("SetTimeZoneInformation()\n");
memcpy(&TimeZoneInformation,
lpTimeZoneInformation,
sizeof(TIME_ZONE_INFORMATION));
Status = RtlSetTimeZoneInformation(&TimeZoneInformation);
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
return FALSE;
}
NtSetSystemTime(0,0);
return TRUE;
}
DWORD STDCALL GetCurrentTime(VOID)
DWORD STDCALL
GetCurrentTime(VOID)
{
return GetTickCount ();
return GetTickCount();
}
DWORD
STDCALL
DWORD STDCALL
GetTickCount(VOID)
{
ULONG UpTime;
NtGetTickCount (&UpTime);
NtGetTickCount(&UpTime);
return UpTime;
}
WINBOOL STDCALL
SystemTimeToTzSpecificLocalTime(
LPTIME_ZONE_INFORMATION lpTimeZoneInformation,
@ -494,29 +507,53 @@ SystemTimeToTzSpecificLocalTime(
return TRUE;
}
WINBOOL
STDCALL
GetSystemTimeAdjustment(
PDWORD lpTimeAdjustment,
PDWORD lpTimeIncrement,
PWINBOOL lpTimeAdjustmentDisabled
)
{
// FIXME: Preliminary default settings.
*lpTimeAdjustment = 0;
*lpTimeIncrement = 0;
*lpTimeAdjustmentDisabled = TRUE;
return TRUE;
WINBOOL STDCALL
GetSystemTimeAdjustment(PDWORD lpTimeAdjustment,
PDWORD lpTimeIncrement,
PWINBOOL lpTimeAdjustmentDisabled)
{
SYSTEM_QUERY_TIME_ADJUSTMENT Buffer;
NTSTATUS Status;
Status = NtQuerySystemInformation(SystemTimeAdjustmentInformation,
&Buffer,
sizeof(SYSTEM_QUERY_TIME_ADJUSTMENT),
NULL);
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
return FALSE;
}
*lpTimeAdjustment = (DWORD)Buffer.TimeAdjustment;
*lpTimeIncrement = (DWORD)Buffer.MaximumIncrement;
*lpTimeAdjustmentDisabled = (WINBOOL)Buffer.TimeSynchronization;
return TRUE;
}
WINBOOL
STDCALL
SetSystemTimeAdjustment(
DWORD dwTimeAdjustment,
WINBOOL bTimeAdjustmentDisabled
)
{
return TRUE;
WINBOOL STDCALL
SetSystemTimeAdjustment(DWORD dwTimeAdjustment,
WINBOOL bTimeAdjustmentDisabled)
{
NTSTATUS Status;
SYSTEM_TIME_ADJUSTMENT_INFO Buffer;
Buffer.TimeAdjustment = (ULONG)dwTimeAdjustment;
Buffer.TimeSynchronization = (BOOLEAN)bTimeAdjustmentDisabled;
Status = NtSetSystemInformation(SystemTimeAdjustmentInformation,
&Buffer,
sizeof(SYSTEM_TIME_ADJUSTMENT_INFO));
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
return FALSE;
}
return TRUE;
}
/* EOF */

View file

@ -1,4 +1,4 @@
; $Id: ntdll.def,v 1.72 2001/05/26 16:49:09 ekohl Exp $
; $Id: ntdll.def,v 1.73 2001/05/30 20:01:58 ekohl Exp $
;
; ReactOS Operating System
;
@ -395,7 +395,7 @@ RtlFindClearBits@12
RtlFindClearBitsAndSet@12
RtlFindLongestRunClear@8
RtlFindLongestRunSet@8
;RtlFindMessage@20
RtlFindMessage@20
RtlFindSetBits@12
RtlFindSetBitsAndClear@12
RtlFirstFreeAce@8
@ -510,7 +510,7 @@ RtlQueryInformationAcl@16
RtlQueryRegistryValues@20
;RtlQuerySecutityObject
;RtlQueryTagHeap
;RtlQueryTimeZoneInformation
RtlQueryTimeZoneInformation@4
RtlRaiseException@4
RtlRaiseStatus@4
;RtlRandom
@ -541,7 +541,7 @@ RtlSetOwnerSecurityDescriptor@12
;RtlSetPropertySetClassId
RtlSetSaclSecurityDescriptor@16
;RtlSetSecurityObject
;RtlSetTimeZoneInformation
RtlSetTimeZoneInformation@4
;RtlSetUnicodeCallouts
;RtlSetUserFlagsHeap
;RtlSetUserValueHeap

View file

@ -1,4 +1,4 @@
; $Id: ntdll.edf,v 1.61 2001/05/26 16:49:09 ekohl Exp $
; $Id: ntdll.edf,v 1.62 2001/05/30 20:01:58 ekohl Exp $
;
; ReactOS Operating System
;
@ -396,7 +396,7 @@ RtlFindClearBitsAndSet=RtlFindClearBitsAndSet@12
RtlFirstFreeAce=RtlFirstFreeAce@8
RtlFindLongestRunClear=RtlFindLongestRunClear@8
RtlFindLongestRunSet=RtlFindLongestRunSet@8
;RtlFindMessage
RtlFindMessage=RtlFindMessage@20
RtlFindSetBits=RtlFindSetBits@12
RtlFindSetBitsAndClear=RtlFindSetBitsAndClear@12
;RtlFlushPropertySet
@ -509,7 +509,7 @@ RtlQueryInformationAcl=RtlQueryInformationAcl@16
RtlQueryRegistryValues=RtlQueryRegistryValues@20
;RtlQuerySecutityObject
;RtlQueryTagHeap
;RtlQueryTimeZoneInformation
RtlQueryTimeZoneInformation=RtlQueryTimeZoneInformation@4
RtlRaiseException=RtlRaiseException@4
RtlRaiseStatus=RtlRaiseStatus@4
;RtlRandom
@ -540,7 +540,7 @@ RtlSetOwnerSecurityDescriptor=RtlSetOwnerSecurityDescriptor@12
;RtlSetPropertySetClassId
RtlSetSaclSecurityDescriptor=RtlSetSaclSecurityDescriptor@16
;RtlSetSecurityObject
;RtlSetTimeZoneInformation
RtlSetTimeZoneInformation=RtlSetTimeZoneInformation@4
;RtlSetUnicodeCallouts
;RtlSetUserFlagsHeap
;RtlSetUserValueHeap

View file

@ -1,4 +1,4 @@
# $Id: makefile,v 1.60 2001/05/26 16:48:52 ekohl Exp $
# $Id: makefile,v 1.61 2001/05/30 20:02:31 ekohl Exp $
#
# ReactOS Operating System
#
@ -25,7 +25,7 @@ RTL_OBJECTS = rtl/critical.o rtl/error.o rtl/heap.o rtl/largeint.o \
rtl/bitmap.o rtl/time.o rtl/acl.o rtl/sid.o rtl/image.o \
rtl/access.o rtl/apc.o rtl/callback.o rtl/luid.o rtl/misc.o \
rtl/registry.o rtl/exception.o rtl/intrlck.o rtl/resource.o \
rtl/handle.o rtl/atom.o
rtl/handle.o rtl/atom.o rtl/message.o rtl/timezone.o
STDIO_OBJECTS = stdio/sprintf.o stdio/swprintf.o

View file

@ -0,0 +1,124 @@
/* $Id: message.c,v 1.1 2001/05/30 20:00:34 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* PURPOSE: Message table functions
* FILE: lib/ntdll/rtl/message.c
* PROGRAMER: Eric Kohl <ekohl@zr-online.de>
* REVISION HISTORY:
* 29/05/2001: Created
*/
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
#define NDEBUG
#include <ntdll/ntdll.h>
/* FUNCTIONS *****************************************************************/
NTSTATUS STDCALL
RtlFindMessage(PVOID BaseAddress,
ULONG Type,
ULONG Language,
ULONG MessageId,
PRTL_MESSAGE_RESOURCE_ENTRY *MessageResourceEntry)
{
LDR_RESOURCE_INFO ResourceInfo;
PIMAGE_RESOURCE_DATA_ENTRY ResourceDataEntry;
PRTL_MESSAGE_RESOURCE_DATA MessageTable;
NTSTATUS Status;
ULONG EntryOffset, IdOffset;
PRTL_MESSAGE_RESOURCE_ENTRY MessageEntry;
ULONG i;
DPRINT("RtlFindMessage()\n");
ResourceInfo.Type = Type;
ResourceInfo.Name = 1;
ResourceInfo.Language = Language;
Status = LdrFindResource_U(BaseAddress,
&ResourceInfo,
RESOURCE_DATA_LEVEL,
&ResourceDataEntry);
if (!NT_SUCCESS(Status))
{
return(Status);
}
DPRINT("ResourceDataEntry: %p\n", ResourceDataEntry);
Status = LdrAccessResource(BaseAddress,
ResourceDataEntry,
&MessageTable,
NULL);
if (!NT_SUCCESS(Status))
{
return(Status);
}
DPRINT("MessageTable: %p\n", MessageTable);
DPRINT("NumberOfBlocks %lu\n", MessageTable->NumberOfBlocks);
for (i = 0; i < MessageTable->NumberOfBlocks; i++)
{
DPRINT("LoId 0x%08lx HiId 0x%08lx Offset 0x%08lx\n",
MessageTable->Blocks[i].LowId,
MessageTable->Blocks[i].HighId,
MessageTable->Blocks[i].OffsetToEntries);
}
for (i = 0; i < MessageTable->NumberOfBlocks; i++)
{
if ((MessageId >= MessageTable->Blocks[i].LowId) &&
(MessageId <= MessageTable->Blocks[i].HighId))
{
EntryOffset = MessageTable->Blocks[i].OffsetToEntries;
IdOffset = MessageId - MessageTable->Blocks[i].LowId;
break;
}
if (MessageId < MessageTable->Blocks[i].LowId)
{
return STATUS_MESSAGE_NOT_FOUND;
}
}
MessageEntry = (PRTL_MESSAGE_RESOURCE_ENTRY)((ULONG)MessageTable + MessageTable->Blocks[i].OffsetToEntries);
DPRINT("EntryOffset 0x%08lx\n", EntryOffset);
DPRINT("IdOffset 0x%08lx\n", IdOffset);
DPRINT("MessageEntry: %p\n", MessageEntry);
for (i = 0; i < IdOffset; i++)
{
MessageEntry = (PRTL_MESSAGE_RESOURCE_ENTRY)(MessageEntry + (ULONG)MessageEntry->Length);
}
if (MessageEntry->Flags == 0)
{
DPRINT("AnsiText: %s\n", MessageEntry->Text);
}
else
{
DPRINT("UnicodeText: %S\n", (PWSTR)MessageEntry->Text);
}
if (MessageResourceEntry != NULL);
{
*MessageResourceEntry = MessageEntry;
}
return(STATUS_SUCCESS);
}
/*
RtlFormatMessage
*/
/* EOF */

View file

@ -1,4 +1,4 @@
/* $Id: registry.c,v 1.2 2001/05/02 22:23:21 ekohl Exp $
/* $Id: registry.c,v 1.3 2001/05/30 20:00:34 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -9,19 +9,24 @@
* 2000/08/11: Created
*/
/*
* TODO:
* - finish RtlQueryRegistryValues()
* - finish RtlFormatCurrentUserKeyPath()
* - implement RtlOpenCurrentUser()
* - implement RtlNtXxxx() functions
*/
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
#include <ntdll/registry.h>
#include <ntos/minmax.h>
#define NDEBUG
#include <ntdll/ntdll.h>
static NTSTATUS RtlpGetRegistryHandle(ULONG RelativeTo,
PWSTR Path,
BOOLEAN Create,
PHANDLE KeyHandle);
/* FUNCTIONS ***************************************************************/
NTSTATUS STDCALL
@ -75,7 +80,7 @@ RtlDeleteRegistryValue(IN ULONG RelativeTo,
Status = RtlpGetRegistryHandle(RelativeTo,
Path,
TRUE,
FALSE,
&KeyHandle);
if (!NT_SUCCESS(Status))
return Status;
@ -101,19 +106,153 @@ RtlFormatCurrentUserKeyPath(PUNICODE_STRING KeyPath)
/*
NTSTATUS STDCALL
RtlOpenCurrentUser(...)
{
}
*/
NTSTATUS STDCALL
RtlQueryRegistryValues (
IN ULONG RelativeTo,
IN PWSTR Path,
IN PRTL_QUERY_REGISTRY_TABLE QueryTable,
IN PVOID Context,
IN PVOID Environment
)
RtlQueryRegistryValues(IN ULONG RelativeTo,
IN PWSTR Path,
IN PRTL_QUERY_REGISTRY_TABLE QueryTable,
IN PVOID Context,
IN PVOID Environment)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
NTSTATUS Status;
HANDLE BaseKeyHandle;
HANDLE CurrentKeyHandle;
PRTL_QUERY_REGISTRY_TABLE QueryEntry;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName;
PKEY_VALUE_PARTIAL_INFORMATION ValueInfo;
ULONG BufferSize;
ULONG ResultSize;
DPRINT1("RtlQueryRegistryValues()\n");
Status = RtlpGetRegistryHandle(RelativeTo,
Path,
FALSE,
&BaseKeyHandle);
if (!NT_SUCCESS(Status))
return Status;
CurrentKeyHandle = BaseKeyHandle;
QueryEntry = QueryTable;
while ((QueryEntry->QueryRoutine != NULL) ||
(QueryEntry->Name != NULL))
{
if ((QueryEntry->QueryRoutine == NULL) &&
(QueryEntry->Flags & (RTL_QUERY_REGISTRY_SUBKEY | RTL_QUERY_REGISTRY_DIRECT) != 0))
{
Status = STATUS_INVALID_PARAMETER;
break;
}
DPRINT1("Name: %S\n", QueryEntry->Name);
if (((QueryEntry->Flags & (RTL_QUERY_REGISTRY_SUBKEY | RTL_QUERY_REGISTRY_TOPKEY)) != 0) &&
(BaseKeyHandle != CurrentKeyHandle))
{
NtClose(CurrentKeyHandle);
CurrentKeyHandle = BaseKeyHandle;
}
if (QueryEntry->Flags & RTL_QUERY_REGISTRY_SUBKEY)
{
DPRINT1("Open new subkey: %S\n", QueryEntry->Name);
RtlInitUnicodeString(&KeyName,
QueryEntry->Name);
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
BaseKeyHandle,
NULL);
Status = NtOpenKey(&CurrentKeyHandle,
KEY_ALL_ACCESS,
&ObjectAttributes);
if (!NT_SUCCESS(Status))
break;
}
else if (QueryEntry->Flags & RTL_QUERY_REGISTRY_DIRECT)
{
DPRINT1("Query value directly: %S\n", QueryEntry->Name);
RtlInitUnicodeString(&KeyName,
QueryEntry->Name);
BufferSize = sizeof (KEY_VALUE_PARTIAL_INFORMATION) + 4096;
ValueInfo = RtlAllocateHeap(RtlGetProcessHeap(),
0,
BufferSize);
if (ValueInfo == NULL)
{
Status = STATUS_NO_MEMORY;
break;
}
Status = NtQueryValueKey(CurrentKeyHandle,
&KeyName,
KeyValuePartialInformation,
ValueInfo,
BufferSize,
&ResultSize);
if (!NT_SUCCESS(Status))
{
RtlFreeHeap(RtlGetProcessHeap(), 0, ValueInfo);
break;
}
else
{
if (ValueInfo->Type == REG_SZ)
{
PUNICODE_STRING ValueString;
ValueString = (PUNICODE_STRING)QueryEntry->EntryContext;
if (ValueString->Buffer == 0)
{
/* FIXME: allocate buffer !!! */
// ValueString->MaximumLength =
// ValueString->Buffer =
}
ValueString->Length = min(ValueInfo->DataLength,
ValueString->MaximumLength - sizeof(WCHAR));
memcpy(ValueString->Buffer,
ValueInfo->Data,
ValueInfo->DataLength);
((PWSTR)ValueString->Buffer)[ValueString->Length / sizeof(WCHAR)] = 0;
}
else
{
memcpy(QueryEntry->EntryContext,
ValueInfo->Data,
ValueInfo->DataLength);
}
}
RtlFreeHeap (RtlGetProcessHeap(), 0, ValueInfo);
}
else
{
DPRINT1("Query value via query routine: %S\n", QueryEntry->Name);
}
if (QueryEntry->Flags & RTL_QUERY_REGISTRY_DELETE)
{
DPRINT1("Delete value: %S\n", QueryEntry->Name);
}
QueryEntry++;
}
if (CurrentKeyHandle != BaseKeyHandle)
NtClose(CurrentKeyHandle);
NtClose(BaseKeyHandle);
return Status;
}
@ -161,7 +300,7 @@ RtlpNtMakeTemporaryKey(HANDLE KeyHandle)
/* INTERNAL FUNCTIONS ******************************************************/
static NTSTATUS
NTSTATUS
RtlpGetRegistryHandle(ULONG RelativeTo,
PWSTR Path,
BOOLEAN Create,
@ -171,7 +310,9 @@ RtlpGetRegistryHandle(ULONG RelativeTo,
WCHAR KeyBuffer[MAX_PATH];
OBJECT_ATTRIBUTES ObjectAttributes;
NTSTATUS Status;
DPRINT("RtlpGetRegistryHandle()\n");
if (RelativeTo & RTL_REGISTRY_HANDLE)
{
*KeyHandle = (HANDLE)Path;
@ -191,6 +332,11 @@ RtlpGetRegistryHandle(ULONG RelativeTo,
switch (RelativeTo)
{
case RTL_REGISTRY_ABSOLUTE:
RtlAppendUnicodeToString(&KeyName,
L"\\");
break;
case RTL_REGISTRY_SERVICES:
RtlAppendUnicodeToString(&KeyName,
L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\");
@ -219,12 +365,19 @@ RtlpGetRegistryHandle(ULONG RelativeTo,
}
if (Path[0] != L'\\')
RtlAppendUnicodeToString(&KeyName,
L"\\");
RtlAppendUnicodeToString(&KeyName,
Path);
{
RtlAppendUnicodeToString(&KeyName,
Path);
}
else
{
Path++;
RtlAppendUnicodeToString(&KeyName,
Path);
}
DPRINT("KeyName %wZ\n", &KeyName);
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,

View file

@ -0,0 +1,200 @@
/* $Id: timezone.c,v 1.1 2001/05/30 20:00:34 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* PURPOSE: Timezone functions
* FILE: lib/ntdll/rtl/timezone.c
* PROGRAMER: Eric Kohl
* REVISION HISTORY:
* 29/05/2001: Created
*/
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
#include <ntos/registry.h>
#include <ntos/time.h>
#define NDEBUG
#include <ntdll/ntdll.h>
/* FUNCTIONS *****************************************************************/
NTSTATUS STDCALL
RtlQueryTimeZoneInformation(PTIME_ZONE_INFORMATION TimeZoneInformation)
{
HANDLE KeyHandle;
RTL_QUERY_REGISTRY_TABLE QueryTable[8];
UNICODE_STRING StandardName;
UNICODE_STRING DaylightName;
NTSTATUS Status;
DPRINT("RtlQueryTimeZoneInformation()\n");
Status = RtlpGetRegistryHandle(RTL_REGISTRY_CONTROL,
L"TimeZoneInformation",
TRUE,
&KeyHandle);
if (!NT_SUCCESS(Status))
{
DPRINT("RtlpGetRegistryHandle failed (Status %x)\n", Status);
return Status;
}
RtlZeroMemory(QueryTable,
sizeof(QueryTable));
StandardName.Length = 0;
StandardName.MaximumLength = 32 * sizeof(WCHAR);
StandardName.Buffer = TimeZoneInformation->StandardName;
DaylightName.Length = 0;
DaylightName.MaximumLength = 32 * sizeof(WCHAR);
DaylightName.Buffer = TimeZoneInformation->DaylightName;
QueryTable[0].Name = L"Bias";
QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
QueryTable[0].EntryContext = &TimeZoneInformation->Bias;
QueryTable[1].Name = L"Standard Name";
QueryTable[1].Flags = RTL_QUERY_REGISTRY_DIRECT;
QueryTable[1].EntryContext = &StandardName;
QueryTable[2].Name = L"Standard Bias";
QueryTable[2].Flags = RTL_QUERY_REGISTRY_DIRECT;
QueryTable[2].EntryContext = &TimeZoneInformation->StandardBias;
QueryTable[3].Name = L"Standard Start";
QueryTable[3].Flags = RTL_QUERY_REGISTRY_DIRECT;
QueryTable[3].EntryContext = &TimeZoneInformation->StandardDate;
QueryTable[4].Name = L"Daylight Name";
QueryTable[4].Flags = RTL_QUERY_REGISTRY_DIRECT;
QueryTable[4].EntryContext = &DaylightName;
QueryTable[5].Name = L"Daylight Bias";
QueryTable[5].Flags = RTL_QUERY_REGISTRY_DIRECT;
QueryTable[5].EntryContext = &TimeZoneInformation->DaylightBias;
QueryTable[6].Name = L"Daylight Start";
QueryTable[6].Flags = RTL_QUERY_REGISTRY_DIRECT;
QueryTable[6].EntryContext = &TimeZoneInformation->DaylightDate;
Status = RtlQueryRegistryValues(RTL_REGISTRY_HANDLE,
(PWSTR)KeyHandle,
QueryTable,
NULL,
NULL);
NtClose(KeyHandle);
return Status;
}
NTSTATUS STDCALL
RtlSetTimeZoneInformation(PTIME_ZONE_INFORMATION TimeZoneInformation)
{
HANDLE KeyHandle;
ULONG Length;
NTSTATUS Status;
DPRINT("RtlSetTimeZoneInformation()\n");
Status = RtlpGetRegistryHandle(RTL_REGISTRY_CONTROL,
L"TimeZoneInformation",
TRUE,
&KeyHandle);
if (!NT_SUCCESS(Status))
{
DPRINT("RtlpGetRegistryHandle failed (Status %x)\n", Status);
return Status;
}
Status = RtlWriteRegistryValue(RTL_REGISTRY_HANDLE,
(PWSTR)KeyHandle,
L"Bias",
REG_DWORD,
&TimeZoneInformation->Bias,
sizeof(LONG));
if (!NT_SUCCESS(Status))
{
NtClose(KeyHandle);
return Status;
}
Length = (wcslen(TimeZoneInformation->StandardName) + 1) * sizeof(WCHAR);
Status = RtlWriteRegistryValue(RTL_REGISTRY_HANDLE,
(PWSTR)KeyHandle,
L"Standard Name",
REG_SZ,
TimeZoneInformation->StandardName,
Length);
if (!NT_SUCCESS(Status))
{
NtClose(KeyHandle);
return Status;
}
Status = RtlWriteRegistryValue(RTL_REGISTRY_HANDLE,
(PWSTR)KeyHandle,
L"Standard Bias",
REG_DWORD,
&TimeZoneInformation->StandardBias,
sizeof(LONG));
if (!NT_SUCCESS(Status))
{
NtClose(KeyHandle);
return Status;
}
Status = RtlWriteRegistryValue(RTL_REGISTRY_HANDLE,
(PWSTR)KeyHandle,
L"Standard Start",
REG_BINARY,
&TimeZoneInformation->StandardDate,
sizeof(SYSTEMTIME));
if (!NT_SUCCESS(Status))
{
NtClose(KeyHandle);
return Status;
}
Length = (wcslen(TimeZoneInformation->DaylightName) + 1) * sizeof(WCHAR);
Status = RtlWriteRegistryValue(RTL_REGISTRY_HANDLE,
(PWSTR)KeyHandle,
L"Daylight Name",
REG_SZ,
TimeZoneInformation->DaylightName,
Length);
if (!NT_SUCCESS(Status))
{
NtClose(KeyHandle);
return Status;
}
Status = RtlWriteRegistryValue(RTL_REGISTRY_HANDLE,
(PWSTR)KeyHandle,
L"Daylight Bias",
REG_DWORD,
&TimeZoneInformation->DaylightBias,
sizeof(LONG));
if (!NT_SUCCESS(Status))
{
NtClose(KeyHandle);
return Status;
}
Status = RtlWriteRegistryValue(RTL_REGISTRY_HANDLE,
(PWSTR)KeyHandle,
L"Daylight Start",
REG_BINARY,
&TimeZoneInformation->DaylightDate,
sizeof(SYSTEMTIME));
NtClose(KeyHandle);
return Status;
}
/* EOF */