Re: Setting OID_802_11_BSSID through DeviceIOControl()

Tech-Archive recommends: Fix windows errors by optimizing your registry



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





.



Relevant Pages

  • Re: [2.6 patch] ieee1394_core.c: remove unneeded EXPORT_SYMBOLs
    ... distribution will call us and require intense support. ... profits with Linux sales - and 99.99 % of our income with Windows sales. ... I do not see the licensing issue of a stable kernel API where venders ... Our driver is GPL so there should no be a licensing issue. ...
    (Linux-Kernel)
  • Re: Setting OID_802_11_BSSID through DeviceIOControl()
    ... Yes, WLAN API exists on Vista, ... I did not write a specific driver myself. ... DeviceIOControl() function, I can query all the OIDs of interest without any ...
    (microsoft.public.development.device.drivers)
  • Re: Writing kernel API functions
    ... Why not just use the existing WMI facilities, ... Windows 2003/XP/2000 Consulting ... > I do not want the service to have to issue any IOCTL to the driver at all. ... > I want the driver to be able to execute a kernel API call that will, ...
    (microsoft.public.development.device.drivers)
  • Re: Display driver installation issue on VISTA OS....
    ... I believe the key is in the user API. ... If you don't need the Windows ... API, and if you can roll your own user level API, it's a simple matter ... to encapsulate your driver to accept your new API, ...
    (microsoft.public.development.device.drivers)
  • Re: OnComm event parity error detection
    ... The basic problem is that device drivers tend to cause Windows to go ... MSComm hides some of the details of the underlying API, ... driver for use with their Serial Async ... virtual serial ports. ...
    (microsoft.public.vb.bugs)