Nmap Development mailing list archives
Re: nmap 3.3+V-2.99
From: "Jay Freeman \(saurik\)" <saurik () saurik com>
Date: Sun, 31 Aug 2003 18:21:36 -0500
Gisle: I use Linux on my servers and for a lot of networking related things, but always run Windows on my desktop clients. Also, nmap is really only barely compiling on Win32 period due to the way it was ported (someone just added a million #define statements to try to map Unix calls to Win32 and then tried to add a makeshift POSIX layer); I've mentioned issues I've had with this in a previous e-mail to some people (including Fyodor), although I'm not sure if it hit this list. Thanks for the patch, it's much more complete than the hack I put in to fix it earlier today when I got your e-mail. Fyodor should apply the utils.cc part of that, too. Note that I'm rather certain the refcount.hpp change doesn't change anything :). Sincerely, Jay Freeman (saurik) saurik () saurik com ----- Original Message ----- From: "Gisle Vanem" <giva () bgnett no> To: "Jay Freeman (saurik)" <saurik () saurik com>; <nmap-dev () insecure org> Sent: Sunday, August 31, 2003 5:54 PM Subject: Re: nmap 3.3+V-2.99
"Jay Freeman (saurik)" <saurik () saurik com> said:Considering the first entry in my CHANGELOG was "I broke the Win32
build." I
would have to say "no, I didn't test it on Windows, I didn't even
realize
anyone else was going to be able to compile it on Windows", hehe. It
totally
slipped my mind that you could still use gcc to get it to compile on Windows.Funny that you seem to prefer Linux, but you post using X-Mailer: Microsoft Outlook Express 6.00.2600.0000 :-) Here's some patches that works for me: diff -u3 -H -B -r .\menes-ext\refcount.hpp ..\menes-ext\refcount.hpp --- .\menes-ext\refcount.hpp Sun Aug 31 07:05:09 2003 +++ ..\menes-ext\refcount.hpp Sun Aug 31 18:45:41 2003 @@ -114,7 +114,8 @@ typedef Counted_ Value; inline void Clear(Value &value) const { - value = NULL; + if (value) + value = NULL; } Not sure why, but Clear() is using a NULL-ptr somewhere. And most importantly: diff -u3 -H -B -r .\utils.cc ..\utils.cc --- .\utils.cc Sun Aug 31 07:05:09 2003 +++ ..\utils.cc Sun Aug 31 20:49:36 2003 @@ -45,6 +45,9 @@ /* $Id: utils.cc,v 1.1.1.4 2003/07/18 19:32:27 saurik Exp $ */ #include "utils.h" +#include "NmapOps.h" + +extern NmapOps o; /* Return num if it is between min and max. Otherwise return min or max (whichever is closest to num), */ @@ -616,9 +619,12 @@ file at a time (note how gmap is used).*/ /* I believe this was written by Ryan Permeh ( ryan () eeye com) */ -HANDLE gmap = 0; -char *mmapfile(char *fname, int *length, int openflags) { +static HANDLE gmap = NULL; + +char *mmapfile(char *fname, int *length, int openflags) +{ HANDLE fd; + DWORD mflags, oflags; char *fileptr; if (!length || !fname) { @@ -626,27 +632,44 @@ return NULL; } - *length = -1; + if (openflags == O_RDONLY) { + oflags = GENERIC_READ; + mflags = PAGE_READONLY; + } + else { + oflags = GENERIC_READ | GENERIC_WRITE; + mflags = PAGE_READONLY | PAGE_READWRITE; + } + + fd = CreateFile ( + fname, + oflags, // open flags + 0, // do not share + NULL, // no security + OPEN_EXISTING, // open existing + FILE_ATTRIBUTE_NORMAL, + NULL); // no attr. template + if (!fd) + pfatal ("%s(%u): CreateFile()", __FILE__, __LINE__); + + *length = (int) GetFileSize (fd, NULL); + + gmap = CreateFileMapping (fd, NULL, mflags, 0, 0, NULL); + if (!gmap) + pfatal ("%s(%u): CreateFileMapping(), file '%s', length %d, mflags
%08lX",
+ __FILE__, __LINE__, fname, *length, mflags); + + fileptr = (char*) MapViewOfFile (gmap, oflags == GENERIC_READ ?
FILE_MAP_READ : FILE_MAP_WRITE,
+ 0, 0, 0); + if (!fileptr) + pfatal ("%s(%u): MapViewOfFile()", __FILE__, __LINE__); + + CloseHandle (fd); + + if (o.debugging > 2) + printf ("mmapfile(): fd %08lX, gmap %08lX, fileptr %08lX, length %d\n", + (DWORD)fd, (DWORD)gmap, (DWORD)fileptr, *length); - fd= CreateFile(fname, - openflags, // open for writing - 0, // do not share - NULL, // no security - OPEN_EXISTING, // overwrite existing - FILE_ATTRIBUTE_NORMAL, - NULL); // no attr. template - - gmap=CreateFileMapping(fd,NULL, (openflags & O_RDONLY)?
PAGE_READONLY:(openflags & O_RDWR)? (PAGE_READONLY|PAGE_READWRITE) :
PAGE_READWRITE,0,0,NULL); - - fileptr = (char *)MapViewOfFile(gmap, FILE_MAP_ALL_ACCESS,0,0,0); - *length = (int) GetFileSize(fd,NULL); - CloseHandle(fd); - - #ifdef MAP_FAILED - if (fileptr == MAP_FAILED) return NULL; - #else - if (fileptr == (char *) -1) return NULL; - #endif return fileptr; } @@ -655,12 +678,13 @@ works if the file is the most recently mapped one */ int win32_munmap(char *filestr, int filelen) { - if(gmap == 0) - fatal("win32_munmap: no current mapping !\n"); - FlushViewOfFile(filestr, filelen); - UnmapViewOfFile(filestr); - CloseHandle(gmap); - gmap = 0; + if(gmap) + { + FlushViewOfFile(filestr, filelen); + UnmapViewOfFile(filestr); + CloseHandle(gmap); + } + gmap = NULL; return 0; } Sorry about the wrapping lines and OE collapsing tabs. But you figure it out. -- Gisle V. Not what you think it is; http://www.nice-tits.org
--------------------------------------------------------------------- For help using this (nmap-dev) mailing list, send a blank email to nmap-dev-help () insecure org . List run by ezmlm-idx (www.ezmlm.org).
Current thread:
- nmap 3.3+V-2.99 Gisle Vanem (Aug 31)
- <Possible follow-ups>
- Re: nmap 3.3+V-2.99 Gisle Vanem (Aug 31)
- Re: nmap 3.3+V-2.99 Gisle Vanem (Aug 31)
- Re: nmap 3.3+V-2.99 Jay Freeman (saurik) (Aug 31)
- Re: nmap 3.3+V-2.99 Gisle Vanem (Aug 31)
- Re: nmap 3.3+V-2.99 Jay Freeman (saurik) (Aug 31)
- Re: nmap 3.3+V-2.99 Brett Hutley (Aug 31)
- Re: nmap 3.3+V-2.99 Jay Freeman (saurik) (Aug 31)
- Re: nmap 3.3+V-2.99 Brett Hutley (Aug 31)
- Re: nmap 3.3+V-2.99 Gisle Vanem (Aug 31)
- Re: nmap 3.3+V-2.99 Fyodor (Sep 04)
- Re: nmap 3.3+V-2.99 Gisle Vanem (Sep 04)
- Re: nmap 3.3+V-2.99 Jay Freeman (saurik) (Sep 04)