flat assembler
Message board for the users of flat assembler.

Index > Windows > [SOLVED] AutoDial Problem

Author
Thread Post new topic Reply to topic
Force



Joined: 12 Jun 2012
Posts: 29
Force
I don't know why it doesn't work
please can anybody help me about this code ?

Code:
 format PE GUI 4.0
entry start

include 'd:\fasm\include\win32a.inc'


 struc dw [arg] {
 common
 . dw arg
 sizeof.#. = $-.
}


    struct RASENTRYNAME

        dwSize dd ?
        szEntryName db 260 dup(?)
        dwFlags dd ?
        szPhonebookPath db 264 dup(?)

    ends




   struct RASDIALPARAMS

        dwSize dd ?
        szEntryName db 101h dup(?)
        szPhoneNumber db 81h dup(?)
        szCallbackNumber db 81h dup(?)
        szUserName db 101h dup(?)
        szPassword db 101h dup(?)
        szDomain db 13h dup(?)

        dwSubEntry dd ?
        dwCallbackId dd ?

   ends




section '.data'data writable readable


szApp db "AutoDial",0
szSucc db "connection is success!",0

lpRasEntryName     dd ?
dwCb               dd ?
dwEntries          dd ?
fPass              dd ?
hConn              dd ?
     
rpp  RASDIALPARAMS<>


section '.code' code readable executable
start:

 mov [dwCb],sizeof.RASENTRYNAME
 mov [lpRasEntryName], 0

AllocateRasEntryNameLoop:

 cmp [lpRasEntryName], 0
 je AllocateRasEntryName
 invoke GetProcessHeap
 invoke HeapFree, eax, 0, [lpRasEntryName]


 AllocateRasEntryName:
 invoke GetProcessHeap
 invoke HeapAlloc, eax, 0, [dwCb]
 cmp eax, 0
 je RetFail


 mov [lpRasEntryName], eax
 invoke RtlZeroMemory, [lpRasEntryName], [dwCb]
 mov ebx, sizeof.RASENTRYNAME
 mov eax, [lpRasEntryName]
 mov   [RASENTRYNAME.dwSize+eax],ebx

invoke RasEnumEntries, NULL, NULL, [lpRasEntryName],  dwCb, dwEntries
cmp eax, 278h
je AllocateRasEntryNameLoop
cmp eax, 0
jne RetFail



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 mov [dwCb], sizeof.RASDIALPARAMS
 invoke RtlZeroMemory, rpp, [dwCb]
 mov eax, [dwCb]
 mov [rpp.dwSize], eax
 mov eax, [lpRasEntryName]


 invoke lstrcpy,rpp.szEntryName,RASENTRYNAME.szEntryName[EAX]



invoke RasGetEntryDialParams,0,rpp, fPass
cmp eax, 0
jne RetFail
mov [hConn], 0

invoke RasDial, NULL, NULL,rpp, 0, NULL,hConn
cmp eax, 0
jne RetFail
invoke MessageBox,0,szSucc,szApp,MB_OK
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
RetFail:

      cmp [lpRasEntryName], 0
      je AllocateRasEntryName
      invoke GetProcessHeap
      invoke HeapFree, eax, 0, [lpRasEntryName]



invoke ExitProcess,NULL

section '.idata' import data readable writable

library kernel32,'KERNEL32.DLL',\
        user32 ,'USER32.DLL',\
        rasapi32,'RASAPI32.DLL'


import rasapi32,\
       RasEnumEntries,'RasEnumEntriesA',\
       RasGetEntryDialParams,'RasGetEntryDialParamsA',\
       RasDial,'RasDialA'
                
    include 'd:\fasm\include\api\kernel32.inc'
    include 'd:\fasm\include\api\user32.inc'    


Last edited by Force on 01 Feb 2014, 12:04; edited 1 time in total
Post 31 Jan 2014, 22:01
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
Your question is too generalized. What doesn't work?

Editor? Compiler? API ? This website? You?
Post 31 Jan 2014, 22:45
View user's profile Send private message Reply with quote
Force



Joined: 12 Jun 2012
Posts: 29
Force
typedef

i m trying to translate that Autodial internet connection code

i think after this code
Code:
invoke lstrcpy,rpp.szEntryName,RASENTRYNAME.szEntryName[EAX]
invoke RasGetEntryDialParams,0,rpp, fPass     


eax value is not zero so it is Failed


Last edited by Force on 01 Feb 2014, 00:01; edited 1 time in total
Post 31 Jan 2014, 22:52
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
Quote:

Code:
invoke lstrcpy,rpp.szEntryName,RASENTRYNAME.szEntryName[EAX]
    



What is EAX doing here? Is this compiling in FASM?

Your're better off translating from C to FASM syntax not from MASM to FASM.
Post 31 Jan 2014, 23:03
View user's profile Send private message Reply with quote
Force



Joined: 12 Jun 2012
Posts: 29
Force
Code:
invoke lstrcpy,rpp.szEntryName,RASENTRYNAME.szEntryName[EAX]
invoke RasGetEntryDialParams,0,rpp, fPass
cmp eax, 0 ; ====== > this eax
jne RetFail
mov [hConn], 0    


in MSDN

DWORD RasGetEntryDialParams(

LPTSTR lpszPhonebook, // pointer to the full path and filename of the phone-book file
LPRASDIALPARAMS lprasdialparams, // pointer to a structure that receives the connection parameters
LPBOOL lpfPassword // indicates whether the user's password was retrieved
);

