Removed deprecated function GetVersion() from eth_win32.cc and niclist.c.
Since the presence of UNICODE or ANSI format only depends on the PACKET.DLL version, no Windows version check is necessary.
This commit is contained in:
parent
038ebf5815
commit
445bf01b2a
@ -2,7 +2,7 @@
|
||||
// $Id$
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001-2017 The Bochs Project
|
||||
// Copyright (C) 2001-2019 The Bochs Project
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
@ -183,11 +183,10 @@ LPADAPTER lpAdapter = 0;
|
||||
LPPACKET pkSend;
|
||||
LPPACKET pkRecv;
|
||||
char buffer[256000];
|
||||
DWORD dwVersion, dwMajorVersion;
|
||||
char AdapterList[10][1024];
|
||||
char cMacAddr[6];
|
||||
char NetDev[512];
|
||||
BOOL IsNT = FALSE;
|
||||
BOOL IsNT = TRUE;
|
||||
|
||||
typedef LPADAPTER (CDECL *POpenAdapter) (LPTSTR);
|
||||
typedef VOID (CDECL *PCloseAdapter) (LPADAPTER);
|
||||
@ -277,8 +276,6 @@ bx_win32_pktmover_c::bx_win32_pktmover_c(
|
||||
this->netdev = dev;
|
||||
BX_INFO(("win32 network driver"));
|
||||
// Open Packet Driver Here.
|
||||
DWORD dwVersion;
|
||||
DWORD dwWindowsMajorVersion;
|
||||
|
||||
this->rxh = rxh;
|
||||
this->rxstat = rxstat;
|
||||
@ -303,16 +300,8 @@ bx_win32_pktmover_c::bx_win32_pktmover_c(
|
||||
}
|
||||
|
||||
memset(&NetDev, 0, sizeof(NetDev));
|
||||
dwVersion=GetVersion();
|
||||
dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
|
||||
if (!(dwVersion >= 0x80000000 && dwWindowsMajorVersion >= 4))
|
||||
{ // Windows NT/2k
|
||||
int nLen = MultiByteToWideChar(CP_ACP, 0, netif, -1, NULL, 0);
|
||||
MultiByteToWideChar(CP_ACP, 0, netif, -1, (WCHAR *)NetDev, nLen);
|
||||
IsNT = TRUE;
|
||||
} else { // Win9x
|
||||
strcpy(NetDev, netif);
|
||||
}
|
||||
// Expecting ANSI format for WinPCap 3.1 or newer
|
||||
strcpy(NetDev, netif);
|
||||
|
||||
lpAdapter = PacketOpenAdapter(NetDev);
|
||||
if (!lpAdapter || (lpAdapter->hFile == INVALID_HANDLE_VALUE)) {
|
||||
@ -380,7 +369,7 @@ void bx_win32_pktmover_c::sendpkt(void *buf, unsigned io_len)
|
||||
PacketInitPacket(pkSend, (char *)buf, io_len);
|
||||
|
||||
if (!PacketSendPacket(lpAdapter, pkSend, TRUE)) {
|
||||
fprintf(stderr, "[ETH-WIN32] Error sending packet: %lu\n", GetLastError());
|
||||
BX_ERROR(("Error sending packet: %lu\n", GetLastError()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ typedef PCHAR (CDECL *PGetVersion)();
|
||||
PGetAdapterNames PacketGetAdapterNames = NULL;
|
||||
PGetVersion PacketGetVersion = NULL;
|
||||
|
||||
void myexit (int code)
|
||||
void myexit(int code)
|
||||
{
|
||||
#ifndef __CYGWIN__
|
||||
printf ("\nPress any key to continue\n");
|
||||
@ -74,7 +74,6 @@ int CDECL main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
HINSTANCE hPacket;
|
||||
DWORD dwVersion, dwMajorVersion;
|
||||
char AdapterInfo[NIC_BUFFER_SIZE] = { '\0','\0' };
|
||||
ULONG AdapterLength = NIC_BUFFER_SIZE;
|
||||
LPWSTR wstrName;
|
||||
@ -86,22 +85,18 @@ int CDECL main(int argc, char **argv)
|
||||
|
||||
// Attemp to load the WinpCap packet library
|
||||
hPacket = LoadLibrary("PACKET.DLL");
|
||||
if(hPacket)
|
||||
if (hPacket)
|
||||
{
|
||||
// Now look up the address
|
||||
PacketGetAdapterNames = (PGetAdapterNames)GetProcAddress(hPacket, "PacketGetAdapterNames");
|
||||
PacketGetVersion = (PGetVersion)GetProcAddress(hPacket, "PacketGetVersion");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
printf("Could not load WinPCap driver!\n");
|
||||
printf ("You can download them for free from\n");
|
||||
printf ("http://www.winpcap.org/\n");
|
||||
myexit(1);
|
||||
}
|
||||
|
||||
dwVersion = GetVersion();
|
||||
dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
|
||||
|
||||
// Get DLL Version and Tokenize
|
||||
dllVersion = PacketGetVersion();
|
||||
nDLLMajorVersion = -1;
|
||||
@ -125,12 +120,11 @@ int CDECL main(int argc, char **argv)
|
||||
}
|
||||
|
||||
// Get out blob of adapter info
|
||||
PacketGetAdapterNames(AdapterInfo,&AdapterLength);
|
||||
PacketGetAdapterNames(AdapterInfo, &AdapterLength);
|
||||
|
||||
// If this is Windows NT ... And DLL Returns UNICODE
|
||||
if(!(dwVersion >= 0x80000000 && dwMajorVersion >= 4) &&
|
||||
(nDLLMajorVersion < 3 || (nDLLMajorVersion == 3 && nDLLMinorVersion < 1)))
|
||||
if (nDLLMajorVersion < 3 || (nDLLMajorVersion == 3 && nDLLMinorVersion < 1))
|
||||
{
|
||||
// DLL returns UNICODE
|
||||
wstrName=(LPWSTR)AdapterInfo;
|
||||
|
||||
// Obtain Names
|
||||
@ -146,7 +140,7 @@ int CDECL main(int argc, char **argv)
|
||||
strDesc = (LPSTR)++wstrName;
|
||||
|
||||
// Obtain descriptions ....
|
||||
for(i=0;i<nAdapterCount;i++)
|
||||
for (i=0;i<nAdapterCount;i++)
|
||||
{
|
||||
// store pointer to description
|
||||
niNT[i].strDesc=strDesc;
|
||||
@ -157,16 +151,14 @@ int CDECL main(int argc, char **argv)
|
||||
wprintf(L" Device: %s",niNT[i].wstrName);
|
||||
}
|
||||
|
||||
if(i) {
|
||||
if (i) {
|
||||
printf("\n\nExample config for bochsrc:\n");
|
||||
wprintf(L"ne2k: ioaddr=0x300, irq=3, mac=b0:c4:20:00:00:00, ethmod=win32, ethdev=%s",niNT[0].wstrName);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// Windows 9x
|
||||
} else {
|
||||
// DLL returns ANSI
|
||||
strName=(LPSTR)AdapterInfo;
|
||||
|
||||
// Obtain Names
|
||||
@ -182,7 +174,7 @@ int CDECL main(int argc, char **argv)
|
||||
strDesc = (LPSTR)++strName;
|
||||
|
||||
// Obtain descriptions ....
|
||||
for(i=0;i<nAdapterCount;i++)
|
||||
for (i=0;i<nAdapterCount;i++)
|
||||
{
|
||||
// store pointer to description
|
||||
ni9X[i].strDesc=strDesc;
|
||||
@ -193,8 +185,7 @@ int CDECL main(int argc, char **argv)
|
||||
printf(" Device: %s",ni9X[i].strName);
|
||||
}
|
||||
|
||||
if(i)
|
||||
{
|
||||
if (i) {
|
||||
printf("\n\nExample config for bochsrc:\n");
|
||||
printf("ne2k: ioaddr=0x300, irq=3, mac=b0:c4:20:00:00:00, ethmod=win32, ethdev=%s",ni9X[0].strName);
|
||||
printf("\n");
|
||||
|
Loading…
Reference in New Issue
Block a user