Hasher Posted May 10, 2008 Share Posted May 10, 2008 Hi Trying to do a Winapi call in Autoit and below is as far as I have got. Want to know to handle a GUID in autoit into the call. Also confused with some types and could someone give me advice if I have translated the types correctly. Thanks expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.10.0 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here Dim $pInterfaceGuid = '{0AA83A87-1BE9-4691-B480-B767C34F2E12}' Dim $dwClientVersion = '1' Dim $pReserved = '0' Dim $pdwNegotiatedVersion Dim $phClientHandle Dim $strProfileName = 'qactester' Dim $pReserved = '' Dim $pstrProfileXml Dim $pdwFlags = 'nil' Dim $pdwGrantedAccess $dll = DllOpen("wlanapi.dll") DllCall($dll, "dword" , "WlanOpenHandle", "dword" , $dwClientVersion , "ptr" , $pReserved, "dword*", $pdwNegotiatedVersion, "ptr" , $phClientHandle) ConsoleWrite($pdwNegotiatedVersion) ConsoleWrite($phClientHandle) ;http://msdn.microsoft.com/en-us/library/ms706759(VS.85).aspx ;DWORD WINAPI WlanOpenHandle( ; __in DWORD dwClientVersion, ; __reserved PVOID pReserved, ; __out PDWORD pdwNegotiatedVersion, ; __out PHANDLE phClientHandle ;); DllCall($dll, "Dword", "WlanGetProfile", "ptr", $phClientHandle, "str", $pInterfaceGuid, "wstr" , $strProfileName , "ptr*" ,$pReserved , "wstr*" , $pstrProfileXml, "dword*", $pdwFlags , "dword*", $pdwGrantedAccess) ConsoleWrite($pstrProfileXml) DllClose($dll) ;http://msdn.microsoft.com/en-us/library/ms706738(VS.85).aspx ;DWORD WINAPI WlanGetProfile( ; __in HANDLE hClientHandle, ; __in const GUID* pInterfaceGuid, ; __in LPCWSTR strProfileName, ; __reserved PVOID pReserved, ; __out LPWSTR* pstrProfileXml, ; __out_opt DWORD* pdwFlags, ; __out_opt PDWORD pdwGrantedAccess Firefox's secret is the same as Jessica Simpson's: its effortless, glamorous style is the result of shhh extensions! Link to comment Share on other sites More sharing options...
Hasher Posted May 11, 2008 Author Share Posted May 11, 2008 No one can help :-( Firefox's secret is the same as Jessica Simpson's: its effortless, glamorous style is the result of shhh extensions! Link to comment Share on other sites More sharing options...
martin Posted May 11, 2008 Share Posted May 11, 2008 Hi Trying to do a Winapi call in Autoit and below is as far as I have got. Want to know to handle a GUID in autoit into the call. Also confused with some types and could someone give me advice if I have translated the types correctly. Thanks expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.10.0 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here Dim $pInterfaceGuid = '{0AA83A87-1BE9-4691-B480-B767C34F2E12}' Dim $dwClientVersion = '1' Dim $pReserved = '0' Dim $pdwNegotiatedVersion Dim $phClientHandle Dim $strProfileName = 'qactester' Dim $pReserved = '' Dim $pstrProfileXml Dim $pdwFlags = 'nil' Dim $pdwGrantedAccess $dll = DllOpen("wlanapi.dll") DllCall($dll, "dword" , "WlanOpenHandle", "dword" , $dwClientVersion , "ptr" , $pReserved, "dword*", $pdwNegotiatedVersion, "ptr" , $phClientHandle) ConsoleWrite($pdwNegotiatedVersion) ConsoleWrite($phClientHandle) ;http://msdn.microsoft.com/en-us/library/ms706759(VS.85).aspx ;DWORD WINAPI WlanOpenHandle( ; __in DWORD dwClientVersion, ; __reserved PVOID pReserved, ; __out PDWORD pdwNegotiatedVersion, ; __out PHANDLE phClientHandle ;); DllCall($dll, "Dword", "WlanGetProfile", "ptr", $phClientHandle, "str", $pInterfaceGuid, "wstr" , $strProfileName , "ptr*" ,$pReserved , "wstr*" , $pstrProfileXml, "dword*", $pdwFlags , "dword*", $pdwGrantedAccess) ConsoleWrite($pstrProfileXml) DllClose($dll) ;http://msdn.microsoft.com/en-us/library/ms706738(VS.85).aspx ;DWORD WINAPI WlanGetProfile( ; __in HANDLE hClientHandle, ; __in const GUID* pInterfaceGuid, ; __in LPCWSTR strProfileName, ; __reserved PVOID pReserved, ; __out LPWSTR* pstrProfileXml, ; __out_opt DWORD* pdwFlags, ; __out_opt PDWORD pdwGrantedAccess I think you have got the $clienthandle parameter wrong. You need to pass a pointer to the variable used for the client handle like this expandcollapse popup $pch = dllstructcreate("int") DllCall($dll, "dword" , "WlanOpenHandle", "dword" , $dwClientVersion , "ptr" , $pReserved, "dword*", $pdwNegotiatedVersion, "ptr" , DllStructGetptr($pch)) ConsoleWrite($pdwNegotiatedVersion) ConsoleWrite($phClientHandle) ;http://msdn.microsoft.com/en-us/library/ms706759(VS.85).aspx ;DWORD WINAPI WlanOpenHandle( ; __in DWORD dwClientVersion, ; __reserved PVOID pReserved, ; __out PDWORD pdwNegotiatedVersion, ; __out PHANDLE phClientHandle ; $phClientHandle = DllStructGetData($pch,1);read the handle DllCall($dll, "Dword", "WlanGetProfile", "ptr", $phClientHandle, "str", $pInterfaceGuid, "wstr" , $strProfileName , "ptr*" ,$pReserved , "wstr*" , $pstrProfileXml, "dword*", $pdwFlags , "dword*", $pdwGrantedAccess) ConsoleWrite($pstrProfileXml) [code=auto:0] I don't know about the rest though. I'm only posting here by mistake btw, I was quite interested in your thread until I realized the title wasn't "Native wife api help". Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options... Hasher Posted May 11, 2008 Hasher Active Members 172 Author Share Posted May 11, 2008 Thanks Martin I can now see my handle !!!. Yes it probably was a stupid title , too late to change it now :-/ With $pstrProfileXml its meant to come back as a heap of data , Am I declaring it right ? Seems strange to have such a low function retrieving such a high one as XML. Also is how I am calling the GUID into the api correct. Thanks again Firefox's secret is the same as Jessica Simpson's: its effortless, glamorous style is the result of shhh extensions! Link to comment Share on other sites More sharing options... martin Posted May 11, 2008 martin MVPs 7.1k 3 ~~\o/~~~/0\=¬''~~~ Share Posted May 11, 2008 Thanks MartinI can now see my handle !!!. Yes it probably was a stupid title , too late to change it now :-/With $pstrProfileXml its meant to come back as a heap of data , Am I declaring it right ? Seems strange to have such a low function retrieving such a high one as XML. Also is how I am calling the GUID into the api correct.Thanks againI'm not really sure about this so that means I am probably wrong. But I would try using "wstr" instead of "wstr*" because strings are passed as pointers anyway.Also I would do this$StructGranted = DllStructCreate("dword")DllCall($dll, "Dword", "WlanGetProfile", "ptr", $phClientHandle, "str", $pInterfaceGuid, "wstr" , $strProfileName , "ptr*" ,$pReserved , "wstr" , $pstrProfileXml, "dword*", $pdwFlags , "dword*", DllStructGetPtr($StructGranted))$pdwGrantedAccess =DllStructGetData($structGranted,1) Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options... 8 months later... MattyD Posted January 23, 2009 MattyD Active Members 166 Share Posted January 23, 2009 Any luck?I cant seem to get anything working that requires me to pass a guid... The functions all return 2. here is the simplest function I could find.http://msdn.microsoft.com/en-us/library/ms706714(VS.85).aspxDWORD WINAPI WlanDisconnect( __in HANDLE hClientHandle, __in const GUID *pInterfaceGuid, __reserved PVOID pReserved);and here is the closest i came to interpreting the error codes but im not entirely sure if im in the right place... (invalid handle and invalid parameter are definately right.)http://msdn.microsoft.com/en-us/library/ms681382(VS.85).aspxReturn code Description for WlanDisconnect: (numeric value in brackets)ERROR_INVALID_PARAMETER (87) hClientHandle is NULL or invalid, pInterfaceGuid is NULL, or pReserved is not NULL.ERROR_INVALID_HANDLE (6) The handle hClientHandle was not found in the handle table.RPC_STATUS (?) Various error codes.ERROR_NOT_ENOUGH_MEMORY(8) Failed to allocate memory for the query results.ERROR_ACCESS_DENIED(5) The caller does not have sufficient permissions. $dll = DllOpen("wlanapi.dll") $GUID = "{F2B36DB5-9793-4293-AB6C-3F64D5C1767F}" $handle = DllStructCreate("dword") $negversion = DllStructCreate("dword") $ret1 = DllCall("wlanapi.dll", "dword", "WlanOpenHandle","dword" ,"1", "ptr", "","dword", DllStructGetPtr($negversion), "ptr", DllStructGetPtr($handle)) $handle = DllStructGetData($handle, 1) $negversion = DllStructGetData($negversion, 1) ConsoleWrite(@error & @lf); writes 0 ConsoleWrite($handle & @lf); writes 1 ConsoleWrite($negversion & @lf); writes 1 ConsoleWrite($ret1[0] & @lf); writes 0 $ret2 = DllCall("wlanapi.dll", "dword", "WlanDisconnect", "ptr", $handle, "str", $GUID & chr(0), "ptr", "") ConsoleWrite("----------" & @lf) ConsoleWrite(@error & @lf); writes 0 ConsoleWrite($ret2[0] & @lf); !!! writes 2 !!! Link to comment Share on other sites More sharing options...
trancexx Posted January 23, 2009 Share Posted January 23, 2009 (edited) Any luck? I cant seem to get anything working that requires me to pass a guid... The functions all return 2. here is the simplest function I could find. http://msdn.microsoft.com/en-us/library/ms706714(VS.85).aspx DWORD WINAPI WlanDisconnect( __in HANDLE hClientHandle, __in const GUID *pInterfaceGuid, __reserved PVOID pReserved ); and here is the closest i came to interpreting the error codes but im not entirely sure if im in the right place... (invalid handle and invalid parameter are definately right.) http://msdn.microsoft.com/en-us/library/ms681382(VS.85).aspx Return code Description for WlanDisconnect: (numeric value in brackets) ERROR_INVALID_PARAMETER (87) hClientHandle is NULL or invalid, pInterfaceGuid is NULL, or pReserved is not NULL. ERROR_INVALID_HANDLE (6) The handle hClientHandle was not found in the handle table. RPC_STATUS (?) Various error codes. ERROR_NOT_ENOUGH_MEMORY(8) Failed to allocate memory for the query results. ERROR_ACCESS_DENIED(5) The caller does not have sufficient permissions. $dll = DllOpen("wlanapi.dll") $GUID = "{F2B36DB5-9793-4293-AB6C-3F64D5C1767F}" $handle = DllStructCreate("dword") $negversion = DllStructCreate("dword") $ret1 = DllCall("wlanapi.dll", "dword", "WlanOpenHandle","dword" ,"1", "ptr", "","dword", DllStructGetPtr($negversion), "ptr", DllStructGetPtr($handle)) $handle = DllStructGetData($handle, 1) $negversion = DllStructGetData($negversion, 1) ConsoleWrite(@error & @lf); writes 0 ConsoleWrite($handle & @lf); writes 1 ConsoleWrite($negversion & @lf); writes 1 ConsoleWrite($ret1[0] & @lf); writes 0 $ret2 = DllCall("wlanapi.dll", "dword", "WlanDisconnect", "ptr", $handle, "str", $GUID & chr(0), "ptr", "") ConsoleWrite("----------" & @lf) ConsoleWrite(@error & @lf); writes 0 ConsoleWrite($ret2[0] & @lf); !!! writes 2 !!!Try this and see what's red: #include <WinApi.au3> DllOpen("wlanapi.dll") $GUID = "{F2B36DB5-9793-4293-AB6C-3F64D5C1767F}" $a_iCall = DllCall("wlanapi.dll", "dword", "WlanOpenHandle", "dword", 1, "ptr", 0, "dword*", 0, "hwnd*", 0) ConsoleWrite("! " & _WinAPI_GetLastErrorMessage()) ;ConsoleWrite("DllCall error: " & @error & @CRLF) ConsoleWrite("Return value: " & $a_iCall[0] & @CRLF) ConsoleWrite("ClientVersion: " & $a_iCall[1] & @CRLF) ConsoleWrite("Reserved: " & $a_iCall[2] & @CRLF) ConsoleWrite("NegotiatedVersion: " & $a_iCall[3] & @CRLF) ConsoleWrite("ClientHandle: " & $a_iCall[4] & @CRLF) $hClientHandle = $a_iCall[4] ConsoleWrite("----------" & @CRLF) $a_iCall = DllCall("wlanapi.dll", "dword", "WlanDisconnect", "hwnd", $hClientHandle, "str", $GUID, "ptr", 0) ConsoleWrite("! " & _WinAPI_GetLastErrorMessage()) ;ConsoleWrite("DllCall error: " & @error & @CRLF) ConsoleWrite("Return value: " & $a_iCall[0] & @CRLF) Edited January 24, 2009 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
MattyD Posted January 27, 2009 Share Posted January 27, 2009 (edited) Try this and see what's red:#include <WinApi.au3> DllOpen("wlanapi.dll") $GUID = "{F2B36DB5-9793-4293-AB6C-3F64D5C1767F}" $a_iCall = DllCall("wlanapi.dll", "dword", "WlanOpenHandle", "dword", 1, "ptr", 0, "dword*", 0, "hwnd*", 0) ConsoleWrite("! " & _WinAPI_GetLastErrorMessage()) ;ConsoleWrite("DllCall error: " & @error & @CRLF) ConsoleWrite("Return value: " & $a_iCall[0] & @CRLF) ConsoleWrite("ClientVersion: " & $a_iCall[1] & @CRLF) ConsoleWrite("Reserved: " & $a_iCall[2] & @CRLF) ConsoleWrite("NegotiatedVersion: " & $a_iCall[3] & @CRLF) ConsoleWrite("ClientHandle: " & $a_iCall[4] & @CRLF) $hClientHandle = $a_iCall[4] ConsoleWrite("----------" & @CRLF) $a_iCall = DllCall("wlanapi.dll", "dword", "WlanDisconnect", "hwnd", $hClientHandle, "str", $GUID, "ptr", 0) ConsoleWrite("! " & _WinAPI_GetLastErrorMessage()) ;ConsoleWrite("DllCall error: " & @error & @CRLF) ConsoleWrite("Return value: " & $a_iCall[0] & @CRLF)Thanks for the speedy reply mate. neat little trick.this is what was returned...! The operation completed successfully.Return value: 0ClientVersion: 1Reserved: 0x00000000NegotiatedVersion: 1ClientHandle: 0x00000001----------! An attempt was made to reference a token that does not exist.Return value: 2does this mean i need to pass the guid by reference? Edited January 27, 2009 by MattyD Link to comment Share on other sites More sharing options...
trancexx Posted January 27, 2009 Share Posted January 27, 2009 Likely you need GUID, not string representation of it. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
ChangMinYang Posted January 27, 2009 Share Posted January 27, 2009 Thanks for the speedy reply mate. neat little trick.this is what was returned...! The operation completed successfully.Return value: 0ClientVersion: 1Reserved: 0x00000000NegotiatedVersion: 1ClientHandle: 0x00000001----------! An attempt was made to reference a token that does not exist.Return value: 2does this mean i need to pass the guid by reference?Winreless LAN adapter's GUID is identical at your computer.First, change it for your own value. Link to comment Share on other sites More sharing options...
MattyD Posted January 28, 2009 Share Posted January 28, 2009 Likely you need GUID, not string representation of it. Okeydoke. It seems I should be able to return GUID (or a pointer to it). It lies in a struct within a struct when calling the enumerate interfaces function. Its a little over my head at the moment on how to get to it so I'll do a bit of research, have a play and report back in a few days with probable failure for anyone who is interested... WlanEnumInterfaces Function http://msdn.microsoft.com/en-us/library/ms706716(VS.85).aspx DWORD WINAPI WlanEnumInterfaces( __in HANDLE hClientHandle, __reserved PVOID pReserved, __out PWLAN_INTERFACE_INFO_LIST *ppInterfaceList ); WLAN_INTERFACE_INFO_LIST Structure http://msdn.microsoft.com/en-us/library/ms706873(VS.85).aspx typedef struct _WLAN_INTERFACE_INFO_LIST { DWORD dwNumberOfItems; DWORD dwIndex; WLAN_INTERFACE_INFO InterfaceInfo[]; } WLAN_INTERFACE_INFO_LIST, *PWLAN_INTERFACE_INFO_LIST; WLAN_INTERFACE_INFO Structure http://msdn.microsoft.com/en-us/library/ms706868(VS.85).aspx typedef struct _WLAN_INTERFACE_INFO { GUID InterfaceGuid; WCHAR strInterfaceDescription[256]; WLAN_INTERFACE_STATE isState; } WLAN_INTERFACE_INFO, *PWLAN_INTERFACE_INFO; Cheers, Matt Link to comment Share on other sites More sharing options...
MattyD Posted February 10, 2009 Share Posted February 10, 2009 (edited) Progress!!!! All I need to do now is to break down the GUID into something usable or get a pointer to it. #include <WinApi.au3> DllOpen("wlanapi.dll") $a_iCall = DllCall("wlanapi.dll", "dword", "WlanOpenHandle", "dword", 1, "ptr", 0, "dword*", 0, "hwnd*", 0) ConsoleWrite("! " & _WinAPI_GetLastErrorMessage()) ConsoleWrite("Return value: " & $a_iCall[0] & @CRLF) ConsoleWrite("[in] ClientVersion: " & $a_iCall[1] & @CRLF) ConsoleWrite("[rsv] Reserved: " & $a_iCall[2] & @CRLF) ConsoleWrite("[out] NegotiatedVersion: " & $a_iCall[3] & @CRLF) ConsoleWrite("[out] ClientHandle: " & $a_iCall[4] & @CRLF) $hClientHandle = $a_iCall[4] ConsoleWrite("----------" & @CRLF) $a_iCall = DllCall("wlanapi.dll", "dword", "WlanEnumInterfaces", "hwnd", $hClientHandle , "ptr", 0, "ptr*", 0) Sleep(1000) ConsoleWrite("! " & _WinAPI_GetLastErrorMessage()) ConsoleWrite("Return value: " & $a_iCall[0] & @CRLF) ConsoleWrite("[in] ClientHandle: " & $a_iCall[1] & @CRLF) ConsoleWrite("[rsv] Reserved: " & $a_iCall[2] & @CRLF) ConsoleWrite("[out] pInfo_List: " & $a_iCall[3] & @CRLF) $pInfoList = $a_iCall[3] ConsoleWrite("----------" & @CRLF) $INFO_LIST = DllStructCreate("dword;dword;byte[16];wchar[256]", $pInfoList) ;$GUID = "{F2B36DB5-9793-4293-AB6C-3F64D5C1767F}" ConsoleWrite("[dw] NumberOfItems: " & DllStructGetData($INFO_LIST, 1) & @CRLF) ConsoleWrite("[dw] Index: " & DllStructGetData($INFO_LIST, 2) & @CRLF) ConsoleWrite("[128 bits] GUID: " & DllStructGetData($INFO_LIST, 3) & @CRLF) ConsoleWrite("[wchr[256]] desc: " & DllStructGetData($INFO_LIST, 4) & @CRLF) ! The operation completed successfully. Return value: 0 [in] ClientVersion: 1 [rsv] Reserved: 0x00000000 [out] NegotiatedVersion: 1 [out] ClientHandle: 0x00000001 ---------- ! The operation completed successfully. Return value: 0 [in] ClientHandle: 0x00000001 [rsv] Reserved: 0x00000000 [out] pInfo_List: 0x008A20A0 ---------- [dw] NumberOfItems: 1 [dw] Index: 0 [128 bits] GUID: 0xB56DB3F293979342AB6C3F64D5C1767F [wchr[256]] desc: Dell Wireless 1505 Draft 802.11n WLAN Mini-Card - Packet Scheduler Miniport Edited February 10, 2009 by MattyD Link to comment Share on other sites More sharing options...
MattyD Posted February 10, 2009 Share Posted February 10, 2009 WEHEHEHEHE SOLVED! $a_iCall = DllCall("wlanapi.dll", "dword", "WlanDisconnect", "hwnd", $hClientHandle , "ptr", 0x008A20A8, "ptr", 0) pInfo_List: 0x008A20A0... (output from "WlanEnumInterfaces") Add 8 to get a pointer to the constant GUID. Thanks to all who helped and a special shoutout to trancexx Cheers, Matt Link to comment Share on other sites More sharing options...
trancexx Posted February 10, 2009 Share Posted February 10, 2009 It's great that you've done it. Don't be lazy or selfish maybe, write that few functions in one script and post on examples so that we all benefit out of your findings. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
MattyD Posted February 11, 2009 Share Posted February 11, 2009 (edited) AutoIt functions corresponding to most of those in the dll are coming but for now this will have to do.. Ok, here we go For one wireless interface: (easier to see whats happening) expandcollapse popup#include <WinApi.au3> $DLL = DllOpen("wlanapi.dll") $a_iCall = DllCall($DLL, "dword", "WlanOpenHandle", "dword", 1, "ptr", 0, "dword*", 0, "hwnd*", 0) ConsoleWrite("//---OpenHandle---\\" & @CRLF) ConsoleWrite("! " & _WinAPI_GetLastErrorMessage()) ConsoleWrite("Return value: " & $a_iCall[0] & @CRLF) ConsoleWrite("[in] ClientVersion: " & $a_iCall[1] & @CRLF) ConsoleWrite("[rsv] Reserved: " & $a_iCall[2] & @CRLF) ConsoleWrite("[out] NegotiatedVersion: " & $a_iCall[3] & @CRLF) ConsoleWrite("[out] ClientHandle: " & $a_iCall[4] & @CRLF) $hClientHandle = $a_iCall[4] ConsoleWrite("----------" & @CRLF) $a_iCall = DllCall($DLL, "dword", "WlanEnumInterfaces", "hwnd", $hClientHandle , "ptr", 0, "ptr*", 0) Sleep(1000);ensures _WinAPI_GetLastErrorMessage() returns success, output is the same whether this line is left in or not. ConsoleWrite("//---EnumInterfaces---\\" & @CRLF) ConsoleWrite("! " & _WinAPI_GetLastErrorMessage()) ConsoleWrite("Return value: " & $a_iCall[0] & @CRLF) ConsoleWrite("[in] ClientHandle: " & $a_iCall[1] & @CRLF) ConsoleWrite("[rsv] Reserved: " & $a_iCall[2] & @CRLF) ConsoleWrite("[out] pInfo_List: " & $a_iCall[3] & @CRLF) $pInfoList = $a_iCall[3] ConsoleWrite("----------" & @CRLF) $INFO_LIST = DllStructCreate("dword;dword;byte[16];wchar[256];dword", $pInfoList) ConsoleWrite("//---INTERFACE_INFO_LIST Structure---\\" & @CRLF) ConsoleWrite("[dw] NumberOfItems: " & DllStructGetData($INFO_LIST, 1) & @CRLF) ConsoleWrite("[dw] Index: " & DllStructGetData($INFO_LIST, 2) & @CRLF) ConsoleWrite("[128 bits] GUID: " & DllStructGetData($INFO_LIST, 3) & @CRLF) ConsoleWrite("[wchr[256]] desc: " & DllStructGetData($INFO_LIST, 4) & @CRLF) ConsoleWrite("[dw] ConnStatus: " & DllStructGetData($INFO_LIST, 5) & @CRLF);1 Connected; 4 Disconnected; 7 Authenticating $pGUID = $pInfoList + 8;pointer to the GUID of the first interface ConsoleWrite("----------" & @CRLF) DllCall($DLL, "dword", "WlanDisconnect", "hwnd", $hClientHandle, "ptr", $pGUID, "ptr", 0) sleep(1000) ConsoleWrite("//---Disconnect---\\" & @CRLF) ConsoleWrite("! " & _WinAPI_GetLastErrorMessage()) ConsoleWrite("Return value: " & $a_iCall[0] & @CRLF) ConsoleWrite("[in] ClientVersion: " & $a_iCall[1] & @CRLF) ConsoleWrite("[in] pGUID: " & $a_iCall[2] & @CRLF) ConsoleWrite("[rsv] Reserved: " & $a_iCall[3] & @CRLF) For multiple wireless interfaces: expandcollapse popup#include <WinApi.au3> $DLL = DllOpen("wlanapi.dll") $a_iCall = DllCall($DLL, "dword", "WlanOpenHandle", "dword", 1, "ptr", 0, "dword*", 0, "hwnd*", 0) ConsoleWrite("//---OpenHandle---\\" & @CRLF) ConsoleWrite("! " & _WinAPI_GetLastErrorMessage()) ConsoleWrite("Return value: " & $a_iCall[0] & @CRLF) ConsoleWrite("[in] ClientVersion: " & $a_iCall[1] & @CRLF) ConsoleWrite("[rsv] Reserved: " & $a_iCall[2] & @CRLF) ConsoleWrite("[out] NegotiatedVersion: " & $a_iCall[3] & @CRLF) ConsoleWrite("[out] ClientHandle: " & $a_iCall[4] & @CRLF) $hClientHandle = $a_iCall[4] ConsoleWrite("----------" & @CRLF) $a_iCall = DllCall($DLL, "dword", "WlanEnumInterfaces", "hwnd", $hClientHandle , "ptr", 0, "ptr*", 0) Sleep(1000);ensures _WinAPI_GetLastErrorMessage() returns success, output is the same whether this line is left in or not. ConsoleWrite("//---EnumInterfaces---\\" & @CRLF) ConsoleWrite("! " & _WinAPI_GetLastErrorMessage()) ConsoleWrite("Return value: " & $a_iCall[0] & @CRLF) ConsoleWrite("[in] ClientHandle: " & $a_iCall[1] & @CRLF) ConsoleWrite("[rsv] Reserved: " & $a_iCall[2] & @CRLF) ConsoleWrite("[out] pInfo_List: " & $a_iCall[3] & @CRLF) $pInfoList = $a_iCall[3] ConsoleWrite("----------" & @CRLF) $INFO_LIST = DllStructCreate("dword", $pInfoList) ConsoleWrite("//---INTERFACE_INFO_LIST Structure---\\" & @CRLF) ConsoleWrite("[dw] NumberOfItems: " & DllStructGetData($INFO_LIST, 1) & @CRLF) $NumberOfItems = DllStructGetData($INFO_LIST, 1) $StructString = "dword;dword" For $i = 0 to $NumberOfItems - 1 $StructString = $StructString & ";byte[16];wchar[256];dword" Next $INFO_LIST = DllStructCreate($StructString, $pInfoList) ConsoleWrite("[dw] Index: " & DllStructGetData($INFO_LIST, 2) & @CRLF) Dim $pGUID_ARRAY[$NumberOfItems] For $i = 0 to $NumberOfItems - 1 ConsoleWrite("(interface " & $i & ")" & " [128 bits] GUID: " & DllStructGetData($INFO_LIST, $i * 3 + 3) & @CRLF) ConsoleWrite("(interface " & $i & ")" & " [wchr[256]] desc: " & DllStructGetData($INFO_LIST, $i * 3 + 4) & @CRLF) ConsoleWrite("(interface " & $i & ")" & " [dw] ConnStatus: " & DllStructGetData($INFO_LIST, $i * 3 + 5) & @CRLF);1 Connected; 4 Disconnected; 7 Authenticating Next ConsoleWrite("----------" & @CRLF) ConsoleWrite("//---GUID Pointers---\\" & @CRLF) For $i = 0 to $NumberOfItems - 1 ConsoleWrite("(interface " & $i & ")" & " pGUID: 0x" & hex($pInfoList + $i * 532 + 8) & @CRLF) $pGUID_ARRAY[$i] = $pInfoList + $i * 532 + 8;formula to calculate the pointer to the GUID of a given interface Next ConsoleWrite("----------" & @CRLF) DllCall($DLL, "dword", "WlanDisconnect", "hwnd", $hClientHandle, "ptr", $pGUID_ARRAY[0] , "ptr", 0) sleep(1000) ConsoleWrite("//---Disconnect---\\" & @CRLF) ConsoleWrite("! " & _WinAPI_GetLastErrorMessage()) ConsoleWrite("Return value: " & $a_iCall[0] & @CRLF) ConsoleWrite("[in] ClientVersion: " & $a_iCall[1] & @CRLF) ConsoleWrite("[in] pGUID: " & $a_iCall[2] & @CRLF) ConsoleWrite("[rsv] Reserved: " & $a_iCall[3] & @CRLF) And lastly one for hasher: expandcollapse popup#include <WinApi.au3> $DLL = DllOpen("wlanapi.dll") $PROFILE = "";Insert SSID here... (Case sensitive) $a_iCall = DllCall($DLL, "dword", "WlanOpenHandle", "dword", 1, "ptr", 0, "dword*", 0, "hwnd*", 0) ConsoleWrite("//---OpenHandle---\\" & @CRLF) ConsoleWrite("! " & _WinAPI_GetLastErrorMessage()) ConsoleWrite("Return value: " & $a_iCall[0] & @CRLF) ConsoleWrite("[in] ClientVersion: " & $a_iCall[1] & @CRLF) ConsoleWrite("[rsv] Reserved: " & $a_iCall[2] & @CRLF) ConsoleWrite("[out] NegotiatedVersion: " & $a_iCall[3] & @CRLF) ConsoleWrite("[out] ClientHandle: " & $a_iCall[4] & @CRLF) $hClientHandle = $a_iCall[4] ConsoleWrite("----------" & @CRLF) $a_iCall = DllCall($DLL, "dword", "WlanEnumInterfaces", "hwnd", $hClientHandle , "ptr", 0, "ptr*", 0) Sleep(1000);ensures _WinAPI_GetLastErrorMessage() returns success, output is the same whether this line is left in or not. ConsoleWrite("//---EnumInterfaces---\\" & @CRLF) ConsoleWrite("! " & _WinAPI_GetLastErrorMessage()) ConsoleWrite("Return value: " & $a_iCall[0] & @CRLF) ConsoleWrite("[in] ClientHandle: " & $a_iCall[1] & @CRLF) ConsoleWrite("[rsv] Reserved: " & $a_iCall[2] & @CRLF) ConsoleWrite("[out] pInfo_List: " & $a_iCall[3] & @CRLF) $pInfoList = $a_iCall[3] ConsoleWrite("----------" & @CRLF) $INFO_LIST = DllStructCreate("dword;dword;byte[16];wchar[256];dword", $pInfoList) ConsoleWrite("//---INTERFACE_INFO_LIST Structure---\\" & @CRLF) ConsoleWrite("[dw] NumberOfItems: " & DllStructGetData($INFO_LIST, 1) & @CRLF) ConsoleWrite("[dw] Index: " & DllStructGetData($INFO_LIST, 2) & @CRLF) ConsoleWrite("[128 bits] GUID: " & DllStructGetData($INFO_LIST, 3) & @CRLF) ConsoleWrite("[wchr[256]] desc: " & DllStructGetData($INFO_LIST, 4) & @CRLF) ConsoleWrite("[dw] ConnStatus: " & DllStructGetData($INFO_LIST, 5) & @CRLF);1 Connected; 4 Disconnected; 7 Authenticating $pGUID = $pInfoList + 8;pointer to the GUID of the first interface ConsoleWrite("----------" & @CRLF) $a_iCall = DllCall($DLL, "dword", "WlanGetProfile", "hwnd", $hClientHandle , "ptr", $pGUID, "wstr", $PROFILE, "ptr", 0, "wstr*", 0, "ptr*", 0, "ptr*", 0) sleep(1000) ConsoleWrite("//---GetProfile---\\" & @CRLF) ConsoleWrite("! " & _WinAPI_GetLastErrorMessage()) ConsoleWrite("Return value: " & $a_iCall[0] & @CRLF) ConsoleWrite("[in] ClientHandle: " & $a_iCall[1] & @CRLF) ConsoleWrite("[in] pGUID: " & $a_iCall[2] & @CRLF) ConsoleWrite("[in] ProfileName: " & $a_iCall[3] & @CRLF) ConsoleWrite("[rsv] Reserved: " & $a_iCall[4] & @CRLF) ConsoleWrite("[out] ProfileXml: " & $a_iCall[5] & @CRLF) ConsoleWrite("[out] pdwFlags: " & $a_iCall[6] & @CRLF) ConsoleWrite("[out] pdwAccessGranted: " & $a_iCall[7] & @CRLF) Cheers, Matt Edited February 12, 2009 by MattyD Link to comment Share on other sites More sharing options...
MattyD Posted March 9, 2009 Share Posted March 9, 2009 autoit functions! as promised.http://www.autoitscript.com/forum/index.ph...c=91018&hl= 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