From: Bruno Jesus <00cpxxx@gmail.com> Subject: [PATCH] ntdll: Fake success if changing system date is a no-op Message-Id: <20170122171425.5868-1-00cpxxx@gmail.com> Date: Sun, 22 Jan 2017 15:14:25 -0200 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@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