public SequencePointIterator(RawWriter w, MainForm parent, int[] seqIlOffsets, string[] seqPaths, int[] seqStartLines, int[] seqStartColumns, int[] seqEndLines, int[] seqEndColumns) { m_writer = w; m_parent = parent; m_seqIlOffsets = seqIlOffsets; m_seqPaths = seqPaths; m_seqStartLines = seqStartLines; m_seqStartColumns = seqStartColumns; m_seqEndLines = seqEndLines; m_seqEndColumns = seqEndColumns; Debug.Assert(m_seqCount == 0); if (m_seqIlOffsets != null) { m_seqCount = m_seqIlOffsets.Length; // All arrays should be same length. Debug.Assert(seqIlOffsets.Length == m_seqCount); Debug.Assert(seqPaths.Length == m_seqCount); Debug.Assert(seqStartLines.Length == m_seqCount); Debug.Assert(seqStartColumns.Length == m_seqCount); Debug.Assert(seqEndLines.Length == m_seqCount); Debug.Assert(seqEndColumns.Length == m_seqCount); } }
public Il2NativeIterator(RawWriter w, IL2NativeMap[] il2nativeMapping, byte[] code) { m_writer = w; m_il2nativeMapping = il2nativeMapping; if (m_il2nativeMapping == null) { // No native info, so don't display it. Put range just out of reach. m_il2NativeEndIl = (code.Length + 1); return; } m_CodeLength = code.Length; SortMapByIL(m_il2nativeMapping); // Skip past initial entries for prolog, epilogue, unmapped, etc. // Since we sorted by IL, all of those entries (which get negative IL offsets) will come first. while ((m_il2NativeCursor < m_il2nativeMapping.Length) && (m_il2nativeMapping[m_il2NativeCursor].IlOffset < 0)) { m_il2NativeCursor++; } CalculateNextEndOffset(); }
public TestSuite(List <ISerializer <Catalog> > serializers, Logger logger, RawWriter rawWriter, bool gzipEnabled) { this.serializers = serializers; Logger = logger; RawWriter = rawWriter; GzipEnabled = gzipEnabled; }
public static PixelColor[] DecodeTextureData(byte[] data, int width, int height, TextureFormat format, bool bottomToTop = false, bool rightToLeft = false) { var result = new PixelColor[width * height]; PipelineWriter writer = new RawWriter(result, width, height, bottomToTop, rightToLeft); DecodeTextureDataToWriter(data, width, height, format, writer); return result; }
public static void export(Arg args) { string @string = args.GetString(0, "none"); string text = Path.Combine(Application.persistentDataPath, @string + ".raw"); switch (@string) { case "splatmap": if ((bool)TerrainMeta.SplatMap) { RawWriter.Write(TerrainMeta.SplatMap.ToEnumerable(), text); } break; case "heightmap": if ((bool)TerrainMeta.HeightMap) { RawWriter.Write(TerrainMeta.HeightMap.ToEnumerable(), text); } break; case "biomemap": if ((bool)TerrainMeta.BiomeMap) { RawWriter.Write(TerrainMeta.BiomeMap.ToEnumerable(), text); } break; case "topologymap": if ((bool)TerrainMeta.TopologyMap) { RawWriter.Write(TerrainMeta.TopologyMap.ToEnumerable(), text); } break; case "alphamap": if ((bool)TerrainMeta.AlphaMap) { RawWriter.Write(TerrainMeta.AlphaMap.ToEnumerable(), text); } break; case "watermap": if ((bool)TerrainMeta.WaterMap) { RawWriter.Write(TerrainMeta.WaterMap.ToEnumerable(), text); } break; default: args.ReplyWith("Unknown export source: " + @string); return; } args.ReplyWith("Export written to " + text); }
public static void export(ConsoleSystem.Arg args) { string str = args.GetString(0, "none"); string path = Path.Combine(Application.get_persistentDataPath(), str + ".raw"); if (!(str == "splatmap")) { if (!(str == "heightmap")) { if (!(str == "biomemap")) { if (!(str == "topologymap")) { if (!(str == "alphamap")) { if (str == "watermap") { if (Object.op_Implicit((Object)TerrainMeta.WaterMap)) { RawWriter.Write(TerrainMeta.WaterMap.ToEnumerable(), path); } } else { args.ReplyWith("Unknown export source: " + str); return; } } else if (Object.op_Implicit((Object)TerrainMeta.AlphaMap)) { RawWriter.Write(TerrainMeta.AlphaMap.ToEnumerable(), path); } } else if (Object.op_Implicit((Object)TerrainMeta.TopologyMap)) { RawWriter.Write(TerrainMeta.TopologyMap.ToEnumerable(), path); } } else if (Object.op_Implicit((Object)TerrainMeta.BiomeMap)) { RawWriter.Write(TerrainMeta.BiomeMap.ToEnumerable(), path); } } else if (Object.op_Implicit((Object)TerrainMeta.HeightMap)) { RawWriter.Write(TerrainMeta.HeightMap.ToEnumerable(), path); } } else if (Object.op_Implicit((Object)TerrainMeta.SplatMap)) { RawWriter.Write(TerrainMeta.SplatMap.ToEnumerable(), path); } args.ReplyWith("Export written to " + path); }
public static void export(ConsoleSystem.Arg args) { string str = args.GetString(0, "none"); string str1 = Path.Combine(Application.persistentDataPath, string.Concat(str, ".raw")); if (str == "splatmap") { if (TerrainMeta.SplatMap) { RawWriter.Write(TerrainMeta.SplatMap.ToEnumerable(), str1); } } else if (str == "heightmap") { if (TerrainMeta.HeightMap) { RawWriter.Write(TerrainMeta.HeightMap.ToEnumerable(), str1); } } else if (str == "biomemap") { if (TerrainMeta.BiomeMap) { RawWriter.Write(TerrainMeta.BiomeMap.ToEnumerable(), str1); } } else if (str == "topologymap") { if (TerrainMeta.TopologyMap) { RawWriter.Write(TerrainMeta.TopologyMap.ToEnumerable(), str1); } } else if (str != "alphamap") { if (str != "watermap") { args.ReplyWith(string.Concat("Unknown export source: ", str)); return; } if (TerrainMeta.WaterMap) { RawWriter.Write(TerrainMeta.WaterMap.ToEnumerable(), str1); } } else if (TerrainMeta.AlphaMap) { RawWriter.Write(TerrainMeta.AlphaMap.ToEnumerable(), str1); } args.ReplyWith(string.Concat("Export written to ", str1)); }
/// <summary> /// 构建 /// </summary> public IBufferWriter Build() { Writer.WriteLine($"! 0 200 200 {Height} 1"); Writer.WriteLine($"PAGE-WIDTH {Width}"); BuildText(Width, Height); BuildLine(Width, Height); BuildBox(Width, Height); BuildBarcode(Width, Height); BuildQrCode(Width, Height); BuildBitmap(Width, Height); Writer.Write(RawWriter.GetBytes()); Writer.WriteLine("PRINT"); return(Writer); }
public SequencePointIterator(RawWriter w,MainForm parent, int[] seqIlOffsets, string[] seqPaths, int[] seqStartLines, int[] seqStartColumns, int[] seqEndLines, int [] seqEndColumns) { m_writer = w; m_parent = parent; this.m_seqIlOffsets = seqIlOffsets; this.m_seqPaths = seqPaths; this.m_seqStartLines = seqStartLines; this.m_seqStartColumns = seqStartColumns; this.m_seqEndLines = seqEndLines; this.m_seqEndColumns = seqEndColumns; Debug.Assert(m_seqCount == 0); if (m_seqIlOffsets != null) { m_seqCount = m_seqIlOffsets.Length; // All arrays should be same length. Debug.Assert(seqIlOffsets.Length == m_seqCount); Debug.Assert(seqPaths.Length == m_seqCount); Debug.Assert(seqStartLines.Length == m_seqCount); Debug.Assert(seqStartColumns.Length == m_seqCount); Debug.Assert(seqEndLines.Length == m_seqCount); Debug.Assert(seqEndColumns.Length == m_seqCount); } }
// parent - main containing window that this source window lives inside of. // function - function for which we're building virtual source around. // Get the IL from the given frame. // Called on UI thread. internal VirtualSourceViewerForm(MainForm parent, MDbgFunction function) { m_function = function; Debug.Assert(function != null); // Now actually right in text. do this first so that we can get the current font. BeginInit(parent); // Get fonts FontCache cache; { Font fontCurrent = this.richText.Font; Font emphasis = new Font( fontCurrent.FontFamily, fontCurrent.Size, FontStyle.Bold ); cache = new FontCache(emphasis); } // Underlying writer to the window. RawWriter rawWriter = new RawWriter(cache); // Il2Native mapping can be used to find out what IL offsets we can actually stop on. Il2NativeIterator il2nativeIterator = null; // Actual IL disassembly in string form. ILDasmIterator ilDasm = null; // Iterator through sequence points and source files. SequencePointIterator seqIterator = null; string fullName = "?"; int token = 0; ulong nativeStartAddress = 0; CorDebugJITCompilerFlags codeFlags = CorDebugJITCompilerFlags.CORDEBUG_JIT_DEFAULT; // Make cross-thread call to worker thread to collect raw information. // This needs to access MDbg and so can't be done on our UI thread. parent.ExecuteOnWorkerThreadIfStoppedAndBlock(delegate(MDbgProcess proc) { Debug.Assert(proc != null); Debug.Assert(!proc.IsRunning); Debug.Assert(function.Module.Process == proc); // Get some properties about this function to display. token = function.CorFunction.Token; nativeStartAddress = function.CorFunction.NativeCode.Address; codeFlags = function.CorFunction.NativeCode.CompilerFlags; CorCode ilCode = function.CorFunction.ILCode; Debug.Assert(true == ilCode.IsIL); byte[] code = ilCode.GetCode(); fullName = function.FullName; // This does the real disassembly work. string[] lines = null; // strings of IL. ILDisassembler.Disassemble(code, function.Module.Importer, out lines, out m_il2RowMapping); ilDasm = new ILDasmIterator(rawWriter, m_il2RowMapping, lines); IL2NativeMap[] il2nativeMapping = function.CorFunction.NativeCode.GetILToNativeMapping(); il2nativeIterator = new Il2NativeIterator(rawWriter, il2nativeMapping, code); // Get sequence points ISymbolMethod symMethod = function.SymMethod; // Sequence point information int[] seqIlOffsets = null; string[] seqPaths = null; int[] seqStartLines = null, seqEndLines = null, seqStartColumns = null, seqEndColumns = null; int seqCount = 0; if (symMethod != null) { seqCount = symMethod.SequencePointCount; seqIlOffsets = new int[seqCount]; ISymbolDocument[] seqDocuments = new ISymbolDocument[seqCount]; seqPaths = new string[seqCount]; seqStartLines = new int[seqCount]; seqEndLines = new int[seqCount]; seqStartColumns = new int[seqCount]; seqEndColumns = new int[seqCount]; symMethod.GetSequencePoints(seqIlOffsets, seqDocuments, seqStartLines, seqStartColumns, seqEndLines, seqEndColumns); for (int i = 0; i < seqCount; i++) { seqPaths[i] = seqDocuments[i].URL; } } seqIterator = new SequencePointIterator(rawWriter, parent, seqIlOffsets, seqPaths, seqStartLines, seqStartColumns, seqEndLines, seqEndColumns); } ); // end worker call // We assume sequence points are sorted by IL offset. We assert that in the iterators below. // Now we need to go through and stitch the IL + Source together. // This also works even if we have no source (since that's just the degenerate case of 0 sequence points) // Print out header information Debug.Assert(token != 0); rawWriter.WriteLine(String.Format(CultureInfo.InvariantCulture, "> Function name:{0} (token={1:x})", fullName, token)); rawWriter.WriteLine(String.Format(CultureInfo.InvariantCulture, "> Native Code Address =0x{0:x}, flags={1}", nativeStartAddress, codeFlags)); // Walk through the IL in order and write out interleaved IL and Sequence Points. while (!seqIterator.IsDone) { // Add IL snippets that occur before this sequence point. WriteIlAndNative(ilDasm, il2nativeIterator, seqIterator.IlOffset); seqIterator.WriteSource(); seqIterator.Next(); } // Write the IL that's after the last sequence point WriteIlAndNative(ilDasm, il2nativeIterator, ilDasm.IlLength); // Set the text. InitLines(null, rawWriter.Lines, rawWriter.FormatList); EndInit(fullName); }
// Iterator to loop through all IL and write it out to the supplied RawWriter. // It will also adjust the il2RowMapping as it goes. public ILDasmIterator(RawWriter w, int[] il2RowMapping, string [] ilDissembly) { m_writer = w; m_il2RowMapping = il2RowMapping; m_lines = ilDissembly; }
// This will sort the map in-place. public Il2NativeIterator(RawWriter w, IL2NativeMap[] il2nativeMapping, byte[] code) { m_writer = w; m_il2nativeMapping = il2nativeMapping; if (m_il2nativeMapping == null) { // No native info, so don't display it. Put range just out of reach. m_il2NativeEndIl = (code.Length + 1); return; } m_CodeLength = code.Length; SortMapByIL(m_il2nativeMapping); // Skip past initial entries for prolog, epilogue, unmapped, etc. // Since we sorted by IL, all of those entries (which get negative IL offsets) will come first. while ((m_il2NativeCursor < m_il2nativeMapping.Length) && (m_il2nativeMapping[m_il2NativeCursor].IlOffset < 0)) { m_il2NativeCursor++; } CalculateNextEndOffset(); }
private static void ConvertFile(string fileName) { List <string> lines = File.ReadAllLines(fileName).ToList(); StripBlankLines(ref lines); string type = lines[0].TrimStart('[').TrimEnd(']'); string data = MergeLines(ref lines); RawData rawFile = null; try { switch (type) { case "UNITDATA": rawFile = UnitDataConverter.GetData(data); break; case "SKILLS": rawFile = SkillDataConverter.GetData(data); break; case "AFFIXES": rawFile = AffixDataConverter.GetData(data); break; case "MISSILES": rawFile = MissileDataConverter.GetData(data); break; case "ROOMPIECES": rawFile = RoomPieceDataConverter.GetData(data); break; case "TRIGGERABLES": rawFile = TriggerableDataConverter.GetData(data); break; case "USERINTERFACES": rawFile = UserInterfaceDataConverter.GetData(data); break; default: throw new TxtConverterException("Invalid format of " + type); } } catch (TxtConverterException e) { Console.WriteLine(e.Message); return; } string outputPath = _outputDir != "" ? _outputDir : Path.GetDirectoryName(fileName); RawWriter writer = new RawWriter(rawFile); writer.Write(outputPath, Path.GetFileNameWithoutExtension(fileName)); Console.WriteLine("Converted {0} into binary format", Path.GetFileName(fileName)); }
private int m_lastRow = -1; // unique value public ILDasmIterator(RawWriter w, int[] il2RowMapping, string[] ilDissembly) { m_writer = w; m_il2RowMapping = il2RowMapping; m_lines = ilDissembly; }
internal VirtualSourceViewerForm(MainForm parent, MDbgFunction function) { m_function = function; Debug.Assert(function != null); // Now actually right in text. do this first so that we can get the current font. BeginInit(parent); // Get fonts FontCache cache; { Font fontCurrent = richText.Font; var emphasis = new Font( fontCurrent.FontFamily, fontCurrent.Size, FontStyle.Bold ); cache = new FontCache(emphasis); } // Underlying writer to the window. var rawWriter = new RawWriter(cache); // Il2Native mapping can be used to find out what IL offsets we can actually stop on. Il2NativeIterator il2nativeIterator = null; // Actual IL disassembly in string form. ILDasmIterator ilDasm = null; // Iterator through sequence points and source files. SequencePointIterator seqIterator = null; string fullName = "?"; int token = 0; ulong nativeStartAddress = 0; CorDebugJITCompilerFlags codeFlags = CorDebugJITCompilerFlags.CORDEBUG_JIT_DEFAULT; // Make cross-thread call to worker thread to collect raw information. // This needs to access MDbg and so can't be done on our UI thread. parent.ExecuteOnWorkerThreadIfStoppedAndBlock(delegate(MDbgProcess proc) { Debug.Assert(proc != null); Debug.Assert(!proc.IsRunning); Debug.Assert(function.Module.Process == proc); // Get some properties about this function to display. token = function.CorFunction.Token; nativeStartAddress = function.CorFunction.NativeCode.Address; codeFlags = function.CorFunction.NativeCode.CompilerFlags; CorCode ilCode = function.CorFunction.ILCode; Debug.Assert(ilCode.IsIL); byte[] code = ilCode.GetCode(); fullName = function.FullName; // This does the real disassembly work. string[] lines = null; // strings of IL. ILDisassembler.Disassemble(code, function.Module.Importer, out lines, out m_il2RowMapping); ilDasm = new ILDasmIterator(rawWriter, m_il2RowMapping, lines); IL2NativeMap[] il2nativeMapping = function.CorFunction.NativeCode. GetILToNativeMapping(); il2nativeIterator = new Il2NativeIterator(rawWriter, il2nativeMapping, code); // Get sequence points ISymbolMethod symMethod = function.SymMethod; // Sequence point information int[] seqIlOffsets = null; string[] seqPaths = null; int[] seqStartLines = null, seqEndLines = null, seqStartColumns = null, seqEndColumns = null; int seqCount = 0; if (symMethod != null) { seqCount = symMethod.SequencePointCount; seqIlOffsets = new int[seqCount]; var seqDocuments = new ISymbolDocument[seqCount]; seqPaths = new string[seqCount]; seqStartLines = new int[seqCount]; seqEndLines = new int[seqCount]; seqStartColumns = new int[seqCount]; seqEndColumns = new int[seqCount]; symMethod.GetSequencePoints(seqIlOffsets, seqDocuments, seqStartLines, seqStartColumns, seqEndLines, seqEndColumns); for (int i = 0; i < seqCount; i++) { seqPaths[i] = seqDocuments[i].URL; } } seqIterator = new SequencePointIterator(rawWriter, parent, seqIlOffsets, seqPaths, seqStartLines, seqStartColumns, seqEndLines, seqEndColumns); } ); // end worker call // We assume sequence points are sorted by IL offset. We assert that in the iterators below. // Now we need to go through and stitch the IL + Source together. // This also works even if we have no source (since that's just the degenerate case of 0 sequence points) // Print out header information Debug.Assert(token != 0); rawWriter.WriteLine(String.Format(CultureInfo.InvariantCulture, "> Function name:{0} (token={1:x})", fullName, token)); rawWriter.WriteLine(String.Format(CultureInfo.InvariantCulture, "> Native Code Address =0x{0:x}, flags={1}", nativeStartAddress, codeFlags)); // Walk through the IL in order and write out interleaved IL and Sequence Points. while (!seqIterator.IsDone) { // Add IL snippets that occur before this sequence point. WriteIlAndNative(ilDasm, il2nativeIterator, seqIterator.IlOffset); seqIterator.WriteSource(); seqIterator.Next(); } // Write the IL that's after the last sequence point WriteIlAndNative(ilDasm, il2nativeIterator, ilDasm.IlLength); // Set the text. InitLines(null, rawWriter.Lines, rawWriter.FormatList); EndInit(fullName); }
public TestSuite(List <ISerializer <Catalog> > serializers, Logger logger, RawWriter rawWriter) : this(serializers, logger, rawWriter, true) { }