Exemplo n.º 1
0
        public static void RegisterBytecodeError(UnBytecodeOwner function, string message)
        {
            _bytecodeErrors.Add(new BytecodeError(function, message));
#if AZURE
            Assert.Fail($"There was a problem parsing ME1/ME2 bytecode! Issue was in {function.Export.FileRef.FilePath}, export {function.Export.UIndex} {function.Export.InstancedFullPath}");
#endif
        }
Exemplo n.º 2
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);
         }
     }
 }
Exemplo n.º 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.GetNameEntry(reader.ReadInt32());
             writer.WriteLine($"      {name}");
         }
     }
 }
Exemplo n.º 4
0
 public static void RegisterUnknownBytecode(byte b, UnBytecodeOwner function, byte[] subsequentBytes)
 {
     if (subsequentBytes.Length < 4)
     {
         return;                               // most likely bogus bytes after 'return'
     }
     if (!_unknownBytecodes.TryGetValue(b, out List <UnknownBytecodeOccurrence> occurrences))
     {
         occurrences          = new List <UnknownBytecodeOccurrence>();
         _unknownBytecodes[b] = occurrences;
     }
     occurrences.Add(new UnknownBytecodeOccurrence(function, subsequentBytes));
 }
Exemplo n.º 5
0
 private static void WriteFunctionName(StreamWriter writer, UnBytecodeOwner function)
 {
     if (function.Export.SuperClass is IEntry parent)
     {
         if (parent.ClassName == "State")
         {
             writer.Write("!!!STATE PARENT -- FIX ME IN CODE!!!.");
             //writer.Write(parent.Parent.ObjectName + ".");
         }
         writer.Write($"{parent.ObjectName.Instanced}.");
     }
     writer.WriteLine(function.Export.ObjectName.Instanced);
 }
Exemplo n.º 6
0
 public static void RegisterIncompleteControlFlow(UnBytecodeOwner function)
 {
     _incompleteControlFlow.Add(function);
 }
Exemplo n.º 7
0
 public BytecodeError(UnBytecodeOwner function, string message)
 {
     Function = function;
     Message  = message;
 }
Exemplo n.º 8
0
 public UnknownBytecodeOccurrence(UnBytecodeOwner function, byte[] subsequentBytes)
 {
     Function        = function;
     SubsequentBytes = subsequentBytes;
 }