Ethereal-dev: [Ethereal-dev] Wiretap as Win32 DLL

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Gilbert Ramirez <gram@xxxxxxxxxx>
Date: Fri, 20 Oct 2000 01:30:29 -0400
Here's some changes, plus a wiretap/wtap.def file, to build wiretap as a DLL
on Windows. But after doing so, all 3 executables (edicap, ethereal, tethereal)
crash when I start them up (On win98: "This program has performed an illegal
operation and will be shut down.)

Any ideas as to why? I don't have my system set up such that I can run the MS
debugger on this.

--gilbert
? epan/config.h
? epan/ethereal.lib
? wiretap/wtap.def
? wiretap/wiretap.exp
? wiretap/wiretap.dll
Index: Makefile.nmake
===================================================================
RCS file: /usr/local/cvsroot/ethereal/Makefile.nmake,v
retrieving revision 1.59
diff -u -r1.59 Makefile.nmake
--- Makefile.nmake	2000/10/19 06:45:10	1.59
+++ Makefile.nmake	2000/10/20 05:27:29
@@ -192,7 +192,7 @@
 	strerror.obj	\
 	mkstemp.obj
 
-ethereal_LIBS= wiretap\libwtap.lib gtk\libui.lib epan\ethereal.lib \
+ethereal_LIBS= wiretap\wiretap.lib gtk\libui.lib epan\ethereal.lib \
 	wsock32.lib user32.lib \
 	$(GTK_DIR)\gtk\gtk-$(GTK_VERSION).lib \
 	$(GTK_DIR)\gdk\gdk-$(GTK_VERSION).lib \
@@ -200,13 +200,13 @@
 	$(GLIB_DIR)\gmodule\gmodule-$(GLIB_VERSION).lib \
 	$(PCAP_DIR)\lib\libpcap.lib
 
-tethereal_LIBS= wiretap\libwtap.lib epan\ethereal.lib \
+tethereal_LIBS= wiretap\wiretap.lib epan\ethereal.lib \
 	wsock32.lib user32.lib \
 	$(GLIB_DIR)\glib-$(GLIB_VERSION).lib \
 	$(GLIB_DIR)\gmodule\gmodule-$(GLIB_VERSION).lib \
 	$(PCAP_DIR)\lib\libpcap.lib
 
-editcap_LIBS= wiretap\libwtap.lib wsock32.lib user32.lib \
+editcap_LIBS= wiretap\wiretap.lib wsock32.lib user32.lib \
 	$(GLIB_DIR)\glib-$(GLIB_VERSION).lib \
 	$(GLIB_DIR)\gmodule\gmodule-$(GLIB_VERSION).lib
 
@@ -216,19 +216,19 @@
 
 all: wiretap gtk epan $(EXECUTABLES) $(RESOURCES)
 
-ethereal.exe	: config.h $(ethereal_OBJECTS) $(EXTRA_OBJECTS) image\ethereal.res wiretap\libwtap.lib gtk\libui.lib plugins
+ethereal.exe	: config.h $(ethereal_OBJECTS) $(EXTRA_OBJECTS) image\ethereal.res wiretap\wiretap.lib gtk\libui.lib plugins
 	@echo Linking $@
 	$(LINK) @<<
 		/OUT:ethereal.exe $(LDFLAGS) /SUBSYSTEM:windows $(ethereal_LIBS) $(ethereal_OBJECTS) $(EXTRA_OBJECTS) image\ethereal.res
 <<
 
-tethereal.exe	: config.h $(tethereal_OBJECTS) $(EXTRA_OBJECTS) image\tethereal.res wiretap\libwtap.lib plugins
+tethereal.exe	: config.h $(tethereal_OBJECTS) $(EXTRA_OBJECTS) image\tethereal.res wiretap\wiretap.lib plugins
 	@echo Linking $@
 	$(LINK) @<<
 		/OUT:tethereal.exe $(LDFLAGS) /SUBSYSTEM:console $(tethereal_LIBS) $(tethereal_OBJECTS) $(EXTRA_OBJECTS) image\tethereal.res
 <<
 
