Example #1
0
	  public LFunction(BHeader header, int[] code, LLocal[] locals, LObject[] constants, LUpvalue[] upvalues, LFunction[] functions, int maximumStackSize, int numUpValues, int numParams, int vararg)
	  {
		this.header = header;
		this.code = code;
		this.locals = locals;
		this.constants = constants;
		this.upvalues = upvalues;
		this.functions = functions;
		this.maximumStackSize = maximumStackSize;
		this.numUpvalues = numUpValues;
		this.numParams = numParams;
		this.vararg = vararg;
	  }
Example #2
0
 public ForBlock(LFunction function, int begin, int end, int register, Registers r) : base(function, begin, end)
 {
     this.register = register;
     this.r        = r;
     statements    = new List <Statement>(end - begin + 1);
 }
Example #3
0
 public Code(LFunction function)
 {
     code = function.Code;
     map  = function.Header.Version.GetOpcodeMap();
 }
 public BooleanIndicator(LFunction function, int line) : base(function, line, line)
 {
 }
Example #5
0
 public ClosureExpression(LFunction function, int upvalueLine) : base(Precedence.ATOMIC)
 {
     _function    = function;
     _upvalueLine = upvalueLine;
 }
Example #6
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                PrintVersion(true);
                PrintError("no input file provided");
                PrintUsage(true);

                Environment.Exit(1);
            }
            else
            {
                var       fn    = args[0];
                LFunction lMain = null;

                //Console.BufferHeight = 2500;

                /* Error Levels
                 *
                 * 0 - Successfully decompiled file
                 * 1 - An error occurred while processing the input file
                 * 2 - The specified output file could not be created
                 */

                try
                {
                    lMain = FileToFunction(fn);
                }
                catch (Exception e)
                {
                    PrintVersion(true);
                    PrintError(e.Message);

                    Environment.Exit(1);
                }

                var d = new Decompiler(lMain);

                d.Decompile();

                var writeLog = true;

                if (args.Length > 1)
                {
                    // skip first arg
                    for (int i = 1; i < args.Length; i++)
                    {
                        var arg = args[i];

                        if (arg.StartsWith("-"))
                        {
                            switch (arg.ToLower().TrimStart('-'))
                            {
                            case "nolog":
                                writeLog = false;
                                continue;

                            default:
                                // just ignore it
                                if (writeLog)
                                {
                                    Console.WriteLine("unknown argument '{0}'", arg);
                                }
                                continue;
                            }
                        }
                        else
                        {
                            /** PROGRAM MUST TERMINATE ONCE FINISHED **/
                            var filename = arg;

                            try
                            {
                                using (var writer = new StreamWriter(filename, false, new UTF8Encoding(false)))
                                {
                                    d.Print(new Output(writer));

                                    writer.Flush();

                                    if (writeLog)
                                    {
                                        Console.WriteLine("successfully decompiled to '{0}'", filename);
                                    }

                                    Environment.Exit(0);
                                }
                            }
                            catch (Exception e)
                            {
                                PrintVersion(true);
                                PrintError(e.Message);

                                Environment.Exit(2);
                            }
                            /** PROGRAM MUST BE TERMINATED BY THIS POINT **/
                        }
                    }
                }

                // no output file was specified, spit out to console
                d.Print();

                if (System.Diagnostics.Debugger.IsAttached)
                {
                    Console.ReadKey();
                }

                Environment.Exit(0);
            }
        }
Example #7
0
 public Block(LFunction function, int begin, int end)
 {
     _function = function;
     Begin     = begin;
     End       = end;
 }
Example #8
0
	  public Break(LFunction function, int line, int target) : base(function, line, line)
	  {
		this.target = target;
	  }
Example #9
0
 public CompareBlock(LFunction function, int begin, int end, int target, Branch branch) : base(function, begin, end)
 {
     Target = target;
     Branch = branch;
 }
Example #10
0
 public ElseEndBlock(LFunction function, int begin, int end) : base(function, begin, end) => _statements = new List <Statement>(end - begin + 1);
Example #11
0
 public AlwaysLoop(LFunction function, int begin, int end) : base(function, begin, end) => _statements = new List <Statement>();
Example #12
0
 public OuterBlock(LFunction function, int length) : base(function, 0, length + 1)
 {
     statements = new List <Statement>(length);
 }
Example #13
0
 public Break(LFunction function, int line, int target) : base(function, line, line) => Target = target;
Example #14
0
 public Break(LFunction function, int line, int target) : base(function, line, line)
 {
     this.target = target;
 }
Example #15
0
 public ClosureExpression(LFunction function, int upvalueLine)
     : base(PRECEDENCE_ATOMIC)
 {
     this.m_function    = function;
     this.m_upvalueLine = upvalueLine;
 }
Example #16
0
	  public AlwaysLoop(LFunction function, int begin, int end) : base(function, begin, end)
	  {
		statements = new List<Statement>();
	  }
Example #17
0
 public IfThenEndBlock(LFunction function, Branch branch, Registers r) : this(function, branch, null, r)
 {
 }
Example #18
0
 public Code(LFunction function)
 {
     _code      = function.Code;
     _map       = function.Header.Version.GetOpcodeMap();
     _extractor = function.Header.Extractor;
 }