diff --git a/sdk/lib/rtl/timezone.c b/sdk/lib/rtl/timezone.c index 20369ef4e5..da627f7f37 100644 --- a/sdk/lib/rtl/timezone.c +++ b/sdk/lib/rtl/timezone.c @@ -87,8 +87,29 @@ NTSTATUS NTAPI RtlSetTimeZoneInformation(PRTL_TIME_ZONE_INFORMATION TimeZoneInformation) { + +/* + * RTL_SYSTEM_TIME is almost the same as the SYSTEMTIME structure defined + * in winbase.h, however we need to define it differently here. + * This is used by RtlQueryTimeZoneInformation and RtlSetTimeZoneInformation. + * See: https://social.msdn.microsoft.com/Forums/en-US/home?forum=en-US and + * Search: Reading TimeZone binary data from registry by Patrick + * and then look at the last post showing typedef struct SYSTEMTIME_TZI. + */ +typedef struct _RTL_SYSTEM_TIME { + WORD wYear; + WORD wMonth; + WORD wDay; /* wDayOfWeek was here normally */ + WORD wHour; + WORD wMinute; + WORD wSecond; + WORD wMilliseconds; + WORD wDayOfWeek; /* wDayOfWeek relocated to here */ +} RTL_SYSTEM_TIME; + SIZE_T Length; NTSTATUS Status; + RTL_SYSTEM_TIME tzi; DPRINT("RtlSetTimeZoneInformation()\n"); @@ -128,11 +149,20 @@ RtlSetTimeZoneInformation(PRTL_TIME_ZONE_INFORMATION TimeZoneInformation) return Status; } + tzi.wYear = TimeZoneInformation->StandardDate.wYear; + tzi.wMonth = TimeZoneInformation->StandardDate.wMonth; + tzi.wDay = TimeZoneInformation->StandardDate.wDay; + tzi.wHour = TimeZoneInformation->StandardDate.wHour; + tzi.wMinute = TimeZoneInformation->StandardDate.wMinute; + tzi.wSecond = TimeZoneInformation->StandardDate.wSecond; + tzi.wMilliseconds = TimeZoneInformation->StandardDate.wMilliseconds; + tzi.wDayOfWeek = TimeZoneInformation->StandardDate.wDayOfWeek; + Status = RtlWriteRegistryValue(RTL_REGISTRY_CONTROL, L"TimeZoneInformation", L"StandardStart", REG_BINARY, - &TimeZoneInformation->StandardDate, + &tzi, sizeof(SYSTEMTIME)); if (!NT_SUCCESS(Status)) { @@ -162,11 +192,21 @@ RtlSetTimeZoneInformation(PRTL_TIME_ZONE_INFORMATION TimeZoneInformation) return Status; } + + tzi.wYear = TimeZoneInformation->DaylightDate.wYear; + tzi.wMonth = TimeZoneInformation->DaylightDate.wMonth; + tzi.wDay = TimeZoneInformation->DaylightDate.wDay; + tzi.wHour = TimeZoneInformation->DaylightDate.wHour; + tzi.wMinute = TimeZoneInformation->DaylightDate.wMinute; + tzi.wSecond = TimeZoneInformation->DaylightDate.wSecond; + tzi.wMilliseconds = TimeZoneInformation->DaylightDate.wMilliseconds; + tzi.wDayOfWeek = TimeZoneInformation->DaylightDate.wDayOfWeek; + Status = RtlWriteRegistryValue(RTL_REGISTRY_CONTROL, L"TimeZoneInformation", L"DaylightStart", REG_BINARY, - &TimeZoneInformation->DaylightDate, + &tzi, sizeof(SYSTEMTIME)); return Status;