Re: Set Wireless settings from a program by Alan
Alan
Thu Aug 21 19:54:25 CDT 2003
One more piece of the puzzle... using this code (specifying the device name
I got from OidScope):
NDISUIO_QUERY_OID getoid;
getoid.Oid = OID_802_3_PERMANENT_ADDRESS;
getoid.ptcDeviceName = _T("VNETUSBA1");
retval = DeviceIoControl(m_hFileHandle, IOCTL_NDISUIO_QUERY_OID_VALUE,
&getoid, sizeof getoid, outbuf, sizeof outbuf, &outsize, NULL);
I get a "true" returned from the DeviceIoControl, and 14 in "outsize".
However, when I print out the first 14 bytes of outbuf, it is all hex
zeroes. The OidScope app got back "00 02 8A A9 A1 5C" (in hex). I
understand the data returned is wide character, but I am just printing
byte-by-byte, it shouldn't be all zeroes. Any ideas?
Thanks
Alan
"Alan Hengle" <ahengle@blackbirdtech.com> wrote in message
news:O9ov7$CaDHA.652@TK2MSFTNGP10.phx.gbl...
> Thanks, Marco, you are a life-saver!
>
> I was able to get the CreateFile ok, and got back a handle, but I got
stuck
> on the IOCTL_NDISUIO_QUERY_OID_VALUE call through DeviceIoControl, since
it
> wants the name of the adapter. When I try to get a list of the adapter
> names, I get back a 0-return code (i.e. false since BOOL), though there
> should be a ndis driver defined (the sample OidScope application from
PCAUSA
> shows one). Do you see something I'm doing wrong in this code?
>
> // Try to open the ndisuio handle
> HANDLE m_hFileHandle = CreateFile(NDISUIO_DEVICE_NAME, 0, 0, NULL,
> OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, (HANDLE) INVALID_HANDLE_VALUE);
> // Get list of adapter names
> char outbuf[5000];
> DWORD outsize = 0;
> BOOL retval = DeviceIoControl(
> m_hFileHandle, IOCTL_NDIS_GET_ADAPTER_NAMES,
> NULL, 0, outbuf, sizeof outbuf, &outsize, NULL);
> CString msg;
> msg.Format(_T("IO ctl returned %d, len of output is %d"),
> (int)retval, (int)outsize);
> MessageBox(msg);
>
> Note I also tried this with the same (0 rc) results:
> NDISUIO_QUERY_OID getoid;
> getoid.Oid = OID_802_3_PERMANENT_ADDRESS;
> getoid.ptcDeviceName = NDISUIO_DEVICE_NAME;
> BOOL retval = DeviceIoControl(m_hFileHandle,
IOCTL_NDISUIO_QUERY_OID_VALUE,
> &getoid, sizeof getoid, outbuf, sizeof outbuf, &outsize, NULL);
>
> Thanks very much for your help.
> Alan
>
>
> "Marc-Aurèle Brothier" <m_a_r_c_o@shockfish.com> wrote in message
> news:eu75bT7ZDHA.2476@tk2msftngp13.phx.gbl...
> > I wrote my own app to set the wireless settings, except for the WEP. I
> > used the IOCTL_NDISUIO_GET_OID_VALUE, with all the NDIS IODs defined in
> > NDIS 5.1. You shouldn't need Platform Builder because you don't have to
> > include ndis.h but <ntddndis.h> and <nuiouser.h> instead, I know I had
> > to install it in the beginning du to the same problem but now I'm not
> > using it.
> >
> > You need to open the handle like this first:
> > // Try to open the ndisuio handle
> > m_hFileHandle = CreateFile(NDISUIO_DEVICE_NAME,
> > 0,
> > 0,
> > NULL,
> > OPEN_EXISTING,
> > FILE_ATTRIBUTE_NORMAL,
> > (HANDLE) INVALID_HANDLE_VALUE);
> >
> > Then you can query your OIDs, but some of them my not work since all the
> > drivers do not implement them.
> > Search more about NDISUIO and not NDIS in MSDN.
> >
> > /Marco
> >
> > Alan wrote:
> > > I'm trying to find out how to set up a wireless device
> > > from a program. I need to set things like the channel,
> > > WEP keys, SSID, and Infrastructure/Ad-hoc mode, and be
> > > able to reset them back as well.
> > >
> > > So far I've looked at the CSP's defined in the SDK and I
> > > can run the CMProcessConfigXML, but I don't see the
> > > ability to set all of these things.
> > >
> > > I've also looked at the Ndis tools, such as
> > > NdisGetAdapterNames(), which seem that they would allow me
> > > to access these configuration items through the OID's
> > > passed via the NdisRequest. I'm having problems getting
> > > that going though, the embedded C++4.0 doesn't seem to
> > > have access to some of the .h files referenced in the
> > > ndis.h file (lss.h, for one).
> > >
> > > Possibly this is available through the Platform Builder,
> > > but that seems like building a device driver and I an
> > > hesitant to go down that path.
> > >
> > > Then of course there's the DeviceIoControl and GetFile(),
> > > but these are stream-oriented and don't seem to apply.
> > >
> > > I would appreciate any help on getting started.
> > >
> > > Thanks
> > > Alan
> >
>
>