[Windump] WinDump and CreateProcess

Bizins'kyi Yurii jarni.ua at gmail.com
Thu Feb 3 04:38:58 PST 2011


Hello again,

Problem from previous mail has been solved. Mistake was in rules how paths
with white-spaces are solved in command line parameters. So "c:\\Program
Files\\WinPcap\\WinDump.exe -i 2 -n -s 4096 -w tcpdump.pcap" just had to be
rewritten to
"*\"*c:\\Program Files\\WinPcap\\WinDump.exe*\"* -i 2 -n -s 4096 -w
tcpdump.pcap". But onlu in cmd_line variable. First parameters in
CreateProcess should stay as it is.

Sorry for disturbing with such stupid questions.
Best regards,
Yurii Bizinskyi.

2011/2/3 Bizins'kyi Yurii <jarni.ua at gmail.com>

> Hi.
>
> I'm trying to run WinDump from my application using CreateProcess. But
> WinDump fails with exitcode 1. If I run the same command from cmd.exe or
> from batch all works perfectly. My code is:
>
> int main( int argc, char * argv[] )
> {
>   char * cmd_line = "c:\\Program Files\\WinPcap\\WinDump.exe -i 2 -n -s
> 4096 -w tcpdump.pcap";
>   STARTUPINFO    si = {0};
>   PROCESS_INFORMATION pi = {0};
>   si.cb = sizeof(si);
>
>   if( CreateProcess(
>     "c:\\Program Files\\WinPcap\\WinDump.exe",
>     cmd_line,
>     NULL,                 // Process Security Attributes
>     NULL,                 // Thread Security Attributes
>     FALSE,                                // Inherit handles
>     CREATE_NEW_CONSOLE,      // CreationFlags
>     NULL,                 // Environment
>     "c:\\WinDumpTest\\",  // CurrentDirectory
>     &si,
>     &pi) )
>   {
>     if( WAIT_OBJECT_0 == ::WaitForSingleObject( pi.hProcess, INFINITE ) )
>     {
>       DWORD dwExitCode = -1;
>       if( GetExitCodeProcess(pi.hProcess, &dwExitCode) )
>       {
>         printf("tcpdump exited with %d.\n", dwExitCode );
>       }
>     }
>   }
>   return 0;
> }
>
> Thanks in advance.
> Yurii Bizinskyi.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winpcap.org/pipermail/windump/attachments/20110203/de6798d8/attachment.html>


More information about the Windump mailing list