本文整理汇总了C#中Stream.ReadUInt32方法的典型用法代码示例。如果您正苦于以下问题:C# Stream.ReadUInt32方法的具体用法?C# Stream.ReadUInt32怎么用?C# Stream.ReadUInt32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stream
的用法示例。
在下文中一共展示了Stream.ReadUInt32方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsWsaD2
bool IsWsaD2(Stream s)
{
if (s.Length < 10)
return false;
var start = s.Position;
numTiles = s.ReadUInt16();
tileWidth = s.ReadUInt16();
tileHeight = s.ReadUInt16();
Delta = s.ReadUInt32();
offsets = new uint[numTiles + 1];
for (var i = 0; i <= numTiles; i++)
offsets[i] = s.ReadUInt32();
s.Position = start;
//if (offsets[numTiles] < s.Length)
// return false;
if (offsets[0] == 0)
{
numTiles -= 1;
for (var i = 1; i <= numTiles; i++)
offsets[i - 1] = offsets[i];
}
return true;
}
示例2: D2kSoundResources
public D2kSoundResources(string filename, int priority)
{
this.filename = filename;
this.priority = priority;
s = GlobalFileSystem.Open(filename);
try
{
filenames = new List<string>();
var headerLength = s.ReadUInt32();
while (s.Position < headerLength + 4)
{
var name = s.ReadASCIIZ();
var offset = s.ReadUInt32();
var length = s.ReadUInt32();
var hash = PackageEntry.HashFilename(name, PackageHashType.Classic);
if (!index.ContainsKey(hash))
index.Add(hash, new PackageEntry(hash, offset, length));
filenames.Add(name);
}
}
catch
{
Dispose();
throw;
}
}
示例3: HvaReader
public HvaReader(Stream s)
{
// Index swaps for transposing a matrix
var ids = new byte[]{0,4,8,12,1,5,9,13,2,6,10,14};
s.Seek(16, SeekOrigin.Begin);
FrameCount = s.ReadUInt32();
LimbCount = s.ReadUInt32();
// Skip limb names
s.Seek(16*LimbCount, SeekOrigin.Current);
Transforms = new float[16*FrameCount*LimbCount];
for (var j = 0; j < FrameCount; j++)
for (var i = 0; i < LimbCount; i++)
{
// Convert to column-major matrices and add the final matrix row
var c = 16*(LimbCount*j + i);
Transforms[c + 3] = 0;
Transforms[c + 7] = 0;
Transforms[c + 11] = 0;
Transforms[c + 15] = 1;
for (var k = 0; k < 12; k++)
Transforms[c + ids[k]] = s.ReadFloat();
}
}
示例4: PakFile
public PakFile(string filename, int priority)
{
this.filename = filename;
this.priority = priority;
index = new Dictionary<string, Entry>();
stream = GlobalFileSystem.Open(filename);
try
{
index = new Dictionary<string, Entry>();
var offset = stream.ReadUInt32();
while (offset != 0)
{
var file = stream.ReadASCIIZ();
var next = stream.ReadUInt32();
var length = (next == 0 ? (uint)stream.Length : next) - offset;
// Ignore duplicate files
if (index.ContainsKey(file))
continue;
index.Add(file, new Entry { Offset = offset, Length = length, Filename = file });
offset = next;
}
}
catch
{
Dispose();
throw;
}
}
示例5: FromStream
public static IPackfile FromStream(Stream stream, bool isStr2)
{
stream.Seek(0, SeekOrigin.Begin);
uint descriptor = stream.ReadUInt32();
if (descriptor != 0x51890ACE)
throw new Exception("The input is not a packfile!");
uint version = stream.ReadUInt32();
switch (version)
{
case 0x04: // Saints Row 2
return new Packfiles.Version04.Packfile(stream);
case 0x06: // Saints Row: The Third
return new Packfiles.Version06.Packfile(stream, isStr2);
case 0x0A: // Saints Row IV & Saints Row: Gat out of Hell
return new Packfiles.Version0A.Packfile(stream, isStr2);
default:
throw new Exception(String.Format("Unsupported packfile version: {0:X4}", version));
}
}
示例6: BigFile
public BigFile(FileSystem context, string filename)
{
Name = filename;
s = context.Open(filename);
try
{
if (s.ReadASCII(4) != "BIGF")
throw new InvalidDataException("Header is not BIGF");
// Total archive size.
s.ReadUInt32();
var entryCount = s.ReadUInt32();
if (BitConverter.IsLittleEndian)
entryCount = int2.Swap(entryCount);
// First entry offset? This is apparently bogus for EA's .big files
// and we don't have to try seeking there since the entries typically start next in EA's .big files.
s.ReadUInt32();
for (var i = 0; i < entryCount; i++)
{
var entry = new Entry(s);
index.Add(entry.Path, entry);
}
}
catch
{
Dispose();
throw;
}
}
示例7: HvaReader
public HvaReader(Stream s, string fileName)
{
// Index swaps for transposing a matrix
var ids = new byte[] { 0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14 };
s.Seek(16, SeekOrigin.Begin);
FrameCount = s.ReadUInt32();
LimbCount = s.ReadUInt32();
// Skip limb names
s.Seek(16 * LimbCount, SeekOrigin.Current);
Transforms = new float[16 * FrameCount * LimbCount];
var testMatrix = new float[16];
for (var j = 0; j < FrameCount; j++)
for (var i = 0; i < LimbCount; i++)
{
// Convert to column-major matrices and add the final matrix row
var c = 16 * (LimbCount * j + i);
Transforms[c + 3] = 0;
Transforms[c + 7] = 0;
Transforms[c + 11] = 0;
Transforms[c + 15] = 1;
for (var k = 0; k < 12; k++)
Transforms[c + ids[k]] = s.ReadFloat();
Array.Copy(Transforms, 16 * (LimbCount * j + i), testMatrix, 0, 16);
if (Util.MatrixInverse(testMatrix) == null)
throw new InvalidDataException(
"The transformation matrix for HVA file `{0}` section {1} frame {2} is invalid because it is not invertible!"
.F(fileName, i, j));
}
}
示例8: LoadFile
private bool LoadFile( Stream stream )
{
string magic = stream.ReadAscii( 8 );
uint strategySetCount = stream.ReadUInt32().SwapEndian();
uint strategyOptionCount = stream.ReadUInt32().SwapEndian();
uint refStringStart = stream.ReadUInt32().SwapEndian();
StrategySetList = new List<StrategySet>( (int)strategySetCount );
for ( uint i = 0; i < strategySetCount; ++i ) {
StrategySet ss = new StrategySet( stream, refStringStart );
StrategySetList.Add( ss );
}
StrategyOptionList = new List<StrategyOption>( (int)strategyOptionCount );
for ( uint i = 0; i < strategyOptionCount; ++i ) {
StrategyOption so = new StrategyOption( stream, refStringStart );
StrategyOptionList.Add( so );
}
StrategyOptionDict = new Dictionary<uint, StrategyOption>( StrategyOptionList.Count );
foreach ( var option in StrategyOptionList ) {
StrategyOptionDict.Add( option.InGameID, option );
}
return true;
}
示例9: WwiseSoundbank
public WwiseSoundbank(Stream s)
{
while (s.Position < s.Length)
{
SectionId sectionId = (SectionId)s.ReadUInt32();
uint length = s.ReadUInt32();
byte[] data = new byte[length];
s.Read(data, 0, (int)length);
switch (sectionId)
{
case SectionId.BKHD:
BKHDSection bkhd = new BKHDSection(data);
Sections.Add(bkhd);
break;
case SectionId.ENVS:
ENVSSection envs = new ENVSSection(data);
Sections.Add(envs);
break;
case SectionId.HIRC:
HIRCSection hirc = new HIRCSection(data);
Sections.Add(hirc);
break;
case SectionId.STMG:
STMGSection stmg = new STMGSection(data);
Sections.Add(stmg);
break;
default:
throw new NotImplementedException("Unknown section: " + sectionId.ToString());
}
}
}
示例10: FilePropertiesObject
/// <summary>
/// インスタンスを初期化します。
/// </summary>
/// <param name="src">オブジェクト情報を読み取るストリーム。位置はオブジェクトのボディ先頭 ( サイズ情報の直後 ) に設定します。新規作成なら null を指定します。</param>
public FilePropertiesObject( Stream src )
{
if( src == null )
{
this.FileId = Guid.NewGuid();
this.FileSize = ( ulong )this.Size;
}
else
{
this.FileId = src.ReadGuid();
this.FileSize = src.ReadUInt64();
this.CreationDate = DateTime.FromFileTimeUtc( ( long )src.ReadUInt64() );
this.DataPacketsCount = src.ReadUInt64();
this.Duration = src.ReadUInt64();
this.SendDuration = TimeSpan.FromTicks( ( long )src.ReadUInt64() );
this.Preroll = src.ReadUInt64();
// 再生時間から Preroll x 10000 を差し引いたものが、実際の演奏時間となる。
// この値は複数値からの算出が必要なので、遅延読み込みせずにキャッシュする。
//
this.Duration -= ( this.Preroll * FilePropertiesObject.PrerollDelta );
this.Flags = src.ReadUInt32();
this.MinimumDataPacketSize = src.ReadUInt32();
this.MaximumDataPacketSize = src.ReadUInt32();
this.MaximumBitrate = src.ReadUInt32();
}
}
示例11: FileGroup
public FileGroup(Stream reader, long offset)
{
var nameOffset = reader.ReadUInt32();
/* unknown */ reader.ReadBytes(18);
FirstFile = reader.ReadUInt32();
LastFile = reader.ReadUInt32();
reader.Seek(offset + (long)nameOffset, SeekOrigin.Begin);
Name = reader.ReadASCIIZ();
}
示例12: LoadFile
private bool LoadFile( Stream stream, uint textPointerLocationDiff )
{
string magic = stream.ReadAscii( 8 );
uint alwaysSame = stream.ReadUInt32().SwapEndian();
uint filesize = stream.ReadUInt32().SwapEndian();
uint lengthSection1 = stream.ReadUInt32().SwapEndian();
stream.Position = 0x50;
int textPointerDiffDiff = (int)stream.ReadUInt32().SwapEndian();
stream.Position = 0x20;
uint textStart = stream.ReadUInt32().SwapEndian();
int textPointerDiff = (int)stream.ReadUInt32().SwapEndian() - textPointerDiffDiff;
EntryList = new List<ScenarioFileEntry>();
// i wonder what the actual logic behind this is...
uint textPointersLocation = ( lengthSection1 + 0x80 ).Align( 0x10 ) + textPointerLocationDiff;
// + 0x1888; // + 0x1B4C // diff of 2C4 // Actually this isn't constant, dammit.
if ( textStart != textPointersLocation ) {
stream.Position = textPointersLocation;
while ( true ) {
long loc = stream.Position;
stream.DiscardBytes( 8 );
uint[] ptrs = new uint[4];
ptrs[0] = stream.ReadUInt32().SwapEndian();
ptrs[1] = stream.ReadUInt32().SwapEndian();
ptrs[2] = stream.ReadUInt32().SwapEndian();
ptrs[3] = stream.ReadUInt32().SwapEndian();
if ( stream.Position > textStart ) { break; }
if ( ptrs.Any( x => x == 0 ) ) { break; }
if ( ptrs.Any( x => x + textPointerDiff < textStart ) ) { break; }
if ( ptrs.Any( x => x + textPointerDiff >= filesize ) ) { break; }
var s = new ScenarioFileEntry();
s.Pointer = (uint)loc;
stream.Position = ptrs[0] + textPointerDiff;
s.JpName = stream.ReadShiftJisNullterm();
stream.Position = ptrs[1] + textPointerDiff;
s.JpText = stream.ReadShiftJisNullterm();
stream.Position = ptrs[2] + textPointerDiff;
s.EnName = stream.ReadShiftJisNullterm();
stream.Position = ptrs[3] + textPointerDiff;
s.EnText = stream.ReadShiftJisNullterm();
EntryList.Add( s );
stream.Position = loc + 0x18;
}
}
return true;
}
示例13: IsTmpTD
bool IsTmpTD(Stream s)
{
var start = s.Position;
s.Position += 16;
var a = s.ReadUInt32();
var b = s.ReadUInt32();
s.Position = start;
return a == 0 && b == 0x0D1AFFFF;
}
示例14: InstallShieldCABExtractor
public InstallShieldCABExtractor(FileSystem context, string hdrFilename)
{
var fileGroups = new List<FileGroup>();
var fileGroupOffsets = new List<uint>();
hdrFile = context.Open(hdrFilename);
this.context = context;
// Strips archive number AND file extension
Name = Regex.Replace(hdrFilename, @"\d*\.[^\.]*$", "");
var signature = hdrFile.ReadUInt32();
if (signature != 0x28635349)
throw new InvalidDataException("Not an Installshield CAB package");
commonHeader = new CommonHeader(hdrFile);
cabDescriptor = new CabDescriptor(hdrFile, commonHeader);
/* unknown */ hdrFile.ReadBytes(14);
for (var i = 0U; i < MaxFileGroupCount; ++i)
fileGroupOffsets.Add(hdrFile.ReadUInt32());
hdrFile.Seek(commonHeader.CabDescriptorOffset + cabDescriptor.FileTableOffset, SeekOrigin.Begin);
directoryTable = new List<uint>();
for (var i = 0U; i < cabDescriptor.DirectoryCount; ++i)
directoryTable.Add(hdrFile.ReadUInt32());
foreach (var offset in fileGroupOffsets)
{
var nextOffset = offset;
while (nextOffset != 0)
{
hdrFile.Seek((long)nextOffset + 4 + commonHeader.CabDescriptorOffset, SeekOrigin.Begin);
var descriptorOffset = hdrFile.ReadUInt32();
nextOffset = hdrFile.ReadUInt32();
hdrFile.Seek(descriptorOffset + commonHeader.CabDescriptorOffset, SeekOrigin.Begin);
fileGroups.Add(new FileGroup(hdrFile, commonHeader.CabDescriptorOffset));
}
}
hdrFile.Seek(commonHeader.CabDescriptorOffset + cabDescriptor.FileTableOffset + cabDescriptor.FileTableOffset2, SeekOrigin.Begin);
foreach (var fileGroup in fileGroups)
{
for (var i = fileGroup.FirstFile; i <= fileGroup.LastFile; ++i)
{
AddFileDescriptorToList(i);
var fileDescriptor = fileDescriptors[i];
var fullFilePath = "{0}\\{1}\\{2}".F(fileGroup.Name, DirectoryName(fileDescriptor.DirectoryIndex), fileDescriptor.Filename);
index.Add(fullFilePath, i);
}
}
}
示例15: LoadFile
private bool LoadFile( Stream stream )
{
string magic = stream.ReadAscii( 8 );
uint blockCount = stream.ReadUInt32().SwapEndian();
uint refStringStart = stream.ReadUInt32().SwapEndian();
Blocks = new List<T8BTVABlock>( (int)blockCount );
for ( uint i = 0; i < blockCount; ++i ) {
Blocks.Add( new T8BTVABlock( stream, refStringStart ) );
}
return true;
}