Re: Setting OID_802_11_BSSID through DeviceIOControl()
- From: Bruce Tovac <BruceTovac@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 3 Sep 2007 08:02:28 -0700
Thanks Pavel for your pointer. I looked in MSDN and it seems that the WLAN
API is listed only under Windows CE. I am running Windows XP with a
micration path to Vista next year, and my understanding is that WLAN API is
not supported under any of these platforms. Am I mistaken?
My preference would really to get it to work with NDISUIO.
Bruce
"Pavel A." wrote:
Please give Wlan API a try ( in MSDN: look under "Native wi-fi" )..
NDISUIO is the wrong way.
--PA
"Bruce Tovac" <BruceTovac@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:3A0A5060-569A-4369-B47B-350BE027F738@xxxxxxxxxxxxxxxx
I tried running the same code with WZC disabled and it still not works. If
anyone can help me get the code running without WZC that'll be very helpful.
Thanks
Bruce
"Maxim S. Shatskih" wrote:
I think that this is not doable, since WZC will override your config and
enforce its own.
--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@xxxxxxxxxxxxxxxx
http://www.storagecraft.com
"Bruce Tovac" <BruceTovac@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:B367B505-6051-4C8D-B17B-6403E8445566@xxxxxxxxxxxxxxxx
Hi
I am trying to control the association of a wireless adapter through NDIS
miniport driver. I did not write a specific driver myself. Using
DeviceIOControl() function, I can query all the OIDs of interest without any
difficulty, that is fine. My problem is that I need to set OID_802_11_BSSID
to a specific value to control where I want my wireless adapter to connect.
Here is the code snippet that I am trying to get to work:
BOOL SetAssociated( LPCTSTR lpAdapterName,
NDIS_802_11_MAC_ADDRESS DestinationMacAddress)
{
UCHAR SetBuffer[sizeof(NDISUIO_SET_OID) +
sizeof(NDIS_802_11_MAC_ADDRESS)];
PNDISUIO_SET_OID pSetOid;
DWORD dwBytesReturned=0;
int i = 0, nResult;
TCHAR szOut[64];
long e;
HANDLE hNIC;
UCHAR szMACFileName[512];
pSetOid = (PNDISUIO_SET_OID) &SetBuffer[0];
pSetOid->Oid = OID_802_11_BSSID;
for ( i = 0; i < 6; i++ )
{
pSetOid->Data[i] = DestinationMacAddress[i];
}
//
// Construct a device name to pass to CreateFile
//
strcpy(szMACFileName, DEVICE_PREFIX);
strcat(szMACFileName, lpAdapterName);
hNIC = CreateFile(
szMACFileName,
GENERIC_READ|GENERIC_WRITE, // Device Query Access
FILE_SHARE_READ | FILE_SHARE_WRITE, //FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, //0,
NULL //INVALID_HANDLE_VALUE
);
nResult = GetLastError();
if (hNIC != INVALID_HANDLE_VALUE)
{
//
// We successfully opened the driver, format the IOCTL to pass the
// driver.
//
nResult = DeviceIoControl(
hNIC,
IOCTL_NDISUIO_SET_OID_VALUE,
(LPVOID) &SetBuffer[0],
sizeof(SetBuffer),
(LPVOID) &SetBuffer[0],
0,
&dwBytesReturned,
NULL
);
if( nResult == 0) /// there was an error, print it out.
{
e = GetLastError();
wsprintf(szOut, TEXT("Set Associated AP/PC ERROR\nError Code:
%d"),e );
MessageBox(0,szOut,TEXT("Error"),MB_OK);
return FALSE;
}
}
return TRUE;
}
I have tried many variations of the above but could not get anything to work
yet. I tried both with WZC running or stopped, same results. The
CreateFile() function returns no error, but DeviceIOControl() returns with
error code 1 (ERROR_INVALID_FUNCTION)
Thanks in advance.
Bruce
- Follow-Ups:
- Re: Setting OID_802_11_BSSID through DeviceIOControl()
- From: Pavel A.
- Re: Setting OID_802_11_BSSID through DeviceIOControl()
- References:
- Re: Setting OID_802_11_BSSID through DeviceIOControl()
- From: Pavel A.
- Re: Setting OID_802_11_BSSID through DeviceIOControl()
- Prev by Date: Re: IOCTL_SCSI_PASS_THROUGH_DIRECT
- Next by Date: Re: Implementing a virtual Dvd
- Previous by thread: Re: Setting OID_802_11_BSSID through DeviceIOControl()
- Next by thread: Re: Setting OID_802_11_BSSID through DeviceIOControl()
- Index(es):
Relevant Pages
|