bool getAdapterInfo2(
const char* nicName, // input
char* AdapterName, // output
unsigned char* macAddr, // output
char* ipAddress, // output
char* maskAddress // output
)
{
// string that contains a list of the network adapters
WCHAR TempBuffer[1024];  char        adapterList[512];
char        adapterList2[512]; char AdapterName2[512]; __u32 ipAddr; // IP Address
__u32 maskAddr; // Mask (Subnet) Address EnterCriticalSection(&critSec_getAdapterInfo2); DWORD dwVersion=GetVersion();
DWORD dwWindowsMajorVersion =  (DWORD)(LOBYTE(LOWORD(dwVersion))); // Windows NT 
if (!(!(dwVersion >= 0x80000000 && dwWindowsMajorVersion >= 4)))
return false;
  
ULONG AdapterLength = 1024; memset(TempBuffer,0, sizeof(TempBuffer));
memset(adapterList,0, sizeof(adapterList));
memset(adapterList2,0, sizeof(adapterList2)); WCHAR *temp,*temp1; int nicNameLen = strlen(nicName);
temp = (WCHAR *)(adapterList);

for(int k=0; k < nicNameLen; k++)
{
*temp++ = *nicName++;
} // Change adapterList the part of "/" to "//" for Windows NT
memcpy(adapterList2,adapterList,sizeof(adapterList));
temp1 = temp = (WCHAR *)(adapterList2);

int adapterList2Length = 0;
while ((*temp!='\0')||(*(temp-1)!='\0'))
{
adapterList2Length++;
temp++;
}

int j =0;
temp = temp1;
while ((*temp!='\0')||(*(temp-1)!='\0'))
{
if (*temp == 0x005c)
{
int k;
for (k = adapterList2Length ; k > j ; k--)
{
*(temp1 + k + 1) = *(temp1 + k); 
}

*(temp + 1) =  0x005c; // add "/"
temp++;
adapterList2Length++;
}
j++;
temp++;
}
// Get the IP Address BOOLEAN truefalse = 
PacketGetNetInfo2((LPTSTR)adapterList2,(PULONG)(&ipAddr),(PULONG)(&maskAddr));

rev_inet_addr(ipAddr, ipAddress);
rev_inet_addr(maskAddr, maskAddress); memcpy(AdapterName, adapterList, 512 /*sizeof(AdapterName) */);
memcpy(AdapterName2, adapterList2, 512 /*sizeof(AdapterName2) */);

LPADAPTER temp_lpAdapter 
= PacketOpenAdapter((LPTSTR)adapterList);

if (!temp_lpAdapter || (temp_lpAdapter->hFile == INVALID_HANDLE_VALUE))
{
DWORD dwErrorCode=GetLastError();

return false;
}

// Check the Adapter Type (It should be Ethernet)
NetType netType;

PacketGetNetType(temp_lpAdapter, &netType);
if (netType.LinkType != NdisMedium802_3)
return false;

// Get the MAC Address
PACKET_OID_DATA pod;

pod.Oid = OID_802_3_PERMANENT_ADDRESS;
pod.Length = ETH_ALEN /* sizeof(macAddr) */;

if (PacketRequest(temp_lpAdapter, 0, &pod) == NULL)
{
return false;
}

memcpy(macAddr, pod.Data, pod.Length);

PacketCloseAdapter(temp_lpAdapter); LeaveCriticalSection(&critSec_getAdapterInfo2);
return true;
}