https://git.reactos.org/?p=reactos.git;a=commitdiff;h=912434849f7770f3fd4d66...
commit 912434849f7770f3fd4d6646ecc2846ff285f502 Author: Doug Lyons douglyons@douglyons.com AuthorDate: Tue Jan 16 16:40:03 2018 +0100 Commit: Thomas Faber thomas.faber@reactos.org CommitDate: Wed Jan 31 11:51:08 2018 +0100
[TIMEDATE] Correctly set the time when using the "Update now" button. CORE-14167 --- dll/cpl/timedate/dateandtime.c | 23 +++++++++++++++++------ dll/cpl/timedate/internettime.c | 3 ++- dll/cpl/timedate/ntpclient.c | 4 ++-- dll/cpl/timedate/timedate.h | 2 +- 4 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/dll/cpl/timedate/dateandtime.c b/dll/cpl/timedate/dateandtime.c index c51e175cc9..fbd1dc39f5 100644 --- a/dll/cpl/timedate/dateandtime.c +++ b/dll/cpl/timedate/dateandtime.c @@ -14,7 +14,8 @@ static WNDPROC pOldWndProc = NULL;
BOOL -SystemSetLocalTime(LPSYSTEMTIME lpSystemTime) +SystemSetTime(LPSYSTEMTIME lpSystemTime, + BOOL SystemTime) { HANDLE hToken; DWORD PrevSize; @@ -45,11 +46,20 @@ SystemSetLocalTime(LPSYSTEMTIME lpSystemTime) GetLastError() == ERROR_SUCCESS) { /* - * We successfully enabled it, we're permitted to change the system time - * Call SetLocalTime twice to ensure correct results + * We successfully enabled it, we're permitted to change the time. + * Check the second parameter for SystemTime and if TRUE set System Time. + * Otherwise, if FALSE set the Local Time. + * Call SetLocalTime twice to ensure correct results. */ - Ret = SetLocalTime(lpSystemTime) && - SetLocalTime(lpSystemTime); + if (SystemTime) + { + Ret = SetSystemTime(lpSystemTime); + } + else + { + Ret = SetLocalTime(lpSystemTime) && + SetLocalTime(lpSystemTime); + }
/* * For the sake of security, restore the previous status again @@ -86,7 +96,8 @@ SetLocalSystemTime(HWND hwnd) (WPARAM)&Time, 0)) { - SystemSetLocalTime(&Time); + /* Set Local Time with SystemTime = FALSE */ + SystemSetTime(&Time, FALSE);
SetWindowLongPtrW(hwnd, DWL_MSGRESULT, diff --git a/dll/cpl/timedate/internettime.c b/dll/cpl/timedate/internettime.c index 9f0b851451..35e724948a 100644 --- a/dll/cpl/timedate/internettime.c +++ b/dll/cpl/timedate/internettime.c @@ -258,7 +258,8 @@ UpdateSystemTime(ULONG ulTime) return; }
- if (!SystemSetLocalTime(&stNew)) + /* Use SystemSetTime with SystemTime = TRUE to set System Time */ + if (!SystemSetTime(&stNew, TRUE)) DisplayWin32Error(GetLastError()); }
diff --git a/dll/cpl/timedate/ntpclient.c b/dll/cpl/timedate/ntpclient.c index 7442b49150..fc378c624e 100644 --- a/dll/cpl/timedate/ntpclient.c +++ b/dll/cpl/timedate/ntpclient.c @@ -121,15 +121,15 @@ ReceiveData(PINFO pInfo)
if ((Ret != SOCKET_ERROR) && (Ret != 0)) { - Ret = recvfrom(pInfo->Sock, (char *)&pInfo->RecvPacket, sizeof(pInfo->RecvPacket), 0, NULL, NULL); + if (Ret != SOCKET_ERROR) - ulTime = ntohl(ulTime); + ulTime = ntohl(pInfo->RecvPacket.TransmitTimestamp.dwInteger); }
return ulTime; diff --git a/dll/cpl/timedate/timedate.h b/dll/cpl/timedate/timedate.h index cf9eac1eda..dfc54a18c3 100644 --- a/dll/cpl/timedate/timedate.h +++ b/dll/cpl/timedate/timedate.h @@ -39,7 +39,7 @@ extern HINSTANCE hApplet;
/* dateandtime.c */ INT_PTR CALLBACK DateTimePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); -BOOL SystemSetLocalTime(LPSYSTEMTIME lpSystemTime); +BOOL SystemSetTime(LPSYSTEMTIME lpSystemTime, BOOL SystemTime);
/* timezone.c */