Exemplo n.º 1
0
        static void fixBranch(ILProcessor processor, MonoXIL.Collections.Generic.Collection <Instruction> instructions, Dictionary <Instruction, Instruction> originToNewTarget, HashSet <Instruction> noCheck)
        {
            foreach (var instruction in instructions)
            {
                Instruction target = instruction.Operand as Instruction;
                if (target != null && !noCheck.Contains(instruction))
                {
                    if (originToNewTarget.ContainsKey(target))
                    {
                        instruction.Operand = originToNewTarget[target];
                    }
                }
            }
            for (int i = 0; i < instructions.Count; i++)
            {
                var         instruction = instructions[i];
                Instruction target      = instruction.Operand as Instruction;

                if (target != null)
                {
                    int diff = target.Offset - instruction.Offset;
                    if ((diff > sbyte.MaxValue || diff < sbyte.MinValue) && shortToLong.ContainsKey(instruction.OpCode))
                    {
                        instructions[i] = processor.Create(shortToLong[instruction.OpCode], target);
                    }
                }
            }
        }
Exemplo n.º 2
0
 public static void LogInfo(string key, MonoXIL.Collections.Generic.Collection <Instruction> Instructions)
 {
     System.Text.StringBuilder sb = new System.Text.StringBuilder();
     sb.AppendFormatLine("{0} Total:{1}", key, Instructions.Count);
     for (int i = 0; i < Instructions.Count; ++i)
     {
         sb.AppendFormatLine("{0}){1}", i, Instructions[i].ToString());
     }
     UnityEngine.Debug.Log(sb.ToString());
 }
Exemplo n.º 3
0
 public static void LogInfo(string key, MonoXIL.Collections.Generic.Collection <Instruction> Instructions)
 {
     System.Text.StringBuilder sb = new System.Text.StringBuilder();
     sb.AppendLine($"{key} Total:{Instructions.Count}");
     for (int i = 0; i < Instructions.Count; ++i)
     {
         sb.AppendLine($"{i}){Instructions[i].ToString()}");
     }
     UnityEngine.Debug.Log(sb.ToString());
 }
Exemplo n.º 4
0
        static Instruction findNextRet(MonoXIL.Collections.Generic.Collection <Instruction> instructions, Instruction pos)
        {
            bool posFound = false;

            for (int i = 0; i < instructions.Count; i++)
            {
                if (posFound && instructions[i].OpCode == OpCodes.Ret)
                {
                    return(instructions[i]);
                }
                else if (instructions[i] == pos)
                {
                    posFound = true;
                }
            }
            return(null);
        }