Ejemplo n.º 1
0
        public static string Analyze(FileInfo fInfo)
        {
            PawnFile file;

            try
            {
                file = PawnFile.FromFile(fInfo.FullName);
            }
            catch (Exception e)
            {
                return("Error while loading file." + Environment.NewLine + "Details: " + e.Message + Environment.NewLine + "Stacktrace: " + e.StackTrace);
            }
            StringBuilder outString = new StringBuilder();

            SourceBuilder source;

            try
            {
                source = new SourceBuilder(file, outString);
            }
            catch (Exception e) //I admit: i have no clue if this can happen, i was too lazy to look.
            {
                return("Error while building source." + Environment.NewLine + "Details: " + e.Message + Environment.NewLine + "Stacktrace: " + e.StackTrace);
            }
            try
            {
                source.writeGlobals();
            }
            catch (Exception e)
            {
                outString.AppendLine();
                outString.AppendLine("Error while write Globals");
                outString.AppendLine("Details: " + e.Message);
                outString.AppendLine("Stacktrace: " + e.StackTrace);
            }
            for (int i = 0; i < file.functions.Length; i++)
            {
                Function fun = file.functions[i];
                try
                {
                    DumpMethod((SourcePawnFile)file, source, fun.address);
                    outString.AppendLine();
                }
#if DEBUG
                catch (OpCodeNotKnownException e)
                {
                    outString.AppendLine();
                    outString.AppendLine("/* ERROR! " + e.Message + " */");
                    outString.AppendLine(" function \"" + fun.name + "\" (number " + i + ")");
                    source = new SourceBuilder((SourcePawnFile)file, outString);
                }
                catch (LogicChainConversionException e)
                {
                    outString.AppendLine();
                    outString.AppendLine("/* ERROR! " + e.Message + " */");
                    outString.AppendLine(" function \"" + fun.name + "\" (number " + i + ")");
                    source = new SourceBuilder((SourcePawnFile)file, outString);
                }
#else
                catch (Exception e)
                {
                    outString.AppendLine();
                    outString.AppendLine("/* ERROR! " + e.Message + " */");
                    outString.AppendLine(" function \"" + fun.name + "\" (number " + i + ")");
                    source = new SourceBuilder((SourcePawnFile)file, outString);
                }
#endif
            }
            string NoteString = @"/*" + Environment.NewLine + "** ATTENTION" + Environment.NewLine +
                                "** THE PRODUCED CODE, IS NOT ABLE TO COMPILE!" + Environment.NewLine +
                                "** THE DECOMPILER JUST TRIES TO GIVE YOU A POSSIBILITY" + Environment.NewLine +
                                "** TO LOOK HOW A PLUGIN DOES IT'S JOB AND LOOK FOR" + Environment.NewLine +
                                "** POSSIBLE MALICIOUS CODE." + Environment.NewLine + "**" + Environment.NewLine +
                                "** ALL CONVERSIONS ARE WRONG! AT EXAMPLE:" + Environment.NewLine +
                                "** SetEntityRenderFx(client, RenderFx 0);  →  SetEntityRenderFx(client, view_as<RenderFx>0);  →  SetEntityRenderFx(client, RENDERFX_NONE);" +
                                Environment.NewLine + "*/" + Environment.NewLine + Environment.NewLine;
            outString.Insert(0, NoteString);
            return(outString.ToString());
        }
Ejemplo n.º 2
0
 public SourceBuilder(PawnFile file, StringBuilder tw)
 {
     file_   = file;
     out_    = tw;
     indent_ = "";
 }
Ejemplo n.º 3
0
 public SourceBuilder(PawnFile file, StringBuilder tw)
 {
     file_ = file;
     out_ = tw;
     indent_ = "";
 }