Jump to content

I am trying Rasdial() DLL function


Go to solution Solved by Starstar,

Recommended Posts

Link to comment
Share on other sites

I'll Update this message when I'll be at work where I have my USB with the code.

Saludos

Link to comment
Share on other sites

I'll Update this message when I'll be at work where I have my USB with the code.

Saludos

ok bro no problem..and thanks in advance.

Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once."

Link to comment
Share on other sites

The callback:

Global Enum $RASCS_OpenPort = 0, $RASCS_PortOpened, $RASCS_ConnectDevice, $RASCS_DeviceConnected, $RASCS_AllDevicesConnected, _
        $RASCS_Authenticate, $RASCS_AuthNotify, $RASCS_AuthRetry, $RASCS_AuthCallback, $RASCS_AuthChangePassword, $RASCS_AuthProject, _
        $RASCS_AuthLinkSpeed, $RASCS_AuthAck, $RASCS_ReAuthenticate, $RASCS_Authenticated, $RASCS_PrepareForCallback, _
        $RASCS_WaitForModemReset, $RASCS_WaitForCallback, $RASCS_Projected, _
        $RASCS_StartAuthentication, _
        $RASCS_CallbackComplete, _
        $RASCS_LogonNetwork, _
        $RASCS_SubEntryConnected, _
        $RASCS_SubEntryDisconnected, _
        $RASCS_ApplySettings, _
        $RASCS_Interactive = 0x1000, _
        $RASCS_RetryAuthentication, _
        $RASCS_CallbackSetByCaller, _
        $RASCS_PasswordExpired, _
        $RASCS_InvokeEapUI, _
        $RASCS_Connected = 0x2000, _
        $RASCS_Disconnected

Local $hHandle = DllCallbackRegister("RasDialFunc", "none", "UINT;lparam;wparam")



Func RasDialFunc($iMsg, $rasconnstate, $dwError)
    If $dwError Then
        Local $aRet = DllCall("Rasapi32.dll", "dword", "RasGetErrorStringW", "uint", $dwError, "wstr", "", "dword", 256)
        ConsoleWrite("!" & $aRet[2] & @CRLF)
        Return
    EndIf

    Switch $rasconnstate
        Case $RASCS_OpenPort
            ConsoleWrite("Opening port..." & @CRLF)
        Case $RASCS_PortOpened
            ConsoleWrite("Port Opened..." & @CRLF)
        Case $RASCS_ConnectDevice
            ConsoleWrite("Connecting device..." & @CRLF)

        Case $RASCS_DeviceConnected
            ConsoleWrite("Device connected..." & @CRLF)

        Case $RASCS_AllDevicesConnected
            ConsoleWrite("All devices connected..." & @CRLF)

        Case $RASCS_Authenticate
            ConsoleWrite("Authenticating..." & @CRLF)

        Case $RASCS_AuthNotify
            ConsoleWrite("Authentication notify..." & @CRLF)

        Case $RASCS_AuthRetry
            ConsoleWrite("Retrying authentication..." & @CRLF)

        Case $RASCS_AuthCallback
            ConsoleWrite("Authentication callback..." & @CRLF)

        Case $RASCS_AuthChangePassword
            ConsoleWrite("Change password..." & @CRLF)

        Case $RASCS_AuthProject
            ConsoleWrite("Projection phase started..." & @CRLF)

        Case $RASCS_AuthLinkSpeed
            ConsoleWrite("Negotiating speed..." & @CRLF)

        Case $RASCS_AuthAck
            ConsoleWrite("Authentication acknowledge..." & @CRLF)

        Case $RASCS_ReAuthenticate
            ConsoleWrite("Retrying Authentication..." & @CRLF)

        Case $RASCS_Authenticated
            ConsoleWrite("Authentication complete..." & @CRLF)

        Case $RASCS_PrepareForCallback
            ConsoleWrite("Preparing for callback..." & @CRLF)

        Case $RASCS_WaitForModemReset
            ConsoleWrite("Waiting for modem reset..." & @CRLF)

        Case $RASCS_WaitForCallback
            ConsoleWrite("Waiting for callback..." & @CRLF)

        Case $RASCS_Projected
            ConsoleWrite("Projection completed..." & @CRLF)
        Case $RASCS_StartAuthentication
            ConsoleWrite("Starting authentication..." & @CRLF)

        Case $RASCS_CallbackComplete
            ConsoleWrite("Callback complete..." & @CRLF)

        Case $RASCS_LogonNetwork
            ConsoleWrite("Logon to the network..." & @CRLF)


        Case $RASCS_SubEntryConnected
            ConsoleWrite("Subentry connected..." & @CRLF)

        Case $RASCS_SubEntryDisconnected
            ConsoleWrite("Subentry disconnected..." & @CRLF)

        Case $RASCS_Connected
            ConsoleWrite("Connection completed." & @CRLF)

        Case $RASCS_Disconnected
            ConsoleWrite("Disconnecting..." & @CRLF)


        Case Else
            ConsoleWrite("Unknown Status = " & $rasconnstate  & @CRLF)

    EndSwitch

