Pass the executable path to CreateProcess(), and end it with ".exe".
authorGuy Harris <guy@alum.mit.edu>
Tue, 19 May 2015 01:40:13 +0000 (18:40 -0700)
committerGuy Harris <guy@alum.mit.edu>
Tue, 19 May 2015 01:40:46 +0000 (01:40 +0000)
On Windows, 1) pass the path of the executable as the first argument to
CreateProcess(), which requires that we 2) have that path end with
".exe.

Maybe it'll fix the searching-for-dumpcap that showed up in bug 11196.

Change-Id: I9d06c07c3513fd42b98d3f8d9a1d2d545f651fe2
Reviewed-on: https://code.wireshark.org/review/8534
Reviewed-by: Guy Harris <guy@alum.mit.edu>
capchild/capture_sync.c

index d2c2fc51aa88a4691530a986f9a9052134b3bf1a..c0308dad567932a76b0e0b49d962a48e336b755e 100644 (file)
@@ -329,7 +329,11 @@ init_pipe_args(int *argc) {
     *argv = NULL;
 
     /* take Wireshark's absolute program path and replace "Wireshark" with "dumpcap" */
-    exename = g_strdup_printf("%s" G_DIR_SEPARATOR_S "dumpcap", progfile_dir);
+#ifdef _WIN32
+    exename = g_strdup_printf("%s\\dumpcap.exe", progfile_dir);
+#else
+    exename = g_strdup_printf("%s/dumpcap", progfile_dir);
+#endif
 
     /* Make that the first argument in the argument list (argv[0]). */
     argv = sync_pipe_add_arg(argv, argc, exename);
@@ -643,7 +647,7 @@ sync_pipe_start(capture_options *capture_opts, capture_session *cap_session, voi
     }
 
     /* call dumpcap */
-    if(!CreateProcess(NULL, utf_8to16(args->str), NULL, NULL, TRUE,
+    if(!CreateProcess(utf8_to_16(argv[0]), utf_8to16(args->str), NULL, NULL, TRUE,
                       CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi)) {
         report_failure("Couldn't run %s in child process: %s",
                        args->str, win32strerror(GetLastError()));
@@ -857,7 +861,7 @@ sync_pipe_open_command(char** argv, int *data_read_fd,
     }
 
     /* call dumpcap */
-    if(!CreateProcess(NULL, utf_8to16(args->str), NULL, NULL, TRUE,
+    if(!CreateProcess(utf8_to_16(argv[0]), utf_8to16(args->str), NULL, NULL, TRUE,
                       CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi)) {
         *msg = g_strdup_printf("Couldn't run %s in child process: %s",
                                args->str, win32strerror(GetLastError()));