https://git.reactos.org/?p=reactos.git;a=commitdiff;h=158fda5cdffe09626a097…
commit 158fda5cdffe09626a09730f9a0832b0d7ea9353
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Sat Nov 2 23:59:06 2019 +0100
Commit: Eric Kohl <eric.kohl(a)reactos.org>
CommitDate: Sat Nov 2 23:59:06 2019 +0100
[DNSAPI][PSDK] Implement GetCurrentTimeInSeconds() and fix DnsQuery_A/UTF8/W()
---
dll/win32/dnsapi/dnsapi/query.c | 44 +++++++++++++++++++++++---------------
dll/win32/dnsapi/dnsapi/stubs.c | 7 ------
sdk/include/psdk/windns.h | 6 +++---
sdk/include/reactos/windns_undoc.h | 4 ++++
4 files changed, 34 insertions(+), 27 deletions(-)
diff --git a/dll/win32/dnsapi/dnsapi/query.c b/dll/win32/dnsapi/dnsapi/query.c
index 2daa2803663..f7de6ab96c8 100644
--- a/dll/win32/dnsapi/dnsapi/query.c
+++ b/dll/win32/dnsapi/dnsapi/query.c
@@ -16,6 +16,7 @@
#define NDEBUG
#include <debug.h>
+
/* DnsQuery ****************************
* Begin a DNS query, and allow the result to be placed in the application
* supplied result pointer. The result can be manipulated with the record
@@ -155,7 +156,7 @@ DnsQuery_CodePage(UINT CodePage,
LPCSTR Name,
WORD Type,
DWORD Options,
- PIP4_ARRAY Servers,
+ PVOID Extra,
PDNS_RECORD *QueryResultSet,
PVOID *Reserved)
{
@@ -163,7 +164,7 @@ DnsQuery_CodePage(UINT CodePage,
PWCHAR Buffer;
DNS_STATUS Status;
PDNS_RECORD QueryResultWide;
- PDNS_RECORD ConvertedRecord = 0, LastRecord = 0;
+ PDNS_RECORD ConvertedRecord = NULL, LastRecord = NULL;
if (Name == NULL)
return ERROR_INVALID_PARAMETER;
@@ -184,7 +185,7 @@ DnsQuery_CodePage(UINT CodePage,
return ERROR_INVALID_PARAMETER;
}
- Status = DnsQuery_W(Buffer, Type, Options, Servers, &QueryResultWide, Reserved);
+ Status = DnsQuery_W(Buffer, Type, Options, Extra, &QueryResultWide, Reserved);
while (Status == ERROR_SUCCESS && QueryResultWide)
{
@@ -308,7 +309,7 @@ DnsQuery_CodePage(UINT CodePage,
}
if (LastRecord)
- LastRecord->pNext = 0;
+ LastRecord->pNext = NULL;
/* The name */
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
@@ -322,22 +323,22 @@ DNS_STATUS WINAPI
DnsQuery_A(LPCSTR Name,
WORD Type,
DWORD Options,
- PIP4_ARRAY Servers,
+ PVOID Extra,
PDNS_RECORD *QueryResultSet,
PVOID *Reserved)
{
- return DnsQuery_CodePage(CP_ACP, Name, Type, Options, Servers, QueryResultSet,
Reserved);
+ return DnsQuery_CodePage(CP_ACP, Name, Type, Options, Extra, QueryResultSet,
Reserved);
}
DNS_STATUS WINAPI
DnsQuery_UTF8(LPCSTR Name,
WORD Type,
DWORD Options,
- PIP4_ARRAY Servers,
+ PVOID Extra,
PDNS_RECORD *QueryResultSet,
PVOID *Reserved)
{
- return DnsQuery_CodePage(CP_UTF8, Name, Type, Options, Servers, QueryResultSet,
Reserved);
+ return DnsQuery_CodePage(CP_UTF8, Name, Type, Options, Extra, QueryResultSet,
Reserved);
}
WCHAR
@@ -725,7 +726,7 @@ DNS_STATUS WINAPI
DnsQuery_W(LPCWSTR Name,
WORD Type,
DWORD Options,
- PIP4_ARRAY Servers,
+ PVOID Extra,
PDNS_RECORD *QueryResultSet,
PVOID *Reserved)
{
@@ -922,14 +923,6 @@ DnsQuery_W(LPCWSTR Name,
}
RtlFreeHeap(RtlGetProcessHeap(), 0, network_info);
- if (Servers)
- {
- for (i = 0; i < Servers->AddrCount; i++)
- {
- adns_addserver(astate, *((struct in_addr
*)&Servers->AddrArray[i]));
- }
- }
-
if (!adns_numservers(astate))
{
/* There are no servers to query so bail out */
@@ -1095,3 +1088,20 @@ DnsFlushResolverCache(VOID)
return (Status == ERROR_SUCCESS);
}
+
+DNS_STATUS
+WINAPI
+GetCurrentTimeInSeconds(VOID)
+{
+ FILETIME Time;
+ FILETIME Adjustment;
+ ULARGE_INTEGER lTime, lAdj;
+ SYSTEMTIME st = {1970, 1, 0, 1, 0, 0, 0};
+
+ SystemTimeToFileTime(&st, &Adjustment);
+ memcpy(&lAdj, &Adjustment, sizeof(lAdj));
+ GetSystemTimeAsFileTime(&Time);
+ memcpy(&lTime, &Time, sizeof(lTime));
+ lTime.QuadPart -= lAdj.QuadPart;
+ return (DWORD)(lTime.QuadPart/10000000LLU);
+}
diff --git a/dll/win32/dnsapi/dnsapi/stubs.c b/dll/win32/dnsapi/dnsapi/stubs.c
index f474f34695b..0a4bf59db55 100644
--- a/dll/win32/dnsapi/dnsapi/stubs.c
+++ b/dll/win32/dnsapi/dnsapi/stubs.c
@@ -807,13 +807,6 @@ DnsWriteReverseNameStringForIpAddress()
return ERROR_OUTOFMEMORY;
}
-DNS_STATUS WINAPI
-GetCurrentTimeInSeconds()
-{
- UNIMPLEMENTED;
- return ERROR_OUTOFMEMORY;
-}
-
DNS_STATUS WINAPI
DnsNotifyResolver()
{
diff --git a/sdk/include/psdk/windns.h b/sdk/include/psdk/windns.h
index c989c9b4809..0c7433de660 100644
--- a/sdk/include/psdk/windns.h
+++ b/sdk/include/psdk/windns.h
@@ -741,7 +741,7 @@ DnsQuery_A(
_In_ PCSTR pszName,
_In_ WORD wType,
_In_ DWORD Options,
- _Inout_opt_ PIP4_ARRAY pExtra,
+ _Inout_opt_ PVOID pExtra,
_Outptr_result_maybenull_ PDNS_RECORD *ppQueryResults,
_Outptr_opt_result_maybenull_ PVOID *pReserved);
@@ -751,7 +751,7 @@ DnsQuery_W(
_In_ PCWSTR pszName,
_In_ WORD wType,
_In_ DWORD Options,
- _Inout_opt_ PIP4_ARRAY pExtra,
+ _Inout_opt_ PVOID pExtra,
_Outptr_result_maybenull_ PDNS_RECORD *ppQueryResults,
_Outptr_opt_result_maybenull_ PVOID *pReserved);
@@ -761,7 +761,7 @@ DnsQuery_UTF8(
_In_ PCSTR pszName,
_In_ WORD wType,
_In_ DWORD Options,
- _Inout_opt_ PIP4_ARRAY pExtra,
+ _Inout_opt_ PVOID pExtra,
_Outptr_result_maybenull_ PDNS_RECORD *ppQueryResults,
_Outptr_opt_result_maybenull_ PVOID *pReserved);
diff --git a/sdk/include/reactos/windns_undoc.h b/sdk/include/reactos/windns_undoc.h
index 01e6f412095..cb2e5abdbe4 100644
--- a/sdk/include/reactos/windns_undoc.h
+++ b/sdk/include/reactos/windns_undoc.h
@@ -27,6 +27,10 @@ WINAPI
DnsGetCacheDataTable(
_Out_ PDNS_CACHE_ENTRY *DnsCache);
+DNS_STATUS
+WINAPI
+GetCurrentTimeInSeconds(VOID);
+
#endif /* __WIDL__ */
#ifdef __cplusplus