mIRC Homepage

Implementing Internet Pings using Icmp.dll

Posted By: sazeMaster

Implementing Internet Pings using Icmp.dll - 23/11/05 02:09 PM

Hi! I just wonder if there is a method to implement the ICMP INTERNET PING into mIRC, maybe in mIRCscript, using the dll Icmp.dll located by default in the directory C:\Windows\System32\ in my windows xp.
I know pretty well mirc script but that's is the first time to me, with dlls stuff, and I don't know where to move my steps..
I've tried something like
//echo -a * $dll(C:\Windows\System32\Icmp.dll,ICMPSendEcho,www.google.com)
and mIRC crashes laugh ... i was just trying...
I've already searched in google but without finding somtin' good :\

So.. can you help me? :tongue:
Posted By: Sat

Re: Implementing Internet Pings using Icmp.dll - 23/11/05 02:22 PM

You cannot use icmp.dll directly from mIRC; I have written a mIRC DLL that can use it, but I haven't gotten around to writing all of the documentation for it yet. If I remember, I'll post a message here when it's done. smile
Posted By: sazeMaster

Re: Implementing Internet Pings using Icmp.dll - 23/11/05 02:34 PM

Quote:
You cannot use icmp.dll directly from mIRC; I have written a mIRC DLL that can use it, but I haven't gotten around to writing all of the documentation for it yet. If I remember, I'll post a message here when it's done. smile


OMG u'r great!! smile)
But, I think that "just" the dll would be fine, I don't mind to read all the documentation smirk smile can you send me the dll if it works? :P
I really appreciate that ^_^ :*
Posted By: FiberOPtics

Re: Implementing Internet Pings using Icmp.dll - 23/11/05 02:38 PM

What's wrong with using ping.exe or tracert.exe etc?
Posted By: sazeMaster

Re: Implementing Internet Pings using Icmp.dll - 23/11/05 02:44 PM

Quote:
What's wrong with using ping.exe or tracert.exe etc?


Uhmm.. if u can trig the results, nothing! cool
Posted By: FiberOPtics

Re: Implementing Internet Pings using Icmp.dll - 23/11/05 02:45 PM

Trig the results? You mean you want to be able to return the results to mIRC? Yes that can be done, just export it to a file when you call it with /run.
Posted By: sazeMaster

Re: Implementing Internet Pings using Icmp.dll - 23/11/05 02:49 PM

Quote:
Trig the results? You mean you want to be able to return the results to mIRC? Yes that can be done, just export it to a file when you call it with /run.

oh gosh.. I don't ever know this feature..

And, would not be a little bit slow to run the ping.exe, write down the results, make a $read and manipulate them?
Posted By: Sat

Re: Implementing Internet Pings using Icmp.dll - 23/11/05 02:53 PM

Okay then, you can get a copy of the DLL and partial documentation (which you are going to need, even though it's not complete) here.
Posted By: FiberOPtics

Re: Implementing Internet Pings using Icmp.dll - 23/11/05 03:02 PM

Examples:

//cmdoutput ping localhost >ping.txt | run ping.txt
//cmdoutput netstat -n >netstat.txt
...

Syntax for ping.exe:
  • ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS]
    [-r count] [-s count] [[-j host-list] | [-k host-list]]
    [-w timeout] destination-list

    Options:

    -t
    Pings the specified host until stopped.
    To see statistics and continue - type Control-Break;
    To stop - type Control-C.

    -a Resolve addresses to hostnames.
    -n count Number of echo requests to send.
    -l size Send buffer size.
    -f Set Don't Fragment flag in packet.
    -i TTL Time To Live.
    -v TOS Type Of Service.
    -r count Record route for count hops.
    -s count Timestamp for count hops.
    -j host-list Loose source route along host-list.
    -k host-list Strict source route along host-list.
    -w timeout Timeout in milliseconds to wait for each reply.


I put the signal there, that will notify you when the command has finished processing. It runs a synchrounous call, which means the cmdoutput alias waits with processing until the com call returns.

As you can see you can export the results to a text file, which you can then manipulate, read, etc.

Example:

//window -n @netstat | cmdoutput netstat -n >netstat.txt | loadbuf @netstat netstat.txt | .remove netstat.txt

