Implemented RtlFindMessage() and Rtl[Query/Set]TimeZoneInformation().

svn path=/trunk/; revision=1935
This commit is contained in:
Eric Kohl 2001-06-01 17:14:40 +00:00
parent efe6366a22
commit 7d15b82aa0
7 changed files with 348 additions and 20 deletions

View file

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.41 2001/05/27 11:17:01 ekohl Exp $
# $Id: Makefile,v 1.42 2001/06/01 17:14:40 ekohl Exp $
#
# ReactOS Operating System
#
@ -103,6 +103,7 @@ OBJECTS_RTL = \
rtl/memcpy.o \
rtl/memmove.o \
rtl/memset.o \
rtl/message.o \
rtl/nls.o \
rtl/qsort.o \
rtl/regio.o \
@ -111,6 +112,7 @@ OBJECTS_RTL = \
rtl/string.o \
rtl/swprintf.o \
rtl/time.o \
rtl/timezone.o \
rtl/unicode.o \
rtl/wstring.o \
rtl/bitops.o \

View file

@ -1,4 +1,4 @@
/* $Id: registry.c,v 1.59 2001/05/30 14:40:36 ekohl Exp $
/* $Id: registry.c,v 1.60 2001/06/01 17:12:33 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -18,6 +18,7 @@
#include <limits.h>
#include <string.h>
#include <internal/pool.h>
#include <internal/registry.h>
#define NDEBUG
#include <internal/debug.h>
@ -210,12 +211,6 @@ static GENERIC_MAPPING CmiKeyMapping =
/* ----------------------------------------- Forward Declarations */
static NTSTATUS RtlpGetRegistryHandle(ULONG RelativeTo,
PWSTR Path,
BOOLEAN Create,
PHANDLE KeyHandle);
static NTSTATUS CmiObjectParse(PVOID ParsedObject,
PVOID *NextObject,
PUNICODE_STRING FullPath,
@ -1941,10 +1936,11 @@ RtlFormatCurrentUserKeyPath(IN OUT PUNICODE_STRING KeyPath)
/* ------------------------------------------ Private Implementation */
static NTSTATUS RtlpGetRegistryHandle(ULONG RelativeTo,
PWSTR Path,
BOOLEAN Create,
PHANDLE KeyHandle)
NTSTATUS
RtlpGetRegistryHandle(ULONG RelativeTo,
PWSTR Path,
BOOLEAN Create,
PHANDLE KeyHandle)
{
UNICODE_STRING KeyName;
WCHAR KeyBuffer[MAX_PATH];

View file

@ -0,0 +1,11 @@
#ifndef __INCLUDE_INTERNAL_REGISTRY_H
#define __INCLUDE_INTERNAL_REGISTRY_H
NTSTATUS
RtlpGetRegistryHandle(ULONG RelativeTo,
PWSTR Path,
BOOLEAN Create,
PHANDLE KeyHandle);
#endif /* __INCLUDE_INTERNAL_REGISTRY_H */

View file

@ -1,4 +1,4 @@
; $Id: ntoskrnl.def,v 1.106 2001/05/04 01:21:42 rex Exp $
; $Id: ntoskrnl.def,v 1.107 2001/06/01 17:14:40 ekohl Exp $
;
; reactos/ntoskrnl/ntoskrnl.def
;
@ -693,7 +693,7 @@ RtlFindFirstRunClear@8
RtlFindFirstRunSet@8
RtlFindLongestRunClear@8
RtlFindLongestRunSet@8
;RtlFindMessage
RtlFindMessage@20
RtlFindSetBits@12
RtlFindSetBitsAndClear@12
;RtlFindUnicodePrefix
@ -755,7 +755,7 @@ RtlPrefixString@12
RtlPrefixUnicodeString@12
RtlQueryAtomInAtomTable@24
RtlQueryRegistryValues@20
;RtlQueryTimeZoneInformation
RtlQueryTimeZoneInformation@4
RtlRaiseException@4
;RtlRandom
;RtlRemoveUnicodePrefix
@ -768,7 +768,7 @@ RtlSetDaclSecurityDescriptor@16
RtlSetGroupSecurityDescriptor@12
RtlSetOwnerSecurityDescriptor@12
RtlSetSaclSecurityDescriptor@16
;RtlSetTimeZoneInformation
RtlSetTimeZoneInformation@4
;RtlSplay
RtlSubAuthorityCountSid@4
RtlSubAuthoritySid@8

View file

@ -1,4 +1,4 @@
; $Id: ntoskrnl.edf,v 1.93 2001/05/04 01:21:43 rex Exp $
; $Id: ntoskrnl.edf,v 1.94 2001/06/01 17:14:40 ekohl Exp $
;
; reactos/ntoskrnl/ntoskrnl.def
;
@ -692,7 +692,7 @@ RtlFindFirstRunClear=RtlFindFirstRunClear@8
RtlFindFirstRunSet=RtlFindFirstRunSet@8
RtlFindLongestRunClear=RtlFindLongestRunClear@8
RtlFindLongestRunSet=RtlFindLongestRunSet@8
;RtlFindMessage
RtlFindMessage=RtlFindMessage@20
RtlFindSetBits=RtlFindSetBits@12
RtlFindSetBitsAndClear=RtlFindSetBitsAndClear@12
;RtlFindUnicodePrefix
@ -753,7 +753,7 @@ RtlPrefixString=RtlPrefixString@12
RtlPrefixUnicodeString=RtlPrefixUnicodeString@12
RtlQueryAtomInAtomTable=RtlQueryAtomInAtomTable@24
RtlQueryRegistryValues=RtlQueryRegistryValues@20
;RtlQueryTimeZoneInformation
RtlQueryTimeZoneInformation=RtlQueryTimeZoneInformation@4
RtlRaiseException=RtlRaiseException@4
;RtlRandom
;RtlRemoveUnicodePrefix
@ -766,7 +766,7 @@ RtlSetDaclSecurityDescriptor=RtlSetDaclSecurityDescriptor@16
RtlSetGroupSecurityDescriptor=RtlSetGroupSecurityDescriptor@12
RtlSetOwnerSecurityDescriptor=RtlSetOwnerSecurityDescriptor@12
RtlSetSaclSecurityDescriptor=RtlSetSaclSecurityDescriptor@16
;RtlSetTimeZoneInformation
RtlSetTimeZoneInformation=RtlSetTimeZoneInformation@4
;RtlSplay
RtlSubAuthorityCountSid=RtlSubAuthorityCountSid@4
RtlSubAuthoritySid=RtlSubAuthoritySid@8

View file

@ -0,0 +1,119 @@
/* $Id: message.c,v 1.1 2001/06/01 17:13:24 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* PURPOSE: Message table functions
* FILE: ntoskrnl/rtl/message.c
* PROGRAMER: Eric Kohl <ekohl@zr-online.de>
* REVISION HISTORY:
* 29/05/2001: Created
*/
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
#define NDEBUG
#include <internal/debug.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,
(PVOID*)&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);
}
/* EOF */

View file

@ -0,0 +1,200 @@
/* $Id: timezone.c,v 1.1 2001/06/01 17:13:24 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* PURPOSE: Timezone functions
* FILE: ntoskrnl/rtl/timezone.c
* PROGRAMER: Eric Kohl
* REVISION HISTORY:
* 29/05/2001: Created
*/
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
#include <internal/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 */