[NDK] Replace the SYSTEMTIME fields StandardDate and DaylightDate in RTL_TIME_ZONE_IN...
authorEric Kohl <eric.kohl@reactos.org>
Thu, 31 May 2018 15:48:29 +0000 (17:48 +0200)
committerEric Kohl <eric.kohl@reactos.org>
Thu, 31 May 2018 15:48:29 +0000 (17:48 +0200)
Patch will be sent upstream.

CORE-14658

dll/win32/kernel32/wine/timezone.c
ntoskrnl/ex/sysinfo.c
ntoskrnl/ex/time.c
ntoskrnl/include/internal/ex.h
sdk/include/ndk/rtltypes.h
sdk/include/reactos/wine/winternl.h
win32ss/user/ntuser/kbdlayout.c

index 23c0c47..8869848 100644 (file)
@@ -261,13 +261,14 @@ DWORD
 WINAPI
 GetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation)
 {
 WINAPI
 GetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation)
 {
+    RTL_TIME_ZONE_INFORMATION TimeZoneInformation;
     NTSTATUS Status;
 
     DPRINT("GetTimeZoneInformation()\n");
 
     Status = NtQuerySystemInformation(SystemCurrentTimeZoneInformation,
     NTSTATUS Status;
 
     DPRINT("GetTimeZoneInformation()\n");
 
     Status = NtQuerySystemInformation(SystemCurrentTimeZoneInformation,
-                                      lpTimeZoneInformation,
-                                      sizeof(TIME_ZONE_INFORMATION),
+                                      &TimeZoneInformation,
+                                      sizeof(RTL_TIME_ZONE_INFORMATION),
                                       NULL);
     if (!NT_SUCCESS(Status))
     {
                                       NULL);
     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
 SetTimeZoneInformation(CONST TIME_ZONE_INFORMATION *lpTimeZoneInformation)
 {
 WINAPI
 SetTimeZoneInformation(CONST TIME_ZONE_INFORMATION *lpTimeZoneInformation)
 {
+    RTL_TIME_ZONE_INFORMATION TimeZoneInformation;
     NTSTATUS Status;
 
     DPRINT("SetTimeZoneInformation()\n");
 
     NTSTATUS Status;
 
     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))
     {
         DPRINT1("RtlSetTimeZoneInformation() failed (Status %lx)\n", Status);
     if (!NT_SUCCESS(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,
-                                    sizeof(TIME_ZONE_INFORMATION));
+                                    (PVOID)&TimeZoneInformation,
+                                    sizeof(RTL_TIME_ZONE_INFORMATION));
     if (!NT_SUCCESS(Status))
     {
         DPRINT1("NtSetSystemInformation() failed (Status %lx)\n", Status);
     if (!NT_SUCCESS(Status))
     {
         DPRINT1("NtSetSystemInformation() failed (Status %lx)\n", Status);
index ceb1d22..016ac5b 100644 (file)
@@ -1939,9 +1939,9 @@ QSI_DEF(SystemLegacyDriverInformation)
 /* Class 44 - Current Time Zone Information */
 QSI_DEF(SystemCurrentTimeZoneInformation)
 {
 /* Class 44 - Current Time Zone Information */
 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 */
     memcpy(Buffer,
            &ExpTimeZoneInfo,
     /* Copy the time zone information struct */
     memcpy(Buffer,
            &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)
 {
     /* Check user buffer's size */
 SSI_DEF(SystemCurrentTimeZoneInformation)
 {
     /* 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
index a9ae21c..44ce39d 100644 (file)
@@ -18,7 +18,7 @@
 /* GLOBALS ******************************************************************/
 
 /* Note: Bias[minutes] = UTC - local time */
 /* GLOBALS ******************************************************************/
 
 /* Note: Bias[minutes] = UTC - local time */
-TIME_ZONE_INFORMATION ExpTimeZoneInfo;
+RTL_TIME_ZONE_INFORMATION ExpTimeZoneInfo;
 ULONG ExpLastTimeZoneBias = -1;
 LARGE_INTEGER ExpTimeZoneBias;
 ULONG ExpAltTimeZoneBias;
 ULONG ExpLastTimeZoneBias = -1;
 LARGE_INTEGER ExpTimeZoneBias;
 ULONG ExpAltTimeZoneBias;
@@ -233,7 +233,7 @@ ExRefreshTimeZoneInformation(IN PLARGE_INTEGER CurrentBootTime)
     if (!NT_SUCCESS(Status))
     {
         /* Failed, clear all data */
     if (!NT_SUCCESS(Status))
     {
         /* Failed, clear all data */
-        RtlZeroMemory(&ExpTimeZoneInfo, sizeof(TIME_ZONE_INFORMATION));
+        RtlZeroMemory(&ExpTimeZoneInfo, sizeof(RTL_TIME_ZONE_INFORMATION));
         ExpTimeZoneBias.QuadPart = (LONGLONG)0;
         ExpTimeZoneId = TIME_ZONE_ID_UNKNOWN;
     }
         ExpTimeZoneBias.QuadPart = (LONGLONG)0;
         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;
     TIME_FIELDS TimeFields;
 {
     LARGE_INTEGER LocalTime, SystemTime, OldTime;
     TIME_FIELDS TimeFields;
@@ -303,7 +303,7 @@ ExpSetTimeZoneInformation(PTIME_ZONE_INFORMATION TimeZoneInformation)
     /* Copy the timezone information */
     RtlCopyMemory(&ExpTimeZoneInfo,
                   TimeZoneInformation,
     /* Copy the timezone information */
     RtlCopyMemory(&ExpTimeZoneInfo,
                   TimeZoneInformation,
-                  sizeof(TIME_ZONE_INFORMATION));
+                  sizeof(RTL_TIME_ZONE_INFORMATION));
 
     /* Set the new time zone information */
     SharedUserData->TimeZoneBias.High1Time = ExpTimeZoneBias.u.HighPart;
 
     /* Set the new time zone information */
     SharedUserData->TimeZoneBias.High1Time = ExpTimeZoneBias.u.HighPart;
index 091b907..740bb96 100644 (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 ULONG ExpTimeZoneId;
 extern ULONG ExpTickCountMultiplier;
 extern LARGE_INTEGER ExpTimeZoneBias;
 extern ULONG ExpTimeZoneId;
 extern ULONG ExpTickCountMultiplier;
@@ -1417,7 +1417,7 @@ ExTryToAcquireResourceExclusiveLite(
 
 NTSTATUS
 ExpSetTimeZoneInformation(
 
 NTSTATUS
 ExpSetTimeZoneInformation(
-    IN PTIME_ZONE_INFORMATION TimeZoneInformation
+    IN PRTL_TIME_ZONE_INFORMATION TimeZoneInformation
 );
 
 BOOLEAN
 );
 
 BOOLEAN
index 1371f4c..b526f9e 100644 (file)
@@ -1662,38 +1662,19 @@ typedef struct _RTL_ATOM_TABLE
     PRTL_ATOM_TABLE_ENTRY Buckets[1];
 } RTL_ATOM_TABLE, *PRTL_ATOM_TABLE;
 
     PRTL_ATOM_TABLE_ENTRY Buckets[1];
 } RTL_ATOM_TABLE, *PRTL_ATOM_TABLE;
 
-#ifndef _WINBASE_
 //
 //
-// System Time and Timezone Structures
+// Timezone Information
 //
 //
-typedef struct _SYSTEMTIME
-{
-    USHORT wYear;
-    USHORT wMonth;
-    USHORT wDayOfWeek;
-    USHORT wDay;
-    USHORT wHour;
-    USHORT wMinute;
-    USHORT wSecond;
-    USHORT wMilliseconds;
-} SYSTEMTIME, *PSYSTEMTIME, *LPSYSTEMTIME;
-
-typedef struct _TIME_ZONE_INFORMATION
+typedef struct _RTL_TIME_ZONE_INFORMATION
 {
     LONG Bias;
     WCHAR StandardName[32];
 {
     LONG Bias;
     WCHAR StandardName[32];
-    SYSTEMTIME StandardDate;
+    TIME_FIELDS StandardDate;
     LONG StandardBias;
     WCHAR DaylightName[32];
     LONG StandardBias;
     WCHAR DaylightName[32];
-    SYSTEMTIME DaylightDate;
+    TIME_FIELDS DaylightDate;
     LONG DaylightBias;
     LONG DaylightBias;
-} TIME_ZONE_INFORMATION, *PTIME_ZONE_INFORMATION, *LPTIME_ZONE_INFORMATION;
-#endif /* !_WINBASE_ */
-
-//
-// Native version of Timezone Structure
-//
-typedef LPTIME_ZONE_INFORMATION PRTL_TIME_ZONE_INFORMATION;
+} RTL_TIME_ZONE_INFORMATION, *PRTL_TIME_ZONE_INFORMATION;
 
 //
 // Hotpatch Header
 
 //
 // Hotpatch Header
index 999f544..edd79e5 100644 (file)
@@ -102,6 +102,7 @@ typedef struct _FILETIME
 } FILETIME, *PFILETIME, *LPFILETIME;
 #endif /* _FILETIME_ */
 
 } FILETIME, *PFILETIME, *LPFILETIME;
 #endif /* _FILETIME_ */
 
+#if 0
 /*
  * RTL_SYSTEM_TIME and RTL_TIME_ZONE_INFORMATION are the same as
  * the SYSTEMTIME and TIME_ZONE_INFORMATION structures defined
 /*
  * RTL_SYSTEM_TIME and RTL_TIME_ZONE_INFORMATION are the same as
  * the SYSTEMTIME and TIME_ZONE_INFORMATION structures defined
@@ -120,14 +121,26 @@ typedef struct _RTL_SYSTEM_TIME {
     WORD wSecond;
     WORD wMilliseconds;
 } RTL_SYSTEM_TIME, *PRTL_SYSTEM_TIME;
     WORD wSecond;
     WORD wMilliseconds;
 } 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 {
     LONG Bias;
     WCHAR StandardName[32];
 
 typedef struct _RTL_TIME_ZONE_INFORMATION {
     LONG Bias;
     WCHAR StandardName[32];
-    RTL_SYSTEM_TIME StandardDate;
+    TIME_FIELDS StandardDate;
     LONG StandardBias;
     WCHAR DaylightName[32];
     LONG StandardBias;
     WCHAR DaylightName[32];
-    RTL_SYSTEM_TIME DaylightDate;
+    TIME_FIELDS DaylightDate;
     LONG DaylightBias;
 } RTL_TIME_ZONE_INFORMATION, *PRTL_TIME_ZONE_INFORMATION;
 
     LONG DaylightBias;
 } RTL_TIME_ZONE_INFORMATION, *PRTL_TIME_ZONE_INFORMATION;
 
@@ -135,10 +148,10 @@ typedef struct _RTL_TIME_DYNAMIC_ZONE_INFORMATION
 {
     LONG Bias;
     WCHAR StandardName[32];
 {
     LONG Bias;
     WCHAR StandardName[32];
-    RTL_SYSTEM_TIME StandardDate;
+    TIME_FIELDS StandardDate;
     LONG StandardBias;
     WCHAR DaylightName[32];
     LONG StandardBias;
     WCHAR DaylightName[32];
-    RTL_SYSTEM_TIME DaylightDate;
+    TIME_FIELDS DaylightDate;
     LONG DaylightBias;
     WCHAR TimeZoneKeyName[128];
     BOOLEAN DynamicDaylightTimeDisabled;
     LONG DaylightBias;
     WCHAR TimeZoneKeyName[128];
     BOOLEAN DynamicDaylightTimeDisabled;
@@ -1647,17 +1660,6 @@ typedef struct _SYSTEM_TIME_ADJUSTMENT {
     BOOLEAN TimeAdjustmentDisabled;
 } SYSTEM_TIME_ADJUSTMENT, *PSYSTEM_TIME_ADJUSTMENT;
 
     BOOLEAN TimeAdjustmentDisabled;
 } 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 {
   BYTE Reserved2[70];
   ULONG LogonId;
 typedef struct _WINSTATIONINFORMATIONW {
   BYTE Reserved2[70];
   ULONG LogonId;
index cd57492..f47ece5 100644 (file)
 
 #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);