Example #1
0
 private static int DumpNextBytecodes(StreamWriter writer, UnBytecodeOwner function, byte[] bytes, int startOffset, int nextBytecodes)
 {
     using (var stream = new MemoryStream(bytes))
     {
         stream.Position = startOffset;
         using (var reader = new BinaryReader(stream))
         {
             var bytecodeReader = new BytecodeReader(function.Package, reader);
             for (int i = 0; i < nextBytecodes; i++)
             {
                 try
                 {
                     var bytecodeToken = bytecodeReader.ReadNext();
                     writer.WriteLine("      " + bytecodeToken);
                 }
                 catch (Exception)
                 {
                     writer.WriteLine("      error reading next bytecode");
                     break;
                 }
             }
             return((int)reader.BaseStream.Position);
         }
     }
 }
Example #2
0
 public static void RegisterUnknownBytecode(byte b, UnBytecodeOwner function, byte[] subsequentBytes)
 {
     if (subsequentBytes.Length < 4) return;   // most likely bogus bytes after 'return'
     List<UnknownBytecodeOccurrence> occurrences;
     if (!_unknownBytecodes.TryGetValue(b, out occurrences))
     {
         occurrences = new List<UnknownBytecodeOccurrence>();
         _unknownBytecodes [b] = occurrences;
     }
     occurrences.Add(new UnknownBytecodeOccurrence(function, subsequentBytes));
 }
Example #3
0
 private static void DumpNextName(StreamWriter writer, UnBytecodeOwner function, byte[] bytes, int startOffset)
 {
     using (var stream = new MemoryStream(bytes))
     {
         stream.Position = startOffset;
         using (var reader = new BinaryReader(stream))
         {
             var name = function.Package.Names[reader.ReadInt32()].Name;
             writer.WriteLine("      " + name);
         }
     }
 }
Example #4
0
        private static void WriteFunctionName(StreamWriter writer, UnBytecodeOwner function)
        {
            UnExport parent = function.Export.Parent;

            if (parent != null)
            {
                if (parent.ClassName == "State")
                {
                    writer.Write(parent.Parent.ObjectName + ".");
                }
                writer.Write(parent.ObjectName + ".");
            }
            writer.WriteLine(function.Export.ObjectName);
        }
Example #5
0
        public static void RegisterUnknownBytecode(byte b, UnBytecodeOwner function, byte[] subsequentBytes)
        {
            if (subsequentBytes.Length < 4)
            {
                return;                               // most likely bogus bytes after 'return'
            }
            List <UnknownBytecodeOccurrence> occurrences;

            if (!_unknownBytecodes.TryGetValue(b, out occurrences))
            {
                occurrences           = new List <UnknownBytecodeOccurrence>();
                _unknownBytecodes [b] = occurrences;
            }
            occurrences.Add(new UnknownBytecodeOccurrence(function, subsequentBytes));
        }
Example #6
0
 private static int DumpNextBytecodes(StreamWriter writer, UnBytecodeOwner function, byte[] bytes, int startOffset, int nextBytecodes)
 {
     using (var stream = new MemoryStream(bytes))
     {
         stream.Position = startOffset;
         using (var reader = new BinaryReader(stream))
         {
             var bytecodeReader = new BytecodeReader(function.Package, reader);
             for (int i = 0; i < nextBytecodes; i++ )
             {
                 try
                 {
                     var bytecodeToken = bytecodeReader.ReadNext();
                     writer.WriteLine("      " + bytecodeToken);
                 }
                 catch (Exception)
                 {
                     writer.WriteLine("      error reading next bytecode");
                     break;
                 }
             }
             return (int) reader.BaseStream.Position;
         }
     }
 }
Example #7
0
 public static void RegisterIncompleteControlFlow(UnBytecodeOwner function)
 {
     _incompleteControlFlow.Add(function);
 }
Example #8
0
 public static void RegisterBytecodeError(UnBytecodeOwner function, string message)
 {
     _bytecodeErrors.Add(new BytecodeError(function, message));
 }
Example #9
0
 public UnknownBytecodeOccurrence(UnBytecodeOwner function, byte[] subsequentBytes)
 {
     Function = function;
     SubsequentBytes = subsequentBytes;
 }
Example #10
0
 public BytecodeError(UnBytecodeOwner function, string message)
 {
     Function = function;
     Message = message;
 }
Example #11
0
 private static void WriteFunctionName(StreamWriter writer, UnBytecodeOwner function)
 {
     UnExport parent = function.Export.Parent;
     if (parent != null)
     {
         if (parent.ClassName == "State")
         {
             writer.Write(parent.Parent.ObjectName + ".");
         }
         writer.Write(parent.ObjectName + ".");
     }
     writer.WriteLine(function.Export.ObjectName);
 }
Example #12
0
 private static void DumpNextName(StreamWriter writer, UnBytecodeOwner function, byte[] bytes, int startOffset)
 {
     using (var stream = new MemoryStream(bytes))
     {
         stream.Position = startOffset;
         using (var reader = new BinaryReader(stream))
         {
             var name = function.Package.Names[reader.ReadInt32()].Name;
             writer.WriteLine("      " + name);
         }
     }
 }
Example #13
0
 public static void RegisterIncompleteControlFlow(UnBytecodeOwner function)
 {
     _incompleteControlFlow.Add(function);
 }
Example #14
0
 public static void RegisterBytecodeError(UnBytecodeOwner function, string message)
 {
     _bytecodeErrors.Add(new BytecodeError(function, message));
 }
Example #15
0
 public BytecodeError(UnBytecodeOwner function, string message)
 {
     Function = function;
     Message  = message;
 }
Example #16
0
 public UnknownBytecodeOccurrence(UnBytecodeOwner function, byte[] subsequentBytes)
 {
     Function        = function;
     SubsequentBytes = subsequentBytes;
 }