CreateProcess



  • Hallo
    ich hab folgendes Problem ich beschäftige mich gerade mit Pipes
    und wenn ich die Funktion CreateProcess aufrufe meldet VS Unhandled exception at 0x7c8196f8

    Hier mal der Code.

    ------------------------main.cpp-------------------

    #include "stdafx.h"
    
    #include <cstdlib>
    #include <iostream>
    #include "terminal.h"
    using namespace std;
    
    int main(int argc, char *argv[])
    {
        SECURITY_ATTRIBUTES sa;
        sa.nLength=sizeof(sa);
        terminal t;
        t.setPipes();
        t.initizilize(TERMINAL_HIDDEN);
    
        t.cleanup();
    
        system("PAUSE");
        return EXIT_SUCCESS;
    }
    

    --------terminal.h------------------

    #ifndef terminal_h_
    #define terminal_h_
    #endif
    #define TERMINAL_HIDDEN 1
    #define TERMINAL_PUBLIC 0
    #include "stdafx.h"
    #include <windows.h>
    #include <iostream>
    #include <string.h>
    class terminal
    {
    private:
            std::string error;
            SECURITY_ATTRIBUTES sa;
    
    		SECURITY_DESCRIPTOR sd;
    		HANDLE newstdin,newstdout,hwrite,hread;      
    public:
           terminal()
    	   {
    
    	   };
           int setPipes()
           {
           InitializeSecurityDescriptor(&sd,SECURITY_DESCRIPTOR_REVISION);
           SetSecurityDescriptorDacl(&sd, true, NULL, false);
           sa.lpSecurityDescriptor = &sd;
           sa.nLength=sizeof(sa);
           sa.bInheritHandle=true;
           std::cout<<"hello"<<std::endl;
           if(!CreatePipe(&newstdin,&hwrite,&sa,0))
           {
    		   error="";
               error="Could not Create InputPipe";
               return 0;
    		}
            if(!CreatePipe(&newstdout,&hread,&sa,0))
            {
    		error="";
    		error="Could not Create OutputPipe";
            return 0;
            }
            return 1;
           };
    
           int initizilize(int mode);
           void reporterror();
    
           void cleanup();
           ~terminal()
    	   {
    	   };
    
    };
    

    ---------------------terminal.cpp-----------------

    #include "stdafx.h"
    #include "terminal.h"
    int terminal::initizilize(int mode)
    {
    
         if(mode==1)
         {
    		 STARTUPINFO si;
    		 GetStartupInfo(&si);
    		 si.dwFlags=STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
    		 si.wShowWindow=SW_HIDE;
    		 si.hStdError=terminal::newstdout;
    		 si.hStdOutput=terminal::newstdout;
    		 si.hStdInput=terminal::newstdin;
    
    		//Hier kommt der Fehler
     CreateProcess(L"HALLO",NULL,NULL,NULL,true,CREATE_NEW_CONSOLE,NULL,NULL,&si,NULL);
    
            std::cout<<"Terminal runs in HIDDEN MODE"<<std::endl;
         }
    	 return 1;
    };
    
    void terminal::reporterror()
    {
        std::cout<<terminal::error.c_str()<<std::endl;
    }
    void terminal::cleanup()
    {
         CloseHandle(terminal::newstdin);
         CloseHandle(terminal::newstdout);
         CloseHandle(terminal::hread);
         CloseHandle(terminal::hwrite);
    };
    

    Ich hoffe ihr könnt mir helfen



  • letzter Parameter von CreateProcess


Anmelden zum Antworten