Esempio n. 1
0
            public static void SuspendProcess()
            {
                UpdateProcessInformation();

                ProcessModule ourModule = OurModule;
                ProcessModule clrJit    = HostProcess.FindProcessModule("clrjit.dll");
                ProcessModule clr       = HostProcess.FindProcessModule("clr.dll");

                foreach (ProcessThread pT in HostProcess.Threads)
                {
                    // Dont suspend any threads started from our module, clr.dll module or clr_jit.dll module
                    if ((pT.StartAddress.ToInt64() >= ourModule.BaseAddress.ToInt64() || pT.StartAddress.ToInt64() <= (ourModule.BaseAddress + ourModule.ModuleMemorySize).ToInt64()) ||
                        (pT.StartAddress.ToInt64() >= clrJit.BaseAddress.ToInt64() || pT.StartAddress.ToInt64() <= (clrJit.BaseAddress + clrJit.ModuleMemorySize).ToInt64()) ||
                        (pT.StartAddress.ToInt64() >= clr.BaseAddress.ToInt64() || pT.StartAddress.ToInt64() <= (clr.BaseAddress + clr.ModuleMemorySize).ToInt64()))
                    {
                        continue;
                    }

                    IntPtr pOpenThread = PInvoke.OpenThread(Enums.ThreadAccess.SUSPEND_RESUME, false, (uint)pT.Id);
                    if (pOpenThread == IntPtr.Zero)
                    {
                        continue;
                    }

                    PInvoke.SuspendThread(pOpenThread);
                    PInvoke.CloseHandle(pOpenThread);
                }
            }
Esempio n. 2
0
        public HostSettings(HostProcess process)
        {
            _process = process;

            _name = new TextBox();
            _name.Bind(
                tb => tb.Text,
                _process,
                proc => proc.Name,
                DualBindingMode.TwoWay);

            _processId = new NumericUpDown();
            _processId.Bind(
                nud => nud.Value,
                _process,
                proc => proc.ProcessId,
                DualBindingMode.TwoWay);

            this.AddRow(new Label()
            {
                Text = Constants.ProcessNameLabel
            }, _name);
            this.AddRow(new Label()
            {
                Text = Constants.ProcessIdLabel
            }, _processId);

            this.AddRow();
        }
Esempio n. 3
0
 private void CloseHostProcess()
 {
     _inProc.Quit();
     if (!HostProcess.WaitForExit(milliseconds: 10000))
     {
         IntegrationHelper.KillProcess(HostProcess);
     }
 }
Esempio n. 4
0
        internal static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(AppDomain_CurrentDomain_UnhandledException);

            if (args.Length == 3 && args[0] == "worker")
            {
                try {
                    host = new HostProcess(args[1], args[2]);
                    host.Run(new Program().DataReceived);
                } catch (Exception ex) {
                    ShowMessageBox(ex.ToString());
                }
            }
            else
            {
                Console.WriteLine("ICSharpCode.SharpDevelop.BuildWorker.exe is used to compile " +
                                  "MSBuild projects inside SharpDevelop.");
                Console.WriteLine("If you want to compile projects on the command line, use " +
                                  "MSBuild.exe (part of the .NET Framework)");
            }
        }
Esempio n. 5
0
        private string ResolveFilePath(PEActivationContext activationContext, string fileName)
        {
            // Check for .local redirection
            var dotLocalFilePath = Path.Combine(HostProcess.BaseProcess.MainModule.FileName, ".local", fileName);

            if (File.Exists(dotLocalFilePath))
            {
                return(dotLocalFilePath);
            }

            // Check for SxS redirection
            var sxsFilePath = activationContext.ProbeManifest(fileName);

            if (!(sxsFilePath is null))
            {
                return(sxsFilePath);
            }

            // Search the root directory of the DLL
            //if (!(_rootDirectoryPath is null))
            //{
            //    var rootDirectoryFilePath = Path.Combine(_rootDirectoryPath, fileName);

            //    if (File.Exists(rootDirectoryFilePath))
            //    {
            //        return rootDirectoryFilePath;
            //    }
            //}

            // Search the directory from which the process was loaded
            var processDirectoryFilePath = Path.Combine(HostProcess.BaseProcess.MainModule.FileName, fileName);

            if (File.Exists(processDirectoryFilePath))
            {
                return(processDirectoryFilePath);
            }

            // Search the System directory
            var systemDirectoryPath     = HostProcess.GetArchitecture() == Architecture.X86 ? Environment.GetFolderPath(Environment.SpecialFolder.SystemX86) : Environment.SystemDirectory;
            var systemDirectoryFilePath = Path.Combine(systemDirectoryPath, fileName);

            if (File.Exists(systemDirectoryFilePath))
            {
                return(systemDirectoryFilePath);
            }

            // Search the Windows directory
            var windowsDirectoryFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), fileName);

            if (File.Exists(windowsDirectoryFilePath))
            {
                return(windowsDirectoryFilePath);
            }

            // Search the current directory
            var currentDirectoryFilePath = Path.Combine(Directory.GetCurrentDirectory(), fileName);

            if (File.Exists(currentDirectoryFilePath))
            {
                return(currentDirectoryFilePath);
            }

            // Search the directories listed in the PATH environment variable
            var path = Environment.GetEnvironmentVariable("PATH");

            return(path?.Split(';').Where(Directory.Exists).Select(directory => Path.Combine(directory, fileName)).FirstOrDefault(File.Exists));
        }