int ReplyCame(PVOID param)
{
char* szAddr = (char*) param;
printf("Replay Came for %s......\n", szAddr);
return 0;
}
char* szAddr1 = "172.18.1.1";
char* szAddr2 = "172.18.1.4";
int _tmain(int argc, _TCHAR* argv[])
{
char *SendData = "Data Buffer";
LPVOID ReplyBuffer;
HANDLE IcmpHandle = IcmpCreateFile();
IPAddr addr1 = inet_addr(szAddr1);
IPAddr addr2 = inet_addr(szAddr2);
ReplyBuffer = (VOID*) malloc(sizeof(ICMP_ECHO_REPLY) + sizeof(SendData));
IcmpSendEcho2(IcmpHandle, NULL, (FARPROC)ReplyCame, szAddr1, addr1,
SendData, sizeof(SendData), NULL, ReplyBuffer, 8*sizeof(ReplyBuffer) +
sizeof(ICMP_ECHO_REPLY), 1000);
IcmpSendEcho2(IcmpHandle, NULL, (FARPROC)ReplyCame, szAddr2, addr2,
SendData, sizeof(SendData), NULL, ReplyBuffer, 8*sizeof(ReplyBuffer) +
sizeof(ICMP_ECHO_REPLY), 1000);
SleepEx(5000, TRUE);
return 0;
}
请注意,如果您想使用replyBuffer,您需要先使用IcmpParseReplies 对其进行解析。