EndFunc   ;==>RasDialFunc

Saludos

Link to comment
Share on other sites

The callback:

Global Enum $RASCS_OpenPort = 0, $RASCS_PortOpened, $RASCS_ConnectDevice, $RASCS_DeviceConnected, $RASCS_AllDevicesConnected, _
        $RASCS_Authenticate, $RASCS_AuthNotify, $RASCS_AuthRetry, $RASCS_AuthCallback, $RASCS_AuthChangePassword, $RASCS_AuthProject, _
        $RASCS_AuthLinkSpeed, $RASCS_AuthAck, $RASCS_ReAuthenticate, $RASCS_Authenticated, $RASCS_PrepareForCallback, _
        $RASCS_WaitForModemReset, $RASCS_WaitForCallback, $RASCS_Projected, _
        $RASCS_StartAuthentication, _
        $RASCS_CallbackComplete, _
        $RASCS_LogonNetwork, _
        $RASCS_SubEntryConnected, _
        $RASCS_SubEntryDisconnected, _
        $RASCS_ApplySettings, _
        $RASCS_Interactive = 0x1000, _
        $RASCS_RetryAuthentication, _
        $RASCS_CallbackSetByCaller, _
        $RASCS_PasswordExpired, _
        $RASCS_InvokeEapUI, _
        $RASCS_Connected = 0x2000, _
        $RASCS_Disconnected

Local $hHandle = DllCallbackRegister("RasDialFunc", "none", "UINT;lparam;wparam")



