How to query SSID with 802.11 OIDs from NDIS

EaE

Joined
Oct 25, 2005
Messages
2
Reaction score
0
Hi all.
I'm tring to write a simple app under Windows Mobile 2003, that will retrieve current connection SSID. The code i got in result looks like it should work, but request returns error 87: "The parameter is incorrent."
Could you help me to find an error? I'm new to ndis programming.
Here is the code:
int getSsid(){
HANDLE ndisAccess;
ndisAccess = INVALID_HANDLE_VALUE;

ndisAccess = CreateFile( NDISUIO_DEVICE_NAME
, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL |
FILE_FLAG_OVERLAPPED, INVALID_HANDLE_VALUE);
if ( ndisAccess == INVALID_HANDLE_VALUE )
return -1;
// CreateFile works fine and i get valid ndisAccess

DWORD dwBytesReturned;

NDISUIO_QUERY_OID queryOid, response;
queryOid.ptcDeviceName = NDISUIO_DEVICE_NAME;
queryOid.Oid = OID_802_11_SSID;

if (DeviceIoControl(ndisAccess,
IOCTL_NDISUIO_QUERY_OID_VALUE,
&queryOid,
sizeof(NDISUIO_QUERY_OID),
(LPVOID) &response,
sizeof(NDISUIO_QUERY_OID),
&dwBytesReturned,
NULL))
{
// we should retrieve ssid here, but it never reaches here, giving an error
return 0;
}else{
int ret = GetLastError();
LPTSTR s;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL, ret, 0, (LPTSTR)&s, 0, NULL);
printf("error number %d: ", ret);
_putts(s);
return ret;
}
}

Thanks,
Evgeny.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top