public BinaryDataAttribute(int? length, EndianType endianType, string encoding, StringReadOptions stringReadOptions) { Length = length; EndianType = endianType; Encoding = String.IsNullOrEmpty(encoding) ? Encoding.BigEndianUnicode : Encoding.GetEncoding(encoding); StringReadOptions = stringReadOptions; }
public EndianIO(string FileName, EndianType EndianType, FileMode FileMode, FileAccess FileAccess, FileShare FileShare) { this.fileMode_0 = FileMode; this.fileAccess_0 = FileAccess; this.fileShare_0 = FileShare; this.EndianType = EndianType; this.FileName = FileName; }
public EndianIO(Stream Stream, EndianType EndianType, bool Open) { this.EndianType = EndianType; this.Stream = Stream; if (Open) { this.Open(); } }
public EndianIO(byte[] ByteArray, EndianType EndianType, bool Open) { this.EndianType = EndianType; this.Stream = new MemoryStream(ByteArray); if (Open) { this.Open(); } }
public byte[] ReadBytes(object Count, EndianType EndianType) { byte[] array = base.ReadBytes(Convert.ToInt32(Count)); if (EndianType == EndianType.BigEndian) { Array.Reverse(array); } return array; }
public EndianIO(string FileName, EndianType EndianType, bool Open) { this.FileMode = FileMode.OpenOrCreate; this.FileAccess = FileAccess.ReadWrite; this.FileShare = FileShare.Read; this.EndianType = EndianType; this.FileName = FileName; if (Open) this.Open(); }
/// <summary> /// Open existing DAT/WAD files /// </summary> /// <param name="datFilename"></param> /// <param name="wadFilename"></param> /// <param name="endianType"></param> public DatWad(string datFilename, string wadFilename, EndianType endianType) { _datFilename = datFilename; _wadFilename = wadFilename; _endianType = endianType; _datItems = new Dictionary<uint, DatItem>(); _headerFileSize = 0; this.parse(); }
public UInt32 ReadUInt32(EndianType endianType) { if ((BitConverter.IsLittleEndian && endianType != EndianType.Little) || (!BitConverter.IsLittleEndian && endianType != EndianType.Big)) { byte[] b = base.ReadBytes(4); Array.Reverse(b); return BitConverter.ToUInt32(b, 0); } else return base.ReadUInt32(); }
public Int16 ReadInt16(EndianType endianType) { if ((BitConverter.IsLittleEndian && endianType != EndianType.Little) || (!BitConverter.IsLittleEndian && endianType != EndianType.Big)) { byte[] b = base.ReadBytes(2); Array.Reverse(b); return BitConverter.ToInt16(b, 0); } else return base.ReadInt16(); }
public void Write(Single value, EndianType endianType) { if ((BitConverter.IsLittleEndian && endianType != EndianType.Little) || (!BitConverter.IsLittleEndian && endianType != EndianType.Big)) { byte[] b = BitConverter.GetBytes(value); Array.Reverse(b); base.Write(b, 0, 4); } else base.Write(value); }
private static byte[] ParseUshortToBytes(ushort buffer, EndianType endian) { var bytes = BitConverter.GetBytes(buffer); NormalizeByteString(bytes); if (endian == EndianType.BigEndian) { Array.Reverse(bytes); } return(bytes); }
public int GetInt32(int pos, EndianType Type = EndianType.BigEndian) { byte[] b = new byte[4]; for (int i = 0; i < 4; i++) { b[i] = buffer[pos + i]; } if (Type == EndianType.BigEndian) { Array.Reverse(b, 0, 4); } return(BitConverter.ToInt32(b, 0)); }
public ulong GetUInt64(int pos, EndianType Type = EndianType.BigEndian) { byte[] b = new byte[8]; for (int i = 0; i < 8; i++) { b[i] = buffer[pos + i]; } if (Type == EndianType.BigEndian) { Array.Reverse(b, 0, 8); } return(BitConverter.ToUInt64(b, 0)); }
public void WriteUInt24(uint value, EndianType endianType) { byte[] buffer = BitConverter.GetBytes(value); Array.Resize(ref buffer, 3); if (endianType == EndianType.BigEndian) { Array.Reverse(buffer); } base.Write(buffer); }
public Int16 ReadInt16(EndianType endianType) { if ((BitConverter.IsLittleEndian && endianType != EndianType.Little) || (!BitConverter.IsLittleEndian && endianType != EndianType.Big)) { byte[] b = base.ReadBytes(2); Array.Reverse(b); return(BitConverter.ToInt16(b, 0)); } else { return(base.ReadInt16()); } }
public Single ReadSingle(EndianType endianType) { if ((BitConverter.IsLittleEndian && endianType != EndianType.Little) || (!BitConverter.IsLittleEndian && endianType != EndianType.Big)) { byte[] b = base.ReadBytes(4); Array.Reverse(b); return(BitConverter.ToSingle(b, 0)); } else { return(base.ReadSingle()); } }
// Token: 0x06000C17 RID: 3095 RVA: 0x0003E1E0 File Offset: 0x0003C3E0 public uint GetUInt32(int pos, EndianType Type = EndianType.BigEndian) { byte[] array = new byte[4]; for (int i = 0; i < 4; i++) { array[i] = this.buffer[pos + i]; } if (Type == EndianType.BigEndian) { Array.Reverse(array, 0, 4); } return(BitConverter.ToUInt32(array, 0)); }
// Token: 0x06000C15 RID: 3093 RVA: 0x0003E130 File Offset: 0x0003C330 public long GetInt64(int pos, EndianType Type = EndianType.BigEndian) { byte[] array = new byte[8]; for (int i = 0; i < 8; i++) { array[i] = this.buffer[pos + i]; } if (Type == EndianType.BigEndian) { Array.Reverse(array, 0, 8); } return(BitConverter.ToInt64(array, 0)); }
public void Write(Single value, EndianType endianType) { if ((BitConverter.IsLittleEndian && endianType != EndianType.Little) || (!BitConverter.IsLittleEndian && endianType != EndianType.Big)) { byte[] b = BitConverter.GetBytes(value); Array.Reverse(b); base.Write(b, 0, 4); } else { base.Write(value); } }
public short GetInt16(int pos, EndianType Type = EndianType.LittleEndian) { byte[] array = new byte[2]; for (int i = 0; i < 2; i++) { array[i] = this.buffer[pos + i]; } if (Type == EndianType.BigEndian) { Array.Reverse(array, 0, 2); } return(BitConverter.ToInt16(array, 0)); }
public short GetInt16(int pos, EndianType Type = EndianType.BigEndian) { byte[] b = new byte[2]; for (int i = 0; i < 2; i++) { b[i] = buffer[pos + i]; } if (Type == EndianType.BigEndian) { Array.Reverse(b, 0, 2); } return(BitConverter.ToInt16(b, 0)); }
public SerializedFile ReadFile(IFileCollection collection, IAssemblyManager manager) { SerializedFile file = new SerializedFile(collection, manager, this); using (PartialStream stream = new PartialStream(m_stream, m_offset, m_size)) { EndianType endianess = Header.SwapEndianess ? EndianType.BigEndian : EndianType.LittleEndian; using (EndianReader reader = new EndianReader(stream, endianess, stream.Position)) { file.Read(reader); } } return(file); }
public int ReadInt24(EndianType EndianType) { byte[] buffer = base.ReadBytes(3); byte[] dest = new byte[0x04]; Array.Copy(buffer, 0, dest, 0, 3); if (EndianType == EndianType.BigEndian) { Array.Reverse(dest); } return(BitConverter.ToInt32(dest, 0)); }
public void Write(string value, int length, EndianType type) { var array = value.ToCharArray(); if (type == EndianType.BigEndian) { Array.Reverse(array); } base.Write(array); for (var i = 0; i < (length - value.Length); i++) { Write((byte)0); } }
public static byte[] ValueToBytes(float data, EndianType et) { var ms = new MemoryStream(); var io = new EndianIO(ms, et); io.Open(); io.Writer.Write(data); io.Reader.BaseStream.Position = 0; var array = io.Reader.ReadBytes((int)io.Reader.BaseStream.Length); io.Close(); ms.Close(); return(array); }
//Constructor public Header() { unchecked { version = (uint)0x04000002; endianType = EndianType.ENDIAN_LITTLE; userVersion = (uint)0; numBlocks = (uint)0; userVersion2 = (uint)0; numBlockTypes = (ushort)0; numStrings = (uint)0; maxStringLength = (uint)0; numGroups = (uint)0; } }
public static void CreateDatWad(QbKey songQk, EndianType endianType, string datFilename, string wadFilename, string songFilename, string guitarFilename, string rhythmFilename, string previewFilename) { QbKey[] keys = new QbKey[4]; int[] offsets = new int[5]; int[] sizes = new int[4]; FileHelper.Delete(wadFilename); FileHelper.Delete(datFilename); using (FileStream fsWad = File.OpenWrite(wadFilename)) { offsets[0] = (int)fsWad.Position; keys[0] = QbKey.Create(string.Format("{0}_guitar", songQk.Text)); sizes[0] = (int)writeFsbToStream(fsWad, guitarFilename, string.Concat(keys[0].Text, ".wav")); offsets[1] = (int)fsWad.Position; keys[1] = QbKey.Create(string.Format("{0}_preview", songQk.Text)); sizes[1] = (int)writeFsbToStream(fsWad, previewFilename, string.Concat(keys[1].Text, ".wav")); offsets[2] = (int)fsWad.Position; keys[2] = QbKey.Create(string.Format("{0}_rhythm", songQk.Text)); sizes[2] = (int)writeFsbToStream(fsWad, rhythmFilename, string.Concat(keys[2].Text, ".wav")); offsets[3] = (int)fsWad.Position; keys[3] = QbKey.Create(string.Format("{0}_song", songQk.Text)); sizes[3] = (int)writeFsbToStream(fsWad, songFilename, string.Concat(keys[3].Text, ".wav")); offsets[4] = (int)fsWad.Position; fsWad.Flush(); } using (FileStream fsDat = File.OpenWrite(datFilename)) { using (BinaryEndianWriter bw = new BinaryEndianWriter(fsDat)) { int l = offsets[3] + sizes[3]; if (l % 16 != 0) l += 16 - (l % 16); bw.Write((uint)keys.Length, endianType); bw.Write((uint)l, endianType); for (int i = 0; i < offsets.Length - 1; i++) { bw.Write(keys[i].Crc, endianType); bw.Write(offsets[i], endianType); bw.Write(sizes[i], endianType); bw.Write(new byte[] { 0,0,0,0,0,0,0,0 }); } fsDat.Flush(); } } }
public void WriteAsciiString(string @string, int length, EndianType endianType) { int num = @string.Length; for (int i = 0; i < num && i <= length; i++) { this.Write((byte)@string[i]); } int num1 = length - num; if (num1 > 0) { this.Write(new byte[num1]); } }
public void WriteUnicodeString(string @string, int length, EndianType endianType) { int num = @string.Length; for (int i = 0; i < num && i <= length; i++) { this.Write(@string[i], endianType); } int num1 = (length - num) * 2; if (num1 > 0) { this.Write(new byte[num1]); } }
public bool Init(EndianType endian, string ip, Int32 port, IPackageCreator creator) { bool bSuccess = false; Close(); m_EndType = endian; m_Port = port; m_IP = ip; bSuccess = _initSocket(); if (bSuccess) { SetPackageCreator(creator); } return(bSuccess); }
public string ReadUTF16String(int length, EndianType endianType) { length = length * 2; byte[] numArray = this.ReadBytes(length); if (endianType != EndianType.LittleEndian) { for (int i = 0; i < length / 2; i++) { byte num = numArray[2 * i]; numArray[2 * i] = numArray[2 * i + 1]; numArray[2 * i + 1] = num; } } return(Encoding.Unicode.GetString(numArray, 0, length)); }
public string ReadUnicodeNullTermString(EndianType endianType) { string empty = string.Empty; while (true) { ushort num = this.ReadUInt16(endianType); if (num == 0) { break; } empty = string.Concat(empty, (char)num); } return(empty); }
public void WriteUInt24(uint v, EndianType EndianType) { byte[] bytes = BitConverter.GetBytes(v); var bInt24 = new byte[3]; for (int i = 0; i < 3; i++) { bInt24[i] = bytes[i]; } if (EndianType == EndianType.BigEndian) { Array.Reverse(bInt24); } base.Write(bInt24); }
public void Write(Stream stream, SerializedFileHeader header) { bool swapEndianess = header.SwapEndianess; if (HasEndian(header.Generation)) { SwapEndianess = stream.ReadByte() != 0; swapEndianess = SwapEndianess; } EndianType endianess = swapEndianess ? EndianType.BigEndian : EndianType.LittleEndian; using (SerializedWriter writer = new SerializedWriter(stream, endianess, header.Generation)) { Write(writer); } }
public void Read(Stream stream, SerializedFileHeader header) { bool swapEndianess = header.Endianess; if (HasEndian(header.Version)) { SwapEndianess = stream.ReadByte() != 0; swapEndianess = SwapEndianess; } EndianType endianess = swapEndianess ? EndianType.BigEndian : EndianType.LittleEndian; using (SerializedReader reader = new SerializedReader(stream, endianess, header.Version)) { Read(reader); } }
public void Write(Stream stream, SerializedFileHeader header) { bool swapEndianess = header.Endianess; if (HasEndian(header.Version)) { stream.WriteByte((byte)(SwapEndianess ? 1 : 0)); swapEndianess = SwapEndianess; } EndianType endianess = swapEndianess ? EndianType.BigEndian : EndianType.LittleEndian; using (SerializedWriter writer = new SerializedWriter(stream, endianess, header.Version)) { Write(writer); } }
public InstructionDecoder(EndianType endianType) { this.endianType = endianType; opCodeDict = new Dictionary <int, InstructionType>(); // // R-Type // opCodeDict.Add(0x0C, InstructionType.R_Type); opCodeDict.Add(0x0E, InstructionType.R_Type); opCodeDict.Add(0x0B, InstructionType.R_Type); // A Extension // // I-Type 32Bit // opCodeDict.Add(0x04, InstructionType.I_Type); opCodeDict.Add(0x19, InstructionType.I_Type); // JALR opCodeDict.Add(0x00, InstructionType.I_Type); opCodeDict.Add(0x03, InstructionType.I_Type); opCodeDict.Add(0x1C, InstructionType.I_Type); // System // // I-Type 64Bit // opCodeDict.Add(0x06, InstructionType.I_Type); // // U-Type // opCodeDict.Add(0x0D, InstructionType.U_Type); opCodeDict.Add(0x05, InstructionType.U_Type); // // J-Type // opCodeDict.Add(0x1B, InstructionType.J_Type); // JAL // // S-Type // opCodeDict.Add(0x08, InstructionType.S_Type); // Store // // B-Type // opCodeDict.Add(0x18, InstructionType.B_Type); // BNE.. }
public void WriteUInt40(long value, EndianType EndianType) { byte[] bytes = BitConverter.GetBytes(value); var bInt40 = new byte[5]; // Copy the first 5 bytes from the 8 byte array to the 5 byte array for (int i = 0; i < 5; i++) { bInt40[i] = bytes[i]; } if (EndianType == EndianType.BigEndian) { Array.Reverse(bInt40); } base.Write(bInt40); }
private string ToString(EndianType endian) { switch (endian) { case EndianType.Native: return("="); case EndianType.Little: return("<"); case EndianType.Big: return(">"); default: throw new InvalidOperationException(); } }
public int ReadInt24(EndianType endiantype) { var buffer = new byte[4]; if (endiantype == EndianType.BigEndian) { Read(buffer, 1, 3); } else { Read(buffer, 0, 3); } if (endiantype == EndianType.BigEndian) { Array.Reverse(buffer); } return(BitConverter.ToInt32(buffer, 0)); }
public float ReadSingle() { // Am I doing this right? var temp = Endian; if ((!BitConverter.IsLittleEndian) && (temp == EndianType.Little)) { Endian = EndianType.Big; } else if ((BitConverter.IsLittleEndian) && (temp == EndianType.Big)) { Endian = EndianType.Little; } var result = BitConverter.ToSingle(ReadBytes(4).ToArray(), 0); Endian = temp; return(result); }
public EndianIO(string fileName, EndianType endiantype, bool Open, bool IsNewFile) { EndianType = endiantype; FileName = fileName; var mode = IsNewFile ? FileMode.Create : FileMode.Open; try { Stream = new FileStream(FileName, mode); Reader = new EndianReader(Stream, EndianType); Writer = new EndianWriter(Stream, EndianType); if (!Open) { Close(); } } catch { } }
public EndianIO(Stream stream, EndianType endiantype) { EndianType = endiantype; Stream = stream; }
public EndianStream(Stream stream, EndianType endian) : base(stream) { }
public EndianIO(string fileName, EndianType endiantype) { EndianType = endiantype; FileName = fileName; }
public void WriteUnicodeString(string String, int Length, EndianType EndianType) { var strLen = String.Length; for (var x = 0; x < strLen; x++) { if (x > Length) break;//just incase they pass a huge string ushort val = String[x]; Write(val, EndianType); } var nullSize = (Length - strLen) * sizeof(ushort); if (nullSize > 0) Write(new byte[nullSize]); }
public void WriteTagType(string tagType) { EndianType = EndianType.BigEndian; Write(tagType); EndianType = EndianType.LittleEndian; }
public ulong ReadUInt64(EndianType endiantype) { var num = base.ReadUInt64(); if (endiantype == EndianType.BigEndian) { var bytes = BitConverter.GetBytes(num); Array.Reverse(bytes); num = BitConverter.ToUInt64(bytes, 0); } return num; }
public float ReadSingle(EndianType endiantype) { var num = base.ReadSingle(); if (endiantype == EndianType.BigEndian) { var bytes = BitConverter.GetBytes(num); Array.Reverse(bytes); num = BitConverter.ToSingle(bytes, 0); } return num; }
public char[] ReadChars(int count, EndianType endiantype) { var chars = Encoding.ASCII.GetChars(XReadBytes(count)); if (endiantype == EndianType.BigEndian) { Array.Reverse(chars); } return chars; }
public EndianWriter(Stream output, EndianType endianType, Encoding encoding) : base(output, encoding) { EndianType = endianType; }
public EndianWriter(Stream output, EndianType endianType) : base(output) { EndianType = endianType; }
public EndianIO(MemoryStream memoryStream, EndianType endiantype) { EndianType = endiantype; MemoryStream = memoryStream; }
public int ReadInt24(EndianType endiantype) { var buffer = new byte[4]; if (endiantype == EndianType.BigEndian) { Read(buffer, 1, 3); } else { Read(buffer, 0, 3); } if (endiantype == EndianType.BigEndian) { Array.Reverse(buffer); } return BitConverter.ToInt32(buffer, 0); }
public byte[] ReadBytes(int count, EndianType endiantype) { var array = base.ReadBytes(count); if (endiantype == EndianType.BigEndian) { Array.Reverse(array); } return array; }
public EndianIO(byte[] Buffer, EndianType endiantype) { EndianType = endiantype; MemoryStream = new MemoryStream(Buffer); }
public void Write(double value, EndianType EndianType) { var buffer = BitConverter.GetBytes(value); if (EndianType == EndianType.BigEndian) Array.Reverse(buffer); base.Write(buffer); }
public string XReadUnicodeString(int Length, EndianType EndianType) { var str = string.Empty; var num = 0; for (var i = 0; i < Length; i++) { var ch = (char)ReadUInt16(EndianType); num++; if (ch == '\0') { break; } str = str + ch; } var num3 = (Length - num) - 1; BaseStream.Seek(num3, SeekOrigin.Current); return str; }
public int ReadInt32(EndianType endiantype) { var num = base.ReadInt32(); if (endiantype == EndianType.BigEndian) { var bytes = BitConverter.GetBytes(num); Array.Reverse(bytes); num = BitConverter.ToInt32(bytes, 0); } return num; }