mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 00:45:24 +00:00
[W32TIME] Implement a rudimentary version of W32TimeSyncNow. CORE-13001
This commit is contained in:
parent
1938b7484e
commit
d19b792511
9 changed files with 69 additions and 40 deletions
|
@ -14,6 +14,7 @@ add_subdirectory(tcpsvcs)
|
||||||
add_subdirectory(telnetd)
|
add_subdirectory(telnetd)
|
||||||
add_subdirectory(tftpd)
|
add_subdirectory(tftpd)
|
||||||
add_subdirectory(umpnpmgr)
|
add_subdirectory(umpnpmgr)
|
||||||
|
add_subdirectory(w32time)
|
||||||
add_subdirectory(wkssvc)
|
add_subdirectory(wkssvc)
|
||||||
add_subdirectory(wlansvc)
|
add_subdirectory(wlansvc)
|
||||||
add_subdirectory(wmisvc)
|
add_subdirectory(wmisvc)
|
||||||
|
|
12
base/services/w32time/CMakeLists.txt
Normal file
12
base/services/w32time/CMakeLists.txt
Normal 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)
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "timedate.h"
|
#include "w32time.h"
|
||||||
|
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* COPYRIGHT: Copyright 2006 Ged Murphy <gedmurphy@gmail.com>
|
* COPYRIGHT: Copyright 2006 Ged Murphy <gedmurphy@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "timedate.h"
|
#include "w32time.h"
|
||||||
|
|
||||||
/* Get the domain name from the registry */
|
/* Get the domain name from the registry */
|
||||||
static DWORD
|
static DWORD
|
||||||
|
@ -207,11 +207,14 @@ UpdateSystemTime(ULONG ulTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DWORD
|
DWORD WINAPI
|
||||||
SyncTimeNow(VOID)
|
W32TimeSyncNow(LPCWSTR cmdline,
|
||||||
|
UINT blocking,
|
||||||
|
UINT flags)
|
||||||
{
|
{
|
||||||
DWORD dwError;
|
DWORD dwError;
|
||||||
ULONG ulTime;
|
ULONG ulTime;
|
||||||
|
|
||||||
dwError = GetTimeFromServer(&ulTime);
|
dwError = GetTimeFromServer(&ulTime);
|
||||||
if (dwError != ERROR_SUCCESS)
|
if (dwError != ERROR_SUCCESS)
|
||||||
{
|
{
|
44
base/services/w32time/w32time.h
Normal file
44
base/services/w32time/w32time.h
Normal 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 */
|
1
base/services/w32time/w32time.spec
Normal file
1
base/services/w32time/w32time.spec
Normal file
|
@ -0,0 +1 @@
|
||||||
|
18 stdcall W32TimeSyncNow(wstr long long)
|
|
@ -6,10 +6,8 @@ list(APPEND SOURCE
|
||||||
dateandtime.c
|
dateandtime.c
|
||||||
internettime.c
|
internettime.c
|
||||||
monthcal.c
|
monthcal.c
|
||||||
ntpclient.c
|
|
||||||
timedate.c
|
timedate.c
|
||||||
timezone.c
|
timezone.c
|
||||||
w32time.c
|
|
||||||
timedate.h)
|
timedate.h)
|
||||||
|
|
||||||
file(GLOB timedate_rc_deps resources/*.*)
|
file(GLOB timedate_rc_deps resources/*.*)
|
||||||
|
@ -21,6 +19,6 @@ add_library(timedate MODULE
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/timedate.def)
|
${CMAKE_CURRENT_BINARY_DIR}/timedate.def)
|
||||||
|
|
||||||
set_module_type(timedate cpl UNICODE)
|
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_pch(timedate timedate.h SOURCE)
|
||||||
add_cd_file(TARGET timedate DESTINATION reactos/system32 FOR all)
|
add_cd_file(TARGET timedate DESTINATION reactos/system32 FOR all)
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
#include "timedate.h"
|
#include "timedate.h"
|
||||||
|
|
||||||
|
DWORD WINAPI W32TimeSyncNow(LPCWSTR cmdline, UINT blocking, UINT flags);
|
||||||
|
|
||||||
static VOID
|
static VOID
|
||||||
CreateNTPServerList(HWND hwnd)
|
CreateNTPServerList(HWND hwnd)
|
||||||
{
|
{
|
||||||
|
@ -208,7 +210,7 @@ InetTimePageProc(HWND hwndDlg,
|
||||||
|
|
||||||
SetNTPServer(hwndDlg);
|
SetNTPServer(hwndDlg);
|
||||||
|
|
||||||
dwError = SyncTimeNow();
|
dwError = W32TimeSyncNow(L"localhost", 0, 0);
|
||||||
if (dwError != ERROR_SUCCESS)
|
if (dwError != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
DisplayWin32Error(dwError);
|
DisplayWin32Error(dwError);
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#define MAX_VALUE_NAME 16383
|
#define MAX_VALUE_NAME 16383
|
||||||
#define SERVERLISTSIZE 6
|
#define SERVERLISTSIZE 6
|
||||||
#define BUFSIZE 1024
|
#define BUFSIZE 1024
|
||||||
#define NTPPORT 123
|
|
||||||
#define ID_TIMER 1
|
#define ID_TIMER 1
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -67,37 +66,6 @@ BOOL RegisterClockControl(VOID);
|
||||||
VOID UnregisterClockControl(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 */
|
/* monthcal.c */
|
||||||
#define MCCM_SETDATE (WM_USER + 1)
|
#define MCCM_SETDATE (WM_USER + 1)
|
||||||
#define MCCM_GETDATE (WM_USER + 2)
|
#define MCCM_GETDATE (WM_USER + 2)
|
||||||
|
|
Loading…
Reference in a new issue