本文整理汇总了C#中System.IO.BinaryReader.ReadUInt32方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryReader.ReadUInt32方法的具体用法?C# BinaryReader.ReadUInt32怎么用?C# BinaryReader.ReadUInt32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.BinaryReader
的用法示例。
在下文中一共展示了BinaryReader.ReadUInt32方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Read
internal override void Read(BinaryReader reader)
{
Version = reader.ReadUInt16();
VersionNeededToExtract = reader.ReadUInt16();
Flags = (HeaderFlags) reader.ReadUInt16();
CompressionMethod = (ZipCompressionMethod) reader.ReadUInt16();
LastModifiedTime = reader.ReadUInt16();
LastModifiedDate = reader.ReadUInt16();
Crc = reader.ReadUInt32();
CompressedSize = reader.ReadUInt32();
UncompressedSize = reader.ReadUInt32();
ushort nameLength = reader.ReadUInt16();
ushort extraLength = reader.ReadUInt16();
ushort commentLength = reader.ReadUInt16();
DiskNumberStart = reader.ReadUInt16();
InternalFileAttributes = reader.ReadUInt16();
ExternalFileAttributes = reader.ReadUInt32();
RelativeOffsetOfEntryHeader = reader.ReadUInt32();
byte[] name = reader.ReadBytes(nameLength);
Name = DecodeString(name);
byte[] extra = reader.ReadBytes(extraLength);
byte[] comment = reader.ReadBytes(commentLength);
Comment = DecodeString(comment);
LoadExtra(extra);
}
示例2: MpqBlock
public MpqBlock(BinaryReader br, uint HeaderOffset)
{
FilePos = br.ReadUInt32() + HeaderOffset;
CompressedSize = br.ReadUInt32();
FileSize = br.ReadUInt32();
Flags = (MpqFileFlags)br.ReadUInt32();
}
示例3: Steam2ChecksumData
internal Steam2ChecksumData( byte[] blob )
{
maps = new List<ChecksumMapEntry>();
checksums = new Dictionary<uint, int>();
data = blob;
using ( MemoryStream ms = new MemoryStream( data ) )
{
using ( BinaryReader br = new BinaryReader( ms ) )
{
// we don't care about the first two, always the same
br.ReadBytes( 8 );
itemCount = br.ReadUInt32();
checksumCount = br.ReadUInt32();
uint count;
uint start = 0;
for ( int i = 0 ; i < itemCount ; i++ )
{
count = br.ReadUInt32();
start = br.ReadUInt32();
maps.Add( new ChecksumMapEntry( count, start ) );
}
for ( uint i = 0 ; i < checksumCount ; i++ )
{
long pos = br.BaseStream.Position;
checksums[ i ] = br.ReadInt32();
}
}
}
}
示例4: PlayerInfo
private void PlayerInfo(BinaryReader gr)
{
AppendFormatLine("FreePoints: {0}", gr.ReadUInt32());
var speccount=gr.ReadByte();
AppendFormatLine("SpectsCount: {0}", speccount);
AppendFormatLine("ActiveSpec: {0}", gr.ReadByte());
if (speccount > 0)
{
for (int id = 0; id < 1; id++)
{
var talidcount = gr.ReadByte();
AppendFormatLine("TalentIDCount: {0}", talidcount);
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 12; j++)
{
AppendFormatLine("TalentID {0}", gr.ReadUInt32());
AppendFormatLine("CurRanc: {0}", gr.ReadByte());
}
}
var GLYPHMAX = gr.ReadByte();
AppendFormatLine("GLYPHMAX: {0}", GLYPHMAX);
for (int g = 0; g < GLYPHMAX; g++)
{
AppendFormatLine("GLYPID: {0}", gr.ReadUInt16());
}
}
}
}
示例5: Load
public void Load(string destinationDirectory, string resourceName, BinaryReader binaryReader)
{
var start = binaryReader.BaseStream.Position;
uint totalLength = binaryReader.ReadUInt32();
var container = new string(binaryReader.ReadChars(4));
switch (container) {
case "FORM":
case "RIFF":
uint length = binaryReader.ReadUInt32(); // this is probably not really a length, with values like 0xcccccccc
var header = new string(binaryReader.ReadChars(4));
switch (header) {
case "XMID":
case "XDIR":
new XMidiLoader().Load(destinationDirectory, resourceName, binaryReader, totalLength);
break;
case "WAVE":
break;
}
break;
default:
// Possibly a WAV but without a header
binaryReader.BaseStream.Seek(start, SeekOrigin.Begin);
new WaveLoader().Load(destinationDirectory, resourceName, binaryReader, (int)totalLength, true);
break;
}
}
示例6: CasHeader
public CasHeader(BinaryReader b)
{
this.magic = b.ReadUInt32();
this.sha1 = b.ReadBytes(20);
this.size = b.ReadUInt32();
this._null = b.ReadUInt32();
}
示例7: Parse
void Parse(Stream s)
{
BinaryReader br = new BinaryReader(s);
unknown1 = br.ReadUInt32();
data = br.ReadBytes(2 * br.ReadInt32());
unknown2 = br.ReadUInt32();
}
示例8: GetIndex
// 1ST TIER FUNCTIONS
Index GetIndex(BinaryReader binReader)
{
Index getIndex = new Index
{
zone = (Zone) binReader.ReadUInt32(),
unknown02 = binReader.ReadUInt32(),
unknown03 = binReader.ReadUInt32(),
unknown04 = binReader.ReadUInt32()
};
binReader.ReadBytes(12); // nulls
getIndex.triangle = GetTriangles(binReader);
binReader.ReadBytes(8); // nulls
getIndex.triangles = binReader.ReadUInt16();
getIndex.positions = binReader.ReadUInt16();
getIndex.unknown05 = binReader.ReadUInt16();
binReader.ReadBytes(8); // nulls
getIndex.diffuse = GetString(binReader);
getIndex.normal = GetString(binReader);
getIndex.glow = GetString(binReader);
getIndex.specular = GetString(binReader);
getIndex.light = GetString(binReader);
binReader.ReadBytes(38); // nulls
binReader.ReadBytes(8);// Another 8 nulls... this shouldnt be according to old code
return getIndex;
}
示例9: FAR3Archive
/// <summary>
/// Creates a new FAR3Archive instance from a path.
/// </summary>
/// <param name="Path">The path to the archive.</param>
public FAR3Archive(string Path)
{
m_ArchivePath = Path;
if (isReadingSomething == false)
{
isReadingSomething = true;
try
{
m_Reader = new BinaryReader(File.Open(Path, FileMode.Open, FileAccess.Read, FileShare.Read));
}
catch (Exception)
{
throw new FAR3Exception("Could not open the specified archive - " + Path + "! (FAR3Archive())");
}
string Header = Encoding.ASCII.GetString(m_Reader.ReadBytes(8));
uint Version = m_Reader.ReadUInt32();
if ((Header != "FAR!byAZ") || (Version != 3))
{
throw new FAR3Exception("Archive wasn't a valid FAR V.3 archive! (FAR3Archive())");
}
uint ManifestOffset = m_Reader.ReadUInt32();
m_ManifestOffset = ManifestOffset;
m_Reader.BaseStream.Seek(ManifestOffset, SeekOrigin.Begin);
uint NumFiles = m_Reader.ReadUInt32();
for (int i = 0; i < NumFiles; i++)
{
Far3Entry Entry = new Far3Entry();
Entry.DecompressedFileSize = m_Reader.ReadUInt32();
byte[] Dummy = m_Reader.ReadBytes(3);
Entry.CompressedFileSize = (uint)((Dummy[0] << 0) | (Dummy[1] << 8) | (Dummy[2]) << 16);
Entry.DataType = m_Reader.ReadByte();
Entry.DataOffset = m_Reader.ReadUInt32();
//Entry.HasFilename = m_Reader.ReadUInt16();
Entry.IsCompressed = m_Reader.ReadByte();
Entry.AccessNumber = m_Reader.ReadByte();
Entry.FilenameLength = m_Reader.ReadUInt16();
Entry.TypeID = m_Reader.ReadUInt32();
Entry.FileID = m_Reader.ReadUInt32();
Entry.Filename = Encoding.ASCII.GetString(m_Reader.ReadBytes(Entry.FilenameLength));
if (!m_Entries.ContainsKey(Entry.Filename))
m_Entries.Add(Entry.Filename, Entry);
m_EntriesList.Add(Entry);
m_EntryByID.Add(Entry.FileID, Entry); //isn't this a bad idea? i have a feeling this is a bad idea...
}
//Keep the stream open, it helps peformance.
//m_Reader.Close();
isReadingSomething = false;
}
}
示例10: IPHeader
public IPHeader(ArraySegment<byte> buffer)
{
using (var memoryStream = new MemoryStream(buffer.Array, buffer.Offset, buffer.Count))
{
using (var binaryReader = new BinaryReader(memoryStream))
{
var versionAndHeaderLength = binaryReader.ReadByte();
var differentiatedServices = binaryReader.ReadByte();
DifferentiatedServices = (byte)(differentiatedServices >> 2);
CongestionNotification = (byte)(differentiatedServices & 0x03);
TotalLength = (ushort) IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());
Debug.Assert(TotalLength >= 20, "Invalid IP packet Total Lenght");
Identification = (ushort) IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());
_flagsAndOffset = (ushort)IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());
Ttl = binaryReader.ReadByte();
_protocol = binaryReader.ReadByte();
Checksum = IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());
SourceAddress = new IPAddress(binaryReader.ReadUInt32());
DestinationAddress = new IPAddress(binaryReader.ReadUInt32());
HeaderLength = (versionAndHeaderLength & 0x0f) * 4;
}
}
Raw = buffer;
Data = new ArraySegment<byte>(buffer.Array, buffer.Offset + HeaderLength, MessageLength);
}
示例11: Read
internal override void Read(BinaryReader reader)
{
Version = reader.ReadUInt16();
VersionNeededToExtract = reader.ReadUInt16();
Flags = (HeaderFlags) reader.ReadUInt16();
CompressionMethod = (ZipCompressionMethod) reader.ReadUInt16();
LastModifiedTime = reader.ReadUInt16();
LastModifiedDate = reader.ReadUInt16();
Crc = reader.ReadUInt32();
CompressedSize = reader.ReadUInt32();
UncompressedSize = reader.ReadUInt32();
ushort nameLength = reader.ReadUInt16();
ushort extraLength = reader.ReadUInt16();
ushort commentLength = reader.ReadUInt16();
DiskNumberStart = reader.ReadUInt16();
InternalFileAttributes = reader.ReadUInt16();
ExternalFileAttributes = reader.ReadUInt32();
RelativeOffsetOfEntryHeader = reader.ReadUInt32();
byte[] name = reader.ReadBytes(nameLength);
Name = DecodeString(name);
byte[] extra = reader.ReadBytes(extraLength);
byte[] comment = reader.ReadBytes(commentLength);
Comment = DecodeString(comment);
LoadExtra(extra);
var unicodePathExtra = Extra.FirstOrDefault(u => u.Type == ExtraDataType.UnicodePathExtraField);
if (unicodePathExtra != null)
{
Name = ((ExtraUnicodePathExtraField)unicodePathExtra).UnicodeName;
}
}
示例12: GetPEArchitecture
public static CpuArchitectures GetPEArchitecture(string pFilePath)
{
ushort architecture = 0;
ushort[] coffHeader = new ushort[10];
using (FileStream fStream = new FileStream(pFilePath, FileMode.Open, FileAccess.Read))
{
using (BinaryReader bReader = new BinaryReader(fStream))
{
if (bReader.ReadUInt16() == 23117) //check the MZ signature
{
fStream.Seek(0x3A, SeekOrigin.Current); // Go to the location of the location of the NT header
fStream.Seek(bReader.ReadUInt32(), SeekOrigin.Begin); // seek to the start of the NT header.
if (bReader.ReadUInt32() == 17744) //check the PE\0\0 signature.
{
for (int i = 0; i < 10; i++) // Read COFF Header
coffHeader[i] = bReader.ReadUInt16();
if (coffHeader[8] > 0) // Read Optional Header
architecture = bReader.ReadUInt16();
}
}
}
}
switch (architecture)
{
case 0x20b:
return CpuArchitectures.x64;
case 0x10b:
return ((coffHeader[9] & 0x100) == 0) ? CpuArchitectures.AnyCpu : CpuArchitectures.x86;
default:
return CpuArchitectures.Unknown;
}
}
示例13: ReadPackets
public IEnumerable<Packet> ReadPackets(string file)
{
using (var gr = new BinaryReader(new FileStream(file, FileMode.Open, FileAccess.Read), Encoding.ASCII))
{
gr.ReadBytes(3); // PKT
gr.ReadBytes(2); // 0x02, 0x02
gr.ReadByte(); // 0x06
Build = gr.ReadUInt16(); // build
gr.ReadBytes(4); // client locale
gr.ReadBytes(20); // packet key
gr.ReadBytes(64); // realm name
var packets = new List<Packet>();
while (gr.PeekChar() >= 0)
{
Direction direction = gr.ReadByte() == 0xff ? Direction.Server : Direction.Client;
uint unixtime = gr.ReadUInt32();
uint tickcount = gr.ReadUInt32();
uint size = gr.ReadUInt32();
OpCodes opcode = (direction == Direction.Client) ? (OpCodes)gr.ReadUInt32() : (OpCodes)gr.ReadUInt16();
byte[] data = gr.ReadBytes((int)size - ((direction == Direction.Client) ? 4 : 2));
packets.Add(new Packet(direction, opcode, data, unixtime, tickcount));
}
return packets;
}
}
示例14: FARArchive
/// <summary>
/// Opens an existing FAR archive.
/// </summary>
/// <param name="Path">The path to the archive.</param>
public FARArchive(string Path)
{
m_Reader = new BinaryReader(File.Open(Path, FileMode.Open, FileAccess.Read));
m_FarEntries = new List<FarEntry>();
string Header = Encoding.ASCII.GetString(m_Reader.ReadBytes(8));
uint Version = m_Reader.ReadUInt32();
if ((Header != "FAR!byAZ") || (Version != 1))
{
MessageBox.Show("Archive wasn't a valid FAR V.1 archive!");
return;
}
uint ManifestOffset = m_Reader.ReadUInt32();
m_ManifestOffset = ManifestOffset;
m_Reader.BaseStream.Seek(ManifestOffset, SeekOrigin.Begin);
uint NumFiles = m_Reader.ReadUInt32();
for (int i = 0; i < NumFiles; i++)
{
FarEntry Entry = new FarEntry();
Entry.DataLength = m_Reader.ReadInt32();
Entry.DataLength2 = m_Reader.ReadInt32();
Entry.DataOffset = m_Reader.ReadInt32();
Entry.FilenameLength = m_Reader.ReadInt16();
Entry.Filename = Encoding.ASCII.GetString(m_Reader.ReadBytes(Entry.FilenameLength));
m_FarEntries.Add(Entry);
}
//Reader.Close();
}
示例15: Load
public bool Load(string path)
{
using (FileStream fs = new FileStream(path, FileMode.Open))
{
using (BinaryReader reader = new BinaryReader(fs))
{
for (int i = 0; i < 8; ++i)
{
reader.ReadBytes(4);
}
uint count = reader.ReadUInt32();
uint offset = reader.ReadUInt32();
fs.Position = (long)offset;
try
{
for (int i = 0; i < count; ++i)
{
ulong ext = reader.ReadUInt64();
ulong fpath = reader.ReadUInt64();
uint language = reader.ReadUInt32();
reader.ReadBytes(4);
uint id = reader.ReadUInt32();
reader.ReadBytes(4);
this.Add(ext, fpath, language, id);
}
}
catch (Exception)
{
return false;
}
}
}
return true;
}