https://git.reactos.org/?p=reactos.git;a=commitdiff;h=491138291348dbc72f0be52cecb1459d0281d332

commit 491138291348dbc72f0be52cecb1459d0281d332
Author:     Eric Kohl <[email protected]>
AuthorDate: Thu May 31 17:48:29 2018 +0200
Commit:     Eric Kohl <[email protected]>
CommitDate: Thu May 31 17:48:29 2018 +0200

    [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
---
 dll/win32/kernel32/wine/timezone.c  | 64 ++++++++++++++++++++++++++++++++++---
 ntoskrnl/ex/sysinfo.c               | 10 +++---
 ntoskrnl/ex/time.c                  |  8 ++---
 ntoskrnl/include/internal/ex.h      |  4 +--
 sdk/include/ndk/rtltypes.h          | 29 +++--------------
 sdk/include/reactos/wine/winternl.h | 32 ++++++++++---------
 win32ss/user/ntuser/kbdlayout.c     |  5 ++-
 7 files changed, 96 insertions(+), 56 deletions(-)

diff --git a/dll/win32/kernel32/wine/timezone.c 
b/dll/win32/kernel32/wine/timezone.c
index 23c0c47302..8869848d49 100644
--- a/dll/win32/kernel32/wine/timezone.c
+++ b/dll/win32/kernel32/wine/timezone.c
@@ -261,13 +261,14 @@ DWORD
 WINAPI
 GetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation)
 {
+    RTL_TIME_ZONE_INFORMATION TimeZoneInformation;
     NTSTATUS Status;
 
     DPRINT("GetTimeZoneInformation()\n");
 
     Status = NtQuerySystemInformation(SystemCurrentTimeZoneInformation,
-                                      lpTimeZoneInformation,
-                                      sizeof(TIME_ZONE_INFORMATION),
+                                      &TimeZoneInformation,
+                                      sizeof(RTL_TIME_ZONE_INFORMATION),
                                       NULL);
     if (!NT_SUCCESS(Status))
     {
@@ -275,6 +276,32 @@ GetTimeZoneInformation(LPTIME_ZONE_INFORMATION 
lpTimeZoneInformation)
         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);
 }
 
@@ -286,11 +313,38 @@ BOOL
 WINAPI
 SetTimeZoneInformation(CONST TIME_ZONE_INFORMATION *lpTimeZoneInformation)
 {
+    RTL_TIME_ZONE_INFORMATION TimeZoneInformation;
     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);
@@ -299,8 +353,8 @@ SetTimeZoneInformation(CONST TIME_ZONE_INFORMATION 
*lpTimeZoneInformation)
     }
 
     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);
diff --git a/ntoskrnl/ex/sysinfo.c b/ntoskrnl/ex/sysinfo.c
index ceb1d22842..016ac5b1d9 100644
--- a/ntoskrnl/ex/sysinfo.c
+++ b/ntoskrnl/ex/sysinfo.c
@@ -1939,9 +1939,9 @@ QSI_DEF(SystemLegacyDriverInformation)
 /* 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;
     }
@@ -1949,7 +1949,7 @@ QSI_DEF(SystemCurrentTimeZoneInformation)
     /* Copy the time zone information struct */
     memcpy(Buffer,
            &ExpTimeZoneInfo,
-           sizeof(TIME_ZONE_INFORMATION));
+           sizeof(RTL_TIME_ZONE_INFORMATION));
 
     return STATUS_SUCCESS;
 }
@@ -1958,12 +1958,12 @@ QSI_DEF(SystemCurrentTimeZoneInformation)
 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 ExpSetTimeZoneInformation((PTIME_ZONE_INFORMATION)Buffer);
+    return ExpSetTimeZoneInformation((PRTL_TIME_ZONE_INFORMATION)Buffer);
 }
 
 static
diff --git a/ntoskrnl/ex/time.c b/ntoskrnl/ex/time.c
index a9ae21c1ce..44ce39d9ad 100644
--- a/ntoskrnl/ex/time.c
+++ b/ntoskrnl/ex/time.c
@@ -18,7 +18,7 @@
 /* GLOBALS ******************************************************************/
 
 /* Note: Bias[minutes] = UTC - local time */
-TIME_ZONE_INFORMATION ExpTimeZoneInfo;
+RTL_TIME_ZONE_INFORMATION ExpTimeZoneInfo;
 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 */
