https://git.reactos.org/?p=reactos.git;a=commitdiff;h=894cc4ac0c9448d5502a3…
commit 894cc4ac0c9448d5502a3e8e7d37ff7a6512ea71
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Mon May 24 14:43:30 2021 +0200
Commit: Eric Kohl <eric.kohl(a)reactos.org>
CommitDate: Mon May 24 14:43:30 2021 +0200
[dnsapi][dnsrslvr] Implement DnsFlushResolverCacheEntry_A/_UTF8/_W
---
base/services/dnsrslvr/cache.c | 45 ++++++++++++++++
base/services/dnsrslvr/precomp.h | 5 ++
base/services/dnsrslvr/rpcserver.c | 22 +++++++-
dll/win32/dnsapi/dnsapi.spec | 4 +-
dll/win32/dnsapi/query.c | 99 ++++++++++++++++++++++++++++++++++++
dll/win32/dnsapi/stubs.c | 22 --------
sdk/include/reactos/idl/dnsrslvr.idl | 7 ++-
7 files changed, 177 insertions(+), 27 deletions(-)
diff --git a/base/services/dnsrslvr/cache.c b/base/services/dnsrslvr/cache.c
index b232989f372..c3be82ccde5 100644
--- a/base/services/dnsrslvr/cache.c
+++ b/base/services/dnsrslvr/cache.c
@@ -101,6 +101,51 @@ DnsIntCacheFlush(
return ERROR_SUCCESS;
}
+
+DNS_STATUS
+DnsIntFlushCacheEntry(
+ _In_ LPCWSTR pszName,
+ _In_ WORD wType)
+{
+ PLIST_ENTRY Entry, NextEntry;
+ PRESOLVER_CACHE_ENTRY CacheEntry;
+
+ DPRINT("DnsIntFlushCacheEntry(%S %x)\n", pszName, wType);
+
+ /* Lock the cache */
+ DnsCacheLock();
+
+ /* Loop every entry */
+ Entry = DnsCache.RecordList.Flink;
+ while (Entry != &DnsCache.RecordList)
+ {
+ NextEntry = Entry->Flink;
+
+ /* Get this entry */
+ CacheEntry = CONTAINING_RECORD(Entry, RESOLVER_CACHE_ENTRY, CacheLink);
+
+ /* Remove it from the list */
+ if ((_wcsicmp(CacheEntry->Record->pName, pszName) == 0) &&
+ (CacheEntry->bHostsFileEntry == FALSE))
+ {
+ if ((wType == DNS_TYPE_ANY) ||
+ (CacheEntry->Record->wType == wType))
+ {
+ DnsIntCacheRemoveEntryItem(CacheEntry);
+ }
+ }
+
+ /* Move to the next entry */
+ Entry = NextEntry;
+ }
+
+ /* Unlock the cache */
+ DnsCacheUnlock();
+
+ return ERROR_SUCCESS;
+}
+
+
DNS_STATUS
DnsIntCacheGetEntryByName(
LPCWSTR Name,
diff --git a/base/services/dnsrslvr/precomp.h b/base/services/dnsrslvr/precomp.h
index 2b7e5f35dd6..ac355a9f06f 100644
--- a/base/services/dnsrslvr/precomp.h
+++ b/base/services/dnsrslvr/precomp.h
@@ -52,6 +52,11 @@ DNS_STATUS
DnsIntCacheFlush(
_In_ ULONG ulFlags);
+DNS_STATUS
+DnsIntFlushCacheEntry(
+ _In_ LPCWSTR pszName,
+ _In_ WORD wType);
+
DNS_STATUS
DnsIntCacheGetEntryByName(
LPCWSTR Name,
diff --git a/base/services/dnsrslvr/rpcserver.c b/base/services/dnsrslvr/rpcserver.c
index 59e91cb4791..550e98786b1 100644
--- a/base/services/dnsrslvr/rpcserver.c
+++ b/base/services/dnsrslvr/rpcserver.c
@@ -60,15 +60,33 @@ CRrReadCache(
DWORD
__stdcall
R_ResolverFlushCache(
- _In_ DNSRSLVR_HANDLE pwszServerName)
+ _In_ DNSRSLVR_HANDLE pszServerName)
{
DPRINT("R_ResolverFlushCache(%S)\n",
- pwszServerName);
+ pszServerName);
return DnsIntCacheFlush(CACHE_FLUSH_NON_HOSTS_FILE_ENTRIES);
}
+/* Function: 0x05 */
+DWORD
+__stdcall
+R_ResolverFlushCacheEntry(
+ _In_ DNSRSLVR_HANDLE pszServerName,
+ _In_ LPCWSTR pszName,
+ _In_ WORD wType)
+{
+ DPRINT("R_ResolverFlushCacheEntry(%S %S %x)\n",
+ pszServerName, pszName, wType);
+
+ if (pszName == NULL)
+ return ERROR_INVALID_PARAMETER;
+
+ return DnsIntFlushCacheEntry(pszName, wType);
+}
+
+
/* Function: 0x07 */
DWORD
__stdcall
diff --git a/dll/win32/dnsapi/dnsapi.spec b/dll/win32/dnsapi/dnsapi.spec
index afc309e83bc..1b72ea192ca 100644
--- a/dll/win32/dnsapi/dnsapi.spec
+++ b/dll/win32/dnsapi/dnsapi.spec
@@ -39,8 +39,8 @@
@ stdcall DnsFindAuthoritativeZone()
@ stdcall DnsFlushResolverCache()
@ stdcall DnsFlushResolverCacheEntry_A(str)
-@ stdcall DnsFlushResolverCacheEntry_UTF8()
-@ stdcall DnsFlushResolverCacheEntry_W()
+@ stdcall DnsFlushResolverCacheEntry_UTF8(str)
+@ stdcall DnsFlushResolverCacheEntry_W(wstr)
@ stdcall DnsFree(ptr long)
@ stdcall DnsFreeAdapterInformation()
@ stub DnsFreeConfigStructure
diff --git a/dll/win32/dnsapi/query.c b/dll/win32/dnsapi/query.c
index 6dbe665473e..8006a3f60bd 100644
--- a/dll/win32/dnsapi/query.c
+++ b/dll/win32/dnsapi/query.c
@@ -951,6 +951,105 @@ DnsFlushResolverCache(VOID)
return (Status == ERROR_SUCCESS);
}
+
+BOOL
+WINAPI
+DnsFlushResolverCacheEntry_A(
+ _In_ LPCSTR pszEntry)
+{
+ DNS_STATUS Status = ERROR_SUCCESS;
+ LPWSTR pszUnicodeEntry;
+
+ DPRINT1("DnsFlushResolverCacheEntry_A(%s)\n", pszEntry);
+
+ if (pszEntry == NULL)
+ return FALSE;
+
+ pszUnicodeEntry = DnsCToW(pszEntry);
+ if (pszUnicodeEntry == NULL)
+ return FALSE;
+
+ RpcTryExcept
+ {
+ Status = R_ResolverFlushCacheEntry(NULL, pszUnicodeEntry, DNS_TYPE_ANY);
+ DPRINT("R_ResolverFlushCacheEntry() returned %lu\n", Status);
+ }
+ RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = RpcExceptionCode();
+ DPRINT("Exception returned %lu\n", Status);
+ }
+ RpcEndExcept;
+
+ RtlFreeHeap(RtlGetProcessHeap(), 0, pszUnicodeEntry);
+
+ return (Status == ERROR_SUCCESS);
+}
+
+
+BOOL
+WINAPI
+DnsFlushResolverCacheEntry_UTF8(
+ _In_ LPCSTR pszEntry)
+{
+ DNS_STATUS Status = ERROR_SUCCESS;
+ LPWSTR pszUnicodeEntry;
+
+ DPRINT1("DnsFlushResolverCacheEntry_UTF8(%s)\n", pszEntry);
+
+ if (pszEntry == NULL)
+ return FALSE;
+
+ pszUnicodeEntry = DnsCToW(pszEntry);
+ if (pszUnicodeEntry == NULL)
+ return FALSE;
+
+ RpcTryExcept
+ {
+ Status = R_ResolverFlushCacheEntry(NULL, pszUnicodeEntry, DNS_TYPE_ANY);
+ DPRINT("R_ResolverFlushCacheEntry() returned %lu\n", Status);
+ }
+ RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = RpcExceptionCode();
+ DPRINT("Exception returned %lu\n", Status);
+ }
+ RpcEndExcept;
+
+ RtlFreeHeap(RtlGetProcessHeap(), 0, pszUnicodeEntry);
+
+ return (Status == ERROR_SUCCESS);
+}
+
+
+BOOL
+WINAPI
+DnsFlushResolverCacheEntry_W(
+ _In_ LPCWSTR pszEntry)
+{
+ DNS_STATUS Status = ERROR_SUCCESS;
+
+ DPRINT1("DnsFlushResolverCacheEntry_W(%S)\n", pszEntry);
+
+ if (pszEntry == NULL)
+ return FALSE;
+
+ RpcTryExcept
+ {
+ Status = R_ResolverFlushCacheEntry(NULL, pszEntry, DNS_TYPE_ANY);
+ DPRINT("R_ResolverFlushCacheEntry() returned %lu\n", Status);
+ }
+ RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = RpcExceptionCode();
+ DPRINT("Exception returned %lu\n", Status);
+ }
+ RpcEndExcept;
+
+ return (Status == ERROR_SUCCESS);
+}
+
+
BOOL
WINAPI
DnsGetCacheDataTable(
diff --git a/dll/win32/dnsapi/stubs.c b/dll/win32/dnsapi/stubs.c
index 7d946ababfa..313792facda 100644
--- a/dll/win32/dnsapi/stubs.c
+++ b/dll/win32/dnsapi/stubs.c
@@ -216,28 +216,6 @@ DnsFindAuthoritativeZone()
return ERROR_OUTOFMEMORY;
}
-BOOL WINAPI
-DnsFlushResolverCacheEntry_A(PCSTR entry)
-{
- DPRINT1("DnsFlushResolverCacheEntry_A(%s) is stubplemented.\n", entry);
- if (!entry) return FALSE;
- return TRUE;
-}
-
-DNS_STATUS WINAPI
-DnsFlushResolverCacheEntry_UTF8()
-{
- UNIMPLEMENTED;
- return ERROR_OUTOFMEMORY;
-}
-
-DNS_STATUS WINAPI
-DnsFlushResolverCacheEntry_W()
-{
- UNIMPLEMENTED;
- return ERROR_OUTOFMEMORY;
-}
-
DNS_STATUS WINAPI
DnsFreeAdapterInformation()
{
diff --git a/sdk/include/reactos/idl/dnsrslvr.idl b/sdk/include/reactos/idl/dnsrslvr.idl
index 91cad5a52eb..ce4d3af41ae 100644
--- a/sdk/include/reactos/idl/dnsrslvr.idl
+++ b/sdk/include/reactos/idl/dnsrslvr.idl
@@ -50,7 +50,12 @@ interface DnsResolver
[in, unique, string] DNSRSLVR_HANDLE pwszServerName);
/* Function: 0x05 */
- /* R_ResolverFlushCacheEntry */
+ DWORD
+ __stdcall
+ R_ResolverFlushCacheEntry(
+ [in, unique, string] DNSRSLVR_HANDLE pwszServerName,
+ [in, string] LPCWSTR pszName,
+ [in] WORD wType);
/* Function: 0x06 */
/* R_ResolverRegisterCluster */