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)