/*
 * Process Hacker Extra Plugins -
 *   DNS Cache Plugin
 *
 * Copyright (C) 2014 dmex
 *
 * This file is part of Process Hacker.
 *
 * Process Hacker is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Process Hacker is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Process Hacker.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _DNS_H_
#define _DNS_H_

#define PLUGIN_NAME L"dmex.DnsCachePlugin"
#define SETTING_NAME_WINDOW_POSITION (PLUGIN_NAME L".WindowPosition")
#define SETTING_NAME_WINDOW_SIZE (PLUGIN_NAME L".WindowSize")
#define SETTING_NAME_COLUMNS (PLUGIN_NAME L".WindowColumns")

#define DNSCACHE_MENUITEM   1000
#define INET_ADDRSTRLEN     22
#define INET6_ADDRSTRLEN    65

#define CINTERFACE
#define COBJMACROS
#include <phdk.h>
#include <phappresource.h>
#include "resource.h"

#include <windns.h>
#include <Winsock2.h>
#include <ws2tcpip.h>
#include <iphlpapi.h>

#pragma comment(lib, "Ws2_32.lib")

extern PPH_PLUGIN PluginInstance;

VOID ShowDnsCacheDialog(
    VOID
    );

typedef struct _DNS_CACHE_ENTRY
{
    struct _DNS_CACHE_ENTRY* Next;  // Pointer to next entry
    PCWSTR Name;                    // DNS Record Name
    USHORT Type;                    // DNS Record Type
    USHORT DataLength;              // Not referenced
    ULONG Flags;                    // DNS Record Flags
} DNS_CACHE_ENTRY, *PDNS_CACHE_ENTRY;

typedef DNS_STATUS (WINAPI* _DnsGetCacheDataTable)(
    _Inout_ PDNS_CACHE_ENTRY* DnsCacheEntry
    );

typedef BOOL (WINAPI* _DnsFlushResolverCache)(
    VOID
    );

typedef BOOL (WINAPI* _DnsFlushResolverCacheEntry)(
    _In_ PCWSTR Name
    );

#endif