Some computers show "NDIS 5.0 Driver" as the description instead of the real one as shown by IPCONFIG. I did an SNMP walk and saw that this the 184.108.40.206.220.127.116.11.1.2 entry only contained "MS TCP Loopback interface" and "NDIS 5.0 driver" so the code is ok.
Is there any way to get the MAC description as reported by IPCONFIG?
It seems to work okay under Win 98/98SE/ME/2K and XP but I couldn't make it work under Win 95 a,b and c. If I select LOOPBACK ADAPTERS and DIALUP ADAPTERS and if the system has an Ethernet Card (NIC) installed, ViewNIC returns all invalid information about the Ethernet Device. If I do not select LOOPBACK and DIALUP ADAPTERS or If I just select any one of those ViewNIC returns all invalid information. Anyone knows why ?
I found a bug with the code. I noticed on some machines that it would crash. Those machines had logical PPP adapters on them. The machines without out the logical PPP adapters worked great.
When debugging I looked at:
UINT MibII::GetNICCount(BOOL bDialup, BOOL bLoopback)
It appeared to work ok, however I think that the correct fix may need to be in that method.
The problem was in:
void MibII::GetNICInfo(tSTRUCTNICINFO *pNICInfo)
This section of code here is the problem:
// Find the Interface Entry Number that matches the Interface Index.
for (j = 0; j < m_ifCount; j++)
if (m_ifIndex[i] == m_ifEntryNum[j])
That code assumes that it will find the adapter. However, with the PPP adapters installed, it wouldn't find it. So it would grab some piece of memory and try to do a memcpy on it below. The data was all garbage. So what you need to do is add the following after that for loop:
// Couldn't find one that match.
if (j == m_ifCount)
That will skip that adapter and go on the next. That's fine since it's garbage anyway.
This fix works, but it's not the best one. It should be fixed where the problem occurs. Since I was under a time constraint I didn't bother investigating too deeply.
Inside the function: int CViewNICDlg::GetNICInfo()
Add the line : memset(m_pNICInfo, 0, sizeof(tSTRUCTNICINFO) * m.GetIPCount());
After the memory is allocated : m_pNICInfo = new tSTRUCTNICINFO [m.GetIPCount()];
NOTE: this is including the fix noted earlier about using m_ifCount to get the count of IP addresses, just added a function GetIPCount() to return this value.
Problem was if a NIC didn't have a valid IP address like in the middle of a "ipconfig /release_all" the structure was filled with random data and since a loop depended on the MAC address length being filled out correctly app would get an access violation and a crash.