diff --git a/crypto/bio/bss_dgram.c b/crypto/bio/bss_dgram.c index 7b87a043c430fbe21691a1514f0206c87a22d2e5..d121386a52abd9ea9109e27c1faee4cda6efe35d 100644 --- a/crypto/bio/bss_dgram.c +++ b/crypto/bio/bss_dgram.c @@ -1895,11 +1895,15 @@ int BIO_dgram_non_fatal_error(int err) static void get_current_time(struct timeval *t) { -#ifdef OPENSSL_SYS_WIN32 - struct _timeb tb; - _ftime(&tb); - t->tv_sec = (long)tb.time; - t->tv_usec = (long)tb.millitm * 1000; +#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WINCE) + SYSTEMTIME st; + union { unsigned __int64 ul; FILETIME ft; } now; + + GetSystemTime(&st); + SystemTimeToFileTime(&st,&now.ft); + now.ul -= 116444736000000000UI64; /* re-bias to 1/1/1970 */ + t->tv_sec = (long)(now.ul/10000000); + t->tv_usec = ((int)(now.ul%10000000))/10; #elif defined(OPENSSL_SYS_VMS) struct timeb tb; ftime(&tb); diff --git a/ssl/d1_lib.c b/ssl/d1_lib.c index f61f718183083ff23bcbb281c777ee6f9bd364ae..048ce3b4b088a76e9a9cec43d5cb4a476f8e19ba 100644 --- a/ssl/d1_lib.c +++ b/ssl/d1_lib.c @@ -452,11 +452,15 @@ int dtls1_handle_timeout(SSL *s) static void get_current_time(struct timeval *t) { -#ifdef OPENSSL_SYS_WIN32 - struct _timeb tb; - _ftime(&tb); - t->tv_sec = (long)tb.time; - t->tv_usec = (long)tb.millitm * 1000; +#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WINCE) + SYSTEMTIME st; + union { unsigned __int64 ul; FILETIME ft; } now; + + GetSystemTime(&st); + SystemTimeToFileTime(&st,&now.ft); + now.ul -= 116444736000000000UI64; /* re-bias to 1/1/1970 */ + t->tv_sec = (long)(now.ul/10000000); + t->tv_usec = ((int)(now.ul%10000000))/10; #elif defined(OPENSSL_SYS_VMS) struct timeb tb; ftime(&tb);