-        RtlZeroMemory(&ExpTimeZoneInfo, sizeof(TIME_ZONE_INFORMATION));
+        RtlZeroMemory(&ExpTimeZoneInfo, sizeof(RTL_TIME_ZONE_INFORMATION));
         ExpTimeZoneBias.QuadPart = (LONGLONG)0;
         ExpTimeZoneId = TIME_ZONE_ID_UNKNOWN;
     }
@@ -275,7 +275,7 @@ ExRefreshTimeZoneInformation(IN PLARGE_INTEGER 
CurrentBootTime)
 }
 
 NTSTATUS
-ExpSetTimeZoneInformation(PTIME_ZONE_INFORMATION TimeZoneInformation)
+ExpSetTimeZoneInformation(PRTL_TIME_ZONE_INFORMATION TimeZoneInformation)
 {
     LARGE_INTEGER LocalTime, SystemTime, OldTime;
     TIME_FIELDS TimeFields;
@@ -303,7 +303,7 @@ ExpSetTimeZoneInformation(PTIME_ZONE_INFORMATION 
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;
diff --git a/ntoskrnl/include/internal/ex.h b/ntoskrnl/include/internal/ex.h
index 091b90783d..740bb96564 100644
--- a/ntoskrnl/include/internal/ex.h
+++ b/ntoskrnl/include/internal/ex.h
@@ -2,7 +2,7 @@
 
 /* GLOBAL VARIABLES *********************************************************/
 
-extern TIME_ZONE_INFORMATION ExpTimeZoneInfo;
+extern RTL_TIME_ZONE_INFORMATION ExpTimeZoneInfo;
 extern LARGE_INTEGER ExpTimeZoneBias;
 extern ULONG ExpTimeZoneId;
 extern ULONG ExpTickCountMultiplier;
@@ -1417,7 +1417,7 @@ ExTryToAcquireResourceExclusiveLite(
 
 NTSTATUS
 ExpSetTimeZoneInformation(
-    IN PTIME_ZONE_INFORMATION TimeZoneInformation
+    IN PRTL_TIME_ZONE_INFORMATION TimeZoneInformation
 );
 
 BOOLEAN
diff --git a/sdk/include/ndk/rtltypes.h b/sdk/include/ndk/rtltypes.h
index 1371f4c86f..b526f9ea04 100644
--- a/sdk/include/ndk/rtltypes.h
+++ b/sdk/include/ndk/rtltypes.h
@@ -1662,38 +1662,19 @@ typedef struct _RTL_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];
-    SYSTEMTIME StandardDate;
+    TIME_FIELDS StandardDate;
     LONG StandardBias;
     WCHAR DaylightName[32];
-    SYSTEMTIME DaylightDate;
+    TIME_FIELDS DaylightDate;
     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
diff --git a/sdk/include/reactos/wine/winternl.h 
b/sdk/include/reactos/wine/winternl.h
index 999f544edb..edd79e5a6f 100644
--- a/sdk/include/reactos/wine/winternl.h
+++ b/sdk/include/reactos/wine/winternl.h
@@ -102,6 +102,7 @@ typedef struct _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
@@ -120,14 +121,26 @@ typedef struct _RTL_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];
-    RTL_SYSTEM_TIME StandardDate;
+    TIME_FIELDS StandardDate;
     LONG StandardBias;
     WCHAR DaylightName[32];
-    RTL_SYSTEM_TIME DaylightDate;
+    TIME_FIELDS DaylightDate;
     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];
-    RTL_SYSTEM_TIME StandardDate;
+    TIME_FIELDS StandardDate;
     LONG StandardBias;
     WCHAR DaylightName[32];
-    RTL_SYSTEM_TIME DaylightDate;
+    TIME_FIELDS DaylightDate;
     LONG DaylightBias;
     WCHAR TimeZoneKeyName[128];
     BOOLEAN DynamicDaylightTimeDisabled;
@@ -1647,17 +1660,6 @@ typedef struct _SYSTEM_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;
diff --git a/win32ss/user/ntuser/kbdlayout.c b/win32ss/user/ntuser/kbdlayout.c
index cd57492d99..f47ece5cba 100644
--- a/win32ss/user/ntuser/kbdlayout.c
+++ b/win32ss/user/ntuser/kbdlayout.c
@@ -10,7 +10,10 @@
 
 #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);
 

Reply via email to