本文整理汇总了C#中Stream.ReadValueU32方法的典型用法代码示例。如果您正苦于以下问题:C# Stream.ReadValueU32方法的具体用法?C# Stream.ReadValueU32怎么用?C# Stream.ReadValueU32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stream
的用法示例。
在下文中一共展示了Stream.ReadValueU32方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
public static WwiseIndex Load(Stream input)
{
if (input == null)
{
throw new ArgumentNullException("input");
}
var magic = input.ReadValueU32(Endian.Little);
if (magic != 0x58444957 &&
magic.Swap() != 0x58444957)
{
throw new FormatException("invalid magic");
}
var endian = magic == 0x58444957 ? Endian.Little : Endian.Big;
var version = input.ReadValueU32(endian);
if (version != 1)
{
throw new FormatException("unexpected version");
}
var reader = new FileFormats.Unreal.FileReader(input, version, endian);
var index = new WwiseIndex();
index.Serialize(reader);
return index;
}
示例2: Deserialize
public void Deserialize(Stream input)
{
var magic = input.ReadValueU32(Endian.Little);
if (magic != 0x434F4E44 && // COND
magic.Swap() != 0x434F4E44)
{
throw new FormatException();
}
var endian = magic == 0x434F4E44 ? Endian.Little : Endian.Big;
var version = input.ReadValueU32(endian);
if (version != 1)
{
throw new FormatException();
}
this.Version = version;
var unknown08 = input.ReadValueU16(endian);
var count = input.ReadValueU16(endian);
var ids = new int[count];
var offsets = new uint[count];
for (ushort i = 0; i < count; i++)
{
ids[i] = input.ReadValueS32(endian);
offsets[i] = input.ReadValueU32(endian);
}
for (ushort i = 0; i < count; i++)
{
var id = ids[i];
var offset = offsets[i];
input.Seek(offset, SeekOrigin.Begin);
var flags = input.ReadValueU8();
var valueType = (Conditionals.ValueType)((flags & 0x0F) >> 0);
var opType = (Conditionals.OpType)((flags & 0xF0) >> 4);
if (valueType == Conditionals.ValueType.Bool)
{
switch (opType)
{
default:
{
throw new NotSupportedException();
}
}
}
}
//throw new NotImplementedException();
this.Endian = endian;
}
示例3: Deserialize
public void Deserialize(Stream input)
{
var magic = input.ReadValueU32(this.LittleEndian);
if (magic != 0x54414653)
throw new NotSupportedException("Bad magic number");
this.Unknown04 = input.ReadValueU32(this.LittleEndian);
this.NumberOfFiles = input.ReadValueU32(this.LittleEndian);
var count = input.ReadValueU32(this.LittleEndian);
this.Unknown10 = input.ReadValueU32(this.LittleEndian);
this.BasePath = input.ReadString(32, true, Encoding.ASCII);
this.Entries.Clear();
for (uint i = 0; i < count; i++)
{
var entry = new Big.EntryV2();
entry.NameHash = input.ReadValueU32(this.LittleEndian);
entry.Locale = input.ReadValueU32(this.LittleEndian);
entry.Size = input.ReadValueU32(this.LittleEndian);
var offset = input.ReadValueU32(this.LittleEndian);
entry.Offset = offset & 0xFFFFFF00;
entry.File = offset & 0xFF;
this.Entries.Add(entry);
}
}
示例4: Deserialize
public void Deserialize(Stream input, Endian endianness)
{
if (input.Length < 20)
{
throw new FormatException("bad section header size?");
}
var count0 = input.ReadValueU32(endianness);
var count1 = input.ReadValueU32(endianness);
var count2 = input.ReadValueU32(endianness);
var count3 = input.ReadValueU32(endianness);
var count4 = input.ReadValueU32(endianness);
this.LocalDataResolvers.Clear();
for (uint i = 0; i < count0; i++)
{
var unknown = new LocalDataResolver();
unknown.Deserialize(input);
this.LocalDataResolvers.Add(unknown);
}
this.RemoteDataResolvers.Clear();
for (uint i = 0; i < count1; i++)
{
var unknown = new RemoteDataResolver();
unknown.Deserialize(input);
this.RemoteDataResolvers.Add(unknown);
}
this.Unknown2s.Clear();
for (uint i = 0; i < count2; i++)
{
var unknown = new Unknown2Resolver();
unknown.Deserialize(input);
this.Unknown2s.Add(unknown);
}
this.Unknown3s.Clear();
if (count3 > 0)
throw new NotSupportedException();
//for (uint i = 0; i < count3; i++)
//{
// var a = input.ReadValueU32();
// this.Unknown3s.Add(a);
//}
this.Unknown4s.Clear();
for (uint i = 0; i < count4; i++)
{
var unknown = new Unknown4Resolver();
unknown.Deserialize(input);
this.Unknown4s.Add(unknown);
}
}
示例5: Deserialize
public void Deserialize(Stream input)
{
if (input.ReadValueU32(false) != 0x626D6174)
{
throw new FormatException();
}
uint count = input.ReadValueU32();
this.Unknown0.Clear();
for (uint i = 0; i < count; i++)
{
var unknown0 = new Subtype1();
unknown0.Deserialize(input);
this.Unknown0.Add(unknown0);
}
}
示例6: Deserialize
public void Deserialize(Stream input)
{
input.Seek(0, SeekOrigin.Begin);
var header = input.ReadStructure<SimGroup.FileHeader>();
if (header.HeaderSize < Marshal.SizeOf(header) ||
header.HeaderSize > input.Length)
{
throw new FormatException("bad data size");
}
uint[] unknown08s = new uint[header.Unknown14Count];
input.Seek(header.Unknown08Offset, SeekOrigin.Begin);
for (ushort i = 0; i < header.Unknown14Count; i++)
{
unknown08s[i] = input.ReadValueU32();
}
input.Seek(header.Unknown0COffset, SeekOrigin.Begin);
for (ushort i = 0; i < header.Unknown16Count; i++)
{
}
}
示例7: Deserialize
public void Deserialize(Stream input)
{
if (input.ReadValueU32() != 4)
{
throw new FormatException("unsupported script version");
}
}
示例8: ReadString
private static string ReadString(Stream input)
{
var length = input.ReadValueU32();
if (length >= 1024)
{
throw new InvalidOperationException();
}
return input.ReadString(length, true, Encoding.ASCII);
}
示例9: Deserialize
public void Deserialize(Stream input)
{
var fileAlignment = input.ReadValueU32(true);
if (fileAlignment != 0x7FF00000 &&
fileAlignment != 0x0000F07F &&
fileAlignment != 0x62300000 &&
fileAlignment != 0x00003062)
{
throw new FormatException("unexpected file alignment (should have been 0x7FF00000)");
}
this.LittleEndian =
fileAlignment == 0x7FF00000 ||
fileAlignment == 0x62300000;
this.FileAlignment = this.LittleEndian == true ?
fileAlignment : fileAlignment.Swap();
this.BasePath = input.ReadString(64, true, Encoding.ASCII);
var count = input.ReadValueU32(this.LittleEndian);
var hashes = new uint[count];
for (uint i = 0; i < count; i++)
{
hashes[i] = input.ReadValueU32(this.LittleEndian);
}
this.Entries.Clear();
for (uint i = 0; i < count; i++)
{
var entry = new Big.Entry();
entry.NameHash = hashes[i];
entry.UncompressedSize = input.ReadValueU32(this.LittleEndian);
entry.Offset = input.ReadValueU32(this.LittleEndian);
entry.Locale = input.ReadValueU32(this.LittleEndian);
entry.CompressedSize = input.ReadValueU32(this.LittleEndian);
this.Entries.Add(entry);
if (entry.CompressedSize != 0)
{
throw new NotSupportedException();
}
}
}
示例10: Deserialize
public static object Deserialize(Stream input, FieldType type, bool littleEndian)
{
switch (type)
{
case FieldType.UInt8: return input.ReadValueU8();
case FieldType.Int8: return input.ReadValueS8();
case FieldType.UInt16: return input.ReadValueU16(littleEndian);
case FieldType.Int16: return input.ReadValueS16(littleEndian);
case FieldType.UInt32: return input.ReadValueU32(littleEndian);
case FieldType.Int32: return input.ReadValueS32(littleEndian);
case FieldType.UInt64: return input.ReadValueU64(littleEndian);
case FieldType.Int64: return input.ReadValueS64(littleEndian);
case FieldType.Single: return input.ReadValueF32(littleEndian);
case FieldType.Double: return input.ReadValueF64(littleEndian);
case FieldType.Vector3:
{
var value = new Builtins.Vector3();
value.Deserialize(input, littleEndian);
return value;
}
case FieldType.Vector4:
{
var value = new Builtins.Vector4();
value.Deserialize(input, littleEndian);
return value;
}
case FieldType.Quaternion:
{
var value = new Builtins.Quaternion();
value.Deserialize(input, littleEndian);
return value;
}
case FieldType.String:
{
throw new NotSupportedException("cannot deserialize strings via Builtin");
}
case FieldType.Color:
{
var value = new Builtins.Color();
value.Deserialize(input, littleEndian);
return value;
}
case FieldType.Matrix4x4:
{
var value = new Builtins.Matrix4x4();
value.Deserialize(input, littleEndian);
return value;
}
}
throw new NotSupportedException("unsupported builtin type");
}
示例11: Deserialize
public void Deserialize(Stream input)
{
this.Version = input.ReadValueU32();
if (this.Version < 1 || this.Version > 2)
{
throw new FormatException("unsupported blob version");
}
var nameLength = this.Version == 2 ? 32u : 14u;
var count = input.ReadValueU32();
this.Entries = new List<Entry>();
for (uint i = 0; i < count; i++)
{
// ReSharper disable UseObjectOrCollectionInitializer
var entry = new Entry();
// ReSharper restore UseObjectOrCollectionInitializer
entry.Name = input.ReadString(nameLength, true);
entry.Offset = input.ReadValueU32();
entry.Size = input.ReadValueU32();
this.Entries.Add(entry);
}
}
示例12: LoadME3save
void LoadME3save(Stream file)
{
if (file != null)
{
if (file.ReadValueU32(Endian.Big) == 0x434F4E20)
{
return;
}
file.Seek(-4, SeekOrigin.Current);
try
{
me3Save = Gibbed.MassEffect3.FileFormats.SFXSaveGameFile.Read(file);
}
catch (Exception)
{
return;
}
}
}
示例13: Deserialize
public void Deserialize(Stream input, Endian endian)
{
this.Size = input.ReadValueU32(endian);
this.Flags = input.ReadValueEnum<HeaderFlags>(endian);
this.Height = input.ReadValueS32(endian);
this.Width = input.ReadValueS32(endian);
this.PitchOrLinearSize = input.ReadValueU32(endian);
this.Depth = input.ReadValueU32(endian);
this.MipMapCount = input.ReadValueU32(endian);
if (input.Read(this.Reserved1, 0, this.Reserved1.Length) != this.Reserved1.Length)
{
throw new EndOfStreamException();
}
this.PixelFormat.Deserialize(input, endian);
this.SurfaceFlags = input.ReadValueU32(endian);
this.CubemapFlags = input.ReadValueU32(endian);
if (input.Read(this.Reserved2, 0, this.Reserved2.Length) != this.Reserved2.Length)
{
throw new EndOfStreamException();
}
}
示例14: Deserialize
public void Deserialize(Stream input)
{
input.Seek(0, SeekOrigin.Begin);
var magic = input.ReadValueU32(false);
if (magic != 0x42494748) // BIGH
{
throw new FormatException("unknown magic");
}
this.TotalFileSize = input.ReadValueU32(true); // :wtc:
uint fileCount = input.ReadValueU32(false);
uint headerSize = input.ReadValueU32(false);
this.Entries.Clear();
var duplicateNames = new List<uint>();
for (uint i = 0; i < fileCount; i++)
{
var entry = new Entry();
entry.Offset = input.ReadValueU32(false);
entry.Size = input.ReadValueU32(false);
entry.Name = input.ReadValueU32(false);
if (duplicateNames.Contains(entry.Name) == true)
{
entry.Duplicate = true;
}
else
{
entry.Duplicate = false;
duplicateNames.Add(entry.Name);
}
this.Entries.Add(entry);
}
}
示例15: Compress
/// <summary>
/// compress an entire ME3 pcc into a byte array.
/// </summary>
/// <param name="uncompressedPcc">uncompressed pcc stream.</param>
/// <returns>a compressed array of bytes.</returns>
public static Stream Compress(Stream uncompressedPcc)
{
uncompressedPcc.Position = 0;
var magic = uncompressedPcc.ReadValueU32(Endian.Little);
if (magic != 0x9E2A83C1 &&
magic.Swap() != 0x9E2A83C1)
{
throw new FormatException("not a pcc package");
}
var endian = magic == 0x9E2A83C1 ?
Endian.Little : Endian.Big;
var encoding = endian == Endian.Little ?
Encoding.Unicode : Encoding.BigEndianUnicode;
var versionLo = uncompressedPcc.ReadValueU16(endian);
var versionHi = uncompressedPcc.ReadValueU16(endian);
if (versionLo != 684 &&
versionHi != 194)
{
throw new FormatException("unsupported version");
}
uncompressedPcc.Seek(4, SeekOrigin.Current);
var folderNameLength = uncompressedPcc.ReadValueS32(endian);
var folderNameByteLength =
folderNameLength >= 0 ? folderNameLength : (-folderNameLength * 2);
uncompressedPcc.Seek(folderNameByteLength, SeekOrigin.Current);
var packageFlagsOffset = uncompressedPcc.Position;
var packageFlags = uncompressedPcc.ReadValueU32(endian);
if ((packageFlags & 8) != 0)
{
uncompressedPcc.Seek(4, SeekOrigin.Current);
}
var nameCount = uncompressedPcc.ReadValueU32(endian);
var namesOffset = uncompressedPcc.ReadValueU32(endian);
var exportCount = uncompressedPcc.ReadValueU32(endian);
var exportInfosOffset = uncompressedPcc.ReadValueU32(endian);
SortedDictionary<uint, uint> exportDataOffsets = new SortedDictionary<uint, uint>();
Stream data;
if ((packageFlags & 0x02000000) == 0)
{
data = uncompressedPcc;
}
else
{
throw new FormatException("pcc data is compressed");
}
// get info about export data, sizes and offsets
data.Seek(exportInfosOffset, SeekOrigin.Begin);
for (uint i = 0; i < exportCount; i++)
{
var classIndex = data.ReadValueS32(endian);
data.Seek(4, SeekOrigin.Current);
var outerIndex = data.ReadValueS32(endian);
var objectNameIndex = data.ReadValueS32(endian);
data.Seek(16, SeekOrigin.Current);
uint exportDataSize = data.ReadValueU32(endian);
uint exportDataOffset = data.ReadValueU32(endian);
exportDataOffsets.Add(exportDataOffset, exportDataSize);
data.Seek(4, SeekOrigin.Current);
var count = data.ReadValueU32(endian);
data.Seek(count * 4, SeekOrigin.Current);
data.Seek(20, SeekOrigin.Current);
}
const uint maxBlockSize = 0x100000;
Stream outputStream = new MemoryStream();
// copying pcc header
byte[] buffer = new byte[130];
uncompressedPcc.Seek(0, SeekOrigin.Begin);
uncompressedPcc.Read(buffer, 0, 130);
outputStream.Write(buffer, 0, buffer.Length);
//add compressed pcc flag
uncompressedPcc.Seek(12, SeekOrigin.Begin);
folderNameLength = uncompressedPcc.ReadValueS32();
folderNameByteLength =
folderNameLength >= 0 ? folderNameLength : (-folderNameLength * 2);
uncompressedPcc.Seek(folderNameByteLength, SeekOrigin.Current);
outputStream.Seek(uncompressedPcc.Position, SeekOrigin.Begin);
packageFlags = uncompressedPcc.ReadValueU32();
packageFlags |= 0x02000000; // add compression flag
outputStream.WriteValueU32(packageFlags);
//.........这里部分代码省略.........