[W32TIME] Implement a rudimentary version of W32TimeSyncNow. CORE-13001

This commit is contained in:
Thomas Faber 2018-06-03 16:28:57 +02:00
parent 1938b7484e
commit d19b792511
No known key found for this signature in database
GPG key ID: 076E7C3D44720826
9 changed files with 69 additions and 40 deletions

View file

@ -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)

View file

@ -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)

View file

@ -7,7 +7,7 @@
*
*/
#include "timedate.h"
#include "w32time.h"
#include <winsock2.h>

View file

@ -5,7 +5,7 @@
* COPYRIGHT: Copyright 2006 Ged Murphy <gedmurphy@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)
{

View file

@ -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 */

View file

@ -0,0 +1 @@
18 stdcall W32TimeSyncNow(wstr long long)

View file

@ -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)

View file

@ -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);

View file

@ -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)