Func RasDialFunc($iMsg, $rasconnstate, $dwError)
    If $dwError Then
        Local $aRet = DllCall("Rasapi32.dll", "dword", "RasGetErrorStringW", "uint", $dwError, "wstr", "", "dword", 256)
        ConsoleWrite("!" & $aRet[2] & @CRLF)
        Return
    EndIf

    Switch $rasconnstate
        Case $RASCS_OpenPort
            ConsoleWrite("Opening port..." & @CRLF)
        Case $RASCS_PortOpened
            ConsoleWrite("Port Opened..." & @CRLF)
        Case $RASCS_ConnectDevice
            ConsoleWrite("Connecting device..." & @CRLF)

        Case $RASCS_DeviceConnected
            ConsoleWrite("Device connected..." & @CRLF)

        Case $RASCS_AllDevicesConnected
            ConsoleWrite("All devices connected..." & @CRLF)

        Case $RASCS_Authenticate
            ConsoleWrite("Authenticating..." & @CRLF)

        Case $RASCS_AuthNotify
            ConsoleWrite("Authentication notify..." & @CRLF)

        Case $RASCS_AuthRetry
            ConsoleWrite("Retrying authentication..." & @CRLF)

        Case $RASCS_AuthCallback
            ConsoleWrite("Authentication callback..." & @CRLF)

        Case $RASCS_AuthChangePassword
            ConsoleWrite("Change password..." & @CRLF)

        Case $RASCS_AuthProject
            ConsoleWrite("Projection phase started..." & @CRLF)

        Case $RASCS_AuthLinkSpeed
            ConsoleWrite("Negotiating speed..." & @CRLF)

        Case $RASCS_AuthAck
            ConsoleWrite("Authentication acknowledge..." & @CRLF)

        Case $RASCS_ReAuthenticate
            ConsoleWrite("Retrying Authentication..." & @CRLF)

        Case $RASCS_Authenticated
            ConsoleWrite("Authentication complete..." & @CRLF)

        Case $RASCS_PrepareForCallback
            ConsoleWrite("Preparing for callback..." & @CRLF)

        Case $RASCS_WaitForModemReset
            ConsoleWrite("Waiting for modem reset..." & @CRLF)

        Case $RASCS_WaitForCallback
            ConsoleWrite("Waiting for callback..." & @CRLF)

        Case $RASCS_Projected
            ConsoleWrite("Projection completed..." & @CRLF)
        Case $RASCS_StartAuthentication
            ConsoleWrite("Starting authentication..." & @CRLF)

        Case $RASCS_CallbackComplete
            ConsoleWrite("Callback complete..." & @CRLF)

        Case $RASCS_LogonNetwork
            ConsoleWrite("Logon to the network..." & @CRLF)


        Case $RASCS_SubEntryConnected
            ConsoleWrite("Subentry connected..." & @CRLF)

        Case $RASCS_SubEntryDisconnected
            ConsoleWrite("Subentry disconnected..." & @CRLF)

        Case $RASCS_Connected
            ConsoleWrite("Connection completed." & @CRLF)

        Case $RASCS_Disconnected
            ConsoleWrite("Disconnecting..." & @CRLF)


        Case Else
            ConsoleWrite("Unknown Status = " & $rasconnstate  & @CRLF)

    EndSwitch

EndFunc   ;==>RasDialFunc

Saludos

Thanks a lot of you bro...........

Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once."

Link to comment
Share on other sites

Link to comment
Share on other sites

  • 3 years later...
  • 4 years later...
On 11/9/2014 at 7:32 PM, Danyfirex said:

The callback:

Global Enum $RASCS_OpenPort = 0, $RASCS_PortOpened, $RASCS_ConnectDevice, $RASCS_DeviceConnected, $RASCS_AllDevicesConnected, _
        $RASCS_Authenticate, $RASCS_AuthNotify, $RASCS_AuthRetry, $RASCS_AuthCallback, $RASCS_AuthChangePassword, $RASCS_AuthProject, _
        $RASCS_AuthLinkSpeed, $RASCS_AuthAck, $RASCS_ReAuthenticate, $RASCS_Authenticated, $RASCS_PrepareForCallback, _
        $RASCS_WaitForModemReset, $RASCS_WaitForCallback, $RASCS_Projected, _
        $RASCS_StartAuthentication, _
        $RASCS_CallbackComplete, _
        $RASCS_LogonNetwork, _
        $RASCS_SubEntryConnected, _
        $RASCS_SubEntryDisconnected, _
        $RASCS_ApplySettings, _
        $RASCS_Interactive = 0x1000, _
        $RASCS_RetryAuthentication, _
        $RASCS_CallbackSetByCaller, _
        $RASCS_PasswordExpired, _
        $RASCS_InvokeEapUI, _
        $RASCS_Connected = 0x2000, _
        $RASCS_Disconnected

Local $hHandle = DllCallbackRegister("RasDialFunc", "none", "UINT;lparam;wparam")



