WinAsm Studio, The Assembly IDE - Free Downloads, Source Code
Sponsors
Articles
Programming Quick Start
32-bit Assembler is Easy
Porting Iczelion tutorials
What is FASM
What is FASM G
Hard Drive Recovery
Wiring your own LAN
Personal menu
Welcome Guest
User:
Pass:
Register!
Resend Validation Email
 
Forum
Pages (2) [1] 2   ( Go to first unread post )

RasHangup not working, Ollydbg gives no error message, but this will not hang up

Slider
Quote Post


Extremely Active Member
******

Group: Moderators
Posts: 313
Member No.: 5004
Joined: 11-May 07


Ollydbg gives no error message, but this will not hang up.

CODE
include \masm32\include\masm32rt.inc  

include \MASM32\include\rasapi32.inc
includelib \MASM32\lib\rasapi32.lib

.data

.data?

l_RASCONN RASCONN 0FFh dup ({})
l_Buffer_Size dd   ?
l_Conn_Count  dd   ?

.code

start:


; list all active RAS connections
invoke RasEnumConnections, addr l_RASCONN, addr l_Buffer_Size, addr l_Conn_Count

; 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

Sponsored Links
PMEmail Poster
Top
huntingspace
Quote Post


Very Active Member
****

Group: Members
Posts: 60
Member No.: 49504
Joined: 11-February 12


see MSDN code sample code:
CODE
include masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \MASM32\include\rasapi32.inc
include \masm32\include\msvcrt.inc
includelib \MASM32\lib\kernel32.lib
includelib \MASM32\lib\rasapi32.lib
includelib \MASM32\lib\msvcrt.lib
include \masm32\macros\macros.asm

printf equ <crt_printf>

.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)
  invoke printf,CTXT("HeapAlloc failed!",13,10)
  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)
� �invoke printf,CTXT("The following RAS connections are currently active:",13,10)
� �xor ebx,ebx
� � �.repeat
� � � �lea eax,[esi].RASCONN.szEntryName
� � � �invoke printf,CTXT("%s",13,10),eax
� � � �add esi,sizeof RASCONN
� � � �inc ebx
� � �.until (ebx>=dwConnections)
� .endif

;Deallocate memory for the connection buffer
�iinvoke HeapFree,edi,0,lpRasConn
�jmp exit0
.endif

; There was either a problem with RAS or there are no connections to enumerate
.if(dwConnections >= 1)
�invoke printf,CTXT("The operation failed to acquire the buffer size.",13,10)
.else
�invoke printf,CTXT("There are no active RAS connections.",13,10)
.endif
exit0:
invoke ExitProcess,0


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


regards, huntingspace.
PMEmail Poster
Top
Slider
Quote Post


Extremely Active Member
******

Group: Moderators
Posts: 313
Member No.: 5004
Joined: 11-May 07


Thanks, I will study your code.

PMEmail Poster
Top
Slider
Quote Post


Extremely Active Member
******

Group: Moderators
Posts: 313
Member No.: 5004
Joined: 11-May 07


When I run this I get 278h in the EAX register and it does not hang up.

I don't know what to check next ?

Andy

CODE

.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

end     start
PMEmail Poster
Top
huntingspace
Quote Post


Very Active Member
****

Group: Members
Posts: 60
Member No.: 49504
Joined: 11-February 12


if RasEnumConnections API return ERROR_INVALID_SIZE (error 278h or 632d) it means incorrect structure size. RASCONN structure has some errors in winextra.inc
you should use this structure:
CODE

RASCONNA STRUCT 4
 dwSize            dd ?
 hrasconn          dd ?
 szEntryName       db RAS_MaxEntryName + 1 dup(?)
 szDeviceType      db RAS_MaxDeviceType + 1 dup(?)
 szDeviceName      db RAS_MaxDeviceName + 1 dup(?)
 szPhonebook       db MAX_PATH dup(?)
 dwSubEntry        dd ?
 guidEntry         GUID <>
 dwFlags           dd ?
 luid              LUID <>
 guidCorrelationId GUID <>
RASCONNA ENDS

huntingspace
PMEmail Poster
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

Topic Options Pages (2) [1] 2  Reply to this topicStart new topicStart Poll

 

Sponsors
Computer Science

Internet
C/C++
Hardware & PC maintenance

HiEditor

General Discussions
Suggestions/Bug Reports
WinAsm Studio

General Discussions
Suggestions/Bug Reports
WinAsm Studio FAQ
Multilingual User Interface
Add-Ins
Assembly Programming

Main
Newbies
Projects
Custom Controls
Snippets
Announcements & Rules

Announcements

General

Online Degrees - Distance Learning
The Heap
Russian
Google