Wireshark-dev: [Wireshark-dev] Would this help to implement bug 655?
From: Jaap Keuter <jaap.keuter@xxxxxxxxx>
Date: Thu, 15 Jun 2006 15:58:52 +0200 (CEST)
Hi,

Attached is a patch to dumpcap that would allow it to run as service, as
described in bug 655. It's all done from the books, since I couldn't test
it. Can one of the Windows wizards have a look?

Thanx,
Jaap

Index: dumpcap.c
===================================================================
--- dumpcap.c	(revision 18465)
+++ dumpcap.c	(working copy)
@@ -193,13 +193,17 @@
 BOOL WINAPI ConsoleCtrlHandlerRoutine(DWORD dwCtrlType)
 {
     g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_INFO,
-        "Console: Ctrl+C");
+        "Console: Control signal");
     g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG,
-        "Console: Ctrl+C CtrlType: %u", dwCtrlType);
+        "Console: Control signal, CtrlType: %u", dwCtrlType);
 
-    capture_loop_stop();
-
-    return TRUE;
+    /* Keep capture running if we're a service and a user logs off */
+    if (capture_child || (dwCtrlType != CTRL_LOGOFF_EVENT)) {
+        capture_loop_stop();
+        return TRUE;
+    } else {
+	return FALSE;
+    }
 }
 #endif