Ping Program - C++ : Can you modify this working program

G

Guest

Guest
Archived from groups: microsoft.public.windowsnt.protocol.tcpip (More info?)

Can you help me make some minor modifications to this working sample of
code?

The source code below will compile and run. I want to use the icmp.dll,
because it will run without administrator rights.

Here is what I would like:

1. Modify source code to send this byte array:

// static Byte requestData[] =
{0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0
x68,0x69};

2. Make the PIP_OPTION_INFORMATION parameter work for IcmpSendEcho() method.


// Begin Source
/*
#include <windows.h> #include <ipexport.h>#include <icmpapi.h>#include
<stdio.h>
Link to: icmp.lib ws2_32.lib
You may have to add additional library directory for icmp.lib.
*/

HANDLE icmphandle = IcmpCreateFile();
char reply[sizeof(icmp_echo_reply)+8];
icmp_echo_reply* iep = (icmp_echo_reply*)&reply;
iep->RoundTripTime = 0xffffffff;

DWORD dwReturn = IcmpSendEcho(icmphandle, inet_addr("204.212.40.1") , 0,
0, NULL, reply, sizeof(icmp_echo_reply)+8, PING_TIMEOUT);

if(dwReturn != 0)
{
printf("Ping Success: %ld ms\n", iep->RoundTripTime);
}
IcmpCloseHandle(icmphandle);
// End Source

Thanks
Russell Mangel
Las Vegs, NV
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsnt.protocol.tcpip (More info?)

Look at my answer on kernel group and use cross-posting in future
Arkady
"Russell Mangel" <russell@tymer.net> wrote in message
news:eWwUOcWIFHA.580@TK2MSFTNGP15.phx.gbl...
> Can you help me make some minor modifications to this working sample of
> code?
>
> The source code below will compile and run. I want to use the icmp.dll,
> because it will run without administrator rights.
>
> Here is what I would like:
>
> 1. Modify source code to send this byte array:
>
> // static Byte requestData[] =
> {0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
> 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0
> x68,0x69};
>
> 2. Make the PIP_OPTION_INFORMATION parameter work for IcmpSendEcho()
> method.
>
>
> // Begin Source
> /*
> #include <windows.h> #include <ipexport.h>#include <icmpapi.h>#include
> <stdio.h>
> Link to: icmp.lib ws2_32.lib
> You may have to add additional library directory for icmp.lib.
> */
>
> HANDLE icmphandle = IcmpCreateFile();
> char reply[sizeof(icmp_echo_reply)+8];
> icmp_echo_reply* iep = (icmp_echo_reply*)&reply;
> iep->RoundTripTime = 0xffffffff;
>
> DWORD dwReturn = IcmpSendEcho(icmphandle, inet_addr("204.212.40.1") ,
> 0,
> 0, NULL, reply, sizeof(icmp_echo_reply)+8, PING_TIMEOUT);
>
> if(dwReturn != 0)
> {
> printf("Ping Success: %ld ms\n", iep->RoundTripTime);
> }
> IcmpCloseHandle(icmphandle);
> // End Source
>
> Thanks
> Russell Mangel
> Las Vegs, NV
>
>