the follows is my coding, who can tell me where is wrong,
and how to correct it?
DWORD myinfo::IoctlNdisQueryTest(LPCTSTR lpAdapterName)
{

UCHAR OidData[4096];
DWORD nResult, ReturnedCount = 0;


nResult = Test_IoctlNdisQueryGlobalStats
(lpAdapterName,OID_802_11_STATISTICS,OidData,sizeof
(OidData),&ReturnedCount);
if( nResult != ERROR_SUCCESS )
sprintf(sLabel,"%s","The driver
unsupported");
else
/* ****************************************** */
sprintf(sLabel,"%d,%d",OidData[1],OidData
[10]);// wrong message
/* ******************************************* */
m_temp.SetWindowText(sLabel);

nResult = Test_IoctlNdisQueryGlobalStats
(lpAdapterName,OID_802_11_SSID,OidData,sizeof
(OidData),&ReturnedCount);
if( nResult != ERROR_SUCCESS )
sprintf(sLabel,"%s","The driver
unsupported");
else
/* ***************************************** */
sprintf(sLabel,"%d-%s",OidData[],OidData
[1]);//wrong message
/* ****************************************** */
m_temp.SetWindowText(sLabel);

return( nResult );
}DWORD myinfo::Test_IoctlNdisQueryGlobalStats(
LPCTSTR lpAdapterName,
ULONG OidCode,
PVOID InformationBuffer,
UINT InformationBufferLength,
PULONG pBytesWritten)
{
CHAR LinkName[512];
CHAR szMACFileName[512];
BOOLEAN bCreatedDevice = FALSE;
DWORD ErrorNumber, nResult = ERROR_SUCCESS;
HANDLE hMAC;

*pBytesWritten = 0;

strcpy( LinkName, "\\Device\\" );
strcat( LinkName, lpAdapterName );
strcpy(szMACFileName, DEVICE_PREFIX);
strcat(szMACFileName, lpAdapterName);

hMAC = CreateFile
(szMACFileName,0,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,INVAL
ID_HANDLE_VALUE);

if (hMAC != INVALID_HANDLE_VALUE)

if(!DeviceIoControl
(hMAC,IOCTL_NDIS_QUERY_GLOBAL_STATS,&OidCode,
sizeof
(OidCode),InformationBuffer,InformationBufferLength,
pBytesWritten,NULL))
printf(" DeviceIoControl returned an
error = %d\n",nResult = GetLastError());
else
printf(" CreateFile returned an error = %
d\n",nResult = GetLastError());

if (bCreatedDevice)

if (!DefineDosDevice(DDD_RAW_TARGET_PATH |
DDD_REMOVE_DEFINITION

|DDD_EXACT_MATCH_ON_REMOVE,lpAdapterName,LinkName))
{
ErrorNumber = GetLastError();
printf("DefineDosDevice returned an
error creating the device = %d\n", ErrorNumber);
return( ErrorNumber );
}

return( nResult );
}

Re: Where is wrong? by Tim

Tim
Tue Jul 01 00:27:05 CDT 2003

"Jeffery" <shic@aston.ac.uk> wrote:
>
>the follows is my coding, who can tell me where is wrong,
>and how to correct it?
>DWORD myinfo::IoctlNdisQueryTest(LPCTSTR lpAdapterName)
>{
>
> UCHAR OidData[4096];
> DWORD nResult, ReturnedCount = 0;
>
> nResult = Test_IoctlNdisQueryGlobalStats
>(lpAdapterName,OID_802_11_STATISTICS,OidData,sizeof
>(OidData),&ReturnedCount);
> if( nResult != ERROR_SUCCESS )
> sprintf(sLabel,"%s","The driver
>unsupported");
> else
>/* ****************************************** */
> sprintf(sLabel,"%d,%d",OidData[1],OidData
>[10]);// wrong message
>/* ******************************************* */

No doubt. Are you trying to print the transmitted and received fragment
counts? OID_802_11_STATISTICS returns a structure containing a double
word, which is 4 bytes, and 12 quad words, which are 8 bytes each. You are
printing out the second BYTE and the 11th BYTE. Those are essentially
garbage.

The right way to do this is to use the structure that was designed
specifically for this purpose:

DWORD myinfo::IoctlNdisQueryTest(LPCTSTR lpAdapterName)
{
NDIS_802_11_STATISTICS OidData;
DWORD nResult, ReturnedCount = 0;

ZeroMemory( &OidData, sizeof(OidData));
OidData.Length = sizeof(OidData);
nResult = Test_IoctlNdisQueryGlobalStats
(lpAdapterName,OID_802_11_STATISTICS,OidData,sizeof
(OidData),&ReturnedCount);

if( nResult != ERROR_SUCCESS )
sprintf(sLabel,"%s","The driver unsupported");
else
sprintf(sLabel,"%I64d,%I64d",
OidData.TransmittedFragmentCount.QuadPart,
OidData.ReceivedFragmentCount.QuadPart);

...
--
- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.