-editcap.exe	: config.h editcap.obj getopt.obj wiretap\libwtap.lib image\editcap.res
+editcap.exe	: config.h editcap.obj getopt.obj wiretap\wiretap.lib image\editcap.res
 	@echo Linking $@
 	$(LINK) @<<
 		/OUT:editcap.exe $(LDFLAGS) /SUBSYSTEM:console editcap.obj getopt.obj $(editcap_LIBS) image\editcap.res
Index: epan/Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/ethereal/epan/Makefile.am,v
retrieving revision 1.12
diff -u -r1.12 Makefile.am
--- Makefile.am	2000/10/19 07:18:19	1.12
+++ Makefile.am	2000/10/20 05:27:30
@@ -76,7 +76,8 @@
 	inet_pton.c		\
 	inet_ntop.c		\
 	inet_aton.h		\
-	inet_v6defs.h
+	inet_v6defs.h		\
+	@INET_ATON_O@ @INET_PTON_O@ @INET_NTOP_O@ 
 
 EXTRA_DIST = \
 	config.h.win32		\
Index: epan/Makefile.nmake
===================================================================
RCS file: /usr/local/cvsroot/ethereal/epan/Makefile.nmake,v
retrieving revision 1.4
diff -u -r1.4 Makefile.nmake
--- Makefile.nmake	2000/10/17 09:25:37	1.4
+++ Makefile.nmake	2000/10/20 05:27:30
@@ -34,12 +34,13 @@
 	strutil.obj      \
 	tvbuff.obj       \
 
-# For use when making ethereal.dll
-#ethereal.dll ethereal.lib	: config.h $(OBJECTS)
-#	link /DLL /out:ethereal.dll $(OBJECTS) $(libethereal_LIBS)
 
 ethereal.lib	: config.h $(OBJECTS)
 	lib /out:ethereal.lib $(OBJECTS)
+
+# For use when making ethereal.dll
+ethereal.dll 	: ..\config.h $(OBJECTS)
+	link /DLL /out:ethereal.dll $(OBJECTS) $(libethereal_LIBS)
 
 dfilter-scanner.obj : dfilter-scanner.c dfilter-grammar.h
 
Index: wiretap/Makefile.nmake
===================================================================
RCS file: /usr/local/cvsroot/ethereal/wiretap/Makefile.nmake,v
retrieving revision 1.15
diff -u -r1.15 Makefile.nmake
--- Makefile.nmake	2000/09/19 17:27:08	1.15
+++ Makefile.nmake	2000/10/20 05:27:30
@@ -32,8 +32,16 @@
 	toshiba.obj \
 	wtap.obj
 
-libwtap.lib	: config.h $(OBJECTS)
-	lib /out:libwtap.lib $(OBJECTS)
+#	wsock32.lib user32.lib 
+#	$(GLIB_DIR)\gmodule\gmodule-$(GLIB_VERSION).lib
+
+wiretap_LIBS = \
+	wsock32.lib \
+	$(GLIB_DIR)\glib-$(GLIB_VERSION).lib 
+
+wiretap.dll wiretap.lib	wiretap.exp : config.h $(OBJECTS)
+	link /NOLOGO /DLL /OUT:wiretap.dll /IMPLIB:wiretap.lib \
+		/DEF:wtap.def $(OBJECTS) $(wiretap_LIBS)
 
 ascend-grammar.c ascend-grammar.h : ascend-grammar.y
 	$(YACC) $(YACC_OPTS) -d -p ascend ascend-grammar.y -o ascend-grammar.c
EXPORTS
	wtap_buf_ptr
	wtap_close
	wtap_def_seek_read
	wtap_dump
	wtap_dump_can_open
	wtap_dump_can_write_encap
	wtap_dump_close
	wtap_dump_fdopen
	wtap_dump_file
	wtap_dump_open
	wtap_encap_short_string
	wtap_encap_string
	wtap_fd
	wtap_file
	wtap_file_encap
	wtap_file_type
	wtap_file_type_short_string
	wtap_file_type_string
	wtap_loop
	wtap_open_offline
	wtap_pcap_encap_to_wtap_encap
	wtap_phdr
	wtap_pseudoheader
	wtap_read
	wtap_seek_read
	wtap_sequential_close
	wtap_short_string_to_encap
	wtap_short_string_to_file_type
	wtap_snapshot_length
	wtap_strerror