public void CaseClosure() { int num5 = base.Edges().Count() - 1; for (int i = 0; i <= num5; i++) { NumberSet setB = new NumberSet(new int[0]); CharacterSet characters = base.Edges()[i].Characters; int num6 = characters.Count() - 1; for (int j = 0; j <= num6; j++) { int charCode = characters[j]; int num3 = UnicodeTable.ToLowerCase(charCode); if (charCode != num3) { setB.Add(new int[] { num3 }); } num3 = UnicodeTable.ToUpperCase(charCode); if (charCode != num3) { setB.Add(new int[] { num3 }); } } characters.UnionWith(setB); characters = null; } }
public unic ExpandUnicode(unic unicodeTagblock, UnicodeTable unicodeTable) { List<UnicodeTable.Entry> entries = new List<UnicodeTable.Entry>(); byte[] unicodeBytes = (unicodeTagblock.Values[1] as ByteArray).Data; TagBlockArray array =(unicodeTagblock.Values[0] as TagBlockArray); for (int i = 0; i < array.Length; i++) { int sId = BitConverter.ToInt32(array.TagBlocks[i].Data, 0); short offset = BitConverter.ToInt16(array.TagBlocks[i].Data, 4); List<byte> strBytes = new List<byte>(); int index = 0; while (true) { if (unicodeBytes[offset + index] == 0x00) break; strBytes.Add(unicodeBytes[offset + index]); index++; } string str = Encoding.UTF8.GetString(strBytes.ToArray()); entries.Add(new UnicodeTable.Entry() { StringReference = sId, Value = str, }); } int start = unicodeTable.Count; //unicodeTable.AddRange(entries); unic unic = new unic(); unic.Data = new byte[unic.Size]; MemoryStream ms = new MemoryStream(unic.Data); BinaryWriter bw = new BinaryWriter(ms); ms.Position = 16; bw.Write((short)start); bw.Write((short)entries.Count); return unic; }
public void MappingClosure(BuilderApp.CharMappingMode Mapping) { int num5 = base.Edges().Count() - 1; for (int i = 0; i <= num5; i++) { NumberSet setB = new NumberSet(new int[0]); CharacterSet characters = base.Edges()[i].Characters; int num6 = characters.Count() - 1; for (int j = 0; j <= num6; j++) { int charCode = characters[j]; int num3 = UnicodeTable.ToWin1252(charCode); if (charCode != num3) { setB.Add(new int[] { num3 }); } } characters.UnionWith(setB); characters = null; } }
public static unic CollapseUnicode(unic unicodeTagblock, UnicodeTable dataSource) { unic unic = new unic(true); TagBlockArray array = unic.Values[0] as TagBlockArray; unic.Data = new byte[16]; MemoryStream ms = new MemoryStream(unicodeTagblock.Data); BinaryReader reader = new BinaryReader(ms); ms.Position = 16; int offset = reader.ReadInt16(); int count = reader.ReadInt16(); TagBlock[] tagBlocks = new TagBlock[count]; TagBlockArray tagBlockArray = unic.Values[0] as TagBlockArray; for (int i = 0; i < count; i++) tagBlocks[i] = (TagBlock)Activator.CreateInstance(array.TagBlockType); List<byte> unicodeBytes = new List<byte>(); for (int i = 0; i < count; i++) { byte[] buffer = new byte[48]; MemoryStream blockStream = new MemoryStream(buffer); using (blockStream) { BinaryWriter bw = new BinaryWriter(blockStream); blockStream.Position = 0; bw.Write(dataSource[offset + i].StringReference); bw.Write(unicodeBytes.Count); } tagBlocks[i].Data = buffer; unicodeBytes.AddRange(Encoding.UTF8.GetBytes(dataSource[offset + i].Value)); unicodeBytes.Add((byte)0x00); } array.TagBlocks = tagBlocks; (unic.Values[1] as ByteArray).Length = unicodeBytes.Count; (unic.Values[1] as ByteArray).Data = unicodeBytes.ToArray(); return unic; }
/// <summary> /// The get offsets and sizes. /// </summary> /// <param name="scan">The scan.</param> /// <remarks></remarks> private void GetOffsetsAndSizes(bool scan) { ut = new UnicodeTable[9]; FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); for (int counter = 0; counter < 9; counter++) { br.BaseStream.Position = matgOffset + 400 + 28 * counter; ut[counter] = new UnicodeTable( false, counter, br.ReadInt32(), br.ReadInt32(), (int)br.BaseStream.Position - matgOffset, br.ReadInt32(), (int)br.BaseStream.Position - matgOffset, br.ReadInt32(), filePath); } br.Close(); fs.Close(); }
public void DecompileUnic(Index.TagInformation tag, string filename, int magic, UnicodeTable unicodeTable) { ResetBuffers(); binReader = new BinaryReader(map.BaseStream); binWriter = new BinaryWriter(bufferStream); type = tag.Type.ToString(); Block block = Blocks.Types[type]; pointerCache.Add(new Pointer()); ProcessBlock(block, 1, tag.VirtualAddress, magic); binReader = new BinaryReader(bufferStream); bufferStream.Position = 16; int offset = binReader.ReadInt16(); int count = binReader.ReadInt16(); List<byte> unicodeBytes = new List<byte>(); for (int i = 0; i < count; i++) { bufferStream.Position = 16 + (i * 40); binWriter.Write(map.Unicode[UnicodeTable.Language.English][offset + i].StringReference); binWriter.Write(unicodeBytes.Count); binWriter.Write(new byte[32]); unicodeBytes.AddRange(Encoding.UTF8.GetBytes(map.Unicode[UnicodeTable.Language.English][offset + i].Value)); unicodeBytes.Add(byte.MinValue); } bufferStream.Position = 16 + (count * 40); binWriter.Write(unicodeBytes.ToArray()); binWriter.Write(Padding.GetBytes(bufferStream.Position, 4)); metaLength = (int)bufferStream.Position; bufferStream.Position = 0; binWriter.Write(count); binWriter.Write(16); binWriter.Write(unicodeBytes.Count); binWriter.Write(16 + (count * 40)); stringReferences.Clear(); idReferences.Clear(); rawReferences.Clear(); valueCache.Clear(); pointerCache.Clear(); rawCache.Clear(); type = "utf8"; block = Blocks.Types[type]; pointerCache.Add(new Pointer()); ProcessBlock(block, 1, 0); ProcessValues(); ProcessPointers(); ProcessRaws(); binWriter.Flush(); BufferedWriteFile(filename, stringReferences.ToArray(), idReferences.ToArray(), rawReferences.ToArray()); }