Func RasDialFunc($iMsg, $rasconnstate, $dwError)
    If $dwError Then
        Local $aRet = DllCall("Rasapi32.dll", "dword", "RasGetErrorStringW", "uint", $dwError, "wstr", "", "dword", 256)
        ConsoleWrite("!" & $aRet[2] & @CRLF)
        Return
    EndIf

    Switch $rasconnstate
        Case $RASCS_OpenPort
            ConsoleWrite("Opening port..." & @CRLF)
        Case $RASCS_PortOpened
            ConsoleWrite("Port Opened..." & @CRLF)
        Case $RASCS_ConnectDevice
            ConsoleWrite("Connecting device..." & @CRLF)

        Case $RASCS_DeviceConnected
            ConsoleWrite("Device connected..." & @CRLF)

        Case $RASCS_AllDevicesConnected
            ConsoleWrite("All devices connected..." & @CRLF)

        Case $RASCS_Authenticate
            ConsoleWrite("Authenticating..." & @CRLF)

        Case $RASCS_AuthNotify
            ConsoleWrite("Authentication notify..." & @CRLF)

        Case $RASCS_AuthRetry
            ConsoleWrite("Retrying authentication..." & @CRLF)

        Case $RASCS_AuthCallback
            ConsoleWrite("Authentication callback..." & @CRLF)

        Case $RASCS_AuthChangePassword
            ConsoleWrite("Change password..." & @CRLF)

        Case $RASCS_AuthProject
            ConsoleWrite("Projection phase started..." & @CRLF)

        Case $RASCS_AuthLinkSpeed
            ConsoleWrite("Negotiating speed..." & @CRLF)

        Case $RASCS_AuthAck
            ConsoleWrite("Authentication acknowledge..." & @CRLF)

        Case $RASCS_ReAuthenticate
            ConsoleWrite("Retrying Authentication..." & @CRLF)

        Case $RASCS_Authenticated
            ConsoleWrite("Authentication complete..." & @CRLF)

        Case $RASCS_PrepareForCallback
            ConsoleWrite("Preparing for callback..." & @CRLF)

        Case $RASCS_WaitForModemReset
            ConsoleWrite("Waiting for modem reset..." & @CRLF)

        Case $RASCS_WaitForCallback
            ConsoleWrite("Waiting for callback..." & @CRLF)

        Case $RASCS_Projected
            ConsoleWrite("Projection completed..." & @CRLF)
        Case $RASCS_StartAuthentication
            ConsoleWrite("Starting authentication..." & @CRLF)

        Case $RASCS_CallbackComplete
            ConsoleWrite("Callback complete..." & @CRLF)

        Case $RASCS_LogonNetwork
            ConsoleWrite("Logon to the network..." & @CRLF)


        Case $RASCS_SubEntryConnected
            ConsoleWrite("Subentry connected..." & @CRLF)

        Case $RASCS_SubEntryDisconnected
            ConsoleWrite("Subentry disconnected..." & @CRLF)

        Case $RASCS_Connected
            ConsoleWrite("Connection completed." & @CRLF)

        Case $RASCS_Disconnected
            ConsoleWrite("Disconnecting..." & @CRLF)


        Case Else
            ConsoleWrite("Unknown Status = " & $rasconnstate  & @CRLF)

    EndSwitch

EndFunc   ;==>RasDialFunc

Saludos

hi, how to use  ?

Edited by Parsix
Link to comment
Share on other sites

Link to comment
Share on other sites

  • 2 weeks later...
