[NDK] Replace the SYSTEMTIME fields StandardDate and DaylightDate in RTL_TIME_ZONE_INFORMATION by TIME_FIELDs and fix resulting errors

Patch will be sent upstream.

CORE-14658
This commit is contained in:
Eric Kohl 2018-05-31 17:48:29 +02:00
parent ac45758aff
commit 4911382913
7 changed files with 96 additions and 56 deletions

View file

@ -261,13 +261,14 @@ DWORD
WINAPI WINAPI
GetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation) GetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation)
{ {
RTL_TIME_ZONE_INFORMATION TimeZoneInformation;
NTSTATUS Status; NTSTATUS Status;
DPRINT("GetTimeZoneInformation()\n"); DPRINT("GetTimeZoneInformation()\n");
Status = NtQuerySystemInformation(SystemCurrentTimeZoneInformation, Status = NtQuerySystemInformation(SystemCurrentTimeZoneInformation,
lpTimeZoneInformation, &TimeZoneInformation,
sizeof(TIME_ZONE_INFORMATION), sizeof(RTL_TIME_ZONE_INFORMATION),
NULL); NULL);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
@ -275,6 +276,32 @@ GetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation)
return TIME_ZONE_ID_INVALID; return TIME_ZONE_ID_INVALID;
} }
lpTimeZoneInformation->Bias = TimeZoneInformation.Bias;
wcsncpy(lpTimeZoneInformation->StandardName,
TimeZoneInformation.StandardName,
ARRAYSIZE(lpTimeZoneInformation->StandardName));
lpTimeZoneInformation->StandardDate.wYear = TimeZoneInformation.StandardDate.Year;
lpTimeZoneInformation->StandardDate.wMonth = TimeZoneInformation.StandardDate.Month;
lpTimeZoneInformation->StandardDate.wDay = TimeZoneInformation.StandardDate.Day;
lpTimeZoneInformation->StandardDate.wHour = TimeZoneInformation.StandardDate.Hour;
lpTimeZoneInformation->StandardDate.wMinute = TimeZoneInformation.StandardDate.Minute;
lpTimeZoneInformation->StandardDate.wSecond = TimeZoneInformation.StandardDate.Second;
lpTimeZoneInformation->StandardDate.wDayOfWeek = TimeZoneInformation.StandardDate.Weekday;
lpTimeZoneInformation->StandardBias = TimeZoneInformation.StandardBias;
wcsncpy(lpTimeZoneInformation->DaylightName,
TimeZoneInformation.DaylightName,
ARRAYSIZE(lpTimeZoneInformation->DaylightName));
lpTimeZoneInformation->DaylightDate.wYear = TimeZoneInformation.DaylightDate.Year;
lpTimeZoneInformation->DaylightDate.wMonth = TimeZoneInformation.DaylightDate.Month;
lpTimeZoneInformation->DaylightDate.wDay = TimeZoneInformation.DaylightDate.Day;
lpTimeZoneInformation->DaylightDate.wHour = TimeZoneInformation.DaylightDate.Hour;
lpTimeZoneInformation->DaylightDate.wMinute = TimeZoneInformation.DaylightDate.Minute;
lpTimeZoneInformation->DaylightDate.wSecond = TimeZoneInformation.DaylightDate.Second;
lpTimeZoneInformation->DaylightDate.wDayOfWeek = TimeZoneInformation.DaylightDate.Weekday;
lpTimeZoneInformation->DaylightBias = TimeZoneInformation.DaylightBias;
return TIME_ZoneID(lpTimeZoneInformation); return TIME_ZoneID(lpTimeZoneInformation);
} }
@ -286,11 +313,38 @@ BOOL
WINAPI WINAPI
SetTimeZoneInformation(CONST TIME_ZONE_INFORMATION *lpTimeZoneInformation) SetTimeZoneInformation(CONST TIME_ZONE_INFORMATION *lpTimeZoneInformation)
{ {
RTL_TIME_ZONE_INFORMATION TimeZoneInformation;
NTSTATUS Status; NTSTATUS Status;
DPRINT("SetTimeZoneInformation()\n"); DPRINT("SetTimeZoneInformation()\n");
Status = RtlSetTimeZoneInformation((LPTIME_ZONE_INFORMATION)lpTimeZoneInformation); TimeZoneInformation.Bias = lpTimeZoneInformation->Bias;
wcsncpy(TimeZoneInformation.StandardName,
lpTimeZoneInformation->StandardName,
ARRAYSIZE(TimeZoneInformation.StandardName));
TimeZoneInformation.StandardDate.Year = lpTimeZoneInformation->StandardDate.wYear;
TimeZoneInformation.StandardDate.Month = lpTimeZoneInformation->StandardDate.wMonth;
TimeZoneInformation.StandardDate.Day = lpTimeZoneInformation->StandardDate.wDay;
TimeZoneInformation.StandardDate.Hour = lpTimeZoneInformation->StandardDate.wHour;
TimeZoneInformation.StandardDate.Minute = lpTimeZoneInformation->StandardDate.wMinute;
TimeZoneInformation.StandardDate.Second = lpTimeZoneInformation->StandardDate.wSecond;
TimeZoneInformation.StandardDate.Weekday = lpTimeZoneInformation->StandardDate.wDayOfWeek;
TimeZoneInformation.StandardBias = lpTimeZoneInformation->StandardBias;
wcsncpy(TimeZoneInformation.DaylightName,
lpTimeZoneInformation->DaylightName,
ARRAYSIZE(TimeZoneInformation.DaylightName));
TimeZoneInformation.DaylightDate.Year = lpTimeZoneInformation->DaylightDate.wYear;
TimeZoneInformation.DaylightDate.Month = lpTimeZoneInformation->DaylightDate.wMonth;
TimeZoneInformation.DaylightDate.Day = lpTimeZoneInformation->DaylightDate.wDay;
TimeZoneInformation.DaylightDate.Hour = lpTimeZoneInformation->DaylightDate.wHour;
TimeZoneInformation.DaylightDate.Minute = lpTimeZoneInformation->DaylightDate.wMinute;
TimeZoneInformation.DaylightDate.Second = lpTimeZoneInformation->DaylightDate.wSecond;
TimeZoneInformation.DaylightDate.Weekday = lpTimeZoneInformation->DaylightDate.wDayOfWeek;
TimeZoneInformation.DaylightBias = lpTimeZoneInformation->DaylightBias;
Status = RtlSetTimeZoneInformation(&TimeZoneInformation);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT1("RtlSetTimeZoneInformation() failed (Status %lx)\n", Status); DPRINT1("RtlSetTimeZoneInformation() failed (Status %lx)\n", Status);
@ -299,8 +353,8 @@ SetTimeZoneInformation(CONST TIME_ZONE_INFORMATION *lpTimeZoneInformation)
} }
Status = NtSetSystemInformation(SystemCurrentTimeZoneInformation, Status = NtSetSystemInformation(SystemCurrentTimeZoneInformation,
(PVOID)lpTimeZoneInformation, (PVOID)&TimeZoneInformation,
sizeof(TIME_ZONE_INFORMATION)); sizeof(RTL_TIME_ZONE_INFORMATION));
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT1("NtSetSystemInformation() failed (Status %lx)\n", Status); DPRINT1("NtSetSystemInformation() failed (Status %lx)\n", Status);

