2001-10-03 17:36:14 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// misc/niclist.c
|
|
|
|
// by Don Becker <x-odus@iname.com>
|
2001-10-31 19:01:29 +03:00
|
|
|
// $Id: niclist.c,v 1.2 2001-10-31 16:01:29 bdenney Exp $
|
2001-10-03 17:36:14 +04:00
|
|
|
//
|
|
|
|
// This program is for win32 only. It lists the network interface cards
|
|
|
|
// that you can use in the "ethdev" field of the ne2k line in your bochsrc.
|
|
|
|
//
|
|
|
|
// For this program and for win32 ethernet, the winpcap library is required.
|
|
|
|
// Download it from http://netgroup-serv.polito.it/winpcap.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
#include <stdio.h>
|
2001-10-31 19:01:29 +03:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <wchar.h>
|
2001-10-03 17:36:14 +04:00
|
|
|
|
|
|
|
BOOLEAN (*PacketGetAdapterNames) (PTSTR, PULONG);
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
2001-10-31 19:01:29 +03:00
|
|
|
int i = 0;
|
|
|
|
wchar_t AdapterNameW[512];
|
2001-10-03 17:36:14 +04:00
|
|
|
char AdapterNameA[512];
|
|
|
|
int AdapterNum = 0;
|
|
|
|
ULONG AdapterLength;
|
2001-10-31 19:01:29 +03:00
|
|
|
HINSTANCE hPacket;
|
|
|
|
DWORD dwVersion, dwMajorVersion;
|
2001-10-03 17:36:14 +04:00
|
|
|
char AdapterList[10][1024];
|
2001-10-31 19:01:29 +03:00
|
|
|
wchar_t *tempW, *tempW2;
|
|
|
|
char *tempA, *tempA2;
|
|
|
|
char buff[512];
|
2001-10-03 17:36:14 +04:00
|
|
|
|
|
|
|
hPacket = LoadLibrary("PACKET.DLL");
|
|
|
|
|
|
|
|
if(hPacket) {
|
|
|
|
PacketGetAdapterNames = (BOOLEAN (*)(PTSTR, PULONG)) GetProcAddress(hPacket, "PacketGetAdapterNames");
|
|
|
|
} else {
|
|
|
|
printf("Could not load WinPCap driver!\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
dwVersion = GetVersion();
|
|
|
|
dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
|
|
|
|
if (!(dwVersion >= 0x80000000 && dwMajorVersion >= 4))
|
|
|
|
{ // Windows NT
|
|
|
|
PacketGetAdapterNames((char *)AdapterNameW,&AdapterLength);
|
|
|
|
tempW = AdapterNameW;
|
|
|
|
tempW2 = AdapterNameW;
|
|
|
|
while ((*tempW!='\0')||(*(tempW-1)!='\0'))
|
|
|
|
{
|
|
|
|
if (*tempW=='\0')
|
|
|
|
{
|
|
|
|
memcpy(AdapterList[i],tempW2,(tempW-tempW2)*2);
|
|
|
|
tempW2=tempW+1;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
tempW++;
|
|
|
|
}
|
|
|
|
|
|
|
|
AdapterNum=i;
|
2001-10-31 19:01:29 +03:00
|
|
|
for (i=0;i<AdapterNum;i++) {
|
|
|
|
#if defined(__CYGWIN__) || defined(__MINGW32__)
|
|
|
|
memset(&buff, 0, sizeof(buff));
|
|
|
|
wcstombs(buff, (wchar_t *)AdapterList[i], wcslen((wchar_t *)AdapterList[i]));
|
|
|
|
printf("\n%d.) %s\n",i+1,buff);
|
|
|
|
#else
|
|
|
|
wprintf(L"\n%d.) %s\n",i+1,AdapterList[i]);
|
|
|
|
#endif
|
|
|
|
}
|
2001-10-03 17:36:14 +04:00
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else //windows 95
|
|
|
|
{
|
|
|
|
PacketGetAdapterNames(AdapterNameA,&AdapterLength);
|
|
|
|
tempA = AdapterNameA;
|
|
|
|
tempA2 = AdapterNameA;
|
|
|
|
|
|
|
|
while ((*tempA!='\0')||(*(tempA-1)!='\0'))
|
|
|
|
{
|
|
|
|
if (*tempA=='\0')
|
|
|
|
{
|
|
|
|
memcpy(AdapterList[i],tempA2,tempA-tempA2);
|
|
|
|
tempA2=tempA+1;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
tempA++;
|
|
|
|
}
|
|
|
|
|
|
|
|
AdapterNum=i;
|
|
|
|
for (i=0;i<AdapterNum;i++)
|
|
|
|
printf("\n%d.) %s\n",i+1,AdapterList[i]);
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|