The problem is with the IcmpSendEcho API function.
Posted: Sat Sep 14, 2024 11:18 am
Hi guys, help me solve the problem.
There is a program:
In version 6.04 this program worked, but in subsequent versions it stopped working.
Debugger version 6.11 and version 6.12 give an error:
[15:09:03] Waiting for executable to start...
[15:09:03] Executable type: Windows - x64 (64bit, Unicode, Thread, Purifier)
[15:09:03] Executable started.
[15:09:06] The debugged executable quit unexpectedly.
What could it be?
There is a program:
Code: Select all
Procedure.w Ping(lngDAddress.l, paramTimeOut=1000, paramCountPing=4)
Define ECHO.ICMP_ECHO_REPLY
Define lngHPort.l, lngResult.l
Define *buffer, CountPing;
Define strMessage.s = "Ping, ping, ping!!!"
Define CountMillSec.w=0, ColGoodPing.w = 0
Define MsgLen.b = Len(strMessage)
lngHPort = IcmpCreateFile_()
*buffer=AllocateMemory(SizeOf(ICMP_ECHO_REPLY)+MsgLen)
For CountPing = 1 To paramCountPing
lngResult = IcmpSendEcho_(lngHPort, lngDAddress, @strMessage, MsgLen , #Null,*buffer, SizeOf(ICMP_ECHO_REPLY)+MsgLen, paramTimeOut)
CopyMemory(*buffer,@ECHO,SizeOf(ICMP_ECHO_REPLY))
If ECHO\RoundTripTime=0 And ECHO\Options\Ttl>0 And ECHO\Status=0
CountMillSec+1
ColGoodPing+1
ElseIf ECHO\RoundTripTime>0 And ECHO\Options\Ttl>0 And ECHO\Status=0
CountMillSec + ECHO\RoundTripTime
ColGoodPing + 1
EndIf
Debug "CountPing="+CountPing+" Address="+IPString(lngDAddress)+" RoundTripTime="+ECHO\RoundTripTime+" Status="+ECHO\Status+" TTL="+ECHO\Options\Ttl
Delay(1)
Next CountPing
If CountMillSec>0
PingResult = CountMillSec/ColGoodPing ;CountPing
Else
PingResult = -1
EndIf
FreeMemory(*buffer)
lngResult = IcmpCloseHandle_(lngHPort)
ProcedureReturn PingResult
EndProcedure
Debug Ping(MakeIPAddress(8,8,8,8))
Debugger version 6.11 and version 6.12 give an error:
[15:09:03] Waiting for executable to start...
[15:09:03] Executable type: Windows - x64 (64bit, Unicode, Thread, Purifier)
[15:09:03] Executable started.
[15:09:06] The debugged executable quit unexpectedly.
What could it be?