Revision: 9125 https://osdn.net/projects/ttssh2/scm/svn/commits/9125 Author: zmatsuo Date: 2021-01-16 14:20:14 +0900 (Sat, 16 Jan 2021) Log Message: ----------- dnsapi.dll の DnsQuery_A(), DnsFree() を遅延ロード指定なしで使えるようにした - compat_win に追加 Modified Paths: -------------- trunk/teraterm/common/compat_win.cpp trunk/ttssh2/ttxssh/dns.c trunk/ttssh2/ttxssh/dns.h Added Paths: ----------- trunk/teraterm/common/compat_windns.h -------------- next part -------------- Modified: trunk/teraterm/common/compat_win.cpp =================================================================== --- trunk/teraterm/common/compat_win.cpp 2021-01-16 05:19:55 UTC (rev 9124) +++ trunk/teraterm/common/compat_win.cpp 2021-01-16 05:20:14 UTC (rev 9125) @@ -30,7 +30,10 @@ #include <windows.h> #include <tchar.h> +#include <windns.h> + #include "compat_win.h" +#include "compat_windns.h" #include "dllutil.h" #include "ttlib.h" @@ -134,6 +137,10 @@ BOOL (WINAPI *pGetOpenFileNameW)(LPOPENFILENAMEW ofnW); BOOL (WINAPI *pGetSaveFileNameW)(LPOPENFILENAMEW ofnW); +// dnsapi +DNS_STATUS (WINAPI *pDnsQuery_A)(PCSTR pszName, WORD wType, DWORD Options, PVOID pExtra, PDNS_RECORD *ppQueryResults, PVOID *pReserved); +VOID (WINAPI *pDnsFree)(PVOID pData, DNS_FREE_TYPE FreeType); + /** * GetConsoleWindow() \x82Ɠ\xAF\x82\xB6\x93\xAE\x8D\xEC\x82\xF0\x82\xB7\x82\xE9 * https://support.microsoft.com/ja-jp/help/124103/how-to-obtain-a-console-window-handle-hwnd @@ -292,8 +299,12 @@ {}, }; +static const APIInfo Lists_dnsapi[] = { + { "DnsQuery_A", (void **)&pDnsQuery_A }, + { "DnsFree", (void **)&pDnsFree }, + {}, +}; - static const DllInfo DllInfos[] = { { _T("user32.dll"), DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_user32 }, { _T("msimg32.dll"), DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_msimg32 }, @@ -304,6 +315,7 @@ { _T("Comctl32.dll"), DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_comctl32 }, { _T("hhctrl.ocx"), DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_hhctrl }, { _T("comdlg32.dll"), DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_comdlg32 }, + { _T("dnsapi.dll"), DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_dnsapi }, {}, }; Copied: trunk/teraterm/common/compat_windns.h (from rev 9124, trunk/ttssh2/ttxssh/dns.h) =================================================================== --- trunk/teraterm/common/compat_windns.h (rev 0) +++ trunk/teraterm/common/compat_windns.h 2021-01-16 05:20:14 UTC (rev 9125) @@ -0,0 +1,43 @@ +/* + * (C) 2018-2020 TeraTerm Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include <windns.h> + +#ifdef __cplusplus +extern "C" { +#endif + +// windns +extern DNS_STATUS (WINAPI *pDnsQuery_A)(PCSTR pszName, WORD wType, DWORD Options, PVOID pExtra, PDNS_RECORD *ppQueryResults, PVOID *pReserved); +extern VOID (WINAPI *pDnsFree)(PVOID pData, DNS_FREE_TYPE FreeType); + +#ifdef __cplusplus +} +#endif Modified: trunk/ttssh2/ttxssh/dns.c =================================================================== --- trunk/ttssh2/ttxssh/dns.c 2021-01-16 05:19:55 UTC (rev 9124) +++ trunk/ttssh2/ttxssh/dns.c 2021-01-16 05:20:14 UTC (rev 9125) @@ -32,6 +32,7 @@ #include "ssh.h" #include "key.h" #include "dns.h" +#include "compat_windns.h" //#include <windns.h> int is_numeric_hostname(const char *hostname) { @@ -63,7 +64,7 @@ BYTE *hostkey_digest = NULL; int found = DNS_VERIFY_NOTFOUND; - if (!HasDnsQuery()) { + if (pDnsQuery_A == NULL) { // DnsQuery \x82\xCD Windows 2000 \x88ȏ\xE3\x82ł\xB5\x82\xA9\x93\xAE\x8D삵\x82Ȃ\xA2\x82\xBD\x82\xDF return DNS_VERIFY_NONE; } @@ -88,7 +89,7 @@ } logprintf(LOG_LEVEL_VERBOSE, "verify_hostkey_dns: key type = %d, SSHFP type = %d", key->type, hostkey_alg); - status = DnsQuery(hostname, DNS_TYPE_SSHFP, DNS_QUERY_STANDARD, NULL, &rec, NULL); + status = pDnsQuery_A(hostname, DNS_TYPE_SSHFP, DNS_QUERY_STANDARD, NULL, &rec, NULL); if (status == 0) { for (p=rec; p!=NULL; p=p->pNext) { @@ -153,7 +154,7 @@ logprintf(LOG_LEVEL_VERBOSE, "verify_hostkey_dns: not SSHFP RR (%d)", p->wType); } } - DnsRecordListFree(rec, DnsFreeRecordList); + pDnsFree(rec, DnsFreeRecordList); } else { logputs(LOG_LEVEL_VERBOSE, "verify_hostkey_dns: DnsQuery failed."); Modified: trunk/ttssh2/ttxssh/dns.h =================================================================== --- trunk/ttssh2/ttxssh/dns.h 2021-01-16 05:19:55 UTC (rev 9124) +++ trunk/ttssh2/ttxssh/dns.h 2021-01-16 05:20:14 UTC (rev 9125) @@ -29,8 +29,6 @@ #ifndef __TTSSH_DNS_H #define __TTSSH_DNS_H -#include <windns.h> - #define DNS_TYPE_SSHFP 44 enum sshfp_types {