Code:
alias cmdoutput {
  var %wsh = wsh $+ $ticks
  .comopen %wsh wscript.shell
  .comclose %wsh $com(%wsh,run,1,bstr*,% $+ comspec% /c $1-,uint,0,bool,true)
  .signal cmdoutput $1-
}
 [color:red]  [/color] 
on *:signal:cmdoutput:{
  echo -ac info * /cmdoutput: finished processing command: $1-
}
Posted By: Sat

Re: Implementing Internet Pings using Icmp.dll - 23/11/05 03:06 PM

Sure you can run ping.exe and tracert.exe, but good luck with parsing the results properly and reliably, in all translations of all (including future) versions of Windows...
Posted By: sazeMaster

Re: Implementing Internet Pings using Icmp.dll - 23/11/05 03:09 PM

Quote:
Okay then, you can get a copy of the DLL and partial documentation (which you are going to need, even though it's not complete) here.


Ok, 16:08:51 * Dns resolved www.google.it to 216.239.59.99
then i launch the dll with
//echo -a $dll(ping.dll, ping, 216.239.59.99)
but the result is:
1
No response from 216.239.59.99

what's wrong here? frown
Posted By: FiberOPtics

Re: Implementing Internet Pings using Icmp.dll - 23/11/05 03:12 PM

Quote:
Sure you can run ping.exe and tracert.exe, but good luck with parsing the results properly and reliably, in all translations of all (including future) versions of Windows...


Who cares about that? If his OS is English, then he's all set. ping.exe's output will be the same on all English Windows OS'es, so I don't see the problem really. It's a solution for him without requiring a DLL, it's not meant to be a universal solution for all languages.
Posted By: Sat

Re: Implementing Internet Pings using Icmp.dll - 23/11/05 03:16 PM

Quote:
No response from 216.239.59.99

what's wrong here? frown

Pinging that IP even crashes in iphlpapi.dll here. That's the result of me not having had enough time to test the DLL thoroughly.. I'll look into it.
Posted By: sazeMaster

Re: Implementing Internet Pings using Icmp.dll - 23/11/05 03:17 PM

Quote:
Examples:

//cmdoutput ping localhost >ping.txt | run ping.txt
//cmdoutput netstat -n >netstat.txt
(...)


shocked great.. but.. it is not a bit slow all that? I mean, shure it works, but.. I dunno.. I have to make a ping every tot seconds..to control if a server is up obviously.. and i won't to see (neither minimized to tray) the window pop-upping every tot seconds _ it would make me crazy :PPPPPPPPPPPPP
Posted By: Sat

Re: Implementing Internet Pings using Icmp.dll - 23/11/05 03:18 PM

Quote:
Who cares about that?

Pretty much everyone who ever intends to distribute the scripts they make. Binding a solution to e.g. a specific language of an OS is not very neat IMO.
Posted By: FiberOPtics

Re: Implementing Internet Pings using Icmp.dll - 23/11/05 03:20 PM

What are you talking about? No window pops up with that code... it's all done hidden. It's speed is the same as the speed of using ping.exe in your command prompt. If you are talking about my example with the window @netstat, that is obviously an example, no one says you have to loadbuf them to a window...
Posted By: FiberOPtics

Re: Implementing Internet Pings using Icmp.dll - 23/11/05 03:21 PM

This is a forum to help people with specific problems, it's not like he's going to release an addon, it looks like a clear case of a user specific problem, which doesn't need universal solutions. Not saying universal solutions aren't good, in fact they are preferable, but I wouldn't know why I shouldn't be able to post workarounds that don't require a DLL.

When posting code, there might always be compatibility issues, whether due to mIRC itsself, or the OS. That doesn't mean solutions may not be posted. If so I should have never released any code using COM, because it either relies on having a certain version of IE installed, WMI installed, mIRC 6.16 (due to $comval) etc.

Your DLL has more compatibility issues than my COM solution, as people actually need to download your DLL, whilst ping.exe is already on everyone's Windows OS.

I think it's great you made that DLL, but don't give me comments like "good luck parsing..." when I give other solutions.
Posted By: Sat

Re: Implementing Internet Pings using Icmp.dll - 23/11/05 03:28 PM

Strawman. I never said you should not post your solution, I merely pointed out that it has certain downsides.
Posted By: sazeMaster

Re: Implementing Internet Pings using Icmp.dll - 23/11/05 03:29 PM

Quote:
This is a forum to help people with specific problems, (...).


yeah it works!!! Thanxs ^______________^ :***********
Posted By: FiberOPtics

Re: Implementing Internet Pings using Icmp.dll - 23/11/05 03:31 PM

You didn't "merely point it out", you downplayed it. The strawman principle doesn't apply, as I knew exactly what you meant with your "sure.. good luck" line.
Posted By: Sat

Re: Implementing Internet Pings using Icmp.dll - 23/11/05 03:43 PM

I disagree, but if that's how you perceived it, fine. Let's leave it at that, I really am not interested in a flamewar.

Edit: and can you please stop adding text to your posts all the time? It really makes it very hard for me to reply to the points you make in a coherent way.
Posted By: FiberOPtics

Re: Implementing Internet Pings using Icmp.dll - 23/11/05 03:57 PM

I understand your point about the edits, it's indeed probably annoying, but what's the purpose of an edit feature?

To conclude this discussion, when someone tells me "sure you could.... but good luck with ..." that basically means: "yes, you could use that, but it still stinks as a solution". That's not just my interpretation, that's a quite common way of saying something stinks. And I don't like being said my code sucks when I take the time to try to help another person, with no benefit for my own really.

<Timmy> I still haven't rented a Halloween suit.
<Jon> Don't worry about it, just pick one up the night before Halloween.
<Sat> Sure you could do that, but good luck finding anything decent right before Halloween.

Sat means: your proposal sucks, buddy.
Posted By: sazeMaster

Re: Implementing Internet Pings using Icmp.dll - 23/11/05 04:08 PM

Hey... u 2... stop it now! laugh make peace and stay calm :tongue:
thanks to you now I post a simple code to get in mirc the result of a ICMP ping:

alias icmp {
var %wsh = wsh $+ $ticks
.comopen %wsh wscript.shell
.comclose %wsh $com(%wsh,run,1,bstr*,% $+ comspec% /c ping $1 >ping.txt,uint,0,bool,true)
echo -a * $read(ping.txt,$calc($lines(ping.txt) - 2))
.remove ping.txt
}

Simply digit /icmp www.google.com
Now it works, but maybe i can add a little control to give as result $true if the server has replied a packet or more, or $false if the hostneme has not replyed at all. Suggestions, comments r wellcome smile
THANKS U GUYS smile
Posted By: Sat

Re: Implementing Internet Pings using Icmp.dll - 23/11/05 04:15 PM

Quote:
To conclude this discussion, when someone tells me "sure you could.... but good luck with ..." that basically means: "yes, you could use that, but it still stinks as a solution". That's not just my interpretation, that's a quite common way of saying something stinks.

Perhaps we're dealing with small cultural differences here, because this is simply not true where I live.. the "good luck" construction is just a sarcastic way of presenting a downside which, if not applicable in the current situation (e.g. Jon knows this shop that always has nice suits left, or sazeMaster does not need the script to work anywhere else), does not invalidate the proposal as a whole.
Posted By: sazeMaster

Re: Implementing Internet Pings using Icmp.dll - 23/11/05 04:29 PM

ok........

Here I am with the ended code. This code does not needs dll and is fast enough for my purposes. It is a simple alias that return $true if the hostname/ip replies to the ping, and $false if not.

Code:
alias icmp {
  var %t = $ticks
  var %wsh = wsh $+ %t
  .comopen %wsh wscript.shell
  .comclose %wsh $com(%wsh,run,1,bstr*,% $+ comspec% /c ping $1 &gt;ping $+ %t $+ .txt,uint,0,bool,true)
  var %res = $read(ping $+ %t $+ .txt,$calc($lines(ping $+ %t $+ .txt) - 2))
  var %r = $iif($remove($gettok(%res,$calc($numtok(%res,32) - 1),32),$chr(40),$chr(37)) &lt; 100,$true,$false)
  .remove ping $+ %t $+ .txt
  return %r
}


Ok, to use this script, simply put it in your remotes and where u want to use it (i.e. an alias called "test"), simply write somtin' like this:

Code:
alias test {
  icmp www.google.com
  echo -a * $result
}


Very very simple smile
U have to wait from 1 to 20 seconds to get the result, it is normal ^__^

Thanks u guys, really smile
Posted By: sazeMaster

Re: Implementing Internet Pings using Icmp.dll - 23/11/05 05:04 PM

Hey do u have idea of why this strange thing happens?
If i make a ping (even from cmd -> ping) to www.google.com it works, but to www.190.it or www.virgilio.it or www.rossoalice.it they all seems doesn't responds to the ping request... why? Their sites are all up frown
Posted By: Sat

Re: Implementing Internet Pings using Icmp.dll - 23/11/05 05:12 PM

Their firewalls block ICMP PING packets, apparently..
Posted By: FiberOPtics

Re: Implementing Internet Pings using Icmp.dll - 23/11/05 05:13 PM

If all you want to do is know if a site is up, and get the ip, then why don't you just open a socket, and close it immediately when the sockopen event triggers, storing the ip property from $sock?

Or if you just want to get the ip, and see if the site exists, why not just /dns <url> and catch the results with the on dns event.

My point is, does it really need to be a ping? Because your icmp alias only wants to see if the host exists or not, so you could use other/easier methods, as the ones mentioned above.
Posted By: sazeMaster

Re: Implementing Internet Pings using Icmp.dll - 23/11/05 05:25 PM

Quote:
If all you want to do is know if a site is up, and get the ip, then why don't you just open a socket, and close it immediately when the sockopen event triggers, storing the ip property from $sock?

Or if you just want to get the ip, and see if the site exists, why not just /dns <url> and catch the results with the on dns event.

My point is, does it really need to be a ping? Because your icmp alias only wants to see if the host exists or not, so you could use other/easier methods, as the ones mentioned above.


God, open 3 or 4 socks every 5 or 10 second would be muuuuuuuuuuuuuuuuuuuuuuuch more dispendious, there is no comparison to me. smirk
Posted By: FiberOPtics

Re: Implementing Internet Pings using Icmp.dll - 23/11/05 05:33 PM

Actually, it would be much more efficient/faster than what you are currently using. This is because you don't actually have to send/receive any data. You just open the socket, and close it as soon as it opened. $sockerr will be filled if the host doesn't exist.

Btw, you should specify some of the flags when using ping.exe, like -n 1, that will make it much faster, as the default is 4 echo requests that are sent.

/checkhost <url>

Code:
alias checkhost sockopen checkhost $+ $ticks $$1 80
[color:red]  [/color] 
on *:sockopen:checkhost*:{
  echo -a $iif($sockerr,$false,$true - $sock($sockname).ip)
  sockclose $sockname
}

I am far from any sort of network/internet expert, but I think this will suffice for your specific problem.
Posted By: sazeMaster

Re: Implementing Internet Pings using Icmp.dll - 23/11/05 08:51 PM

very nice idea.. i was thinkin' about using ICMP for his nature.. unconsidering that some ISP block that protocol (maybe for protecting themselves from ping DoS?).. it is strange that a such small, speedy, useful protocol, is blocked.. ppl like me has to find other ways to do our stuff laugh
Thanks a lot!!
Posted By: brethren

Re: Implementing Internet Pings using Icmp.dll - 12/01/06 06:48 PM

Code:
alias checkhost sockopen checkhost $+ $ticks $$1 80

on *:sockopen:checkhost*:{

  echo -a $iif($sockerr,$false,$true - $sock($sockname).ip)

  sockclose $sockname
}

Hey I'm tottally lost here.. I'm trying to figure out a way where I can ping the certain ip/port into the channel for everyone to see rather than using echo -a. Does anyone have an idea? I already tried displying it by $chan or $nick. I'd like to make it where it where you can tell which servers are up or down to others by $nick. But by using the on TEXT action instead.

Sorta like this?

;; Message the channel to tell it whether it's true or false....
on 1:Text:*!serverstatus*:*:{ }

Example:

<me>!serverstatus
<bot> msg $nick Servers Servers Currently Up
<bot> .timer 1 3 msg $nick Kastien: IP: 127.0.0.1 Port: 7777
<bot> .timer 1 5 msg $nick Titan: IP: 127.0.0.1 Port: 7777
<bot> .timer 1 5 msg $nick ETC: IP: 127.0.0.1 Port: 7777

Can any of you please help me on this? it would be highly appreciated
© 2020 mIRC Discussion Forums