コード例 #1
0
        public ManagedCallback GetProcessCallbackInterface(string name, ICorDebugThread pThread)
        {
            ICorDebugProcess pProcess;

            try
            {
                pProcess = pThread.GetProcess();
            }
            catch (COMException e)
            {
                debugger.TraceMessage("Ignoring callback \"" + name + "\": " + e.Message);
                return(null);
            }
            return(GetProcessCallbackInterface(name, pProcess));
        }
コード例 #2
0
ファイル: Process.cs プロジェクト: wmade/SoftwareZator-2012
        static unsafe public Process CreateProcess(NDebugger debugger, string filename, string workingDirectory, string arguments)
        {
            debugger.TraceMessage("Executing " + filename + " " + arguments);

            uint[] processStartupInfo = new uint[17];
            processStartupInfo[0] = sizeof(uint) * 17;
            uint[] processInfo = new uint[4];

            ICorDebugProcess outProcess;

            if (workingDirectory == null || workingDirectory == "")
            {
                workingDirectory = System.IO.Path.GetDirectoryName(filename);
            }

            _SECURITY_ATTRIBUTES secAttr = new _SECURITY_ATTRIBUTES();

            secAttr.bInheritHandle       = 0;
            secAttr.lpSecurityDescriptor = IntPtr.Zero;
            secAttr.nLength = (uint)sizeof(_SECURITY_ATTRIBUTES);

            fixed(uint *pprocessStartupInfo = processStartupInfo)
            fixed(uint *pprocessInfo = processInfo)
            outProcess =
                debugger.CorDebug.CreateProcess(
                    filename,                                           // lpApplicationName
                    // If we do not prepend " ", the first argument migh just get lost
                    " " + arguments,                                    // lpCommandLine
                    ref secAttr,                                        // lpProcessAttributes
                    ref secAttr,                                        // lpThreadAttributes
                    1,                                                  //TRUE                    // bInheritHandles
                    0x00000010 /*CREATE_NEW_CONSOLE*/,                  // dwCreationFlags
                    IntPtr.Zero,                                        // lpEnvironment
                    workingDirectory,                                   // lpCurrentDirectory
                    (uint)pprocessStartupInfo,                          // lpStartupInfo
                    (uint)pprocessInfo,                                 // lpProcessInformation,
                    CorDebugCreateProcessFlags.DEBUG_NO_SPECIAL_OPTIONS // debuggingFlags
                    );

            return(new Process(debugger, outProcess, workingDirectory));
        }