in reply to Re^4: Adding WlanConnect() to Win32::Wlan::API
in thread Adding WlanConnect() to Win32::Wlan::API
typedef enum _WLAN_CONNECTION_MODE { wlan_connection_mode_profile = 0, wlan_connection_mode_temporary_profile, wlan_connection_mode_discovery_secure, wlan_connection_mode_discovery_unsecure, wlan_connection_mode_auto, wlan_connection_mode_invalid } WLAN_CONNECTION_MODE, *PWLAN_CONNECTION_MODE; #define DOT11_SSID_MAX_LENGTH 32 // 32 bytes typedef struct _DOT11_SSID { ULONG uSSIDLength; UCHAR ucSSID[DOT11_SSID_MAX_LENGTH]; } DOT11_SSID, * PDOT11_SSID; typedef struct _NDIS_OBJECT_HEADER { UCHAR Type; UCHAR Revision; USHORT Size; } NDIS_OBJECT_HEADER, *PNDIS_OBJECT_HEADER; // These are needed for wlanapi.h for pre-vista targets #ifdef __midl typedef struct _DOT11_MAC_ADDRESS { UCHAR ucDot11MacAddress[6]; } DOT11_MAC_ADDRESS, * PDOT11_MAC_ADDRESS; #else typedef UCHAR DOT11_MAC_ADDRESS[6]; typedef DOT11_MAC_ADDRESS * PDOT11_MAC_ADDRESS; #endif // A list of DOT11_MAC_ADDRESS typedef struct DOT11_BSSID_LIST { #define DOT11_BSSID_LIST_REVISION_1 1 NDIS_OBJECT_HEADER Header; ULONG uNumOfEntries; ULONG uTotalNumOfEntries; #ifdef __midl [unique, size_is(uTotalNumOfEntries)] DOT11_MAC_ADDRESS BSSIDs[*]; #else DOT11_MAC_ADDRESS BSSIDs[1]; #endif } DOT11_BSSID_LIST, * PDOT11_BSSID_LIST; typedef enum _DOT11_BSS_TYPE { dot11_BSS_type_infrastructure = 1, dot11_BSS_type_independent = 2, dot11_BSS_type_any = 3 } DOT11_BSS_TYPE, * PDOT11_BSS_TYPE; typedef struct _WLAN_CONNECTION_PARAMETERS { WLAN_CONNECTION_MODE wlanConnectionMode; #ifdef __midl [string] LPCWSTR strProfile; #else LPCWSTR strProfile; #endif PDOT11_SSID pDot11Ssid; PDOT11_BSSID_LIST pDesiredBssidList; DOT11_BSS_TYPE dot11BssType; DWORD dwFlags; } WLAN_CONNECTION_PARAMETERS, *PWLAN_CONNECTION_PARAMETERS; API_TEST_API DWORD WINAPI WlanConnect( HANDLE hClientHandle, CONST GUID *pInterfaceGuid, CONST PWLAN_CONNECTION_PARAMETERS pConnectionParameters, PVOID pReserved ){ 0; return 1234; }
#!/usr/bin/perl -w use Win32::API '0.70'; use Win32::API::Test; use Encode; use Carp; $test_dll = Win32::API::Test::find_test_dll(); Win32::API::Struct->typedef('WLAN_CONNECTION_PARAMETERS', qw( WLAN_CONNECTION_MODE wlanConnectionMode; LPCWSTR strProfile; PDOT11_SSID pDot11Ssid; PDOT11_BSSID_LIST pDesiredBssidList; DOT11_BSS_TYPE dot11BssType; DWORD dwFlags; )); Win32::API::Struct->typedef ('DOT11_SSID', qw( ULONG uSSIDLength; UCHAR ucSSID; )); $api = Win32::API->new($test_dll, 'WlanConnect', 'IPPI', 'I'); $wlan_available = 1; sub WlanConnect { croak "Wlan functions are not available" unless $wlan_available; my ($handle, $guuid, $profilename, $ssid) = @_; # possibly overkill, a pDot11Ssid = 0 should suffice my $pDot11Ssid = Win32::API::Struct->new('DOT11_SSID'); $pDot11Ssid->{uSSIDLength} = length $ssid; $pDot11Ssid->{ucSSID} = $ssid; my $Wlan_connection_parameters = Win32::API::Struct->new('WLAN_CON +NECTION_PARAMETERS'); $Wlan_connection_parameters->{wlanConnectionMode} = 0; $Wlan_connection_parameters->{strProfile} = $profilename; $Wlan_connection_parameters->{pDot11Ssid} = $pDot11Ssid; $Wlan_connection_parameters->{pDesiredBssidList} = 0; $Wlan_connection_parameters->{dot11BssType} = 3; $Wlan_connection_parameters->{dwFlags} = 0; $api->Call($handle, $guuid, $Wlan_connection_parameters, 0) == 123 +4 or die "bad ret"; }; WlanConnect(1, "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\ +x15\x16", Encode::encode("UTF-16LE","TheProfileName"), "TheSSID");
in C. pConnectionParameters is gibberish, and its exactly what I thought it would be.hClientHandle 0x00000001 void * + pInterfaceGuid 0x00a55324 {04030201-0605-0807-0910-11121314151 +6} const _GUID * - pConnectionParameters 0x00a21594 {wlanConnectionMode=862873943 + strProfile=0x413a3a32 <Bad Ptr> pDot11Ssid=0x3a3a4950 {uSSIDLength=? +?? ucSSID=0x3a3a4954 <Bad Ptr> } ...} _WLAN_CONNECTION_PARAMETERS +* const wlanConnectionMode 862873943 _WLAN_CONNECTION_MODE - strProfile 0x413a3a32 <Bad Ptr> const unsigned short * CXX0030: Error: expression cannot be evaluated const unsign +ed short - pDot11Ssid 0x3a3a4950 {uSSIDLength=??? ucSSID=0x3a3a4954 <Bad +Ptr> } _DOT11_SSID * uSSIDLength CXX0030: Error: expression cannot be evaluated u +nsigned long + ucSSID 0x3a3a4954 <Bad Ptr> unsigned char [32] - pDesiredBssidList 0x75727453 {Header={Type=??? Revision=??? Si +ze=??? } uNumOfEntries=??? uTotalNumOfEntries=??? ...} DOT11_BSSID +_LIST * + Header {Type=??? Revision=??? Size=??? } _NDIS_OBJECT_HEADE +R uNumOfEntries CXX0030: Error: expression cannot be evaluated + unsigned long uTotalNumOfEntries CXX0030: Error: expression cannot be evaluat +ed unsigned long + BSSIDs 0x7572745f unsigned char [1][6] dot11BssType 1211987043 _DOT11_BSS_TYPE dwFlags 675828545 unsigned long pReserved 0x00000000 void *
Now I changed the signature to IPSI, and, I don't know how you ran it, but Win32::API errored out and died on me.0x00A21594 57 69 6e 33 32 3a 3a 41 50 49 3a 3a 53 74 72 75 63 74 3d 4 +8 41 53 48 28 30 78 61 34 64 Win32::API::Struct=HASH(0xa4d 0x00A215B1 61 62 63 29 00 00 00 00 26 94 22 14 0d 02 00 00 00 ad ba a +b ab ab ab ab ab ab ab ee 04 abc)....&”"......н║ллллллллю.
Use of uninitialized value $type in string eq at C:/perl512/site/lib/W +in32/API/S truct.pm line 205. Use of uninitialized value $type in pattern match (m//) at C:/perl512/ +site/lib/W in32/API/Struct.pm line 216. Use of uninitialized value $type in concatenation (.) or string at C:/ +perl512/si te/lib/Win32/API/Struct.pm line 221. Use of uninitialized value $type in string eq at C:/perl512/site/lib/W +in32/API/S truct.pm line 223. Use of uninitialized value $name in hash element at C:/perl512/site/li +b/Win32/AP I/Struct.pm line 228. Use of uninitialized value $self in string eq at C:/perl512/site/lib/W +in32/API/T ype.pm line 161. Use of uninitialized value $type in exists at C:/perl512/site/lib/Win3 +2/API/Type .pm line 167. Use of uninitialized value $type in pattern match (m//) at C:/perl512/ +site/lib/W in32/API/Type.pm line 173. Use of uninitialized value $type in substitution (s///) at C:/perl512/ +site/lib/W in32/API/Type.pm line 180. Use of uninitialized value $type in exists at C:/perl512/site/lib/Win3 +2/API/Type .pm line 182. Use of uninitialized value $packing in pattern match (m//) at C:/perl5 +12/site/li b/Win32/API/Type.pm line 142. Use of uninitialized value $packing in hash element at C:/perl512/site +/lib/Win32 /API/Type.pm line 146. Use of uninitialized value $type_size in addition (+) at C:/perl512/si +te/lib/Win 32/API/Struct.pm line 232. Use of uninitialized value $type_size in modulus (%) at C:/perl512/sit +e/lib/Win3 2/API/Struct.pm line 232. Illegal modulus zero at C:/perl512/site/lib/Win32/API/Struct.pm line 2 +32.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Adding WlanConnect() to Win32::Wlan::API (modded Wlan::API.pm)
by tomsell (Acolyte) on Jun 27, 2012 at 15:45 UTC | |
by bulk88 (Priest) on Jun 27, 2012 at 19:08 UTC | |
by tomsell (Acolyte) on Jun 27, 2012 at 20:00 UTC | |
by bulk88 (Priest) on Jun 27, 2012 at 21:47 UTC | |
by bulk88 (Priest) on Jun 28, 2012 at 02:48 UTC | |
|