[IPHLPAPI] Make icmp functions use IOCTL_ICMP_ECHO_REQUEST from tcpip.sys

This adds missing features like using events and APCs within IcmpSendEcho2
functions and others.
CORE-10742 CORE-14411

Co-authored-by: Tim Crawford <crawfxrd@gmail.com>
This commit is contained in:
Victor Perevertkin 2019-11-18 20:54:03 +03:00 committed by Victor Perevertkin
parent cf3ab9d15a
commit dd2ff41dfc
4 changed files with 525 additions and 1078 deletions

File diff suppressed because it is too large Load diff

View file

@ -80,11 +80,11 @@
@ stub GetUdpTableFromStack
@ stdcall GetUniDirectionalAdapterInfo( ptr ptr )
@ stdcall Icmp6CreateFile()
@ stdcall -stub Icmp6ParseReplies(ptr long)
@ stdcall Icmp6ParseReplies(ptr long)
@ stdcall Icmp6SendEcho2(ptr ptr ptr ptr ptr ptr ptr long ptr ptr long long)
@ stdcall IcmpCloseHandle(ptr)
@ stdcall IcmpCreateFile()
@ stdcall -stub IcmpParseReplies(ptr long)
@ stdcall IcmpParseReplies(ptr long)
@ stdcall IcmpSendEcho2(ptr ptr ptr ptr long ptr long ptr ptr long long)
@ stdcall IcmpSendEcho(ptr long ptr long ptr ptr long long)
@ stub InternalCreateIpForwardEntry

View file

@ -28,14 +28,14 @@ typedef ULONG IPAddr;
typedef ULONG IPMask;
typedef ULONG IP_STATUS;
struct ip_option_information
typedef struct ip_option_information
{
unsigned char Ttl;
unsigned char Tos;
unsigned char Flags;
unsigned char OptionsSize;
unsigned char* OptionsData;
};
} IP_OPTION_INFORMATION, *PIP_OPTION_INFORMATION;
#if defined(_WIN64)
@ -64,20 +64,31 @@ struct ip_option_information32
#define MAX_OPT_SIZE 40
struct icmp_echo_reply
typedef struct icmp_echo_request
{
IPAddr Address;
ULONG Status;
ULONG RoundTripTime;
unsigned short DataSize;
unsigned short Reserved;
void* Data;
struct ip_option_information Options;
};
IPAddr Address;
UINT32 Timeout;
UINT16 DataOffset;
UINT16 DataSize;
UINT8 HasOptions;
UINT8 Ttl;
UINT8 Tos;
UINT8 Flags;
UINT16 OptionsOffset;
UINT8 OptionsSize;
UINT8 Padding;
} ICMP_ECHO_REQUEST, *PICMP_ECHO_REQUEST;
typedef struct ip_option_information IP_OPTION_INFORMATION, *PIP_OPTION_INFORMATION;
typedef struct icmp_echo_reply ICMP_ECHO_REPLY, *PICMP_ECHO_REPLY;
typedef struct icmp_echo_reply
{
IPAddr Address;
UINT32 Status;
UINT32 RoundTripTime;
UINT16 DataSize;
UINT16 Reserved;
PVOID Data;
IP_OPTION_INFORMATION Options;
} ICMP_ECHO_REPLY, *PICMP_ECHO_REPLY;
#ifdef _WIN64
struct icmp_echo_reply32
@ -164,6 +175,16 @@ typedef struct _IPV6_ADDRESS_EX {
} IPV6_ADDRESS_EX, *PIPV6_ADDRESS_EX;
#include <poppack.h>
typedef struct _ICMPV6_ECHO_REQUEST
{
IPV6_ADDRESS_EX DestinationAddress;
IPV6_ADDRESS_EX SourceAddress;
UINT32 Timeout;
UINT16 Unknown1;
UINT16 Ttl; // XXX: These seem unnecessarily large.
UINT32 Flags; // Is something else in the struct?
} ICMPV6_ECHO_REQUEST, *PICMPV6_ECHO_REQUEST;
typedef struct icmpv6_echo_reply_lh {
IPV6_ADDRESS_EX Address;
ULONG Status;

View file

@ -46,6 +46,9 @@
#define IOCTL_DELETE_IP_ADDRESS \
_TCP_CTL_CODE(16, METHOD_BUFFERED, FILE_WRITE_ACCESS)
#define IOCTL_ICMP_ECHO_REQUEST \
_TCP_CTL_CODE(0, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IF_MIB_STATS_ID 1
#define IP_MIB_STATS_ID 1
#define IP_MIB_ARPTABLE_ENTRY_ID 0x101