Func _Create_RASPARAMS_STRUCT_A($sEntryName, $sUserName, $sPassword)

    #Region ;Options
        Local Const $RAS_MaxAreaCode = 10
        Local Const $RAS_MaxPhoneNumber = 128
        Local Const $RAS_MaxDeviceType = 16
        Local Const $RAS_MaxDeviceName = 128
        Local Const $RAS_MaxPadType = 32
        Local Const $RAS_MaxX25Address = 200
        Local Const $RAS_MaxCallbackNumber = 128 ;$RAS_MaxPhoneNumber
        Local Const $RAS_MaxFacilities = $RAS_MaxX25Address
        Local Const $RAS_MaxUserData = $RAS_MaxFacilities
        Local Const $RAS_MaxDnsSuffix = 256
        Local Const $RAS_MaxEntryName = 256
        Local Const $WM_RASDIALEVENT = 0xCCCD
        Local Const $RASCS_DONE = 0x2000
        Local Const $WAIT_OBJECT_0 = 0
        Local $hConection = 0
        Local Const $DNLEN =15

        #cs
        typedef struct _RASDIALPARAMS   {
                                          DWORD     dwSize;
                                          TCHAR     szEntryName[RAS_MaxEntryName + 1];
                                          TCHAR     szPhoneNumber[RAS_MaxPhoneNumber + 1];
                                          TCHAR     szCallbackNumber[RAS_MaxCallbackNumber + 1];
                                          TCHAR     szUserName[UNLEN + 1];
                                          TCHAR     szPassword[PWLEN + 1];
                                          TCHAR     szDomain[DNLEN + 1];
                                          DWORD     dwSubEntry;
                                          ULONG_PTR dwCallbackId;
                                          DWORD     dwIfIndex;
                                        } RASDIALPARAMS, *PRASDIALPARAMS;
        #ce

        Local Const $tagRASDIALPARAMS =     "dword dwSize;"                                         & _
                                            "wchar szEntryName["& $RAS_MaxEntryName +1 &"];"        & _
                                            "wchar szPhoneNumber["& $RAS_MaxPhoneNumber +1 &"];"    & _
                                            "wchar szCallbackNumber["& $RAS_MaxCallbackNumber +1 & "];" & _
                                            "wchar szUserName[" & $RAS_MaxDnsSuffix +1 & "];"       & _
                                            "wchar szPassword["& $RAS_MaxDnsSuffix + 1 & "];"       & _
                                            "wchar szDomain["&$DNLEN +1 &"];"                       & _
                                            "dword dwSubEntry;"                                     & _
                                            "ULONG_PTR dwCallbackId;"                               & _
                                            "dword dwIfIndex"
    #EndRegion ;Options

    Local $tRASDIALPARAMS = DllStructCreate($tagRASDIALPARAMS)
    $tRASDIALPARAMS.dwSize = DllStructGetSize($tRASDIALPARAMS)
    DllStructSetData($tRASDIALPARAMS, "szEntryName", $sEntryName)
    DllStructSetData($tRASDIALPARAMS, "szPhoneNumber", "")
    DllStructSetData($tRASDIALPARAMS, "szUserName", $sUserName)
    DllStructSetData($tRASDIALPARAMS, "szPassword", $sPassword)
    DllStructSetData($tRASDIALPARAMS, "szDomain", "")
    Return $tRASDIALPARAMS
EndFunc

Func _RAS_DialA($sConnectionName, $sUSR, $sPSW, $sPhoneBook)
    Local $ERROR = 0
    If Not FileExists($sPhoneBook) Then Return $ERROR
    Local $tRASDIAL_PARAMS = _Create_RASPARAMS_STRUCT_A($sConnectionName, $sUSR, $sPSW)
    Local $iRet = DllCall("Rasapi32.dll", "dword", "RasDialA", "ptr", 0,"wstr",$sPhoneBook, "ptr",DllStructGetPtr($tRASDIAL_PARAMS), "dword", 0, "ptr", Null, "handle*", NULL)
    $tRASDIAL_PARAMS = 0
    If Not $iRet[0] Then
        Return 1 ;convert 0 to 1 when dial is ok
    Else
        ;Local $Ret = DllCall("Rasapi32.dll", "dword", "RasGetErrorStringW", "uint", $iRet[0], "wstr", NULL, "dword", 256)
        ;$Ret[2]
        Return $iRet[0]
    EndIf
EndFunc

Local $FilePath="C:\VPN-Conn.pbk"
ConsoleWrite (@CRLF & " --> "& _RAS_DialA("VPN1", "USR1", "PSW1", $FilePath) & @CRLF)

got Error 632

Edit: Fixed by 

replace wchar with char in param and "wstr" with "str" in dllcall

Local $iRet = DllCall("Rasapi32.dll", "dword", "RasDialA", "ptr", 0,"str",$sPhoneBook, "ptr",DllStructGetPtr($tRASDIAL_PARAMS), "dword", 0, "ptr", Null, "handle*", NULL)

 

RasDialW  and RasDialA causes execution of other script code (GDI+ animated loading screens)

 

 

 

Edited by Parsix
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...