示例#1
0
            public WorkerProcess(ClipboardAccess clipboard, WmiSession wmisession, IExceptionHandler exceptionhandler, IWorkerProcessHandler wphandler, IntPtr consoletoken)
            {
                this.clipboard        = clipboard;
                this.wmisession       = wmisession;
                this.exceptionhandler = exceptionhandler;
                this.wphandler        = wphandler;

                workerlock = new object();
                try
                {
                    comms = new CommServer(this);
                }
                catch (Exception e)
                {
                    wmisession.Log("Comms server failed to start:" + e.ToString());
                    throw;
                }
                try
                {
                    AddToXDIgnoreApplicationList();
                    string path     = (string)Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Citrix\\XenTools", "Install_Dir", "");
                    string fullpath = string.Format("{0}\\" + Branding.Instance.getString("FILENAME_dpriv"), path);
                    string cmdline  = string.Format(Branding.Instance.getString("FILENAME_dpriv") + " {0}", comms.secret);
                    this.worker            = new SafeWaitHandle(Win32Impl.CreateUserProcess(consoletoken, fullpath, cmdline), true);
                    workerWaiter           = new ProcessWaitHandle(this.worker);
                    registeredWorkerWaiter = ThreadPool.RegisterWaitForSingleObject(workerWaiter, handleWorker, null, Timeout.Infinite, true);
                    this.workerrunning     = true;
                    wmisession.Log("Worker Process spawned");
                }
                catch (Exception e)
                {
                    wmisession.Log("Worker process spawn exception : " + e.ToString());
                    comms.CloseMessagePipes();

                    throw;
                }
            }
            public WorkerProcess(ClipboardAccess clipboard, WmiSession wmisession, IExceptionHandler exceptionhandler, IWorkerProcessHandler wphandler, IntPtr consoletoken)
            {
                this.clipboard = clipboard;
                this.wmisession = wmisession;
                this.exceptionhandler = exceptionhandler;
                this.wphandler = wphandler;

                workerlock = new object();
                try
                {
                    comms = new CommServer(this);
                }
                catch (Exception e)
                {
                    wmisession.Log("Comms server failed to start:" + e.ToString());
                    throw;
                }
                try
                {
                    string path = (string)Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Citrix\\XenTools", "Install_Dir", "");
                    string fullpath = string.Format("{0}\\XenDpriv.exe", path);
                    string cmdline = string.Format("XenDpriv.exe {0}", comms.secret);
                    this.worker = new SafeWaitHandle(Win32Impl.CreateUserProcess(consoletoken, fullpath, cmdline), true);
                    workerWaiter = new ProcessWaitHandle(this.worker);
                    registeredWorkerWaiter = ThreadPool.RegisterWaitForSingleObject(workerWaiter, handleWorker, null, Timeout.Infinite, true);
                    this.workerrunning = true;
                    wmisession.Log("Worker Process spawned");
                }
                catch(Exception e)
                {
                    wmisession.Log("Worker process spawn exception : " + e.ToString());
                    comms.CloseMessagePipes();

                    throw;
                }
            }