Пример #1
0
        protected int TrackerExecuteTool(string pathToTool, string responseFileCommands, string commandLineCommands)
        {
            string dllName               = (string)null;
            string str1                  = (string)null;
            bool   trackFileAccess       = this.TrackFileAccess;
            string str2                  = Environment.ExpandEnvironmentVariables(pathToTool);
            string responseFileCommands1 = responseFileCommands;
            string arguments             = Environment.ExpandEnvironmentVariables(commandLineCommands);

            try
            {
                this.pathToLog = str2;
                string pathToTool1;
                if (trackFileAccess)
                {
                    ExecutableType result = ExecutableType.SameAsCurrentProcess;
                    if (!string.IsNullOrEmpty(this.ToolArchitecture))
                    {
                        if (!Enum.TryParse <ExecutableType>(this.ToolArchitecture, out result))
                        {
                            this.Log.LogErrorWithCodeFromResources("General.InvalidValue", (object)"ToolArchitecture", (object)this.GetType().Name);
                            return(-1);
                        }
                    }
                    else
                    {
                        ExecutableType?toolType = this.ToolType;
                        if (toolType.HasValue)
                        {
                            toolType = this.ToolType;
                            result   = toolType.Value;
                        }
                    }
                    bool is64bit;
                    if ((result == ExecutableType.Native32Bit || result == ExecutableType.Native64Bit) && NativeMethodsShared.Is64bitApplication(str2, out is64bit))
                    {
                        result = is64bit ? ExecutableType.Native64Bit : ExecutableType.Native32Bit;
                    }
                    try
                    {
                        pathToTool1 = FileTracker.GetTrackerPath(result, this.TrackerSdkPath);
                        if (pathToTool1 == null)
                        {
                            this.Log.LogErrorFromResources("Error.MissingFile", (object)"tracker.exe");
                        }
                    }
                    catch (Exception ex)
                    {
                        if (ExceptionHandling.NotExpectedException(ex))
                        {
                            throw;
                        }
                        else
                        {
                            this.Log.LogErrorWithCodeFromResources("General.InvalidValue", (object)"TrackerSdkPath", (object)this.GetType().Name);
                            return(-1);
                        }
                    }
                    try
                    {
                        dllName = FileTracker.GetFileTrackerPath(result, this.TrackerFrameworkPath);
                    }
                    catch (Exception ex)
                    {
                        if (ExceptionHandling.NotExpectedException(ex))
                        {
                            throw;
                        }
                        else
                        {
                            this.Log.LogErrorWithCodeFromResources("General.InvalidValue", (object)"TrackerFrameworkPath", (object)this.GetType().Name);
                            return(-1);
                        }
                    }
                }
                else
                {
                    pathToTool1 = str2;
                }
                if (string.IsNullOrEmpty(pathToTool1))
                {
                    return(-1);
                }
                ErrorUtilities.VerifyThrowInternalRooted(pathToTool1);
                string commandLineCommands1;
                if (trackFileAccess)
                {
                    string str3 = FileTracker.TrackerArguments(str2, arguments, dllName, this.TrackerIntermediateDirectory, this.RootSource, this.CancelEventName);
                    this.Log.LogMessageFromResources(MessageImportance.Low, "Native_TrackingCommandMessage", new object[0]);
                    this.Log.LogMessage(MessageImportance.Low, pathToTool1 + (this.AttributeFileTracking ? " /a " : " ") + str3 + " " + responseFileCommands1, new object[0]);
                    str1 = FileUtilities.GetTemporaryFile();
                    using (StreamWriter streamWriter = new StreamWriter(str1, false, Encoding.Unicode))
                        streamWriter.Write(FileTracker.TrackerResponseFileArguments(dllName, this.TrackerIntermediateDirectory, this.RootSource, this.CancelEventName));
                    commandLineCommands1 = (this.AttributeFileTracking ? "/a @\"" : "@\"") + str1 + "\"" + FileTracker.TrackerCommandArguments(str2, arguments);
                }
                else
                {
                    commandLineCommands1 = arguments;
                }
                return(base.ExecuteTool(pathToTool1, responseFileCommands1, commandLineCommands1));
            }
            finally
            {
                if (str1 != null)
                {
                    this.DeleteTempFile(str1);
                }
            }
        }