Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. CreateProcess() probelms [modified]

CreateProcess() probelms [modified]

Scheduled Pinned Locked Moved Managed C++/CLI
csharpc++dotnetvisual-studiosysadmin
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    darkcloud 42o
    wrote on last edited by
    #1

    the code im about to put down.. seems to run through without errors... however. when i cout out the final conversion i get wierd numbers... but basically what i have here is create process.. im using a dummy.exe to create a txt file so i know if it works right away... if(first4=="EXEC"){ LPWSTR szCmdline=(LPWSTR)cl.c_str(); STARTUPINFO StartupInfo; PROCESS_INFORMATION ProcessInformation; HANDLE hPipeRead, hpRead; HANDLE hPipeWrite; SECURITY_ATTRIBUTES sa; memset(&ProcessInformation,0,sizeof(ProcessInformation)); memset(&sa,0,sizeof(sa)); sa.nLength=sizeof(sa); sa.bInheritHandle = TRUE; CreatePipe(&hPipeRead,&hPipeWrite,&sa,0); memset(&StartupInfo,0,sizeof(StartupInfo)); cout << "pipes and memset"; GetStartupInfo(&StartupInfo); StartupInfo.hStdOutput = hPipeWrite; StartupInfo.hStdInput = hPipeRead; StartupInfo.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; StartupInfo.wShowWindow = SW_HIDE; cout << "StartupInfo Read\n"; CreateProcess(NULL, szCmdline, NULL, NULL, TRUE, 0, NULL, NULL, &StartupInfo, &ProcessInformation); cout << szCmdline; CloseHandle( hPipeWrite ); Sleep(100); DWORD stuff; char buff[1000]; bool firstsend; int offset = 0, bRecv; PeekNamedPipe(hPipeRead, NULL, 0, NULL, &stuff, NULL); if(stuff != 0) { ZeroMemory(buff, sizeof(buff)); firstsend = true; do { ReadFile(hPipeRead, buff, 1000, &stuff, NULL); if(firstsend) { send(usersock, buff + offset, strlen(buff) - offset, 0); firstsend = false; } else send(usersock, buff, strlen(buff), 0); } while(stuff == 1000); } else { char ccc[128]="NoReply program run"; send(usersock, ccc, strlen(ccc), 0); } } // // This is for an ftp server and webserver i have to get this create process functioning and outputing // the dos screen info through a socket which i already have setup here and should work.... but errors // out when if statement is called... ive been playing wiht it for about 2hr... plz help // im using Visual Studio 2005 C++ and im pretty sure this is CLR -- modified at 7:22 Monday 5th March, 2007

    T 1 Reply Last reply
    0
    • D darkcloud 42o

      the code im about to put down.. seems to run through without errors... however. when i cout out the final conversion i get wierd numbers... but basically what i have here is create process.. im using a dummy.exe to create a txt file so i know if it works right away... if(first4=="EXEC"){ LPWSTR szCmdline=(LPWSTR)cl.c_str(); STARTUPINFO StartupInfo; PROCESS_INFORMATION ProcessInformation; HANDLE hPipeRead, hpRead; HANDLE hPipeWrite; SECURITY_ATTRIBUTES sa; memset(&ProcessInformation,0,sizeof(ProcessInformation)); memset(&sa,0,sizeof(sa)); sa.nLength=sizeof(sa); sa.bInheritHandle = TRUE; CreatePipe(&hPipeRead,&hPipeWrite,&sa,0); memset(&StartupInfo,0,sizeof(StartupInfo)); cout << "pipes and memset"; GetStartupInfo(&StartupInfo); StartupInfo.hStdOutput = hPipeWrite; StartupInfo.hStdInput = hPipeRead; StartupInfo.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; StartupInfo.wShowWindow = SW_HIDE; cout << "StartupInfo Read\n"; CreateProcess(NULL, szCmdline, NULL, NULL, TRUE, 0, NULL, NULL, &StartupInfo, &ProcessInformation); cout << szCmdline; CloseHandle( hPipeWrite ); Sleep(100); DWORD stuff; char buff[1000]; bool firstsend; int offset = 0, bRecv; PeekNamedPipe(hPipeRead, NULL, 0, NULL, &stuff, NULL); if(stuff != 0) { ZeroMemory(buff, sizeof(buff)); firstsend = true; do { ReadFile(hPipeRead, buff, 1000, &stuff, NULL); if(firstsend) { send(usersock, buff + offset, strlen(buff) - offset, 0); firstsend = false; } else send(usersock, buff, strlen(buff), 0); } while(stuff == 1000); } else { char ccc[128]="NoReply program run"; send(usersock, ccc, strlen(ccc), 0); } } // // This is for an ftp server and webserver i have to get this create process functioning and outputing // the dos screen info through a socket which i already have setup here and should work.... but errors // out when if statement is called... ive been playing wiht it for about 2hr... plz help // im using Visual Studio 2005 C++ and im pretty sure this is CLR -- modified at 7:22 Monday 5th March, 2007

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2
      1. read the Forum Guidelines[^] first (especially 1. and 5. in your case) 2) your answer is here[^]

      [VisualCalc][Binary Guide updated! ][CommDialogs new! ] | [Forums Guidelines]

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups