53
int main(int argc, char **argv)
52
int CDECL main(int argc, char **argv)
57
DWORD dwVersion, dwMajorVersion;
58
char AdapterInfo[NIC_BUFFER_SIZE] = { '\0','\0' };
59
unsigned long AdapterLength = NIC_BUFFER_SIZE;
61
LPSTR strName, strDesc;
65
int nDLLMajorVersion, nDLLMinorVersion;
68
// Attemp to load the WinpCap packet library
69
hPacket = LoadLibrary("PACKET.DLL");
72
// Now look up the address
73
PacketGetAdapterNames = (BOOLEAN (*)(PTSTR, PULONG))GetProcAddress(hPacket, "PacketGetAdapterNames");
74
PacketGetVersion = (PCHAR (*)())GetProcAddress(hPacket, "PacketGetVersion");
77
printf("Could not load WinPCap driver!\n");
78
printf ("You can download them for free from\n");
79
printf ("http://www.winpcap.org/\n");
83
dwVersion = GetVersion();
84
dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
86
// Get DLL Version and Tokenize
87
dllVersion = PacketGetVersion();
88
nDLLMajorVersion = -1;
89
nDLLMinorVersion = -1;
90
for ( testString = strtok(dllVersion, ",. ");
92
testString = strtok(NULL, ",. ") )
94
// If Single Character, Convert
95
if ( strlen( testString ) == 1 )
98
if ( nDLLMajorVersion == -1 )
100
nDLLMajorVersion = atoi(testString);
102
else if ( nDLLMinorVersion == -1 )
104
nDLLMinorVersion = atoi(testString);
109
// Get out blob of adapter info
110
PacketGetAdapterNames(AdapterInfo,&AdapterLength);
112
// If this is Windows NT ... And DLL Returns UNICODE
113
if(!(dwVersion >= 0x80000000 && dwMajorVersion >= 4) &&
114
(nDLLMajorVersion < 3 || (nDLLMajorVersion == 3 && nDLLMinorVersion < 1)))
116
wstrName=(LPWSTR)AdapterInfo;
122
// store pointer to name
123
niNT[nAdapterCount].wstrName=wstrName;
124
wstrName += lstrlenW(wstrName) +1;
128
strDesc = (LPSTR)++wstrName;
130
// Obtain descriptions ....
131
for(i=0;i<nAdapterCount;i++)
133
// store pointer to description
134
niNT[i].strDesc=strDesc;
135
strDesc += lstrlen(strDesc) +1;
137
// ... and display adapter info
138
printf("\n%d: %s\n",i+1,niNT[i].strDesc);
139
wprintf(L" Device: %s",niNT[i].wstrName);
144
printf("\n\nExample config for bochsrc:\n");
145
wprintf(L"ne2k: ioaddr=0x300, irq=3, mac=b0:c4:20:00:00:00, ethmod=win32, ethdev=%s",niNT[0].wstrName);
153
strName=(LPSTR)AdapterInfo;
159
// store pointer to name
160
ni9X[nAdapterCount].strName=strName;
161
strName += lstrlen(strName) +1;
165
strDesc = (LPSTR)++strName;
167
// Obtain descriptions ....
168
for(i=0;i<nAdapterCount;i++)
170
// store pointer to description
171
ni9X[i].strDesc=strDesc;
172
strDesc += lstrlen(strDesc) +1;
174
// ... and display adapter info
175
printf("\n%d: %s\n",i+1,ni9X[i].strDesc);
176
printf(" Device: %s",ni9X[i].strName);
181
printf("\n\nExample config for bochsrc:\n");
182
printf("ne2k: ioaddr=0x300, irq=3, mac=b0:c4:20:00:00:00, ethmod=win32, ethdev=%s",ni9X[0].strName);
190
return 0; /* shut up stupid compilers */
56
DWORD dwVersion, dwMajorVersion;
57
char AdapterInfo[NIC_BUFFER_SIZE] = { '\0','\0' };
58
unsigned long AdapterLength = NIC_BUFFER_SIZE;
60
LPSTR strName, strDesc;
64
int nDLLMajorVersion, nDLLMinorVersion;
66
// Attemp to load the WinpCap packet library
67
hPacket = LoadLibrary("PACKET.DLL");
70
// Now look up the address
71
PacketGetAdapterNames = (BOOLEAN (*)(PTSTR, PULONG))GetProcAddress(hPacket, "PacketGetAdapterNames");
72
PacketGetVersion = (PCHAR (*)())GetProcAddress(hPacket, "PacketGetVersion");
75
printf("Could not load WinPCap driver!\n");
76
printf ("You can download them for free from\n");
77
printf ("http://www.winpcap.org/\n");
81
dwVersion = GetVersion();
82
dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
84
// Get DLL Version and Tokenize
85
dllVersion = PacketGetVersion();
86
nDLLMajorVersion = -1;
87
nDLLMinorVersion = -1;
88
for (testString = strtok(dllVersion, ",. ");
89
testString != NULL; testString = strtok(NULL, ",. "))
91
// If Single Character, Convert
92
if (strlen( testString ) == 1)
95
if (nDLLMajorVersion == -1)
97
nDLLMajorVersion = atoi(testString);
99
else if ( nDLLMinorVersion == -1 )
101
nDLLMinorVersion = atoi(testString);
106
// Get out blob of adapter info
107
PacketGetAdapterNames(AdapterInfo,&AdapterLength);
109
// If this is Windows NT ... And DLL Returns UNICODE
110
if(!(dwVersion >= 0x80000000 && dwMajorVersion >= 4) &&
111
(nDLLMajorVersion < 3 || (nDLLMajorVersion == 3 && nDLLMinorVersion < 1)))
113
wstrName=(LPWSTR)AdapterInfo;
119
// store pointer to name
120
niNT[nAdapterCount].wstrName=wstrName;
121
wstrName += lstrlenW(wstrName) +1;
125
strDesc = (LPSTR)++wstrName;
127
// Obtain descriptions ....
128
for(i=0;i<nAdapterCount;i++)
130
// store pointer to description
131
niNT[i].strDesc=strDesc;
132
strDesc += lstrlen(strDesc) +1;
134
// ... and display adapter info
135
printf("\n%d: %s\n",i+1,niNT[i].strDesc);
136
wprintf(L" Device: %s",niNT[i].wstrName);
140
printf("\n\nExample config for bochsrc:\n");
141
wprintf(L"ne2k: ioaddr=0x300, irq=3, mac=b0:c4:20:00:00:00, ethmod=win32, ethdev=%s",niNT[0].wstrName);
149
strName=(LPSTR)AdapterInfo;
155
// store pointer to name
156
ni9X[nAdapterCount].strName=strName;
157
strName += lstrlen(strName) +1;
161
strDesc = (LPSTR)++strName;
163
// Obtain descriptions ....
164
for(i=0;i<nAdapterCount;i++)
166
// store pointer to description
167
ni9X[i].strDesc=strDesc;
168
strDesc += lstrlen(strDesc) +1;
170
// ... and display adapter info
171
printf("\n%d: %s\n",i+1,ni9X[i].strDesc);
172
printf(" Device: %s",ni9X[i].strName);
177
printf("\n\nExample config for bochsrc:\n");
178
printf("ne2k: ioaddr=0x300, irq=3, mac=b0:c4:20:00:00:00, ethmod=win32, ethdev=%s",ni9X[0].strName);
186
return 0; /* shut up stupid compilers */