Return Values

If the function succeeds, the return value is zero.
Post 31 Jan 2014, 23:12
View user's profile Send private message Reply with quote
Force



Joined: 12 Jun 2012
Posts: 29
Force
yes C code looks simple
maybe somebody can translate it from C to Fasm who knows C language
Post 31 Jan 2014, 23:22
View user's profile Send private message Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1180
Location: Unknown
HaHaAnonymous
[ Post removed by author. ]


Last edited by HaHaAnonymous on 28 Feb 2015, 18:21; edited 1 time in total
Post 31 Jan 2014, 23:54
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
I just tried to rewrite the code from http://blog.csdn.net/fornormandy/article/details/70039 to FASM. It does execute but after a bit of debugging I noticed I was getting error 632 (ERROR_INVALID_SIZE). Hmm, I did a Google search, then bam!. It turns out it's not an easy task. I was going to write the whole code for you but since I know it can be fixed, I'll leave it to you. The first call worked on my computer and it did return my list of VPN names.

So here, (define the structure in the code attached then use GetVersionEx to determine which structure to use)

Link 1 (solution): http://www.powerbasic.com/support/pbforums/showthread.php?t=14367

TIP: Use ras.h (Comes with your Windows SDK) to create the structures in FASM like I was doing then use GetVersionEx API to determine which structure to use.

Structure definitions: (Please read these thoroughly)

RASDIALPARAMS
http://msdn.microsoft.com/en-us/library/windows/desktop/aa377238(v=vs.85).aspx

RASENTRYNAME
http://msdn.microsoft.com/en-us/library/windows/desktop/aa377267(v=vs.85).aspx


RAS Error codes
http://msdn.microsoft.com/en-us/library/windows/desktop/bb530704(v=vs.85).aspx

Windows Versions
http://msdn.microsoft.com/en-us/library/windows/desktop/ms724832(v=vs.85).aspx

Rules For Programming On Windows:

1. Read the documentation
2. USE A FUCKING DEBUGGER. Actually on any platform. It's the closest thing to the truth.

If I missed anything you'll be able to figure it out. I did you a huge favor here pal. Evil or Very Mad


Description:
Download
Filename: ras_dial.ASM
Filesize: 3.74 KB
Downloaded: 44 Time(s)

Post 01 Feb 2014, 01:14
View user's profile Send private message Reply with quote
Force



Joined: 12 Jun 2012
Posts: 29
Force
Thanks for helping typedef i will read those documentations
and i will try to translate it from C as I know

Masm32 code is confusing
Post 01 Feb 2014, 01:53
View user's profile Send private message Reply with quote
Force



Joined: 12 Jun 2012
Posts: 29
Force
I translated it from C to Fasm. Anyway it works now

Tested on Windows7 with Huawei modem


AUTODIAL FASM CODE :

Code:
   format PE GUI 4.0
entry start

include 'd:\fasm\include\win32a.inc'


 struc dd [arg] {
 common
 . dd arg
 sizeof.#. = $-.
}


    struct RASENTRYNAME

        dwSize dd ?
        szEntryName db 260 dup(?)
        dwFlags dd ?
        szPhonebookPath db 264 dup(?)

    ends


struct RASDIALPARAMS

        dwSize dd ?
        szEntryName db 101h dup(?)
        szPhoneNumber db 81h dup(?)
        szCallbackNumber db 81h dup(?)
        szUserName db 101h dup(?)
        szPassword db 101h dup(?)
        szDomain db 13h dup(?)

        dwSubEntry dd ?
        dwCallbackId dd ?

ends



section '.data'data writable readable
szApp db "AutoDial",0
szSucc db "CONNECTION SUCCESSFUL !",0
szFail db "CONNECTION FAILED",0
dwCb dd ?
dwEntries dd 0
fPass dd 0
hConn dd ?
ren RASENTRYNAME
rpp RASDIALPARAMS
section '.code' code readable executable
start:

 mov [dwCb],sizeof.RASENTRYNAME

mov eax,[dwCb]
mov [ren.dwSize],eax

invoke RasEnumEntries,NULL,NULL,ren,dwCb,dwEntries
cmp eax,0
jne Fail
mov eax,sizeof.RASDIALPARAMS
mov [rpp.dwSize],eax

invoke lstrcpy,rpp.szEntryName, ren.szEntryName
invoke RasGetEntryDialParams,NULL, rpp, fPass
invoke RasDial,NULL,NULL,rpp,0,NULL,hConn
cmp eax,0
jne Fail

invoke MessageBoxTimeout,0,szSucc,szApp,MB_ICONWARNING,LANG_NEUTRAL,5000
jmp Exit
Fail:
invoke MessageBoxTimeout,0,szFail,szApp,MB_ICONWARNING,LANG_NEUTRAL,5000
Exit:
invoke ExitProcess,NULL

section '.idata' import data readable writable

library kernel32,'KERNEL32.DLL',\
        user32 ,'USER32.DLL',\
        rasapi32,'RASAPI32.DLL'


import user32,\
       MessageBoxTimeout,'MessageBoxTimeoutA'

import rasapi32,\
       RasEnumEntries,'RasEnumEntriesA',\
       RasGetEntryDialParams,'RasGetEntryDialParamsA',\
       RasDial,'RasDialA'
                
    include 'd:\fasm\include\api\kernel32.inc'
    
Post 01 Feb 2014, 12:02
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.