View file

@ -1939,9 +1939,9 @@ QSI_DEF(SystemLegacyDriverInformation)
/* Class 44 - Current Time Zone Information */ /* Class 44 - Current Time Zone Information */
QSI_DEF(SystemCurrentTimeZoneInformation) QSI_DEF(SystemCurrentTimeZoneInformation)
{ {
*ReqSize = sizeof(TIME_ZONE_INFORMATION); *ReqSize = sizeof(RTL_TIME_ZONE_INFORMATION);
if (sizeof(TIME_ZONE_INFORMATION) != Size) if (sizeof(RTL_TIME_ZONE_INFORMATION) != Size)
{ {
return STATUS_INFO_LENGTH_MISMATCH; return STATUS_INFO_LENGTH_MISMATCH;
} }
@ -1949,7 +1949,7 @@ QSI_DEF(SystemCurrentTimeZoneInformation)
/* Copy the time zone information struct */ /* Copy the time zone information struct */
memcpy(Buffer, memcpy(Buffer,
&ExpTimeZoneInfo, &ExpTimeZoneInfo,
sizeof(TIME_ZONE_INFORMATION)); sizeof(RTL_TIME_ZONE_INFORMATION));
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -1958,12 +1958,12 @@ QSI_DEF(SystemCurrentTimeZoneInformation)
SSI_DEF(SystemCurrentTimeZoneInformation) SSI_DEF(SystemCurrentTimeZoneInformation)
{ {
/* Check user buffer's size */ /* Check user buffer's size */
if (Size < sizeof(TIME_ZONE_INFORMATION)) if (Size < sizeof(RTL_TIME_ZONE_INFORMATION))
{ {
return STATUS_INFO_LENGTH_MISMATCH; return STATUS_INFO_LENGTH_MISMATCH;
} }
return ExpSetTimeZoneInformation((PTIME_ZONE_INFORMATION)Buffer); return ExpSetTimeZoneInformation((PRTL_TIME_ZONE_INFORMATION)Buffer);
} }
static static

View file

@ -18,7 +18,7 @@
/* GLOBALS ******************************************************************/ /* GLOBALS ******************************************************************/
/* Note: Bias[minutes] = UTC - local time */ /* Note: Bias[minutes] = UTC - local time */
TIME_ZONE_INFORMATION ExpTimeZoneInfo; RTL_TIME_ZONE_INFORMATION ExpTimeZoneInfo;
ULONG ExpLastTimeZoneBias = -1; ULONG ExpLastTimeZoneBias = -1;
LARGE_INTEGER ExpTimeZoneBias; LARGE_INTEGER ExpTimeZoneBias;
ULONG ExpAltTimeZoneBias; ULONG ExpAltTimeZoneBias;
@ -233,7 +233,7 @@ ExRefreshTimeZoneInformation(IN PLARGE_INTEGER CurrentBootTime)
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
/* Failed, clear all data */ /* Failed, clear all data */
RtlZeroMemory(&ExpTimeZoneInfo, sizeof(TIME_ZONE_INFORMATION)); RtlZeroMemory(&ExpTimeZoneInfo, sizeof(RTL_TIME_ZONE_INFORMATION));
ExpTimeZoneBias.QuadPart = (LONGLONG)0; ExpTimeZoneBias.QuadPart = (LONGLONG)0;
ExpTimeZoneId = TIME_ZONE_ID_UNKNOWN; ExpTimeZoneId = TIME_ZONE_ID_UNKNOWN;
} }
@ -275,7 +275,7 @@ ExRefreshTimeZoneInformation(IN PLARGE_INTEGER CurrentBootTime)
} }
NTSTATUS NTSTATUS
ExpSetTimeZoneInformation(PTIME_ZONE_INFORMATION TimeZoneInformation) ExpSetTimeZoneInformation(PRTL_TIME_ZONE_INFORMATION TimeZoneInformation)
{ {
LARGE_INTEGER LocalTime, SystemTime, OldTime; LARGE_INTEGER LocalTime, SystemTime, OldTime;
TIME_FIELDS TimeFields; TIME_FIELDS TimeFields;
@ -303,7 +303,7 @@ ExpSetTimeZoneInformation(PTIME_ZONE_INFORMATION TimeZoneInformation)
/* Copy the timezone information */ /* Copy the timezone information */
RtlCopyMemory(&ExpTimeZoneInfo, RtlCopyMemory(&ExpTimeZoneInfo,
TimeZoneInformation, TimeZoneInformation,
sizeof(TIME_ZONE_INFORMATION)); sizeof(RTL_TIME_ZONE_INFORMATION));
/* Set the new time zone information */ /* Set the new time zone information */
SharedUserData->TimeZoneBias.High1Time = ExpTimeZoneBias.u.HighPart; SharedUserData->TimeZoneBias.High1Time = ExpTimeZoneBias.u.HighPart;

View file

@ -2,7 +2,7 @@
/* GLOBAL VARIABLES *********************************************************/ /* GLOBAL VARIABLES *********************************************************/
extern TIME_ZONE_INFORMATION ExpTimeZoneInfo; extern RTL_TIME_ZONE_INFORMATION ExpTimeZoneInfo;
extern LARGE_INTEGER ExpTimeZoneBias; extern LARGE_INTEGER ExpTimeZoneBias;
extern ULONG ExpTimeZoneId; extern ULONG ExpTimeZoneId;
extern ULONG ExpTickCountMultiplier; extern ULONG ExpTickCountMultiplier;
@ -1417,7 +1417,7 @@ ExTryToAcquireResourceExclusiveLite(
NTSTATUS NTSTATUS
ExpSetTimeZoneInformation( ExpSetTimeZoneInformation(
IN PTIME_ZONE_INFORMATION TimeZoneInformation IN PRTL_TIME_ZONE_INFORMATION TimeZoneInformation
); );
BOOLEAN BOOLEAN

View file

@ -1662,38 +1662,19 @@ typedef struct _RTL_ATOM_TABLE
PRTL_ATOM_TABLE_ENTRY Buckets[1]; PRTL_ATOM_TABLE_ENTRY Buckets[1];
} RTL_ATOM_TABLE, *PRTL_ATOM_TABLE; } RTL_ATOM_TABLE, *PRTL_ATOM_TABLE;
#ifndef _WINBASE_
// //
// System Time and Timezone Structures // Timezone Information
// //
typedef struct _SYSTEMTIME typedef struct _RTL_TIME_ZONE_INFORMATION
{
USHORT wYear;
USHORT wMonth;
USHORT wDayOfWeek;
USHORT wDay;
USHORT wHour;
USHORT wMinute;
USHORT wSecond;
USHORT wMilliseconds;
} SYSTEMTIME, *PSYSTEMTIME, *LPSYSTEMTIME;
typedef struct _TIME_ZONE_INFORMATION
{ {
LONG Bias; LONG Bias;
WCHAR StandardName[32]; WCHAR StandardName[32];
SYSTEMTIME StandardDate; TIME_FIELDS StandardDate;
LONG StandardBias; LONG StandardBias;
WCHAR DaylightName[32]; WCHAR DaylightName[32];
SYSTEMTIME DaylightDate; TIME_FIELDS DaylightDate;
LONG DaylightBias; LONG DaylightBias;
} TIME_ZONE_INFORMATION, *PTIME_ZONE_INFORMATION, *LPTIME_ZONE_INFORMATION; } RTL_TIME_ZONE_INFORMATION, *PRTL_TIME_ZONE_INFORMATION;
#endif /* !_WINBASE_ */
//
// Native version of Timezone Structure
//
typedef LPTIME_ZONE_INFORMATION PRTL_TIME_ZONE_INFORMATION;
// //
// Hotpatch Header // Hotpatch Header

View file

@ -102,6 +102,7 @@ typedef struct _FILETIME
} FILETIME, *PFILETIME, *LPFILETIME; } FILETIME, *PFILETIME, *LPFILETIME;
#endif /* _FILETIME_ */ #endif /* _FILETIME_ */
#if 0
/* /*
* RTL_SYSTEM_TIME and RTL_TIME_ZONE_INFORMATION are the same as * RTL_SYSTEM_TIME and RTL_TIME_ZONE_INFORMATION are the same as
* the SYSTEMTIME and TIME_ZONE_INFORMATION structures defined * the SYSTEMTIME and TIME_ZONE_INFORMATION structures defined
@ -120,14 +121,26 @@ typedef struct _RTL_SYSTEM_TIME {
WORD wSecond; WORD wSecond;
WORD wMilliseconds; WORD wMilliseconds;
} RTL_SYSTEM_TIME, *PRTL_SYSTEM_TIME; } RTL_SYSTEM_TIME, *PRTL_SYSTEM_TIME;
#endif
typedef struct _TIME_FIELDS {
CSHORT Year;
CSHORT Month;
CSHORT Day;
CSHORT Hour;
CSHORT Minute;
CSHORT Second;
CSHORT Milliseconds;
CSHORT Weekday;
} TIME_FIELDS, *PTIME_FIELDS;
typedef struct _RTL_TIME_ZONE_INFORMATION { typedef struct _RTL_TIME_ZONE_INFORMATION {
LONG Bias; LONG Bias;
WCHAR StandardName[32]; WCHAR StandardName[32];
RTL_SYSTEM_TIME StandardDate; TIME_FIELDS StandardDate;
LONG StandardBias; LONG StandardBias;
WCHAR DaylightName[32]; WCHAR DaylightName[32];
RTL_SYSTEM_TIME DaylightDate; TIME_FIELDS DaylightDate;
LONG DaylightBias; LONG DaylightBias;
} RTL_TIME_ZONE_INFORMATION, *PRTL_TIME_ZONE_INFORMATION; } RTL_TIME_ZONE_INFORMATION, *PRTL_TIME_ZONE_INFORMATION;
@ -135,10 +148,10 @@ typedef struct _RTL_TIME_DYNAMIC_ZONE_INFORMATION
{ {
LONG Bias; LONG Bias;
WCHAR StandardName[32]; WCHAR StandardName[32];
RTL_SYSTEM_TIME StandardDate; TIME_FIELDS StandardDate;
LONG StandardBias; LONG StandardBias;
WCHAR DaylightName[32]; WCHAR DaylightName[32];
RTL_SYSTEM_TIME DaylightDate; TIME_FIELDS DaylightDate;
LONG DaylightBias; LONG DaylightBias;
WCHAR TimeZoneKeyName[128]; WCHAR TimeZoneKeyName[128];
BOOLEAN DynamicDaylightTimeDisabled; BOOLEAN DynamicDaylightTimeDisabled;
@ -1647,17 +1660,6 @@ typedef struct _SYSTEM_TIME_ADJUSTMENT {
BOOLEAN TimeAdjustmentDisabled; BOOLEAN TimeAdjustmentDisabled;
} SYSTEM_TIME_ADJUSTMENT, *PSYSTEM_TIME_ADJUSTMENT; } SYSTEM_TIME_ADJUSTMENT, *PSYSTEM_TIME_ADJUSTMENT;
typedef struct _TIME_FIELDS
{ CSHORT Year;
CSHORT Month;
CSHORT Day;
CSHORT Hour;
CSHORT Minute;
CSHORT Second;
CSHORT Milliseconds;
CSHORT Weekday;
} TIME_FIELDS, *PTIME_FIELDS;
typedef struct _WINSTATIONINFORMATIONW { typedef struct _WINSTATIONINFORMATIONW {
BYTE Reserved2[70]; BYTE Reserved2[70];
ULONG LogonId; ULONG LogonId;

View file

@ -10,7 +10,10 @@
#include <win32k.h> #include <win32k.h>
#include <winnls.h> // Was included only because of CP_ACP and required the
// definition of SYSTEMTIME in ndk\rtltypes.h
//#include <winnls.h>
#define CP_ACP 0
DBG_DEFAULT_CHANNEL(UserKbdLayout); DBG_DEFAULT_CHANNEL(UserKbdLayout);