[Windump] WinDump and CreateProcess

Bizins'kyi Yurii jarni.ua at gmail.com
Thu Feb 3 00:35:02 PST 2011


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/7143e1d2/attachment.html>


More information about the Windump mailing list