ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
July 17th, 2024 | 10:00am-11:55am SGT (UTC+8) | Online

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