ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
July 2019
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
22 participants
146 discussions
Start a n
N
ew thread
[reactos] 01/01: [CMAKE] Disable INIT section ld scripts for now. CORE-16183 ROSBE-154
by Thomas Faber
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=36e9a6f8ddc70018b55b0…
commit 36e9a6f8ddc70018b55b0cad0b13128b1cbb60c2 Author: Thomas Faber <thomas.faber(a)reactos.org> AuthorDate: Sun Jul 7 16:06:25 2019 +0200 Commit: Thomas Faber <thomas.faber(a)reactos.org> CommitDate: Sun Jul 7 16:06:43 2019 +0200 [CMAKE] Disable INIT section ld scripts for now. CORE-16183 ROSBE-154 --- ntoskrnl/CMakeLists.txt | 3 ++- sdk/cmake/gcc.cmake | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ntoskrnl/CMakeLists.txt b/ntoskrnl/CMakeLists.txt index 5f2ac879316..7f301afef9b 100644 --- a/ntoskrnl/CMakeLists.txt +++ b/ntoskrnl/CMakeLists.txt @@ -38,7 +38,8 @@ else() else() set_image_base(ntoskrnl 0x80800000) endif() - add_linker_script(ntoskrnl ${REACTOS_SOURCE_DIR}/sdk/cmake/init-section.lds) + #Disabled due to LD bug: ROSBE-154 + #add_linker_script(ntoskrnl ${REACTOS_SOURCE_DIR}/sdk/cmake/init-section.lds) endif() target_link_libraries(ntoskrnl cportlib csq ${PSEH_LIB} cmlib ntlsalib rtl ${ROSSYM_LIB} libcntpr wdmguid ioevent) diff --git a/sdk/cmake/gcc.cmake b/sdk/cmake/gcc.cmake index c4c741ff6a6..c92403538c2 100644 --- a/sdk/cmake/gcc.cmake +++ b/sdk/cmake/gcc.cmake @@ -318,7 +318,8 @@ function(set_module_type_toolchain MODULE TYPE) if(${TYPE} STREQUAL "wdmdriver") add_target_link_flags(${MODULE} "-Wl,--wdmdriver") endif() - add_linker_script(${MODULE} ${REACTOS_SOURCE_DIR}/sdk/cmake/init-section.lds) + #Disabled due to LD bug: ROSBE-154 + #add_linker_script(${MODULE} ${REACTOS_SOURCE_DIR}/sdk/cmake/init-section.lds) endif() if(STACK_PROTECTOR)
5 years, 5 months
1
0
0
0
[reactos] 01/01: [SHELL32] Enable the "Apply" button when user takes action on the edit box control (#1720)
by Bișoc George
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=818d6608689cb2257b92b…
commit 818d6608689cb2257b92bc674638beb33a14a70d Author: Bișoc George <fraizeraust99(a)gmail.com> AuthorDate: Sun Jul 7 14:47:44 2019 +0200 Commit: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito(a)reactos.org> CommitDate: Sun Jul 7 14:47:44 2019 +0200 [SHELL32] Enable the "Apply" button when user takes action on the edit box control (#1720) CORE-12312 --- dll/win32/shell32/dialogs/recycler_prop.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dll/win32/shell32/dialogs/recycler_prop.cpp b/dll/win32/shell32/dialogs/recycler_prop.cpp index d249e05f396..95840be7699 100644 --- a/dll/win32/shell32/dialogs/recycler_prop.cpp +++ b/dll/win32/shell32/dialogs/recycler_prop.cpp @@ -304,6 +304,10 @@ RecycleBinDlg( toggleNukeOnDeleteOption(hwndDlg, FALSE); PropSheet_Changed(GetParent(hwndDlg), hwndDlg); break; + case 14002: + if (HIWORD(wParam) == EN_CHANGE) + PropSheet_Changed(GetParent(hwndDlg), hwndDlg); + break; case 14003: toggleNukeOnDeleteOption(hwndDlg, TRUE); PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
5 years, 5 months
1
0
0
0
[reactos] 01/01: [SETUPAPI][UMPNPMGR] The 3rd parameter of PNP_RegisterNotification() seems to be the service name
by Eric Kohl
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ece54dcd2f4424d516040…
commit ece54dcd2f4424d516040d6802320c413d57b0c6 Author: Eric Kohl <eric.kohl(a)reactos.org> AuthorDate: Sun Jul 7 13:41:00 2019 +0200 Commit: Eric Kohl <eric.kohl(a)reactos.org> CommitDate: Sun Jul 7 13:41:00 2019 +0200 [SETUPAPI][UMPNPMGR] The 3rd parameter of PNP_RegisterNotification() seems to be the service name --- base/services/umpnpmgr/rpcserver.c | 6 +++--- dll/win32/setupapi/cfgmgr.c | 38 ++++++++++++++++++++++++++++++-------- sdk/include/reactos/idl/pnp.idl | 2 +- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/base/services/umpnpmgr/rpcserver.c b/base/services/umpnpmgr/rpcserver.c index b76e250fc6b..63148af8623 100644 --- a/base/services/umpnpmgr/rpcserver.c +++ b/base/services/umpnpmgr/rpcserver.c @@ -3531,7 +3531,7 @@ WINAPI PNP_RegisterNotification( handle_t hBinding, DWORD ulUnknown2, - DWORD ulUnknown3, + LPWSTR pszName, BYTE *pNotificationFilter, DWORD ulNotificationFilterSize, DWORD ulFlags, @@ -3545,8 +3545,8 @@ PNP_RegisterNotification( PNOTIFY_DATA pNotifyData; #endif - DPRINT1("PNP_RegisterNotification(%p %lx %lx %p %lu 0x%lx %p %lx %p)\n", - hBinding, ulUnknown2, ulUnknown3, pNotificationFilter, + DPRINT1("PNP_RegisterNotification(%p %lx '%S' %p %lu 0x%lx %p %lx %p)\n", + hBinding, ulUnknown2, pszName, pNotificationFilter, ulNotificationFilterSize, ulFlags, pulNotify, ulUnknown8, pulUnknown9); if (pNotificationFilter == NULL || diff --git a/dll/win32/setupapi/cfgmgr.c b/dll/win32/setupapi/cfgmgr.c index b5823a99f64..0624ed8f5c8 100644 --- a/dll/win32/setupapi/cfgmgr.c +++ b/dll/win32/setupapi/cfgmgr.c @@ -23,9 +23,17 @@ #include <dbt.h> #include <pnp_c.h> +#include <winsvc.h> #include "rpc_private.h" +DWORD +WINAPI +I_ScPnPGetServiceName(IN SERVICE_STATUS_HANDLE hServiceStatus, + OUT LPWSTR lpServiceName, + IN DWORD cchServiceName); + + /* Registry key and value names */ static const WCHAR Backslash[] = {'\\', 0}; static const WCHAR Class[] = {'C','l','a','s','s',0}; @@ -593,6 +601,8 @@ CMP_RegisterNotification( { RPC_BINDING_HANDLE BindingHandle = NULL; PNOTIFY_DATA pNotifyData = NULL; + WCHAR szNameBuffer[256]; + DWORD dwError; DWORD ulUnknown9 = 0; CONFIGRET ret = CR_SUCCESS; @@ -621,28 +631,40 @@ CMP_RegisterNotification( pNotifyData->ulMagic = NOTIFY_MAGIC; -/* - if (dwFlags & DEVICE_NOTIFY_SERVICE_HANDLE == DEVICE_NOTYFY_WINDOW_HANDLE) + if ((ulFlags & DEVICE_NOTIFY_SERVICE_HANDLE) == DEVICE_NOTIFY_WINDOW_HANDLE) { + FIXME("Register a window\n"); + /* FIXME */ + szNameBuffer[0] = UNICODE_NULL; } - else if (dwFlags & DEVICE_NOTIFY_SERVICE_HANDLE == DEVICE_NOTYFY_SERVICE_HANDLE) + else if ((ulFlags & DEVICE_NOTIFY_SERVICE_HANDLE) == DEVICE_NOTIFY_SERVICE_HANDLE) { + FIXME("Register a service\n"); + + dwError = I_ScPnPGetServiceName((SERVICE_STATUS_HANDLE)hRecipient, + szNameBuffer, + ARRAYSIZE(szNameBuffer)); + if (dwError != ERROR_SUCCESS) + { + HeapFree(GetProcessHeap(), 0, pNotifyData); + return CR_INVALID_DATA; + } + FIXME("Register service: %S\n", szNameBuffer); } -*/ RpcTryExcept { ret = PNP_RegisterNotification(BindingHandle, - 0, - 0, + 0, /* ??? */ + szNameBuffer, (BYTE*)lpvNotificationFilter, ((DEV_BROADCAST_HDR*)lpvNotificationFilter)->dbch_size, ulFlags, &pNotifyData->ulNotifyData, - 0, - &ulUnknown9); + 0, /* ??? */ + &ulUnknown9); /* ??? */ } RpcExcept(EXCEPTION_EXECUTE_HANDLER) { diff --git a/sdk/include/reactos/idl/pnp.idl b/sdk/include/reactos/idl/pnp.idl index 13983a4e18d..6856c4e5ac0 100644 --- a/sdk/include/reactos/idl/pnp.idl +++ b/sdk/include/reactos/idl/pnp.idl @@ -876,7 +876,7 @@ interface pnp PNP_RegisterNotification( [in] handle_t hBinding, [in] DWORD ulUnknown2, - [in] DWORD ulUnknown3, + [in, string, ref] LPWSTR pszName, [in, size_is(ulNotificationFilterSize)] BYTE *pNotificationFilter, [in] DWORD ulNotificationFilterSize, [in] DWORD ulFlags,
5 years, 5 months
1
0
0
0
[reactos] 07/07: [W32TIME] Implement w32time service. CORE-13001
by Doug Lyons
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e4898e6e0bd9517233c25…
commit e4898e6e0bd9517233c25f8f862e5a0ae9dce2f1 Author: Doug Lyons <douglyons(a)douglyons.com> AuthorDate: Sun Jul 7 10:59:11 2019 +0200 Commit: Thomas Faber <thomas.faber(a)reactos.org> CommitDate: Sun Jul 7 12:55:13 2019 +0200 [W32TIME] Implement w32time service. CORE-13001 --- base/services/w32time/ntpclient.c | 6 +- base/services/w32time/w32time.c | 312 ++++++++++++++++++++++++------------- base/services/w32time/w32time.h | 2 + base/services/w32time/w32time.spec | 1 + boot/bootdata/hivesft.inf | 3 +- boot/bootdata/hivesys.inf | 16 ++ 6 files changed, 230 insertions(+), 110 deletions(-) diff --git a/base/services/w32time/ntpclient.c b/base/services/w32time/ntpclient.c index 8ba5910fe13..072772ec955 100644 --- a/base/services/w32time/ntpclient.c +++ b/base/services/w32time/ntpclient.c @@ -1,10 +1,8 @@ /* * PROJECT: ReactOS Timedate Control Panel - * LICENSE: GPL - See COPYING in the top level directory - * FILE: dll/cpl/timedate/ntpclient.c + * LICENSE: GPL-2.0+ (
https://spdx.org/licenses/GPL-2.0+
) * PURPOSE: Queries the NTP server * COPYRIGHT: Copyright 2006 Ged Murphy <gedmurphy(a)gmail.com> - * */ #include "w32time.h" @@ -81,7 +79,7 @@ SendData(PINFO pInfo) INT Ret; ZeroMemory(&pInfo->SendPacket, sizeof(pInfo->SendPacket)); - pInfo->SendPacket.LiVnMode = 27; + pInfo->SendPacket.LiVnMode = 0x1b; /* 0x1b = 011 011 - version 3 , mode 3 (client) */ if (!GetTransmitTime(&tp)) return FALSE; pInfo->SendPacket.TransmitTimestamp = tp; diff --git a/base/services/w32time/w32time.c b/base/services/w32time/w32time.c index 675bb907d69..c32624f8b9a 100644 --- a/base/services/w32time/w32time.c +++ b/base/services/w32time/w32time.c @@ -1,107 +1,20 @@ /* - * PROJECT: ReactOS Timedate Control Panel + * PROJECT: ReactOS W32Time Service * LICENSE: GPL-2.0+ (
https://spdx.org/licenses/GPL-2.0+
) * PURPOSE: Create W32Time Service that reqularly syncs clock to Internet Time * COPYRIGHT: Copyright 2006 Ged Murphy <gedmurphy(a)gmail.com> + * Copyright 2018 Doug Lyons */ #include "w32time.h" +#include <debug.h> +#include <strsafe.h> -/* Get the domain name from the registry */ -static DWORD -GetNTPServerAddress(LPWSTR *lpAddress) -{ - HKEY hKey; - WCHAR szSel[4]; - DWORD dwSize; - LONG lRet; - - *lpAddress = NULL; - hKey = NULL; - - lRet = RegOpenKeyExW(HKEY_LOCAL_MACHINE, - L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\DateTime\\Servers", - 0, - KEY_QUERY_VALUE, - &hKey); - if (lRet != ERROR_SUCCESS) - goto Exit; - - /* Get data from default value */ - dwSize = 4 * sizeof(WCHAR); - lRet = RegQueryValueExW(hKey, - NULL, - NULL, - NULL, - (LPBYTE)szSel, - &dwSize); - if (lRet != ERROR_SUCCESS) - goto Exit; - - dwSize = 0; - lRet = RegQueryValueExW(hKey, - szSel, - NULL, - NULL, - NULL, - &dwSize); - if (lRet != ERROR_SUCCESS) - goto Exit; - - (*lpAddress) = (LPWSTR)HeapAlloc(GetProcessHeap(), - 0, - dwSize); - if ((*lpAddress) == NULL) - { - lRet = ERROR_NOT_ENOUGH_MEMORY; - goto Exit; - } - - lRet = RegQueryValueExW(hKey, - szSel, - NULL, - NULL, - (LPBYTE)*lpAddress, - &dwSize); - if (lRet != ERROR_SUCCESS) - goto Exit; - -Exit: - if (hKey) - RegCloseKey(hKey); - if (lRet != ERROR_SUCCESS) - HeapFree(GetProcessHeap(), 0, *lpAddress); - - return lRet; -} - - -/* Request the time from the current NTP server */ -static DWORD -GetTimeFromServer(PULONG pulTime) -{ - LPWSTR lpAddress; - DWORD dwError; - - dwError = GetNTPServerAddress(&lpAddress); - if (dwError != ERROR_SUCCESS) - { - return dwError; - } - - *pulTime = GetServerTime(lpAddress); - if (*pulTime == 0) - { - dwError = ERROR_GEN_FAILURE; - } - - HeapFree(GetProcessHeap(), - 0, - lpAddress); - - return dwError; -} +SERVICE_STATUS ServiceStatus; +SERVICE_STATUS_HANDLE hStatus; +static WCHAR ServiceName[] = L"W32Time"; +int InitService(VOID); BOOL SystemSetTime(LPSYSTEMTIME lpSystemTime) @@ -207,25 +120,214 @@ UpdateSystemTime(ULONG ulTime) } -DWORD WINAPI -W32TimeSyncNow(LPCWSTR cmdline, - UINT blocking, - UINT flags) +static DWORD +GetIntervalSetting(VOID) +{ + HKEY hKey; + DWORD dwData; + DWORD dwSize = sizeof(dwData); + LONG lRet; + + dwData = 0; + if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, + L"SYSTEM\\CurrentControlSet\\Services\\W32Time\\TimeProviders\\NtpClient", + 0, + KEY_QUERY_VALUE, + &hKey) == ERROR_SUCCESS) + { + /* This key holds the update interval in seconds + * It is useful for testing to set it to a value of 10 (Decimal) + * This will cause the clock to try and update every 10 seconds + * So you can change the time and expect it to be set back correctly in 10-20 seconds + */ + lRet = RegQueryValueExW(hKey, + L"SpecialPollInterval", + NULL, + NULL, + (LPBYTE)&dwData, + &dwSize); + RegCloseKey(hKey); + } + + if (lRet != ERROR_SUCCESS) + return 0; + else + return dwData; +} + + +DWORD +SetTime(VOID) { - DWORD dwError; ULONG ulTime; + LONG lRet; + HKEY hKey; + WCHAR szData[MAX_VALUE_NAME] = L""; + DWORD cbName = sizeof(szData); + + DPRINT("Entered SetTime.\n"); - dwError = GetTimeFromServer(&ulTime); - if (dwError != ERROR_SUCCESS) + lRet = RegOpenKeyExW(HKEY_LOCAL_MACHINE, + L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\DateTime\\Servers", + 0, + KEY_QUERY_VALUE, + &hKey); + if (lRet != ERROR_SUCCESS) + { + return lRet; + } + + lRet = RegQueryValueExW(hKey, NULL, NULL, NULL, (LPBYTE)szData, &cbName); + if (lRet == ERROR_SUCCESS) { - return dwError; + cbName = sizeof(szData); + lRet = RegQueryValueExW(hKey, szData, NULL, NULL, (LPBYTE)szData, &cbName); } + RegCloseKey(hKey); + + DPRINT("Time Server is '%S'.\n", szData); + + ulTime = GetServerTime(szData); + if (ulTime != 0) { - dwError = UpdateSystemTime(ulTime); + return UpdateSystemTime(ulTime); } + else + return ERROR_GEN_FAILURE; +} - return dwError; + +/* Control handler function */ +VOID WINAPI +ControlHandler(DWORD request) +{ + switch (request) + { + case SERVICE_CONTROL_STOP: + DPRINT("W32Time Service stopped.\n"); + + ServiceStatus.dwWin32ExitCode = 0; + ServiceStatus.dwCurrentState = SERVICE_STOPPED; + SetServiceStatus(hStatus, &ServiceStatus); + return; + + case SERVICE_CONTROL_SHUTDOWN: + DPRINT("W32Time Service stopped.\n"); + + ServiceStatus.dwWin32ExitCode = 0; + ServiceStatus.dwCurrentState = SERVICE_STOPPED; + SetServiceStatus(hStatus, &ServiceStatus); + return; + + default: + break; + } + + /* Report current status */ + SetServiceStatus(hStatus, &ServiceStatus); + + return; } + +VOID +WINAPI +ServiceMain(DWORD argc, LPWSTR *argv) +{ + int result; + DWORD dwPollInterval; + + UNREFERENCED_PARAMETER(argc); + UNREFERENCED_PARAMETER(argv); + + ServiceStatus.dwServiceType = SERVICE_WIN32; + ServiceStatus.dwCurrentState = SERVICE_START_PENDING; + ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN; + ServiceStatus.dwWin32ExitCode = 0; + ServiceStatus.dwServiceSpecificExitCode = 0; + ServiceStatus.dwCheckPoint = 0; + ServiceStatus.dwWaitHint = 0; + + hStatus = RegisterServiceCtrlHandlerW(ServiceName, + ControlHandler); + if (!hStatus) + { + /* Registering Control Handler failed */ + return; + } + + /* We report the running status to SCM. */ + ServiceStatus.dwCurrentState = SERVICE_RUNNING; + SetServiceStatus(hStatus, &ServiceStatus); + + /* The worker loop of a service */ + while (ServiceStatus.dwCurrentState == SERVICE_RUNNING) + { + dwPollInterval = GetIntervalSetting(); + result = SetTime(); + + if (result) + DPRINT("W32Time Service failed to set clock.\n"); + else + DPRINT("W32Time Service successfully set clock.\n"); + + if (result) + { + /* In general we do not want to stop this service for a single + * Internet read failure but there may be other reasons for which + * we really might want to stop it. + * Therefore this code is left here to make it easy to stop this + * service when the correct conditions can be determined, but it + * is left commented out. + ServiceStatus.dwCurrentState = SERVICE_STOPPED; + ServiceStatus.dwWin32ExitCode = -1; + SetServiceStatus(hStatus, &ServiceStatus); + return; + */ + } + + Sleep(dwPollInterval * 1000); + } + return; +} + + + +BOOL WINAPI +DllMain(HINSTANCE hinstDLL, + DWORD fdwReason, + LPVOID lpvReserved) +{ + switch (fdwReason) + { + case DLL_PROCESS_ATTACH: + DisableThreadLibraryCalls(hinstDLL); + break; + + case DLL_PROCESS_DETACH: + break; + } + + return TRUE; +} + + +DWORD WINAPI +W32TimeSyncNow(LPCWSTR cmdline, + UINT blocking, + UINT flags) +{ + DWORD result; + result = SetTime(); + if (result) + { + DPRINT("W32TimeSyncNow failed and clock not set.\n"); + } + else + { + DPRINT("W32TimeSyncNow succeeded and clock set.\n"); + } + return result; +} diff --git a/base/services/w32time/w32time.h b/base/services/w32time/w32time.h index bd65de402c3..87be3d09d68 100644 --- a/base/services/w32time/w32time.h +++ b/base/services/w32time/w32time.h @@ -11,7 +11,9 @@ #include <winbase.h> #include <winnls.h> #include <winreg.h> +#include <winsvc.h> +#define MAX_VALUE_NAME 16383 #define NTPPORT 123 diff --git a/base/services/w32time/w32time.spec b/base/services/w32time/w32time.spec index 12b8db5bc1e..b4893ff346f 100644 --- a/base/services/w32time/w32time.spec +++ b/base/services/w32time/w32time.spec @@ -1 +1,2 @@ 18 stdcall W32TimeSyncNow(wstr long long) +21 stdcall ServiceMain(long ptr) diff --git a/boot/bootdata/hivesft.inf b/boot/bootdata/hivesft.inf index 4387338e3f0..330101a29db 100644 --- a/boot/bootdata/hivesft.inf +++ b/boot/bootdata/hivesft.inf @@ -1520,6 +1520,7 @@ HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Notify\wlballoon","L HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Notify\wlballoon","Logon",0x00000000,"RegisterTicketExpiredNotificationEvent" ; Time Zone Servers +HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\DateTime\Servers",,0x00000000,"1" HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\DateTime\Servers","1",0x00000000,"
pool.ntp.org
" HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\DateTime\Servers","2",0x00000000,"
asia.pool.ntp.org
" HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\DateTime\Servers","3",0x00000000,"
europe.pool.ntp.org
" @@ -1780,7 +1781,7 @@ HKLM,"SOFTWARE\Microsoft\Ole","EnableRemoteConnect",0x00000000,"N" ; SvcHost services HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\SvcHost",,0x00000012 HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\SvcHost","DcomLaunch",0x00010000,"DcomLaunch","PlugPlay" -HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\SvcHost","netsvcs",0x00010000,"DHCP","BITS","lanmanserver","lanmanworkstation","Schedule","Themes","winmgmt" +HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\SvcHost","netsvcs",0x00010000,"DHCP","BITS","lanmanserver","lanmanworkstation","Schedule","Themes","winmgmt","W32Time" ; Win32 config HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows",,0x00000012 diff --git a/boot/bootdata/hivesys.inf b/boot/bootdata/hivesys.inf index 0f2fc9369eb..8f65a0ac783 100644 --- a/boot/bootdata/hivesys.inf +++ b/boot/bootdata/hivesys.inf @@ -2002,6 +2002,19 @@ HKLM,"SYSTEM\CurrentControlSet\Services\WlanSvc","ObjectName",0x00000000,"LocalS HKLM,"SYSTEM\CurrentControlSet\Services\WlanSvc","Start",0x00010001,0x00000002 HKLM,"SYSTEM\CurrentControlSet\Services\WlanSvc","Type",0x00010001,0x00000110 +; W32TIME service +HKLM,"SYSTEM\CurrentControlSet\Services\W32Time","DisplayName",0x00000000,%W32TIME_SERVICE% +HKLM,"SYSTEM\CurrentControlSet\Services\W32Time","Description",0x00000000,%W32TIME_SERVICE_DESCRIPTION% +HKLM,"SYSTEM\CurrentControlSet\Services\W32Time","ErrorControl",0x00010001,0x00000001 +HKLM,"SYSTEM\CurrentControlSet\Services\W32Time","Group",0x00000000,"Time" +HKLM,"SYSTEM\CurrentControlSet\Services\W32Time","ImagePath",0x00020000,"%SystemRoot%\system32\svchost.exe -k netsvcs" +HKLM,"SYSTEM\CurrentControlSet\Services\W32Time","ObjectName",0x00000000,"LocalSystem" +HKLM,"SYSTEM\CurrentControlSet\Services\W32Time","Start",0x00010001,0x00000002 +HKLM,"SYSTEM\CurrentControlSet\Services\W32Time","Type",0x00010001,0x00000020 +HKLM,"SYSTEM\CurrentControlSet\Services\W32Time\Parameters","ServiceDll",0x00020000,"%SystemRoot%\system32\w32time.dll" +HKLM,"SYSTEM\CurrentControlSet\Services\W32Time\Parameters","Type",0x00010000,"NTP" +HKLM,"SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient","SpecialPollInterval",0x00010001,0x00093a80 + ; Simple TCP services HKLM,"SYSTEM\CurrentControlSet\Services\tcpsvcs","Description",0x00000000,%TCPSVCS_SERVICE_DECRIPTION% HKLM,"SYSTEM\CurrentControlSet\Services\tcpsvcs","DisplayName",0x00000000,%TCPSVCS_SERVICE% @@ -2245,6 +2258,9 @@ WUAUSERV_SERVICE_DESCRIPTION="AutoUpdate Service stub." WLANSVC_SERVICE="WLAN Service" WLANSVC_SERVICE_DESCRIPTION="WLAN Service" +W32TIME_SERVICE="Time Service" +W32TIME_SERVICE_DESCRIPTION="ReactOS Time Service" + WORKSTATION_SERVICE="Workstation" WORKSTATION_SERVICE_DESCRIPTION="Responsible for creating and maintaining network connections to servers."
5 years, 5 months
1
0
0
0
[reactos] 06/07: [TIMEDATE] Allow editing the time server combo box. CORE-13001
by Doug Lyons
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=119c99ef7eb7dbb23cf17…
commit 119c99ef7eb7dbb23cf1731de8c79be81d122138 Author: Doug Lyons <douglyons(a)douglyons.com> AuthorDate: Sat Feb 10 15:43:21 2018 -0600 Commit: Thomas Faber <thomas.faber(a)reactos.org> CommitDate: Sun Jul 7 12:45:45 2019 +0200 [TIMEDATE] Allow editing the time server combo box. CORE-13001 --- dll/cpl/timedate/lang/bg-BG.rc | 2 +- dll/cpl/timedate/lang/cs-CZ.rc | 2 +- dll/cpl/timedate/lang/da-DK.rc | 2 +- dll/cpl/timedate/lang/de-DE.rc | 2 +- dll/cpl/timedate/lang/el-GR.rc | 2 +- dll/cpl/timedate/lang/en-US.rc | 2 +- dll/cpl/timedate/lang/es-ES.rc | 2 +- dll/cpl/timedate/lang/et-EE.rc | 2 +- dll/cpl/timedate/lang/eu-ES.rc | 2 +- dll/cpl/timedate/lang/fr-FR.rc | 2 +- dll/cpl/timedate/lang/he-IL.rc | 2 +- dll/cpl/timedate/lang/hu-HU.rc | 2 +- dll/cpl/timedate/lang/id-ID.rc | 2 +- dll/cpl/timedate/lang/it-IT.rc | 2 +- dll/cpl/timedate/lang/ja-JP.rc | 2 +- dll/cpl/timedate/lang/nl-NL.rc | 2 +- dll/cpl/timedate/lang/no-NO.rc | 2 +- dll/cpl/timedate/lang/pl-PL.rc | 2 +- dll/cpl/timedate/lang/pt-BR.rc | 2 +- dll/cpl/timedate/lang/ro-RO.rc | 2 +- dll/cpl/timedate/lang/ru-RU.rc | 2 +- dll/cpl/timedate/lang/sk-SK.rc | 2 +- dll/cpl/timedate/lang/sq-AL.rc | 2 +- dll/cpl/timedate/lang/sv-SE.rc | 2 +- dll/cpl/timedate/lang/th-TH.rc | 2 +- dll/cpl/timedate/lang/tr-TR.rc | 2 +- dll/cpl/timedate/lang/uk-UA.rc | 2 +- dll/cpl/timedate/lang/zh-CN.rc | 2 +- dll/cpl/timedate/lang/zh-TW.rc | 2 +- 29 files changed, 29 insertions(+), 29 deletions(-) diff --git a/dll/cpl/timedate/lang/bg-BG.rc b/dll/cpl/timedate/lang/bg-BG.rc index 9665e78fb1a..2ae40c9ed15 100644 --- a/dll/cpl/timedate/lang/bg-BG.rc +++ b/dll/cpl/timedate/lang/bg-BG.rc @@ -33,7 +33,7 @@ STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "Сверяване от интернет" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP AUTOCHECKBOX "Самосверяване през интернет от сървър за времето", IDC_AUTOSYNC, 11, 7, 241, 10, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP LTEXT "Сървър:", IDC_SERVERTEXT, 34, 22, 28, 13 diff --git a/dll/cpl/timedate/lang/cs-CZ.rc b/dll/cpl/timedate/lang/cs-CZ.rc index eb347436365..f4470649051 100644 --- a/dll/cpl/timedate/lang/cs-CZ.rc +++ b/dll/cpl/timedate/lang/cs-CZ.rc @@ -33,7 +33,7 @@ STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "Čas v Internetu" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP AUTOCHECKBOX "Automaticky synchronizovat čas s časovým serverem v Internetu", IDC_AUTOSYNC, 11, 7, 241, 10, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP LTEXT "Server:", IDC_SERVERTEXT, 34, 22, 28, 13 diff --git a/dll/cpl/timedate/lang/da-DK.rc b/dll/cpl/timedate/lang/da-DK.rc index 1889f893c34..59c0d5472bc 100644 --- a/dll/cpl/timedate/lang/da-DK.rc +++ b/dll/cpl/timedate/lang/da-DK.rc @@ -33,7 +33,7 @@ STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "Internet Time" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP AUTOCHECKBOX "Automatically synchronize with an Internet time server", IDC_AUTOSYNC, 11, 7, 241, 10, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP LTEXT "Server:", IDC_SERVERTEXT, 34, 22, 28, 13 diff --git a/dll/cpl/timedate/lang/de-DE.rc b/dll/cpl/timedate/lang/de-DE.rc index 5acea136c48..7afc80ecfcc 100644 --- a/dll/cpl/timedate/lang/de-DE.rc +++ b/dll/cpl/timedate/lang/de-DE.rc @@ -33,7 +33,7 @@ STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "Internetzeit" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP AUTOCHECKBOX "Automatisch mit einem Internetzeitserver synchronisieren", IDC_AUTOSYNC, 11, 7, 241, 10, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP LTEXT "Server:", IDC_SERVERTEXT, 34, 22, 28, 13 diff --git a/dll/cpl/timedate/lang/el-GR.rc b/dll/cpl/timedate/lang/el-GR.rc index 0267525fe8c..abc8550b662 100644 --- a/dll/cpl/timedate/lang/el-GR.rc +++ b/dll/cpl/timedate/lang/el-GR.rc @@ -33,7 +33,7 @@ STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "Internet Time" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP AUTOCHECKBOX "Automatically synchronize with an Internet time server", IDC_AUTOSYNC, 11, 7, 241, 10, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP LTEXT "Server:", IDC_SERVERTEXT, 34, 22, 28, 13 diff --git a/dll/cpl/timedate/lang/en-US.rc b/dll/cpl/timedate/lang/en-US.rc index 407bebcc329..59e83fee61b 100644 --- a/dll/cpl/timedate/lang/en-US.rc +++ b/dll/cpl/timedate/lang/en-US.rc @@ -33,7 +33,7 @@ STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "Internet Time" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP AUTOCHECKBOX "Automatically &synchronize with an Internet time server", IDC_AUTOSYNC, 11, 7, 241, 10, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP LTEXT "Server:", IDC_SERVERTEXT, 34, 22, 28, 13 diff --git a/dll/cpl/timedate/lang/es-ES.rc b/dll/cpl/timedate/lang/es-ES.rc index f423ef791c6..bd5a908058d 100644 --- a/dll/cpl/timedate/lang/es-ES.rc +++ b/dll/cpl/timedate/lang/es-ES.rc @@ -33,7 +33,7 @@ STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "Hora de Internet" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP AUTOCHECKBOX "Sincronizar automáticamente con un servidor horario de Internet", IDC_AUTOSYNC, 11, 7, 241, 10, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP LTEXT "Servidor:", IDC_SERVERTEXT, 34, 22, 28, 13 diff --git a/dll/cpl/timedate/lang/et-EE.rc b/dll/cpl/timedate/lang/et-EE.rc index 16b4eef5b4d..b1c465cb1cc 100644 --- a/dll/cpl/timedate/lang/et-EE.rc +++ b/dll/cpl/timedate/lang/et-EE.rc @@ -40,7 +40,7 @@ STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "Interneti-aeg" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP AUTOCHECKBOX "&Sünkrooni automaatselt mõne Interneti-ajaserveriga", IDC_AUTOSYNC, 11, 7, 241, 10, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP LTEXT "Server:", IDC_SERVERTEXT, 34, 22, 28, 13 diff --git a/dll/cpl/timedate/lang/eu-ES.rc b/dll/cpl/timedate/lang/eu-ES.rc index 6e307185d91..1b7a482b3e5 100644 --- a/dll/cpl/timedate/lang/eu-ES.rc +++ b/dll/cpl/timedate/lang/eu-ES.rc @@ -33,7 +33,7 @@ STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "Internet-en ordua" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP AUTOCHECKBOX "Interneteko ordutegi zerbitzari batekin automatikoki sinkronizatu", IDC_AUTOSYNC, 11, 7, 241, 10, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP LTEXT "Zerbitzaria:", IDC_SERVERTEXT, 34, 22, 28, 13 diff --git a/dll/cpl/timedate/lang/fr-FR.rc b/dll/cpl/timedate/lang/fr-FR.rc index 35af8894960..9cd145884a9 100644 --- a/dll/cpl/timedate/lang/fr-FR.rc +++ b/dll/cpl/timedate/lang/fr-FR.rc @@ -33,7 +33,7 @@ STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "Temps Internet" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP AUTOCHECKBOX "Synchroniser automatiquement avec un serveur d'heure Internet", IDC_AUTOSYNC, 11, 7, 241, 10, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP LTEXT "Serveur:", IDC_SERVERTEXT, 34, 22, 28, 13 diff --git a/dll/cpl/timedate/lang/he-IL.rc b/dll/cpl/timedate/lang/he-IL.rc index 024cd9af410..f1ebafdc00e 100644 --- a/dll/cpl/timedate/lang/he-IL.rc +++ b/dll/cpl/timedate/lang/he-IL.rc @@ -33,7 +33,7 @@ STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "שעון אינטרנט" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP AUTOCHECKBOX "בצע סנכרון עם שרת שעון באינטרנט", IDC_AUTOSYNC, 11, 7, 241, 10, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP LTEXT "שרת:", IDC_SERVERTEXT, 34, 22, 28, 13 diff --git a/dll/cpl/timedate/lang/hu-HU.rc b/dll/cpl/timedate/lang/hu-HU.rc index de7a4f75332..1a37ed95198 100644 --- a/dll/cpl/timedate/lang/hu-HU.rc +++ b/dll/cpl/timedate/lang/hu-HU.rc @@ -35,7 +35,7 @@ STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "Internet Idő" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP AUTOCHECKBOX "Szinkronizálja a számítógép óráját egy internetes kiszolgálóval", IDC_AUTOSYNC, 11, 7, 241, 10, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP LTEXT "Kiszolgáló:", IDC_SERVERTEXT, 34, 22, 28, 13 diff --git a/dll/cpl/timedate/lang/id-ID.rc b/dll/cpl/timedate/lang/id-ID.rc index f274a7e3693..cf6fef10f5e 100644 --- a/dll/cpl/timedate/lang/id-ID.rc +++ b/dll/cpl/timedate/lang/id-ID.rc @@ -33,7 +33,7 @@ STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "Waktu Internet" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP AUTOCHECKBOX "Otomatis selaraskan dengan server waktu Internet", IDC_AUTOSYNC, 11, 7, 241, 10, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP LTEXT "Server:", IDC_SERVERTEXT, 34, 22, 28, 13 diff --git a/dll/cpl/timedate/lang/it-IT.rc b/dll/cpl/timedate/lang/it-IT.rc index d8d3e4ed9db..201ea28496f 100644 --- a/dll/cpl/timedate/lang/it-IT.rc +++ b/dll/cpl/timedate/lang/it-IT.rc @@ -33,7 +33,7 @@ STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "Ora Internet" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP AUTOCHECKBOX "Sincronizza automaticamente con il server di riferimento ora", IDC_AUTOSYNC, 11, 7, 241, 10, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP LTEXT "Server:", IDC_SERVERTEXT, 34, 22, 28, 13 diff --git a/dll/cpl/timedate/lang/ja-JP.rc b/dll/cpl/timedate/lang/ja-JP.rc index c12a612f659..99263dff8e9 100644 --- a/dll/cpl/timedate/lang/ja-JP.rc +++ b/dll/cpl/timedate/lang/ja-JP.rc @@ -33,7 +33,7 @@ STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "インターネット時刻" FONT 9, "MS UI Gothic", 0, 0, 0x0 BEGIN - COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP AUTOCHECKBOX "自動的にインターネット時刻サーバーと同期する", IDC_AUTOSYNC, 11, 7, 241, 10, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP LTEXT "サーバー:", IDC_SERVERTEXT, 34, 22, 28, 13 diff --git a/dll/cpl/timedate/lang/nl-NL.rc b/dll/cpl/timedate/lang/nl-NL.rc index a395b6bb328..dddf6e95763 100644 --- a/dll/cpl/timedate/lang/nl-NL.rc +++ b/dll/cpl/timedate/lang/nl-NL.rc @@ -33,7 +33,7 @@ STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "Internet Tijd" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - COMBOBOX IDC_SERVERLIST, 55, 22, 117, 136, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SERVERLIST, 55, 22, 117, 136, CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP AUTOCHECKBOX "Klok &automatisch met een tijdserver op het Internet synchroniseren.", IDC_AUTOSYNC, 11, 7, 241, 10, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP LTEXT "Server:", IDC_SERVERTEXT, 34, 22, 28, 13 diff --git a/dll/cpl/timedate/lang/no-NO.rc b/dll/cpl/timedate/lang/no-NO.rc index 0c39aab50ed..1b43ef6f27f 100644 --- a/dll/cpl/timedate/lang/no-NO.rc +++ b/dll/cpl/timedate/lang/no-NO.rc @@ -33,7 +33,7 @@ STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "Internett tid" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP AUTOCHECKBOX "Automatisk sykroniser klokken med internett tid serveren", IDC_AUTOSYNC, 11, 7, 241, 10, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP LTEXT "Server:", IDC_SERVERTEXT, 34, 22, 28, 13 diff --git a/dll/cpl/timedate/lang/pl-PL.rc b/dll/cpl/timedate/lang/pl-PL.rc index 8a2e1e2c286..a2a93d17cb5 100644 --- a/dll/cpl/timedate/lang/pl-PL.rc +++ b/dll/cpl/timedate/lang/pl-PL.rc @@ -42,7 +42,7 @@ STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "Czas z Internetu" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP AUTOCHECKBOX "Automatycznie synchronizuj czas z internetowym serwerem czasu", IDC_AUTOSYNC, 11, 7, 241, 10, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP LTEXT "Serwer:", IDC_SERVERTEXT, 34, 22, 28, 13 diff --git a/dll/cpl/timedate/lang/pt-BR.rc b/dll/cpl/timedate/lang/pt-BR.rc index 255e984e09c..b84d407bae8 100644 --- a/dll/cpl/timedate/lang/pt-BR.rc +++ b/dll/cpl/timedate/lang/pt-BR.rc @@ -33,7 +33,7 @@ STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "Horário na Internet" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP AUTOCHECKBOX "&Sincronizar automaticamente com um servidor de horário na Internet", IDC_AUTOSYNC, 11, 7, 241, 10, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP LTEXT "Servidor:", IDC_SERVERTEXT, 34, 22, 28, 13 diff --git a/dll/cpl/timedate/lang/ro-RO.rc b/dll/cpl/timedate/lang/ro-RO.rc index beaca4a4515..308c45c7668 100644 --- a/dll/cpl/timedate/lang/ro-RO.rc +++ b/dll/cpl/timedate/lang/ro-RO.rc @@ -35,7 +35,7 @@ STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "Timp Internet" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP AUTOCHECKBOX "&Permite sincronizarea automată cu un server de oră:", IDC_AUTOSYNC, 11, 7, 241, 10, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP LTEXT "Server:", IDC_SERVERTEXT, 34, 22, 28, 13 diff --git a/dll/cpl/timedate/lang/ru-RU.rc b/dll/cpl/timedate/lang/ru-RU.rc index 2dfe392ce37..9ad368508bd 100644 --- a/dll/cpl/timedate/lang/ru-RU.rc +++ b/dll/cpl/timedate/lang/ru-RU.rc @@ -33,7 +33,7 @@ STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "Время через Интернет" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP AUTOCHECKBOX "&Выполнять синхронизацию с сервером времени в Интернете", IDC_AUTOSYNC, 11, 7, 246, 10, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP LTEXT "Сервер:", IDC_SERVERTEXT, 34, 22, 28, 13 diff --git a/dll/cpl/timedate/lang/sk-SK.rc b/dll/cpl/timedate/lang/sk-SK.rc index ba7097249eb..cd011f73803 100644 --- a/dll/cpl/timedate/lang/sk-SK.rc +++ b/dll/cpl/timedate/lang/sk-SK.rc @@ -40,7 +40,7 @@ STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "Internetový čas" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP AUTOCHECKBOX "Automaticky &synchronizovať čas s internetovým časovým serverom", IDC_AUTOSYNC, 11, 7, 241, 10, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP LTEXT "Server:", IDC_SERVERTEXT, 34, 22, 28, 13 diff --git a/dll/cpl/timedate/lang/sq-AL.rc b/dll/cpl/timedate/lang/sq-AL.rc index 5add59efa9b..82ab28654cd 100644 --- a/dll/cpl/timedate/lang/sq-AL.rc +++ b/dll/cpl/timedate/lang/sq-AL.rc @@ -37,7 +37,7 @@ STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "Ora Internetit" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP AUTOCHECKBOX "Automatikisht sinkronizohu me një server kohën e Internetit", IDC_AUTOSYNC, 11, 7, 241, 10, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP LTEXT "Server:", IDC_SERVERTEXT, 34, 22, 28, 13 diff --git a/dll/cpl/timedate/lang/sv-SE.rc b/dll/cpl/timedate/lang/sv-SE.rc index 8f400273ea9..129c4457e39 100644 --- a/dll/cpl/timedate/lang/sv-SE.rc +++ b/dll/cpl/timedate/lang/sv-SE.rc @@ -35,7 +35,7 @@ STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "Internet Time" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP AUTOCHECKBOX "Automatically synchronize with an Internet time server", IDC_AUTOSYNC, 11, 7, 241, 10, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP LTEXT "Server:", IDC_SERVERTEXT, 34, 22, 28, 13 diff --git a/dll/cpl/timedate/lang/th-TH.rc b/dll/cpl/timedate/lang/th-TH.rc index 5f932926dde..f3c8a210ea8 100644 --- a/dll/cpl/timedate/lang/th-TH.rc +++ b/dll/cpl/timedate/lang/th-TH.rc @@ -33,7 +33,7 @@ STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "เวลาของอินเทอร์เน็ต" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP AUTOCHECKBOX "กำลังปรับเทียบเวลาอัตโนมัติกับเครื่องแม่ข่ายอินเทอร์เน็ต", IDC_AUTOSYNC, 11, 7, 241, 10, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP LTEXT "เครื่องแม่ข่าย:", IDC_SERVERTEXT, 34, 22, 28, 13 diff --git a/dll/cpl/timedate/lang/tr-TR.rc b/dll/cpl/timedate/lang/tr-TR.rc index 7b311fdb633..ebfcfee1461 100644 --- a/dll/cpl/timedate/lang/tr-TR.rc +++ b/dll/cpl/timedate/lang/tr-TR.rc @@ -35,7 +35,7 @@ STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "Umûmî Ağ Zamânı" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP AUTOCHECKBOX "Bir Umûmî Ağ Zamânı Sunucusuyla Kendiliğinden Eşleştir", IDC_AUTOSYNC, 11, 7, 241, 10, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP LTEXT "Sunucu:", IDC_SERVERTEXT, 34, 22, 28, 13 diff --git a/dll/cpl/timedate/lang/uk-UA.rc b/dll/cpl/timedate/lang/uk-UA.rc index 67399b3f68e..454e68396b8 100644 --- a/dll/cpl/timedate/lang/uk-UA.rc +++ b/dll/cpl/timedate/lang/uk-UA.rc @@ -41,7 +41,7 @@ STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "Час Інтернету" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP AUTOCHECKBOX "Автоматично синхронізувати з сервером часу в Інтернеті", IDC_AUTOSYNC, 11, 7, 241, 10, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP LTEXT "Сервер:", IDC_SERVERTEXT, 34, 22, 28, 13 diff --git a/dll/cpl/timedate/lang/zh-CN.rc b/dll/cpl/timedate/lang/zh-CN.rc index bd6567314ef..a83db551000 100644 --- a/dll/cpl/timedate/lang/zh-CN.rc +++ b/dll/cpl/timedate/lang/zh-CN.rc @@ -33,7 +33,7 @@ STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "Internet 时间" FONT 9, "宋体", 0, 0, 0x0 BEGIN - COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP AUTOCHECKBOX "自动与 Internet 时间服务器同步(&S)", IDC_AUTOSYNC, 11, 7, 241, 10, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP LTEXT "服务器:", IDC_SERVERTEXT, 34, 22, 28, 13 diff --git a/dll/cpl/timedate/lang/zh-TW.rc b/dll/cpl/timedate/lang/zh-TW.rc index cc83b9e7f38..7f06777504c 100644 --- a/dll/cpl/timedate/lang/zh-TW.rc +++ b/dll/cpl/timedate/lang/zh-TW.rc @@ -35,7 +35,7 @@ STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "網際網路時間" FONT 9, "新細明體", 0, 0, 0x0 BEGIN - COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP AUTOCHECKBOX "自動與網際網路時間伺服器同步(&S)", IDC_AUTOSYNC, 11, 7, 241, 10, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP LTEXT "伺服器:", IDC_SERVERTEXT, 34, 22, 28, 13
5 years, 5 months
1
0
0
0
[reactos] 05/07: [TIMEDATE] Handle manual time server entry. CORE-13001
by Doug Lyons
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=44b543bad32363dfce59f…
commit 44b543bad32363dfce59f3755d69616e476f8f86 Author: Doug Lyons <douglyons(a)douglyons.com> AuthorDate: Sat Feb 10 15:47:04 2018 -0600 Commit: Thomas Faber <thomas.faber(a)reactos.org> CommitDate: Sun Jul 7 12:45:36 2019 +0200 [TIMEDATE] Handle manual time server entry. CORE-13001 --- dll/cpl/timedate/internettime.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/dll/cpl/timedate/internettime.c b/dll/cpl/timedate/internettime.c index 81a3ed0791c..808930e083e 100644 --- a/dll/cpl/timedate/internettime.c +++ b/dll/cpl/timedate/internettime.c @@ -8,6 +8,7 @@ */ #include "timedate.h" +#include <stdlib.h> DWORD WINAPI W32TimeSyncNow(LPCWSTR cmdline, UINT blocking, UINT flags); @@ -95,12 +96,40 @@ SetNTPServer(HWND hwnd) UINT uSel; WCHAR szSel[4]; LONG lRet; + WCHAR buffer[256]; hList = GetDlgItem(hwnd, IDC_SERVERLIST); uSel = (UINT)SendMessageW(hList, CB_GETCURSEL, 0, 0); + SendDlgItemMessageW(hwnd, IDC_SERVERLIST, WM_GETTEXT, _countof(buffer), (LPARAM)buffer); + + /* If there is new data entered then save it in the registry + The same key name of "0" is used to store all user entered values + */ + if (uSel == -1) + { + lRet = RegOpenKeyExW(HKEY_LOCAL_MACHINE, + L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\DateTime\\Servers", + 0, + KEY_SET_VALUE, + &hKey); + if (lRet != ERROR_SUCCESS) + { + DisplayWin32Error(lRet); + return; + } + lRet = RegSetValueExW(hKey, + L"0", + 0, + REG_SZ, + (LPBYTE)buffer, + (wcslen(buffer) + 1) * sizeof(WCHAR)); + if (lRet != ERROR_SUCCESS) + DisplayWin32Error(lRet); + } + /* Server reg entries count from 1, * Combo boxes count from 0 */ uSel++; @@ -255,7 +284,7 @@ InetTimePageProc(HWND hwndDlg, break; case IDC_SERVERLIST: - if (HIWORD(wParam) == CBN_SELCHANGE) + if ((HIWORD(wParam) == CBN_SELCHANGE) || (HIWORD(wParam) == CBN_EDITCHANGE)) { /* Enable the 'Apply' button */ PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
5 years, 5 months
1
0
0
0
[reactos] 04/07: [TIMEDATE] Use w32time compatible registry settings. CORE-13001
by Doug Lyons
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=33401f38751656ba93704…
commit 33401f38751656ba93704b2b84edb2a57246c6b0 Author: Doug Lyons <douglyons(a)douglyons.com> AuthorDate: Sat Apr 21 08:13:27 2018 +0200 Commit: Thomas Faber <thomas.faber(a)reactos.org> CommitDate: Sun Jul 7 12:45:17 2019 +0200 [TIMEDATE] Use w32time compatible registry settings. CORE-13001 --- dll/cpl/timedate/internettime.c | 46 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/dll/cpl/timedate/internettime.c b/dll/cpl/timedate/internettime.c index a5f102af35b..81a3ed0791c 100644 --- a/dll/cpl/timedate/internettime.c +++ b/dll/cpl/timedate/internettime.c @@ -157,7 +157,7 @@ GetSyncSetting(HWND hwnd) DWORD dwSize; if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, - L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\DateTime\\Parameters", + L"SYSTEM\\CurrentControlSet\\Services\\W32Time\\Parameters", 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) @@ -171,7 +171,9 @@ GetSyncSetting(HWND hwnd) &dwSize) == ERROR_SUCCESS) { if (wcscmp(szData, L"NTP") == 0) - SendDlgItemMessageW(hwnd, IDC_AUTOSYNC, BM_SETCHECK, 0, 0); + SendDlgItemMessageW(hwnd, IDC_AUTOSYNC, BM_SETCHECK, BST_CHECKED, 0); + else + SendDlgItemMessageW(hwnd, IDC_AUTOSYNC, BM_SETCHECK, BST_UNCHECKED, 0); } RegCloseKey(hKey); @@ -187,6 +189,40 @@ OnInitDialog(HWND hwnd) CreateNTPServerList(hwnd); } +static VOID +OnAutoSync(BOOL Sync) +{ + HKEY hKey; + LONG lRet; + LPCWSTR szAuto; + + if (Sync) + szAuto = L"NTP"; + else + szAuto = L"NoSync"; + + lRet = RegOpenKeyExW(HKEY_LOCAL_MACHINE, + L"SYSTEM\\CurrentControlSet\\Services\\W32Time\\Parameters", + 0, + KEY_SET_VALUE, + &hKey); + if (lRet != ERROR_SUCCESS) + { + DisplayWin32Error(lRet); + return; + } + + lRet = RegSetValueExW(hKey, + L"Type", + 0, + REG_SZ, + (LPBYTE)szAuto, + (wcslen(szAuto) + 1) * sizeof(WCHAR)); + if (lRet != ERROR_SUCCESS) + DisplayWin32Error(lRet); + + RegCloseKey(hKey); +} /* Property page dialog callback */ INT_PTR CALLBACK @@ -249,6 +285,12 @@ InetTimePageProc(HWND hwndDlg, { case PSN_APPLY: SetNTPServer(hwndDlg); + + if (SendDlgItemMessageW(hwndDlg, IDC_AUTOSYNC, BM_GETCHECK, 0, 0) == BST_CHECKED) + OnAutoSync(TRUE); + else + OnAutoSync(FALSE); + return TRUE; default:
5 years, 5 months
1
0
0
0
[reactos] 03/07: [W32TIME] Implement a rudimentary version of W32TimeSyncNow. CORE-13001
by Thomas Faber
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d19b79251198adc4db32c…
commit d19b79251198adc4db32ceeeb85772ba2ffeaa9f Author: Thomas Faber <thomas.faber(a)reactos.org> AuthorDate: Sun Jun 3 16:28:57 2018 +0200 Commit: Thomas Faber <thomas.faber(a)reactos.org> CommitDate: Sun Jul 7 12:45:03 2019 +0200 [W32TIME] Implement a rudimentary version of W32TimeSyncNow. CORE-13001 --- base/services/CMakeLists.txt | 1 + base/services/w32time/CMakeLists.txt | 12 ++++++ .../timedate => base/services/w32time}/ntpclient.c | 2 +- .../timedate => base/services/w32time}/w32time.c | 9 +++-- base/services/w32time/w32time.h | 44 ++++++++++++++++++++++ base/services/w32time/w32time.spec | 1 + dll/cpl/timedate/CMakeLists.txt | 4 +- dll/cpl/timedate/internettime.c | 4 +- dll/cpl/timedate/timedate.h | 32 ---------------- 9 files changed, 69 insertions(+), 40 deletions(-) diff --git a/base/services/CMakeLists.txt b/base/services/CMakeLists.txt index 15bdd77bee3..62b5a90ccd9 100644 --- a/base/services/CMakeLists.txt +++ b/base/services/CMakeLists.txt @@ -14,6 +14,7 @@ add_subdirectory(tcpsvcs) add_subdirectory(telnetd) add_subdirectory(tftpd) add_subdirectory(umpnpmgr) +add_subdirectory(w32time) add_subdirectory(wkssvc) add_subdirectory(wlansvc) add_subdirectory(wmisvc) diff --git a/base/services/w32time/CMakeLists.txt b/base/services/w32time/CMakeLists.txt new file mode 100644 index 00000000000..5cc5a3b6e1a --- /dev/null +++ b/base/services/w32time/CMakeLists.txt @@ -0,0 +1,12 @@ + +spec2def(w32time.dll w32time.spec ADD_IMPORTLIB) + +add_library(w32time SHARED + w32time.c + ntpclient.c + ${CMAKE_CURRENT_BINARY_DIR}/w32time.def) + +set_module_type(w32time win32dll UNICODE) + +add_importlibs(w32time ws2_32 advapi32 msvcrt kernel32 ntdll) +add_cd_file(TARGET w32time DESTINATION reactos/system32 FOR all) diff --git a/dll/cpl/timedate/ntpclient.c b/base/services/w32time/ntpclient.c similarity index 99% rename from dll/cpl/timedate/ntpclient.c rename to base/services/w32time/ntpclient.c index fc378c624e2..8ba5910fe13 100644 --- a/dll/cpl/timedate/ntpclient.c +++ b/base/services/w32time/ntpclient.c @@ -7,7 +7,7 @@ * */ -#include "timedate.h" +#include "w32time.h" #include <winsock2.h> diff --git a/dll/cpl/timedate/w32time.c b/base/services/w32time/w32time.c similarity index 97% rename from dll/cpl/timedate/w32time.c rename to base/services/w32time/w32time.c index dfbf14347f1..675bb907d69 100644 --- a/dll/cpl/timedate/w32time.c +++ b/base/services/w32time/w32time.c @@ -5,7 +5,7 @@ * COPYRIGHT: Copyright 2006 Ged Murphy <gedmurphy(a)gmail.com> */ -#include "timedate.h" +#include "w32time.h" /* Get the domain name from the registry */ static DWORD @@ -207,11 +207,14 @@ UpdateSystemTime(ULONG ulTime) } -DWORD -SyncTimeNow(VOID) +DWORD WINAPI +W32TimeSyncNow(LPCWSTR cmdline, + UINT blocking, + UINT flags) { DWORD dwError; ULONG ulTime; + dwError = GetTimeFromServer(&ulTime); if (dwError != ERROR_SUCCESS) { diff --git a/base/services/w32time/w32time.h b/base/services/w32time/w32time.h new file mode 100644 index 00000000000..bd65de402c3 --- /dev/null +++ b/base/services/w32time/w32time.h @@ -0,0 +1,44 @@ +#ifndef _W32TIME_H +#define _W32TIME_H + +#include <stdarg.h> + +#define _INC_WINDOWS +#define COM_NO_WINDOWS_H +#define WIN32_NO_STATUS + +#include <windef.h> +#include <winbase.h> +#include <winnls.h> +#include <winreg.h> + +#define NTPPORT 123 + + +/* ntpclient.c */ +// NTP timestamp +typedef struct _TIMEPACKET +{ + DWORD dwInteger; + DWORD dwFractional; +} TIMEPACKET, *PTIMEPACKET; + +// NTP packet +typedef struct _NTPPACKET +{ + BYTE LiVnMode; + BYTE Stratum; + char Poll; + char Precision; + long RootDelay; + long RootDispersion; + char ReferenceID[4]; + TIMEPACKET ReferenceTimestamp; + TIMEPACKET OriginateTimestamp; + TIMEPACKET ReceiveTimestamp; + TIMEPACKET TransmitTimestamp; +}NTPPACKET, *PNTPPACKET; + +ULONG GetServerTime(LPWSTR lpAddress); + +#endif /* _W32TIME_H */ diff --git a/base/services/w32time/w32time.spec b/base/services/w32time/w32time.spec new file mode 100644 index 00000000000..12b8db5bc1e --- /dev/null +++ b/base/services/w32time/w32time.spec @@ -0,0 +1 @@ +18 stdcall W32TimeSyncNow(wstr long long) diff --git a/dll/cpl/timedate/CMakeLists.txt b/dll/cpl/timedate/CMakeLists.txt index 5103df0f8dd..d1b5275dd07 100644 --- a/dll/cpl/timedate/CMakeLists.txt +++ b/dll/cpl/timedate/CMakeLists.txt @@ -6,10 +6,8 @@ list(APPEND SOURCE dateandtime.c internettime.c monthcal.c - ntpclient.c timedate.c timezone.c - w32time.c timedate.h) file(GLOB timedate_rc_deps resources/*.*) @@ -21,6 +19,6 @@ add_library(timedate MODULE ${CMAKE_CURRENT_BINARY_DIR}/timedate.def) set_module_type(timedate cpl UNICODE) -add_importlibs(timedate advapi32 user32 gdi32 comctl32 ws2_32 iphlpapi msvcrt kernel32) +add_importlibs(timedate w32time advapi32 user32 gdi32 comctl32 ws2_32 iphlpapi msvcrt kernel32) add_pch(timedate timedate.h SOURCE) add_cd_file(TARGET timedate DESTINATION reactos/system32 FOR all) diff --git a/dll/cpl/timedate/internettime.c b/dll/cpl/timedate/internettime.c index 7c971846c7b..a5f102af35b 100644 --- a/dll/cpl/timedate/internettime.c +++ b/dll/cpl/timedate/internettime.c @@ -9,6 +9,8 @@ #include "timedate.h" +DWORD WINAPI W32TimeSyncNow(LPCWSTR cmdline, UINT blocking, UINT flags); + static VOID CreateNTPServerList(HWND hwnd) { @@ -208,7 +210,7 @@ InetTimePageProc(HWND hwndDlg, SetNTPServer(hwndDlg); - dwError = SyncTimeNow(); + dwError = W32TimeSyncNow(L"localhost", 0, 0); if (dwError != ERROR_SUCCESS) { DisplayWin32Error(dwError); diff --git a/dll/cpl/timedate/timedate.h b/dll/cpl/timedate/timedate.h index 73b2a3a7c24..8cf7dbb74bd 100644 --- a/dll/cpl/timedate/timedate.h +++ b/dll/cpl/timedate/timedate.h @@ -23,7 +23,6 @@ #define MAX_VALUE_NAME 16383 #define SERVERLISTSIZE 6 #define BUFSIZE 1024 -#define NTPPORT 123 #define ID_TIMER 1 typedef struct @@ -67,37 +66,6 @@ BOOL RegisterClockControl(VOID); VOID UnregisterClockControl(VOID); -/* ntpclient.c */ -// NTP timestamp -typedef struct _TIMEPACKET -{ - DWORD dwInteger; - DWORD dwFractional; -} TIMEPACKET, *PTIMEPACKET; - -// NTP packet -typedef struct _NTPPACKET -{ - BYTE LiVnMode; - BYTE Stratum; - char Poll; - char Precision; - long RootDelay; - long RootDispersion; - char ReferenceID[4]; - TIMEPACKET ReferenceTimestamp; - TIMEPACKET OriginateTimestamp; - TIMEPACKET ReceiveTimestamp; - TIMEPACKET TransmitTimestamp; -}NTPPACKET, *PNTPPACKET; - -ULONG GetServerTime(LPWSTR lpAddress); - - -/* w32time.c */ -DWORD SyncTimeNow(VOID); - - /* monthcal.c */ #define MCCM_SETDATE (WM_USER + 1) #define MCCM_GETDATE (WM_USER + 2)
5 years, 5 months
1
0
0
0
[reactos] 02/07: [TIMEDATE] Avoid the use of DisplayWin32Error in time sync utility functions. CORE-13001
by Thomas Faber
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1938b7484e03148350296…
commit 1938b7484e031483502962208d67993a3267880d Author: Thomas Faber <thomas.faber(a)reactos.org> AuthorDate: Sun Jun 3 15:35:42 2018 +0200 Commit: Thomas Faber <thomas.faber(a)reactos.org> CommitDate: Sun Jul 7 12:44:51 2019 +0200 [TIMEDATE] Avoid the use of DisplayWin32Error in time sync utility functions. CORE-13001 --- dll/cpl/timedate/internettime.c | 9 ++++- dll/cpl/timedate/timedate.h | 2 +- dll/cpl/timedate/w32time.c | 83 +++++++++++++++++++++++++---------------- 3 files changed, 59 insertions(+), 35 deletions(-) diff --git a/dll/cpl/timedate/internettime.c b/dll/cpl/timedate/internettime.c index 5a419e40e79..7c971846c7b 100644 --- a/dll/cpl/timedate/internettime.c +++ b/dll/cpl/timedate/internettime.c @@ -204,8 +204,15 @@ InetTimePageProc(HWND hwndDlg, { case IDC_UPDATEBUTTON: { + DWORD dwError; + SetNTPServer(hwndDlg); - SyncTimeNow(); + + dwError = SyncTimeNow(); + if (dwError != ERROR_SUCCESS) + { + DisplayWin32Error(dwError); + } } break; diff --git a/dll/cpl/timedate/timedate.h b/dll/cpl/timedate/timedate.h index 2fdddbd5a06..73b2a3a7c24 100644 --- a/dll/cpl/timedate/timedate.h +++ b/dll/cpl/timedate/timedate.h @@ -95,7 +95,7 @@ ULONG GetServerTime(LPWSTR lpAddress); /* w32time.c */ -VOID SyncTimeNow(VOID); +DWORD SyncTimeNow(VOID); /* monthcal.c */ diff --git a/dll/cpl/timedate/w32time.c b/dll/cpl/timedate/w32time.c index a8aed3f4d15..dfbf14347f1 100644 --- a/dll/cpl/timedate/w32time.c +++ b/dll/cpl/timedate/w32time.c @@ -8,7 +8,7 @@ #include "timedate.h" /* Get the domain name from the registry */ -static BOOL +static DWORD GetNTPServerAddress(LPWSTR *lpAddress) { HKEY hKey; @@ -16,13 +16,16 @@ GetNTPServerAddress(LPWSTR *lpAddress) DWORD dwSize; LONG lRet; + *lpAddress = NULL; + hKey = NULL; + lRet = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\DateTime\\Servers", 0, KEY_QUERY_VALUE, &hKey); if (lRet != ERROR_SUCCESS) - goto fail; + goto Exit; /* Get data from default value */ dwSize = 4 * sizeof(WCHAR); @@ -33,7 +36,7 @@ GetNTPServerAddress(LPWSTR *lpAddress) (LPBYTE)szSel, &dwSize); if (lRet != ERROR_SUCCESS) - goto fail; + goto Exit; dwSize = 0; lRet = RegQueryValueExW(hKey, @@ -43,7 +46,7 @@ GetNTPServerAddress(LPWSTR *lpAddress) NULL, &dwSize); if (lRet != ERROR_SUCCESS) - goto fail; + goto Exit; (*lpAddress) = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, @@ -51,7 +54,7 @@ GetNTPServerAddress(LPWSTR *lpAddress) if ((*lpAddress) == NULL) { lRet = ERROR_NOT_ENOUGH_MEMORY; - goto fail; + goto Exit; } lRet = RegQueryValueExW(hKey, @@ -61,38 +64,42 @@ GetNTPServerAddress(LPWSTR *lpAddress) (LPBYTE)*lpAddress, &dwSize); if (lRet != ERROR_SUCCESS) - goto fail; - - RegCloseKey(hKey); + goto Exit; - return TRUE; - -fail: - DisplayWin32Error(lRet); +Exit: if (hKey) RegCloseKey(hKey); - HeapFree(GetProcessHeap(), 0, *lpAddress); - return FALSE; + if (lRet != ERROR_SUCCESS) + HeapFree(GetProcessHeap(), 0, *lpAddress); + + return lRet; } /* Request the time from the current NTP server */ -static ULONG -GetTimeFromServer(VOID) +static DWORD +GetTimeFromServer(PULONG pulTime) { - LPWSTR lpAddress = NULL; - ULONG ulTime = 0; + LPWSTR lpAddress; + DWORD dwError; - if (GetNTPServerAddress(&lpAddress)) + dwError = GetNTPServerAddress(&lpAddress); + if (dwError != ERROR_SUCCESS) { - ulTime = GetServerTime(lpAddress); + return dwError; + } - HeapFree(GetProcessHeap(), - 0, - lpAddress); + *pulTime = GetServerTime(lpAddress); + if (*pulTime == 0) + { + dwError = ERROR_GEN_FAILURE; } - return ulTime; + HeapFree(GetProcessHeap(), + 0, + lpAddress); + + return dwError; } @@ -158,7 +165,7 @@ SystemSetTime(LPSYSTEMTIME lpSystemTime) * 1st Jan, 1900. The time returned from the server * needs adding to that date to get the current Gregorian time */ -static VOID +static DWORD UpdateSystemTime(ULONG ulTime) { FILETIME ftNew; @@ -177,8 +184,7 @@ UpdateSystemTime(ULONG ulTime) /* Convert to a file time */ if (!SystemTimeToFileTime(&stNew, &ftNew)) { - DisplayWin32Error(GetLastError()); - return; + return GetLastError(); } /* Add on the time passed since 1st Jan 1900 */ @@ -189,23 +195,34 @@ UpdateSystemTime(ULONG ulTime) /* Convert back to a system time */ if (!FileTimeToSystemTime(&ftNew, &stNew)) { - DisplayWin32Error(GetLastError()); - return; + return GetLastError(); } if (!SystemSetTime(&stNew)) { - DisplayWin32Error(GetLastError()); + return GetLastError(); } + + return ERROR_SUCCESS; } -VOID +DWORD SyncTimeNow(VOID) { + DWORD dwError; ULONG ulTime; - ulTime = GetTimeFromServer(); + dwError = GetTimeFromServer(&ulTime); + if (dwError != ERROR_SUCCESS) + { + return dwError; + } + if (ulTime != 0) - UpdateSystemTime(ulTime); + { + dwError = UpdateSystemTime(ulTime); + } + + return dwError; }
5 years, 5 months
1
0
0
0
[reactos] 01/07: [TIMEDATE] Separate time sync functions out into their own file. CORE-13001
by Thomas Faber
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=aa24ad74290acdfc359db…
commit aa24ad74290acdfc359db94ac44c477a3c07d9a5 Author: Thomas Faber <thomas.faber(a)reactos.org> AuthorDate: Sun Jun 3 12:33:24 2018 +0200 Commit: Thomas Faber <thomas.faber(a)reactos.org> CommitDate: Sun Jul 7 12:44:37 2019 +0200 [TIMEDATE] Separate time sync functions out into their own file. CORE-13001 This is in preparation for the w32time service, and based on work by Doug Lyons. --- dll/cpl/timedate/CMakeLists.txt | 1 + dll/cpl/timedate/dateandtime.c | 19 +--- dll/cpl/timedate/internettime.c | 141 +-------------------------- dll/cpl/timedate/timedate.h | 6 +- dll/cpl/timedate/w32time.c | 211 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 222 insertions(+), 156 deletions(-) diff --git a/dll/cpl/timedate/CMakeLists.txt b/dll/cpl/timedate/CMakeLists.txt index d1ad1db070e..5103df0f8dd 100644 --- a/dll/cpl/timedate/CMakeLists.txt +++ b/dll/cpl/timedate/CMakeLists.txt @@ -9,6 +9,7 @@ list(APPEND SOURCE ntpclient.c timedate.c timezone.c + w32time.c timedate.h) file(GLOB timedate_rc_deps resources/*.*) diff --git a/dll/cpl/timedate/dateandtime.c b/dll/cpl/timedate/dateandtime.c index 8470db32bcb..026cd305cfc 100644 --- a/dll/cpl/timedate/dateandtime.c +++ b/dll/cpl/timedate/dateandtime.c @@ -14,8 +14,7 @@ static WNDPROC pOldWndProc = NULL; BOOL -SystemSetTime(LPSYSTEMTIME lpSystemTime, - BOOL SystemTime) +SystemSetLocalTime(LPSYSTEMTIME lpSystemTime) { HANDLE hToken; DWORD PrevSize; @@ -47,19 +46,10 @@ SystemSetTime(LPSYSTEMTIME lpSystemTime, { /* * 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. */ - if (SystemTime) - { - Ret = SetSystemTime(lpSystemTime); - } - else - { - Ret = SetLocalTime(lpSystemTime) && - SetLocalTime(lpSystemTime); - } + Ret = SetLocalTime(lpSystemTime) && + SetLocalTime(lpSystemTime); /* * For the sake of security, restore the previous status again @@ -96,8 +86,7 @@ SetLocalSystemTime(HWND hwnd) (WPARAM)&Time, 0)) { - /* Set Local Time with SystemTime = FALSE */ - SystemSetTime(&Time, FALSE); + SystemSetLocalTime(&Time); SetWindowLongPtrW(hwnd, DWLP_MSGRESULT, diff --git a/dll/cpl/timedate/internettime.c b/dll/cpl/timedate/internettime.c index 35e724948a4..5a419e40e79 100644 --- a/dll/cpl/timedate/internettime.c +++ b/dll/cpl/timedate/internettime.c @@ -130,140 +130,6 @@ SetNTPServer(HWND hwnd) } -/* Get the domain name from the registry */ -static BOOL -GetNTPServerAddress(LPWSTR *lpAddress) -{ - HKEY hKey; - WCHAR szSel[4]; - DWORD dwSize; - LONG lRet; - - lRet = RegOpenKeyExW(HKEY_LOCAL_MACHINE, - L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\DateTime\\Servers", - 0, - KEY_QUERY_VALUE, - &hKey); - if (lRet != ERROR_SUCCESS) - goto fail; - - /* Get data from default value */ - dwSize = 4 * sizeof(WCHAR); - lRet = RegQueryValueExW(hKey, - NULL, - NULL, - NULL, - (LPBYTE)szSel, - &dwSize); - if (lRet != ERROR_SUCCESS) - goto fail; - - dwSize = 0; - lRet = RegQueryValueExW(hKey, - szSel, - NULL, - NULL, - NULL, - &dwSize); - if (lRet != ERROR_SUCCESS) - goto fail; - - (*lpAddress) = (LPWSTR)HeapAlloc(GetProcessHeap(), - 0, - dwSize); - if ((*lpAddress) == NULL) - { - lRet = ERROR_NOT_ENOUGH_MEMORY; - goto fail; - } - - lRet = RegQueryValueExW(hKey, - szSel, - NULL, - NULL, - (LPBYTE)*lpAddress, - &dwSize); - if (lRet != ERROR_SUCCESS) - goto fail; - - RegCloseKey(hKey); - - return TRUE; - -fail: - DisplayWin32Error(lRet); - if (hKey) - RegCloseKey(hKey); - HeapFree(GetProcessHeap(), 0, *lpAddress); - return FALSE; -} - - -/* Request the time from the current NTP server */ -static ULONG -GetTimeFromServer(VOID) -{ - LPWSTR lpAddress = NULL; - ULONG ulTime = 0; - - if (GetNTPServerAddress(&lpAddress)) - { - ulTime = GetServerTime(lpAddress); - - HeapFree(GetProcessHeap(), - 0, - lpAddress); - } - - return ulTime; -} - -/* - * NTP servers state the number of seconds passed since - * 1st Jan, 1900. The time returned from the server - * needs adding to that date to get the current Gregorian time - */ -static VOID -UpdateSystemTime(ULONG ulTime) -{ - FILETIME ftNew; - LARGE_INTEGER li; - SYSTEMTIME stNew; - - /* Time at 1st Jan 1900 */ - stNew.wYear = 1900; - stNew.wMonth = 1; - stNew.wDay = 1; - stNew.wHour = 0; - stNew.wMinute = 0; - stNew.wSecond = 0; - stNew.wMilliseconds = 0; - - /* Convert to a file time */ - if (!SystemTimeToFileTime(&stNew, &ftNew)) - { - DisplayWin32Error(GetLastError()); - return; - } - - /* Add on the time passed since 1st Jan 1900 */ - li = *(LARGE_INTEGER *)&ftNew; - li.QuadPart += (LONGLONG)10000000 * ulTime; - ftNew = * (FILETIME *)&li; - - /* Convert back to a system time */ - if (!FileTimeToSystemTime(&ftNew, &stNew)) - { - DisplayWin32Error(GetLastError()); - return; - } - - /* Use SystemSetTime with SystemTime = TRUE to set System Time */ - if (!SystemSetTime(&stNew, TRUE)) - DisplayWin32Error(GetLastError()); -} - - static VOID EnableDialogText(HWND hwnd) { @@ -338,13 +204,8 @@ InetTimePageProc(HWND hwndDlg, { case IDC_UPDATEBUTTON: { - ULONG ulTime; - SetNTPServer(hwndDlg); - - ulTime = GetTimeFromServer(); - if (ulTime != 0) - UpdateSystemTime(ulTime); + SyncTimeNow(); } break; diff --git a/dll/cpl/timedate/timedate.h b/dll/cpl/timedate/timedate.h index dfc54a18c3e..2fdddbd5a06 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 SystemSetTime(LPSYSTEMTIME lpSystemTime, BOOL SystemTime); +BOOL SystemSetLocalTime(LPSYSTEMTIME lpSystemTime); /* timezone.c */ @@ -94,6 +94,10 @@ typedef struct _NTPPACKET ULONG GetServerTime(LPWSTR lpAddress); +/* w32time.c */ +VOID SyncTimeNow(VOID); + + /* monthcal.c */ #define MCCM_SETDATE (WM_USER + 1) #define MCCM_GETDATE (WM_USER + 2) diff --git a/dll/cpl/timedate/w32time.c b/dll/cpl/timedate/w32time.c new file mode 100644 index 00000000000..a8aed3f4d15 --- /dev/null +++ b/dll/cpl/timedate/w32time.c @@ -0,0 +1,211 @@ +/* + * PROJECT: ReactOS Timedate Control Panel + * LICENSE: GPL-2.0+ (
https://spdx.org/licenses/GPL-2.0+
) + * PURPOSE: Create W32Time Service that reqularly syncs clock to Internet Time + * COPYRIGHT: Copyright 2006 Ged Murphy <gedmurphy(a)gmail.com> + */ + +#include "timedate.h" + +/* Get the domain name from the registry */ +static BOOL +GetNTPServerAddress(LPWSTR *lpAddress) +{ + HKEY hKey; + WCHAR szSel[4]; + DWORD dwSize; + LONG lRet; + + lRet = RegOpenKeyExW(HKEY_LOCAL_MACHINE, + L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\DateTime\\Servers", + 0, + KEY_QUERY_VALUE, + &hKey); + if (lRet != ERROR_SUCCESS) + goto fail; + + /* Get data from default value */ + dwSize = 4 * sizeof(WCHAR); + lRet = RegQueryValueExW(hKey, + NULL, + NULL, + NULL, + (LPBYTE)szSel, + &dwSize); + if (lRet != ERROR_SUCCESS) + goto fail; + + dwSize = 0; + lRet = RegQueryValueExW(hKey, + szSel, + NULL, + NULL, + NULL, + &dwSize); + if (lRet != ERROR_SUCCESS) + goto fail; + + (*lpAddress) = (LPWSTR)HeapAlloc(GetProcessHeap(), + 0, + dwSize); + if ((*lpAddress) == NULL) + { + lRet = ERROR_NOT_ENOUGH_MEMORY; + goto fail; + } + + lRet = RegQueryValueExW(hKey, + szSel, + NULL, + NULL, + (LPBYTE)*lpAddress, + &dwSize); + if (lRet != ERROR_SUCCESS) + goto fail; + + RegCloseKey(hKey); + + return TRUE; + +fail: + DisplayWin32Error(lRet); + if (hKey) + RegCloseKey(hKey); + HeapFree(GetProcessHeap(), 0, *lpAddress); + return FALSE; +} + + +/* Request the time from the current NTP server */ +static ULONG +GetTimeFromServer(VOID) +{ + LPWSTR lpAddress = NULL; + ULONG ulTime = 0; + + if (GetNTPServerAddress(&lpAddress)) + { + ulTime = GetServerTime(lpAddress); + + HeapFree(GetProcessHeap(), + 0, + lpAddress); + } + + return ulTime; +} + + +BOOL +SystemSetTime(LPSYSTEMTIME lpSystemTime) +{ + HANDLE hToken; + DWORD PrevSize; + TOKEN_PRIVILEGES priv, previouspriv; + BOOL Ret = FALSE; + + /* + * Enable the SeSystemtimePrivilege privilege + */ + + if (OpenProcessToken(GetCurrentProcess(), + TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, + &hToken)) + { + priv.PrivilegeCount = 1; + priv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; + + if (LookupPrivilegeValueW(NULL, + SE_SYSTEMTIME_NAME, + &priv.Privileges[0].Luid)) + { + if (AdjustTokenPrivileges(hToken, + FALSE, + &priv, + sizeof(previouspriv), + &previouspriv, + &PrevSize) && + GetLastError() == ERROR_SUCCESS) + { + /* + * We successfully enabled it, we're permitted to change the time. + */ + Ret = SetSystemTime(lpSystemTime); + + /* + * For the sake of security, restore the previous status again + */ + if (previouspriv.PrivilegeCount > 0) + { + AdjustTokenPrivileges(hToken, + FALSE, + &previouspriv, + 0, + NULL, + 0); + } + } + } + CloseHandle(hToken); + } + + return Ret; +} + + +/* + * NTP servers state the number of seconds passed since + * 1st Jan, 1900. The time returned from the server + * needs adding to that date to get the current Gregorian time + */ +static VOID +UpdateSystemTime(ULONG ulTime) +{ + FILETIME ftNew; + LARGE_INTEGER li; + SYSTEMTIME stNew; + + /* Time at 1st Jan 1900 */ + stNew.wYear = 1900; + stNew.wMonth = 1; + stNew.wDay = 1; + stNew.wHour = 0; + stNew.wMinute = 0; + stNew.wSecond = 0; + stNew.wMilliseconds = 0; + + /* Convert to a file time */ + if (!SystemTimeToFileTime(&stNew, &ftNew)) + { + DisplayWin32Error(GetLastError()); + return; + } + + /* Add on the time passed since 1st Jan 1900 */ + li = *(LARGE_INTEGER *)&ftNew; + li.QuadPart += (LONGLONG)10000000 * ulTime; + ftNew = * (FILETIME *)&li; + + /* Convert back to a system time */ + if (!FileTimeToSystemTime(&ftNew, &stNew)) + { + DisplayWin32Error(GetLastError()); + return; + } + + if (!SystemSetTime(&stNew)) + { + DisplayWin32Error(GetLastError()); + } +} + + +VOID +SyncTimeNow(VOID) +{ + ULONG ulTime; + ulTime = GetTimeFromServer(); + if (ulTime != 0) + UpdateSystemTime(ulTime); +} +
5 years, 5 months
1
0
0
0
← Newer
1
...
10
11
12
13
14
15
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Results per page:
10
25
50
100
200