Just a small comment... You code god already know the structure of IcmpSendEcho, anyway here it is:
Code:
//From MSDN
DWORD IcmpSendEcho(
HANDLE IcmpHandle,
IPAddr DestinationAddress,
LPVOID RequestData,
WORD RequestSize,
PIP_OPTION_INFORMATION RequestOptions,
LPVOID ReplyBuffer,
DWORD ReplySize,
DWORD Timeout
);
Parameters
IcmpHandle
[in] Open handle returned by IcmpCreateFile.
DestinationAddress
[in] Specifies the destination of the echo request.
RequestData
[in] Specifies the buffer that contains the data to send in the request.
RequestSize
[in] Specifies the number of bytes in the request data buffer.
RequestOptions
ReplyBuffer
[out] Buffer to hold any replies to the request. Upon return, the buffer contains an array of ICMP_ECHO_REPLY structures followed by the options and data for the replies. The buffer should be large enough to hold at least one ICMP_ECHO_REPLY structure plus MAX(RequestSize, 8) bytes of data since an ICMP error message contains 8 bytes of data.
ReplySize
[out] Receives the size in bytes of the reply buffer.
Timeout
[out] Recieves the time in milliseconds to wait for replies.
Return Values
Returns the number of ICMP_ECHO_REPLY structures stored in ReplyBuffer. The status of each reply is contained in the structure. If the return value is zero, see the extended error information available through GetLastError.
So, what my lame brain allows me to understand is that if thereīs some reply in a time lower than the Timeout value, the function will return immediately after this reply and the return value will be '1' because thereīs ONE reply in the buffer and if thereīs no reply and the Timeout value is reached the function will return immediately at the Timeout time and the return value will be '0' because there is no reply in the buffer. Do this really works like that? Or am I misunderstanding everything?