Starstar Posted March 26, 2017 Share Posted March 26, 2017 (edited) expandcollapse popupdim $vbNullString=Chr(0) $Str_RASENTRY = "dword dwSize;dword dwfOptions;dword dwCountryID;dword dwCountryCode;char szLocalPhoneNumber[128];dword dwfNetProtocols;dword dwFramingProtocol;char szDeviceType[16];char szDeviceName[128];dword dwDialMode;dword dwDialExtraPercent;dword dwDialExtraSampleSeconds;dword dwHangUpExtraPercent;dword dwHangUpExtraSampleSeconds;dword dwType;dword dwEncryptionType;dword dwVpnStrategy;dword dwfOptions2;dword dwRedialCount;dword dwRedialPause" $DLL_RASENTRY = DllStructCreate($Str_RASENTRY) $Str_RASCREDENTIALS = "dword dwSize;dword dwMask;char szUserName[256];char szPassword[256];char szDomain[15]" $DLL_RASCREDENTIALS=DllStructCreate($Str_RASCREDENTIALS) $sDeviceName = "WAN MINIPORT (PPPOE)" $sDeviceType = "Vpn" $sEntryName = "Test" $sServer = "Test" $sUsername = "Test" $sPassword = "Test" $Rasentry = @AppDataDir & "\Microsoft\Network\Connections\Pbk\rasphone.pbk" $size = DllStructGetSize($DLL_RASENTRY) DllStructSetData($DLL_RASENTRY,"dwSize",$size) DllStructSetData($DLL_RASENTRY,"dwCountryCode",86) DllStructSetData($DLL_RASENTRY,"dwCountryID",86) DllStructSetData($DLL_RASENTRY,"dwDialExtraPercent",75) DllStructSetData($DLL_RASENTRY,"dwDialExtraSampleSeconds",120) DllStructSetData($DLL_RASENTRY,"dwDialMode",1) DllStructSetData($DLL_RASENTRY,"dwfNetProtocols",4) DllStructSetData($DLL_RASENTRY,"dwfOptions",1024262928) DllStructSetData($DLL_RASENTRY,"dwfOptions2",367) DllStructSetData($DLL_RASENTRY,"dwFramingProtocol",1) DllStructSetData($DLL_RASENTRY,"dwHangUpExtraPercent",10) DllStructSetData($DLL_RASENTRY,"dwHangUpExtraSampleSeconds",120) DllStructSetData($DLL_RASENTRY,"dwRedialCount",3) DllStructSetData($DLL_RASENTRY,"dwRedialPause",60) DllStructSetData($DLL_RASENTRY,"dwType",5) CopyMemory("szDeviceName",$sDeviceName,StringLen($sDeviceName)) CopyMemory("szDeviceType",$sDeviceType,StringLen($sDeviceType)) CopyMemory("szLocalPhoneNumber",$sServer,StringLen($sServer)) DllStructSetData($DLL_RASENTRY,"dwVpnStrategy","VS_Default") DllStructSetData($DLL_RASENTRY,"dwEncryptionType","ET_Optional") DllStructSetData($DLL_RASCREDENTIALS,"dwSize",DllStructGetSize($DLL_RASCREDENTIALS)) DllStructSetData($DLL_RASCREDENTIALS,"dwMask",11) CopyMemory("szUserName",$sUsername,StringLen($sUsername)) CopyMemory("szPassword",$sPassword,StringLen($sPassword)) $Iret= DllCall("rasapi32.dll","dword","RasSetEntryProperties","str",$Rasentry,"str",$sEntryName,"dword*",$DLL_RASENTRY,"dword",$size,"byte",$vbNullString,"dword",0) MsgBox(0,"",$Iret[0]) Func CopyMemory($Destination, $Source, $Length) Local $Return $Return = DllCall("kernel32.dll", "none", "RtlMoveMemory", "ptr", $Destination, "ptr", $Source,"int", $Length) Return $Return[0] EndFunc Error 632 = Incorrect structure size. Edited March 26, 2017 by Starstar 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 More sharing options...
Danyfirex Posted March 26, 2017 Share Posted March 26, 2017 Hello. You're structure is wrong. youre missing fields. https://msdn.microsoft.com/ru-ru/library/windows/desktop/aa377274(v=vs.85).aspx Saludos Starstar 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Starstar Posted March 26, 2017 Author Share Posted March 26, 2017 Just now, Danyfirex said: Hello. You're structure is wrong. youre missing fields. https://msdn.microsoft.com/ru-ru/library/windows/desktop/aa377274(v=vs.85).aspx Saludos Thanks Danyfirex 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 More sharing options...
Danyfirex Posted March 26, 2017 Share Posted March 26, 2017 You're wellcome. I suggest you to use Unicode API version. Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Starstar Posted March 26, 2017 Author Share Posted March 26, 2017 (edited) Can you point out which field i missed? i also tried Unicode like this expandcollapse popupdim $vbNullString=Chr(0) Global Enum $ERROR_SUCCESS=0, $ERROR_INVALID_NAME=123, $ERROR_ALREADY_EXISTS=183, $ERROR_CANNOT_FIND_PHONEBOOK=82 Global Const $ERROR_BUFFER_TOO_SMALL = 603 Global Const $RAS_MaxAreaCode = 10 Global Const $RAS_MaxPhoneNumber = 128 Global Const $RAS_MaxDeviceType = 16 Global Const $RAS_MaxDeviceName = 128 Global Const $RAS_MaxPadType = 32 Global Const $RAS_MaxX25Address = 200 Global Const $RAS_MaxFacilities = $RAS_MaxX25Address Global Const $RAS_MaxUserData = $RAS_MaxFacilities Global Const $RAS_MaxDnsSuffix = 256 Global Const $RAS_MaxEntryName = 256 Global Const $WM_RASDIALEVENT = 0xCCCD Global Const $RASCS_DONE = 0x2000 Global Const $WAIT_OBJECT_0 = 0 Global $hConection = 0 Global Const $MAX_PATH = 256 $Str_RASENTRY = "struct;dword dwSize;dword dwfOptions;dword dwCountryID;dword dwCountryCode;wchar szAreaCode["&$RAS_MaxAreaCode + 1&"];wchar szLocalPhoneNumber["&$RAS_MaxPhoneNumber + 1&"];dword dwAlternateOffset;wstr ipaddr;wstr ipaddrDns;wstr ipaddrDnsAlt;wstr ipaddrWins;wstr ipaddrWinsAlt;dword dwFrameSize;dword dwfNetProtocols;dword dwFramingProtocol;wchar szScript["&$MAX_PATH&"];wchar szAutodialDll["&$MAX_PATH&"];wchar szAutodialFunc["&$MAX_PATH&"];wchar szDeviceType[" & $RAS_MaxDeviceType + 1 & "];wchar szDeviceName[" & $RAS_MaxDeviceName + 1 & "];wchar szX25PadType["&$RAS_MaxPadType + 1&"];wchar szX25Address["&$RAS_MaxX25Address + 1&"];wchar szX25Facilities["&$RAS_MaxFacilities + 1&"];wchar szX25UserData["&$RAS_MaxUserData + 1&"];dword dwChannels;dword dwReserved1;dword dwReserved2;dword dwSubEntries;dword dwDialMode;dword dwDialExtraPercent;dword dwDialExtraSampleSeconds;dword dwHangUpExtraPercent;dword dwHangUpExtraSampleSeconds; dword dwIdleDisconnectSeconds;dword dwType;dword dwType;dword dwType;GUID guidId;wchar szCustomDialDll["&$MAX_PATH&"];dword dwVpnStrategy;dword dwfOptions2;dword dwfOptions3;wchar szDnsSuffix["&$RAS_MaxDnsSuffix&"];dword dwTcpWindowSize;wchar szPrerequisitePbk["&$MAX_PATH&"];wchar szPrerequisiteEntry["&$RAS_MaxEntryName + 1&"];dword dwRedialCount;dword dwRedialPause;wstr ipv6addrDns;wstr ipv6addrDnsAlt;dword dwIPv4InterfaceMetric;dword dwIPv6InterfaceMetric;wstr ipv6addr;dword dwIPv6PrefixLength;dword dwNetworkOutageTime" $DLL_RASENTRY = DllStructCreate($Str_RASENTRY) $Str_RASCREDENTIALS = "dword dwSize;dword dwMask;char szUserName[256];char szPassword[256];char szDomain[15]" $DLL_RASCREDENTIALS=DllStructCreate($Str_RASCREDENTIALS) $sDeviceName = "WAN MINIPORT (PPPOE)" $sDeviceType = "Vpn" $sEntryName = "Test" $sServer = "Test" $sUsername = "Test" $sPassword = "Test" $Rasentry = @AppDataDir & "\Microsoft\Network\Connections\Pbk\rasphone.pbk" $size = DllStructGetSize($DLL_RASENTRY) DllStructSetData($DLL_RASENTRY,"dwSize",$size) DllStructSetData($DLL_RASENTRY,"dwCountryCode",86) DllStructSetData($DLL_RASENTRY,"dwCountryID",86) DllStructSetData($DLL_RASENTRY,"dwDialExtraPercent",75) DllStructSetData($DLL_RASENTRY,"dwDialExtraSampleSeconds",120) DllStructSetData($DLL_RASENTRY,"dwDialMode",1) DllStructSetData($DLL_RASENTRY,"dwfNetProtocols",4) DllStructSetData($DLL_RASENTRY,"dwfOptions",1024262928) DllStructSetData($DLL_RASENTRY,"dwfOptions2",367) DllStructSetData($DLL_RASENTRY,"dwFramingProtocol",1) DllStructSetData($DLL_RASENTRY,"dwHangUpExtraPercent",10) DllStructSetData($DLL_RASENTRY,"dwHangUpExtraSampleSeconds",120) DllStructSetData($DLL_RASENTRY,"dwRedialCount",3) DllStructSetData($DLL_RASENTRY,"dwRedialPause",60) DllStructSetData($DLL_RASENTRY,"dwType",5) CopyMemory("szDeviceName",$sDeviceName,StringLen($sDeviceName)) CopyMemory("szDeviceType",$sDeviceType,StringLen($sDeviceType)) CopyMemory("szLocalPhoneNumber",$sServer,StringLen($sServer)) DllStructSetData($DLL_RASENTRY,"dwVpnStrategy","VS_Default") DllStructSetData($DLL_RASENTRY,"dwEncryptionType","ET_Optional") DllStructSetData($DLL_RASCREDENTIALS,"dwSize",DllStructGetSize($DLL_RASCREDENTIALS)) DllStructSetData($DLL_RASCREDENTIALS,"dwMask",11) CopyMemory("szUserName",$sUsername,StringLen($sUsername)) CopyMemory("szPassword",$sPassword,StringLen($sPassword)) $Iret= DllCall("rasapi32.dll","dword","RasSetEntryPropertiesW","wstr",$Rasentry,"wstr",$sEntryName,"dword*",$DLL_RASENTRY,"dword",$size,"byte",$vbNullString,"dword",0) MsgBox(0,"",$Iret[0]) Func CopyMemory($Destination, $Source, $Length) Local $Return $Return = DllCall("kernel32.dll", "none", "RtlMoveMemory", "ptr", $Destination, "ptr", $Source,"int", $Length) Return $Return[0] EndFunc But until i got error 632 Edited March 26, 2017 by Starstar 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 More sharing options...
Danyfirex Posted March 26, 2017 Share Posted March 26, 2017 The structure is still wrong you're using unkown dllstructure data types. Make sure to check DllStructureCreate help File. I also think you need to add some OS Version Macro to make it compatible for multiples OS versions. I really dont have enough time to do it. But I hope my suggestions help you. Saludos Starstar 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Starstar Posted March 27, 2017 Author Share Posted March 27, 2017 21 hours ago, Danyfirex said: The structure is still wrong you're using unkown dllstructure data types. Make sure to check DllStructureCreate help File. I also think you need to add some OS Version Macro to make it compatible for multiples OS versions. I really dont have enough time to do it. But I hope my suggestions help you. Saludos Thanx Danyfire 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 More sharing options...
Starstar Posted March 27, 2017 Author Share Posted March 27, 2017 Dll is a hell......... 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now