nullschritt Posted August 25, 2013 Posted August 25, 2013 Hello all, I am writing a p2p messaging program, and I have ran into a problem, it;s impossible to get the real IP address of anyone using a VPN adapter. My solution to the problem is to temporarily disable any vpn network devices and then run a network query for their public ip address, to add to the peers list. However my stumbling block is 1) How do I get a list of all the network adapters [know of no solution to this] 2)Disabling then re-enabling the adapter [i know somewhere here there is a solution for this, but I am having trouble locating it] Thanks ahead of time for reading my post!
dragan Posted August 25, 2013 Posted August 25, 2013 '?do=embed' frameborder='0' data-embedContent>>'?do=embed' frameborder='0' data-embedContent>>
nullschritt Posted August 25, 2013 Author Posted August 25, 2013 '?do=embed' frameborder='0' data-embedContent>>'?do=embed' frameborder='0' data-embedContent>> Thanks for the quick response, but I still don't know how to enable/disable the adapaters, and help there would be appreciated.
AutID Posted August 25, 2013 Posted August 25, 2013 expandcollapse popupGlobal $hDLL = DllOpen("wlanapi.dll"), $tGUID = DllStructCreate("byte[16]") Local $hClientHandle, $abGUIDs, $pGUID, $avNetworks $hClientHandle = _GetClientHandle() $abGUIDs = _GetInterfaces($hClientHandle) $pGUID = _SelectInterface($abGUIDs[0]) $avNetworks = _GetNetworkList($hClientHandle, $pGUID, 0) _End() Func _GetClientHandle() Local $aResult = DllCall($hDLL, "dword", "WlanOpenHandle", "dword", 2, "ptr", 0, "dword*", 0, "hwnd*", 0) If @error Or $aResult[0] Then ConsoleWrite("WlanOpenHandle Failed" & @CRLF) Exit EndIf Return $aResult[4] EndFunc Func _GetInterfaces($hClientHandle) Local $aResult, $pInterfaceList, $tInterfaceList, $iInterfaceCount, $pInterface, $tInterface $aResult = DllCall($hDLL, "dword", "WlanEnumInterfaces", "hwnd", $hClientHandle, "ptr", 0, "ptr*", 0) If @error Or $aResult[0] Then ConsoleWrite("WlanEnumInterfaces Failed" & @CRLF) Exit EndIf $pInterfaceList = $aResult[3] $tInterfaceList = DllStructCreate("dword", $pInterfaceList) $iInterfaceCount = DllStructGetData($tInterfaceList, 1) If Not $iInterfaceCount Then ConsoleWrite("no interfaces were found" & @CRLF) Exit EndIf Local $abGUIDs[$iInterfaceCount] For $i = 0 To $iInterfaceCount - 1 $pInterface = Ptr(Number($pInterfaceList) + ($i * 532 + 8)) $tInterface = DllStructCreate("byte GUID[16]; wchar descr[256]; int State", $pInterface) $abGUIDs[$i] = DllStructGetData($tInterface, "GUID") ConsoleWrite("Found Interface: " & DllStructGetData($tInterface, "descr") & @CRLF) Next DllCall($hDLL, "dword", "WlanFreeMemory", "ptr", $pInterfaceList) ;free memory Return $abGUIDs EndFunc Func _SelectInterface($bGUID) DllStructSetData($tGUID, 1, $bGUID) Return DllStructGetPtr($tGUID) EndFunc Func _GetNetworkList($hClientHandle, $pGUID, $iFlags) Local $aResult, $pNetworkList, $tNetworkList, $iNetworkCount, $pNetworkItem, $tNetworkItem $aResult = DllCall($hDLL, "dword", "WlanGetAvailableNetworkList", "hwnd", $hClientHandle, "ptr", $pGUID, "int", $iFlags, "ptr", 0, "ptr*", 0) If @error Or $aResult[0] Then ConsoleWrite("WlanGetAvailableNetworkList Failed" & @CRLF) Exit EndIf $pNetworkList = $aResult[5] $tNetworkList = DllStructCreate("dword", $pNetworkList) $iNetworkCount = DllStructGetData($tNetworkList, 1) If Not $iNetworkCount Then ConsoleWrite("no networks were found" & @CRLF) Exit EndIf Local $avNetworks[$iNetworkCount][20] ;declare array to store information. For $i = 0 To $iNetworkCount - 1 $pNetworkItem = Ptr(Number($pNetworkList) + ($i * 628 + 8)) $tNetworkItem = DllStructCreate("wchar ProfName[256]; dword SSIDLen; char SSID[32]; dword BSSType; dword NoBSSIDs; dword Connectable; dword RsnCode; dword NoPhyTypes; " & _ "dword PhyTypes[8]; dword MorePhyTypes; dword Signal; dword SecEnabled; dword Auth; dword Ciph; dword Flags", $pNetworkItem) $avNetworks[$i][0] = DllStructGetData($tNetworkItem, "ProfName") $avNetworks[$i][1] = DllStructGetData($tNetworkItem, "SSID") $avNetworks[$i][2] = DllStructGetData($tNetworkItem, "Signal") If DllStructGetData($tNetworkItem, "SecEnabled") Then $avNetworks[$i][3] = "Secure" Else $avNetworks[$i][3] = "Not Secure" EndIf ConsoleWrite("Found Network: " & $avNetworks[$i][1] & " [" & $avNetworks[$i][2] & "%]" & @CRLF) Next DllCall($hDLL, "dword", "WlanFreeMemory", "ptr", $pNetworkList) ;Free memory Return $avNetworks EndFunc Func _End() DllCall($hDLL, "dword", "WlanCloseHandle", "ptr", $hClientHandle, "ptr", 0) DllClose($hDLL) EndFuncif you need more informations than if it is enabled add lists to $avNetworks https://iblockify.wordpress.com/
nullschritt Posted August 26, 2013 Author Posted August 26, 2013 (edited) @AutlD Thanks but now I am still looking for how to enable/disable adapters. Perhaps here in a minute I should try some new search combinations and see what I get. Edited August 26, 2013 by nullschritt
AutID Posted August 26, 2013 Posted August 26, 2013 (edited) @AutlD Thanks but now I am still looking for how to enable/disable adapters. Perhaps here in a minute I should try some new search combinations and see what I get.You shouldn't be checking here then but in MSDN site for wlanapi functions. I will take a look.Edit: Check the WlanSetInterface. You can enable/disable wireless network connectivity. Edited August 26, 2013 by AutID https://iblockify.wordpress.com/
AutID Posted August 26, 2013 Posted August 26, 2013 Find your answer here: '?do=embed' frameborder='0' data-embedContent>>Helped me a lot. All MSDN functions of wlanapi written in autoit https://iblockify.wordpress.com/
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