C:\MASM32\SOURCE\DialOut.asm(55) : error A2008: syntax error : ,
I know the comma is not supposed to be there, but don't know how to fix it.
Andy
; Hang_Up.asm Sever POT connection huntingspace,
;
include \masm32\include\masm32rt.inc
include \MASM32\include\rasapi32.inc
includelib \MASM32\lib\rasapi32.lib
.data?
lpRasConn dd ?
dwCb dd ?
dwConnections dd ?
.code
start:
xor eax,eax
mov dwCb,eax
mov dwConnections,eax
mov lpRasConn,eax
; Call RasEnumConnections with lpRasConn = NULL.
; dwCb is returned with the required buffer size and a return code of ERROR_BUFFER_TOO_SMALL
invoke RasEnumConnections,lpRasConn, addr dwCb,addr dwConnections
.if (eax== ERROR_BUFFER_TOO_SMALL)
; Allocate the memory needed for the array of RAS structure(s).
invoke GetProcessHeap
mov edi,eax
invoke HeapAlloc,edi,HEAP_ZERO_MEMORY,dwCb
.if !(eax & eax)
printf("HeapAlloc failed!",13,10)
;printf("RegOpenKeyEx %s\n\n", LastError$())
jmp exit0
.endif
mov lpRasConn,eax
; The first RASCONN structure in the array must contain the RASCONN structure size
mov esi,lpRasConn
mov [esi].RASCONN.dwSize,sizeof RASCONN
; Call RasEnumConnections to enumerate active connections
invoke RasEnumConnections,esi,addr dwCb,addr dwConnections
; If successful, print the names of the active connections.
.if !(eax & eax)
printf("The following RAS connections are currently active:",13,10)
xor ebx,ebx
.repeat
lea eax,[esi].RASCONN.szEntryName
printf("%s",13,10),eax
add esi,sizeof RASCONN
inc ebx
.until (ebx>=dwConnections)
.endif
;Deallocate memory for the connection buffer
invoke HeapFree,edi,0,lpRasConn
jmp exit0
.endif
; There was either a problem with RAS or there are no connections to enumerate
.if(dwConnections >= 1)
printf("The operation failed to acquire the buffer size.",13,10)
.else
printf("There are no active RAS connections.",13,10)
.endif
exit0:
invoke ExitProcess,0
end start
;
; i think you need fill some params in your sample before RasEnumConnections API is called:
; CODE
;
; mov l_RASCONN.RASCONN.dwSize, sizeof RASCONN
; mov l_Buffer_Size, sizeof l_RASCONN
This should work:
printf("%s\n",eax)
Use crt_printf and crt_puts,CTEXT ("blabla"),CR,LF
Thanks ragdog and vertograd.
It assembles fine and runs, but does not terminate the connection.
I will work on this and try to understand this.
Andy
;
; i think you need fill some params in your sample before RasEnumConnections API is called:
; CODE
;
; mov l_RASCONN.RASCONN.dwSize, sizeof RASCONN
; mov l_Buffer_Size, sizeof l_RASCONN
Eax returns 278h and connection is not terminated.
Not sure what to check next.
.data?
l_RASCONN RASCONN 0FFh dup ({})
l_Buffer_Size dd ?
l_Conn_Count dd ?
.code
start:
Close_RAS:
;Find Active Connections.
mov l_RASCONN.dwSize, sizeof RASCONN + 1
mov l_Buffer_Size, sizeof l_RASCONN
invoke RasEnumConnections, addr l_RASCONN, addr l_Buffer_Size, addr l_Conn_Count
.if eax != 0 ; eax = 278h =
jmp TheEnd
.endif
invoke RasHangUp, l_RASCONN.hrasconn
invoke Sleep,1500 ; give the system enuf time to end the connection
; Don't want to leave the port in an inconsistent state.
TheEnd:
invoke ExitProcess,0
after you call RasHangUp, you should wait for the status to reflect the disconnect before terminating
you can call RasGetConnectStatus in a loop with a time delay (Sleep) until it shows RASCS_Disconnected
this guy does it a little differently - he tests the dwError member of RASCONNSTATUS
http://billmccarthy.com/projects/Archived/PlatformVB/dun/rashangup.htm (http://billmccarthy.com/projects/Archived/PlatformVB/dun/rashangup.htm)
I am using an ISP dialer program.
The RasHangUp function is used to terminate a remote access connection. It releases all rasapi32.dll resources associated with the connection.
You should call RasHangUp for any connection that you initiated with the RasDial function if the returned connection handle is non zero, even if the dial operation failed.
You can also use connection handles from the RasEnumConnections function.
And this code is not working.
include \masm32\include\masm32rt.inc
include \MASM32\include\rasapi32.inc
includelib \MASM32\lib\rasapi32.lib
.data
WaterMark db "SiegeWorks 2013 ð__ð" ; Alt 240 char
%Date db " &@Date " ; Compile date
%time db " &@Time"
.data?
l_RASCONN RASCONN 0FFh dup ({})
l_Buffer_Size dd ?
l_Conn_Count dd ?
.code
start:
Close_RAS:
;Find Active Connections.
mov l_RASCONN.dwSize, sizeof RASCONN + 1
mov l_Buffer_Size, sizeof l_RASCONN
invoke RasEnumConnections, addr l_RASCONN, addr l_Buffer_Size, addr l_Conn_Count
.if eax != 0 ; eax = 278h =
jmp TheEnd
.endif
invoke RasHangUp, l_RASCONN.hrasconn
;
; invoke Sleep,1500 ; give the system enuf time to end the connection
; ; Don't want to leave the port in an inconsistent state.
; Dim rtn as long, lngError as Long
; Dim myConnStatus as VBRASCONNSTATUS
; rtn = RasHangUp(hRasConn)
; 'If rtn <> 0 Then Debug.Print VBRasErrorHandler(rtn)
; Do
; Sleep 0&
; lngError = VB RasGetConnectStatus(hRasConn, myConnStatus)
; Loop While lngError <> ERROR_INVALID_HANDLE
TheEnd:
invoke ExitProcess,0
end start
This says no active RAS connection when there is an internet connection via dial up ??
; Hang_Up.asm Sever POT connection huntingspace,
;
include \masm32\include\masm32rt.inc
include \MASM32\include\rasapi32.inc
includelib \MASM32\lib\rasapi32.lib
.data?
lpRasConn dd ?
dwCb dd ?
dwConnections dd ?
l_RASCONN RASCONN 0FFh dup ({})
l_Buffer_Size dd ?
l_Conn_Count dd ?
.code
start:
xor eax,eax
mov dwCb,eax
mov dwConnections,eax
mov lpRasConn,eax
; Call RasEnumConnections with lpRasConn = NULL.
; dwCb is returned with the required buffer size and a return code of ERROR_BUFFER_TOO_SMALL
;invoke RasEnumConnections,lpRasConn, addr dwCb,addr dwConnections
invoke RasEnumConnections, addr l_RASCONN, addr l_Buffer_Size, addr l_Conn_Count
.if (eax== ERROR_BUFFER_TOO_SMALL)
; Allocate the memory needed for the array of RAS structure(s).
invoke GetProcessHeap
mov edi,eax
invoke HeapAlloc,edi,HEAP_ZERO_MEMORY,dwCb
.if !(eax & eax)
printf("HeapAlloc failed!",13,10)
;printf("RegOpenKeyEx %s\n\n", LastError$())
jmp exit0
.endif
mov lpRasConn,eax
; The first RASCONN structure in the array must contain the RASCONN structure size
mov esi,lpRasConn
mov [esi].RASCONN.dwSize,sizeof RASCONN
; Call RasEnumConnections to enumerate active connections
invoke RasEnumConnections,esi,addr dwCb,addr dwConnections
; If successful, print the names of the active connections.
.if !(eax & eax)
printf("The following RAS connections are currently active:",13,10)
xor ebx,ebx
.repeat
lea eax,[esi].RASCONN.szEntryName
;printf("%s",13,10),eax
printf("%s\n",eax)
add esi,sizeof RASCONN
inc ebx
.until (ebx>=dwConnections)
.endif
;Deallocate memory for the connection buffer
invoke HeapFree,edi,0,lpRasConn
jmp exit0
.endif
; There was either a problem with RAS or there are no connections to enumerate
.if(dwConnections >= 1)
printf("The operation failed to acquire the buffer size.",13,10)
.else
printf("There are no active RAS connections.",13,10)
.endif
exit0:
; terminate the Remote Access Connection
invoke RasHangUp, l_RASCONN.hrasconn
invoke Sleep,1500 ; give the system enuf time to end the connection
; Don't want to leave the port in an inconsistent state.
invoke ExitProcess,0
end start
;
; i think you need fill some params in your sample before RasEnumConnections API is called:
; CODE
;
; mov l_RASCONN.RASCONN.dwSize, sizeof RASCONN
; mov l_Buffer_Size, sizeof l_RASCONN
it may be a bit difficult to write code that will work for all versions of windows
personally - i try to be compatible back to win 2000, whenever it's practical
the problem seems to be the size of the RASCONN structure varying from OS to OS
AND - RasEnumConnections doesn't behave the same from OS to OS
when you read the docs for RasEnumConnections on MSDN, it seems to apply to windows 7 and later :icon_rolleyes:
at first glance, you might think you can call RasEnumConnections with a NULL buffer to get the size
well - that apparently doesn't work on XP
also - even if you do get a buffer size, you have to fill in the first RASCONN structure with a size
so - the best solution might be to use GetWinVer to get the windows version
then you have to know the correct size of RASCONN for win2k, XP, vista, win7, and win8
assuming you have a valid RAS handle, you can try this....
let me know whether it works or not - i don't have a dial-up connection to test with
RasWaitHangUp PROTO :HANDLE
;***********************************************************************************************
OPTION PROLOGUE:None
OPTION EPILOGUE:None
RasWaitHangUp PROC hRasConn:HANDLE
RasTimeOutCount = 40 ;125 mS per count, 40 for 5 second timeout
;preserve registers and establish the stack frame
push ebx
push esi
push edi
push ebp
mov ebp,esp
;initialize stack frame variables
push 0 ;[EBP-4] = return status
mov eax,(sizeof RASCONNSTATUS+3) and -4
sub esp,eax
mov esi,esp ;ESI = addr RASCONNSTATUS structure
mov [esi],eax ;set RASCONNSTATUS.dwSize
;attempt to disconnect an RAS connection
mov ebx,[ebp+20] ;EBX = hRasConn
INVOKE RasHangUp,ebx
.if eax
mov [ebp-4],eax
.else
mov edi,RasTimeOutCount+1 ;EDI = timeout counter
.repeat
.if edi!=RasTimeOutCount+1
INVOKE Sleep,125
.endif
INVOKE RasGetConnectStatus,ebx,esi
dec edi
.until (ZERO?) || (eax==ERROR_INVALID_HANDLE)
.if eax!=ERROR_INVALID_HANDLE
mov [ebp-4],eax
.endif
.endif
;return status, clean up stack frame, and restore registers
mov eax,[ebp-4]
leave
pop edi
pop esi
pop ebx
ret 4
RasWaitHangUp ENDP
OPTION PROLOGUE:PrologueDef
OPTION EPILOGUE:EpilogueDef
;***********************************************************************************************
by the way....
you likely have more than 1 open connection
see what quantity is returned when you enumerate - then close that many
in days of old (DOS to Win98), we used to send "Hayes AT commands" to the modem to control it
ATH0 would be hang up, i think
i don't know if there's a way to do that through an already-open TAPI connection
but, you might try looking around
if successful, it would terminate the phone call, rather than closing connection handles
EarthLink knows hot to disconnect in XP.
I thought it was not that long ago that some folks used dialup.
Ragdog, Tedd, Mr. Kleebauger, Bill Gates, :t
Help me Obi Wan Kanobi you're my only hope.
Obi Wan Cannoli can't help you now, Luke Andy
(http://www.storewars.org/pressroom/thumbnails/obi.jpg)
very few of us have dial-up connections to play with
you may have to do some reading
we can only help so much :P
http://msdn.microsoft.com/en-us/library/windows/desktop/ms725516%28v=vs.85%29.aspx (http://msdn.microsoft.com/en-us/library/windows/desktop/ms725516%28v=vs.85%29.aspx)
the 3 sub-sections on the left will keep you busy for a while
may the schwartz be with you !