public static void RunPipeClient() { Process2ProcessComm p2p = new Process2ProcessComm(); if (p2p.ConnectPipe(ProgramAgent.PipeGUID) == false) { FoxEventLog.VerboseWriteEventLog("Cannot connect to pipe " + ProgramAgent.PipeGUID, EventLogEntryType.Error); return; } string Action = p2p.GetAction(); if (Action == null) { FoxEventLog.VerboseWriteEventLog("Got no action data from pipe " + ProgramAgent.PipeGUID, EventLogEntryType.Error); return; } switch (Action.ToLower()) { case "install": { PackageInstaller inst = new PackageInstaller(); DataHInstallPackageTODO todo = p2p.GetTODO <DataHInstallPackageTODO>(); if (todo == null) { FoxEventLog.VerboseWriteEventLog("Got no todo data from pipe " + ProgramAgent.PipeGUID, EventLogEntryType.Error); return; } DataHInstallPackageResult result = new DataHInstallPackageResult(); result.Return = inst.InstallPackage(todo.Filename, todo.CerCertificates, todo.Mode, todo.ZipIsMetaOnly, out result.ErrorText, out result.res, out result.Reciept, todo.OtherDLL); if (inst.ScriptTempDLLFilename != null) { FoxEventLog.VerboseWriteEventLog("Script DLL file = " + inst.ScriptTempDLLFilename, EventLogEntryType.Information); } result.TempDLLFilename = inst.ScriptTempDLLFilename; p2p.SetResult(result); break; } case "runuser": { DataHRunasUserTODO todo = p2p.GetTODO <DataHRunasUserTODO>(); DataHRunasUserResult res = new DataHRunasUserResult(); try { Process p = new Process(); p.StartInfo.FileName = todo.Filename; p.StartInfo.Arguments = todo.Args; p.StartInfo.UserName = todo.Username; p.StartInfo.Password = Utilities.MakeSecString(todo.Password); p.StartInfo.UseShellExecute = false; p.Start(); } catch (Win32Exception ee) { FoxEventLog.VerboseWriteEventLog("RUNUSER: Cannot run " + todo.Filename + " as user " + todo.Username + ": " + ee.ToString(), EventLogEntryType.Warning); res.Result = 0x00000000FFFFFFFF & ee.NativeErrorCode; Debug.WriteLine(ee.ToString()); } catch (Exception ee) { FoxEventLog.VerboseWriteEventLog("RUNUSER: Cannot run " + todo.Filename + " as user " + todo.Username + ": " + ee.ToString(), EventLogEntryType.Warning); res.Result = 0x8000ffff; Debug.WriteLine(ee.ToString()); } p2p.SetResult(res); break; } case "conredir": { DataHRunConredir R = p2p.GetTODO <DataHRunConredir>(); MainSTDIORedir.RunPipeConsoleEnd(p2p, R); break; } default: FoxEventLog.VerboseWriteEventLog("Action " + Action + " from pipe " + ProgramAgent.PipeGUID + "?? häh???", EventLogEntryType.Warning); return; } }
public static bool InvokeInstallPackage(string Filename, List <byte[]> CerCertificates, InstallMode Mode, bool ZipIsMetaOnly, out string ErrorText, out PKGStatus res, out PKGRecieptData Reciept, string OtherDLL = "") { ErrorText = "Internal issues"; res = PKGStatus.Failed; Reciept = null; DataHInstallPackageTODO inst = new DataHInstallPackageTODO(); inst.Filename = Filename; inst.CerCertificates = CerCertificates; inst.Mode = Mode; inst.ZipIsMetaOnly = ZipIsMetaOnly; inst.OtherDLL = OtherDLL; Process2ProcessComm p2p = new Process2ProcessComm(); p2p.SetTODO("INSTALL", inst); if (p2p.StartPipe() == false) { FoxEventLog.WriteEventLog("Cannot start P2PC for INSTALL " + p2p.GetGUID(), EventLogEntryType.Error); return(false); } Process p = new Process(); p.StartInfo.Arguments = "-pipeaction " + p2p.GetGUID(); p.StartInfo.FileName = Assembly.GetExecutingAssembly().Location; p.StartInfo.UseShellExecute = false; if (p.Start() == false) { FoxEventLog.WriteEventLog("Cannot start P2PC Process for INSTALL " + p2p.GetGUID(), EventLogEntryType.Error); p2p.ClosePipe(); return(false); } p.WaitForExit(); DataHInstallPackageResult ores = p2p.GetResult <DataHInstallPackageResult>(); p2p.ClosePipe(); if (ores == null) { FoxEventLog.WriteEventLog("P2PC didn't return any data for INSTALL " + p2p.GetGUID(), EventLogEntryType.Error); return(false); } ErrorText = ores.ErrorText; res = ores.res; Reciept = ores.Reciept; if (ores.TempDLLFilename != null) { try { File.Delete(ores.TempDLLFilename); } catch { } } return(ores.Return); }