[DNSAPI][PSDK] Implement GetCurrentTimeInSeconds() and fix DnsQuery_A/UTF8/W()
authorEric Kohl <eric.kohl@reactos.org>
Sat, 2 Nov 2019 22:59:06 +0000 (23:59 +0100)
committerEric Kohl <eric.kohl@reactos.org>
Sat, 2 Nov 2019 22:59:06 +0000 (23:59 +0100)
dll/win32/dnsapi/dnsapi/query.c
dll/win32/dnsapi/dnsapi/stubs.c
sdk/include/psdk/windns.h
sdk/include/reactos/windns_undoc.h

index 2daa280..f7de6ab 100644 (file)
@@ -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);
+}
index f474f34..0a4bf59 100644 (file)
@@ -807,13 +807,6 @@ DnsWriteReverseNameStringForIpAddress()
     return ERROR_OUTOFMEMORY;
 }
 
-DNS_STATUS WINAPI
-GetCurrentTimeInSeconds()
-{
-    UNIMPLEMENTED;
-    return ERROR_OUTOFMEMORY;
-}
-
 DNS_STATUS WINAPI
 DnsNotifyResolver()
 {
index c989c9b..0c7433d 100644 (file)
@@ -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);
 
index 01e6f41..cb2e5ab 100644 (file)
@@ -27,6 +27,10 @@ WINAPI
 DnsGetCacheDataTable(
     _Out_ PDNS_CACHE_ENTRY *DnsCache);
 
+DNS_STATUS
+WINAPI
+GetCurrentTimeInSeconds(VOID);
+
 #endif /* __WIDL__ */
 
 #ifdef __cplusplus