예제 #1
0
        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);
        }
예제 #2
0
        public static bool InvokeRunAsUser(string Filename, string Args, string Username, string Password, int SessionID, out DataHRunasUserResult ores, out Int64 W32Res)
        {
            ores   = null;
            W32Res = 0xe9;
            DataHRunasUserTODO d = new DataHRunasUserTODO();

            d.Filename = Filename;
            d.Args     = Args;
            d.Username = Username;
            d.Password = Password;

            Process2ProcessComm p2p = new Process2ProcessComm();

            p2p.SetTODO("RUNUSER", d);
            if (p2p.StartPipe() == false)
            {
                FoxEventLog.WriteEventLog("Cannot start P2PC for RUNUSER " + p2p.GetGUID(), EventLogEntryType.Error);
                return(false);
            }

            if (SessionID == 0)
            {
                try
                {
                    Process proc = new Process();
                    proc.StartInfo.FileName        = Assembly.GetExecutingAssembly().Location;
                    proc.StartInfo.Arguments       = "-pipeaction " + p2p.GetGUID();
                    proc.StartInfo.UseShellExecute = false;
                    proc.Start();
                    proc.WaitForExit();
                }
                catch (Win32Exception ee)
                {
                    W32Res = 0x00000000FFFFFFFF & ee.NativeErrorCode;
                    Debug.WriteLine(ee.ToString());
                    FoxEventLog.WriteEventLog("Cannot start P2PC for SYS RUNUSER " + p2p.GetGUID(), EventLogEntryType.Error);
                    return(false);
                }
                catch (Exception ee)
                {
                    W32Res = 0x8000ffff;
                    Debug.WriteLine(ee.ToString());
                    FoxEventLog.WriteEventLog("Cannot start P2PC for SYS RUNUSER " + p2p.GetGUID(), EventLogEntryType.Error);
                    return(false);
                }
            }
            else
            {
                if (ProgramAgent.CPP.StartAppAsUserWait(Assembly.GetExecutingAssembly().Location, "-pipeaction " + p2p.GetGUID(), SessionID) == false)
                {
                    W32Res = ProgramAgent.CPP.WGetLastError();
                    FoxEventLog.WriteEventLog("Cannot start P2PC Process for RUNUSER " + p2p.GetGUID() + " Error: 0x" + ProgramAgent.CPP.WGetLastError().ToString("X"), EventLogEntryType.Error);
                    p2p.ClosePipe();
                    return(false);
                }
            }

            ores = p2p.GetResult <DataHRunasUserResult>();
            p2p.ClosePipe();
            if (ores == null)
            {
                FoxEventLog.WriteEventLog("P2PC didn't return any data for RUNUSER " + p2p.GetGUID(), EventLogEntryType.Error);
                return(false);
            }

            return(true);
        }