[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...)
This commit is contained in:
Hermès Bélusca-Maïto 2023-09-03 16:44:12 +02:00
parent 4814dfea01
commit c66a1582ac
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
2 changed files with 17 additions and 7 deletions

View file

@ -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 */

View file

@ -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)