Nmap Development mailing list archives

Path to nmap.xsl for win32


From: jah <jah () zadkiel plus com>
Date: Sun, 14 Sep 2008 02:13:56 +0100

Hello,

When writing xml output on windows the path to the stylesheet isn't
written into xml-stylesheet, only the filename.
Attached is a possible fix which uses GetModuleFileName in the same way
as is done in nmap.cc:2787.
I would like to have done something with the NMAPDATADIR declaration in
nmap_winconfig.h, but honestly don't know what to do with it.  Maybe
this will do for now...

Regards,

jah

--- NmapOps.cc.orig     2008-08-06 15:27:14.218750000 +0100
+++ NmapOps.cc  2008-09-14 01:48:21.203125000 +0100
@@ -248,7 +248,14 @@
   if (datadir) free(datadir);
   datadir = NULL;
 #if WIN32
-  Strncpy(tmpxsl, "nmap.xsl", sizeof(tmpxsl));
+  char exePath[MAXPATHLEN];
+  int i, res;
+  res = GetModuleFileName(GetModuleHandle(0), exePath, MAXPATHLEN);
+  if(!res) fatal("GetModuleFileName failed (!)\n");
+  for(i = res - 1; i >= 0 && exePath[i] != '/' && exePath[i] != '\\'; i--);
+  if(i >= 0)
+    exePath[i] = 0;
+  Snprintf(tmpxsl, sizeof(tmpxsl), "%s\\nmap.xsl", exePath);
 #else
   Snprintf(tmpxsl, sizeof(tmpxsl), "%s/nmap.xsl", NMAPDATADIR);
 #endif

_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://SecLists.Org

Current thread: