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

commit c66a1582aca1ca1ed98d142276b16bb4db71e0e2
Author:     Hermès Bélusca-Maïto <[email protected]>
AuthorDate: Sun Sep 3 16:44:12 2023 +0200
Commit:     Hermès Bélusca-Maïto <[email protected]>
CommitDate: Sun Sep 3 17:39:39 2023 +0200

    [NTOS:EX] Add some missing PoNotifySystemTimeSet() calls. Stub out 
NtSetSystemTime() with NULL parameter.
    
    - They notify, via the "\\Callback\\SetSystemTime" callback, components
      of a change of system time (for example, Win32k).
      Note, that our Win32k currently does not handle power callouts, so
      it isn't affected by these changes (yet).
    
    - NtSetSystemTime(NULL, ...) means "update system time using the current
      time-zone information", which is something we don't implement yet.
      (And, nothing was previously protecting this call from a NULL 
parameter...)
---
 ntoskrnl/ex/init.c |  7 +++----
 ntoskrnl/ex/time.c | 17 ++++++++++++++---
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/ntoskrnl/ex/init.c b/ntoskrnl/ex/init.c
index 2953a442e35..517661dfd4c 100644
--- a/ntoskrnl/ex/init.c
+++ b/ntoskrnl/ex/init.c
@@ -1549,10 +1549,8 @@ Phase1InitializationDiscard(IN PVOID Context)
                                          ExpTimeZoneBias.QuadPart;
         }
 
-        /* Update the system time */
+        /* Update the system time and notify the system */
         KeSetSystemTime(&UniversalBootTime, &OldTime, FALSE, NULL);
-
-        /* Do system callback */
         PoNotifySystemTimeSet();
 
         /* Remember this as the boot time */
@@ -1681,7 +1679,8 @@ Phase1InitializationDiscard(IN PVOID Context)
     else
     {
         /* Check if the timezone switched and update the time */
-        if (LastTzBias != ExpLastTimeZoneBias) ZwSetSystemTime(NULL, NULL);
+        if (LastTzBias != ExpLastTimeZoneBias)
+            ZwSetSystemTime(NULL, NULL);
     }
 
     /* Initialize the File System Runtime Library */
diff --git a/ntoskrnl/ex/time.c b/ntoskrnl/ex/time.c
index ad971773a8d..a2de0591178 100644
--- a/ntoskrnl/ex/time.c
+++ b/ntoskrnl/ex/time.c
@@ -372,8 +372,9 @@ ExpSetTimeZoneInformation(PRTL_TIME_ZONE_INFORMATION 
TimeZoneInformation)
     /* Calculate the new system time */
     ExLocalTimeToSystemTime(&LocalTime, &SystemTime);
 
-    /* Set the new system time */
+    /* Set the new system time and notify the system */
     KeSetSystemTime(&SystemTime, &OldTime, FALSE, NULL);
+    PoNotifySystemTimeSet();
 
     /* Return success */
     DPRINT("ExpSetTimeZoneInformation() done\n");
@@ -400,8 +401,17 @@ NtSetSystemTime(IN PLARGE_INTEGER SystemTime,
     TIME_FIELDS TimeFields;
     KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
     NTSTATUS Status = STATUS_SUCCESS;
+
     PAGED_CODE();
 
+    // TODO: Handle the case when SystemTime == NULL, which means:
+    // "update system time using the current time-zone information".
+    if (!SystemTime)
+    {
+        UNIMPLEMENTED;
+        return STATUS_NOT_IMPLEMENTED;
+    }
+
     /* Check if we were called from user-mode */
     if (PreviousMode != KernelMode)
     {
@@ -409,7 +419,7 @@ NtSetSystemTime(IN PLARGE_INTEGER SystemTime,
         {
             /* Verify the time pointers */
             NewSystemTime = ProbeForReadLargeInteger(SystemTime);
-            if(PreviousTime) ProbeForWriteLargeInteger(PreviousTime);
+            if (PreviousTime) ProbeForWriteLargeInteger(PreviousTime);
         }
         _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
         {
@@ -437,8 +447,9 @@ NtSetSystemTime(IN PLARGE_INTEGER SystemTime,
     RtlTimeToTimeFields(&LocalTime, &TimeFields);
     HalSetRealTimeClock(&TimeFields);
 
-    /* Now set system time */
+    /* Now set the system time and notify the system */
     KeSetSystemTime(&NewSystemTime, &OldSystemTime, FALSE, NULL);
+    PoNotifySystemTimeSet();
 
     /* Check if caller wanted previous time */
     if (PreviousTime)

Reply via email to