[PATCH] ntdll: Fake success if changing system date is a no-op

Bruno Jesus 00cpxxx at gmail.com
Sun Jan 22 11:14:25 CST 2017


Will solve time changing problems in programs where the computer is already in sync.

Related to https://bugs.winehq.org/show_bug.cgi?id=42274

Signed-off-by: Bruno Jesus <00cpxxx at gmail.com>
---
 dlls/ntdll/time.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/dlls/ntdll/time.c b/dlls/ntdll/time.c
index 96ffcfa..d232c4c 100644
--- a/dlls/ntdll/time.c
+++ b/dlls/ntdll/time.c
@@ -951,14 +951,21 @@ NTSTATUS WINAPI NtSetSystemTime(const LARGE_INTEGER *NewTime, LARGE_INTEGER *Old
 
     RtlTimeToSecondsSince1970( NewTime, &sec );
 
+    /* fake success if time didn't change */
+    if (oldsec == sec)
+        return STATUS_SUCCESS;
+
     /* set the new time */
     tv.tv_sec = sec;
     tv.tv_usec = 0;
 
 #ifdef HAVE_SETTIMEOFDAY
+    tm_t = sec;
     if (!settimeofday(&tv, NULL)) /* 0 is OK, -1 is error */
+    {
+        TRACE("OS time changed to %s\n", ctime(&tm_t));
         return STATUS_SUCCESS;
-    tm_t = sec;
+    }
     ERR("Cannot set time to %s, time adjustment %ld: %s\n",
         ctime(&tm_t), (long)(sec-oldsec), strerror(errno));
     if (errno == EPERM)
-- 
2.9.3




More information about the wine-patches mailing list