diff --git a/NmapOps.cc b/NmapOps.cc index dc8c57b28..abd72f376 100644 --- a/NmapOps.cc +++ b/NmapOps.cc @@ -217,6 +217,7 @@ void NmapOps::Initialize() { else isr00t = !(geteuid()); #endif + have_pcap = true; debugging = 0; verbose = 0; min_packet_send_rate = 0.0; /* Unset. */ @@ -335,10 +336,10 @@ bool NmapOps::RawScan() { void NmapOps::ValidateOptions() { -#ifdef WIN32 - const char *privreq = "that WinPcap version 3.1 or higher and iphlpapi.dll be installed. You seem to be missing one or both of these. Winpcap is available from http://www.winpcap.org. iphlpapi.dll comes with Win98 and later operating sytems and NT 4.0 with SP4 or greater. For previous windows versions, you may be able to take iphlpapi.dll from another system and place it in your system32 dir (e.g. c:\\windows\\system32)"; -#else const char *privreq = "root privileges"; +#ifdef WIN32 + if (!o.have_pcap) + privreq = "that WinPcap version 3.1 or higher and iphlpapi.dll be installed. You seem to be missing one or both of these. Winpcap is available from http://www.winpcap.org. iphlpapi.dll comes with Win98 and later operating sytems and NT 4.0 with SP4 or greater. For previous windows versions, you may be able to take iphlpapi.dll from another system and place it in your system32 dir (e.g. c:\\windows\\system32)"; #endif diff --git a/NmapOps.h b/NmapOps.h index a56739dca..467ad415b 100644 --- a/NmapOps.h +++ b/NmapOps.h @@ -145,6 +145,8 @@ class NmapOps { adjustments (quietly or with a warning to the user). */ int isr00t; + /* Whether we have pcap functions (can be false on Windows). */ + bool have_pcap; int debugging; #define PACKET_SEND_NOPREF 1 diff --git a/mswin32/winfix.cc b/mswin32/winfix.cc index 51385c0cd..06b4f7573 100644 --- a/mswin32/winfix.cc +++ b/mswin32/winfix.cc @@ -120,8 +120,6 @@ extern NmapOps o; -int pcap_avail = 0; - /* internal functions */ static void win_cleanup(void); static char pcaplist[4096]; @@ -173,7 +171,7 @@ void win_init() { ULONG len = sizeof(pcaplist); - pcap_avail = 1; + o.have_pcap = true; if(o.debugging > 2) printf("***WinIP*** trying to initialize WinPcap\n"); PacketGetAdapterNames(pcaplist, &len); @@ -181,7 +179,7 @@ void win_init() if(FAILED(__HrLoadAllImportsForDll("wpcap.dll"))) { error("WARNING: your winpcap is too old to use. Nmap may not function.\n"); - pcap_avail = 0; + o.have_pcap = false; } #endif if(o.debugging) @@ -190,11 +188,11 @@ void win_init() #ifdef _MSC_VER __except (1) { error("WARNING: Could not import all necessary WinPcap functions. You may need to upgrade to version 3.1 or higher from http://www.winpcap.org. Resorting to connect() mode -- Nmap may not function completely"); - pcap_avail=0; + o.have_pcap=false; } #endif - if (!pcap_avail) + if (!o.have_pcap) o.isr00t = 0; atexit(win_cleanup); }