本文整理汇总了C#中IReader.ReadInt32方法的典型用法代码示例。如果您正苦于以下问题:C# IReader.ReadInt32方法的具体用法?C# IReader.ReadInt32怎么用?C# IReader.ReadInt32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IReader
的用法示例。
在下文中一共展示了IReader.ReadInt32方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadPatchInfo
private static void ReadPatchInfo(IReader reader, byte version, Patch output)
{
// Version 0 (all versions)
output.MapID = reader.ReadInt32();
output.MapInternalName = reader.ReadAscii();
output.Name = reader.ReadUTF16();
output.Description = reader.ReadUTF16();
output.Author = reader.ReadUTF16();
int screenshotLength = reader.ReadInt32();
if (screenshotLength > 0)
output.Screenshot = reader.ReadBlock(screenshotLength);
// Version 1
if (version >= 1)
{
output.MetaPokeBase = reader.ReadUInt32();
output.MetaChangesIndex = reader.ReadSByte();
}
// Version 2
if (version >= 2)
output.OutputName = reader.ReadAscii();
else
output.OutputName = "";
}
示例2: Load
/// <summary>
/// Loads the strings into the StringTable
/// </summary>
private void Load(IReader reader)
{
reader.SeekTo(0);
// Read the header
var stringCount = reader.ReadInt32(); // int32 string count
var dataSize = reader.ReadInt32(); // int32 string data size
// Read string offsets
var stringOffsets = new int[stringCount];
for (var i = 0; i < stringCount; i++)
stringOffsets[i] = reader.ReadInt32();
// Seek to each offset and read each string
var dataOffset = reader.BaseStream.Position;
foreach (var offset in stringOffsets)
{
if (offset == -1 || offset >= dataSize)
{
_strings.Add("");
continue;
}
reader.BaseStream.Position = dataOffset + offset;
_strings.Add(reader.ReadAscii());
}
}
示例3: ReadDataBlock
private static DataBlock ReadDataBlock(IReader reader, byte version)
{
if (version > 2)
throw new InvalidOperationException("Unrecognized \"data\" block version");
// Block data
uint originalAddress = reader.ReadUInt32();
int entryCount = (version >= 1) ? reader.ReadInt32() : 1;
byte[] data = ReadByteArray(reader);
var block = new DataBlock(originalAddress, entryCount, data);
// Address fixups
int numAddressFixups = reader.ReadInt32();
for (int i = 0; i < numAddressFixups; i++)
{
uint dataAddress = reader.ReadUInt32();
int writeOffset = reader.ReadInt32();
block.AddressFixups.Add(new DataBlockAddressFixup(dataAddress, writeOffset));
}
// Tagref fixups
int numTagFixups = reader.ReadInt32();
for (int i = 0; i < numTagFixups; i++)
{
var datum = new DatumIndex(reader.ReadUInt32());
int writeOffset = reader.ReadInt32();
block.TagFixups.Add(new DataBlockTagFixup(datum, writeOffset));
}
// Resource reference fixups
int numResourceFixups = reader.ReadInt32();
for (int i = 0; i < numResourceFixups; i++)
{
var datum = new DatumIndex(reader.ReadUInt32());
int writeOffset = reader.ReadInt32();
block.ResourceFixups.Add(new DataBlockResourceFixup(datum, writeOffset));
}
if (version >= 2)
{
// StringID fixups
int numSIDFixups = reader.ReadInt32();
for (int i = 0; i < numSIDFixups; i++)
{
string str = reader.ReadAscii();
int writeOffset = reader.ReadInt32();
block.StringIDFixups.Add(new DataBlockStringIDFixup(str, writeOffset));
}
}
return block;
}
示例4: CacheFileVersionInfo
public CacheFileVersionInfo(IReader reader)
{
reader.SeekTo(0x4);
Version = reader.ReadInt32();
if (Version == SecondGenVersion)
{
Engine = EngineType.SecondGeneration;
// Read second-generation build string
reader.SeekTo(0x12C);
BuildString = reader.ReadAscii();
}
else if (Version >= ThirdGenVersion)
{
Engine = EngineType.ThirdGeneration;
// Read third-generation build string
reader.SeekTo(0x11C);
BuildString = reader.ReadAscii();
}
if (string.IsNullOrWhiteSpace(BuildString))
{
// Assume it's a first-generation build
Engine = EngineType.FirstGeneration;
Version = 0;
// Read first-generation build string
reader.SeekTo(0x40);
BuildString = reader.ReadAscii();
}
}
示例5: GetTagAddress
public static uint GetTagAddress(IReader memoryReader, ushort index, uint exeBase)
{
//uint newcountaddr = MaxTagCountAddress;
// Read the tag count and validate the tag index
memoryReader.SeekTo(MaxTagCountAddress + exeBase);
var maxIndex = memoryReader.ReadUInt16();
if (index >= maxIndex)
return 0;
// Read the tag index table to get the index of the tag in the address table
memoryReader.SeekTo(TagIndexArrayPointerAddress + exeBase);
var tagIndexTableAddress = memoryReader.ReadUInt32();
if (tagIndexTableAddress == 0)
return 0;
memoryReader.SeekTo(tagIndexTableAddress + index * 4);
var addressIndex = memoryReader.ReadInt32();
if (addressIndex < 0)
return 0;
// Read the tag's address in the address table
memoryReader.SeekTo(TagAddressArrayPointerAddress + exeBase);
var tagAddressTableAddress = memoryReader.ReadUInt32();
if (tagAddressTableAddress == 0)
return 0;
memoryReader.SeekTo(tagAddressTableAddress + addressIndex * 4);
return memoryReader.ReadUInt32();
}
示例6: ReadByteArray
private static byte[] ReadByteArray(IReader reader)
{
int size = reader.ReadInt32();
if (size <= 0)
return new byte[0];
return reader.ReadBlock(size);
}
示例7: LoadPatch
public static Patch LoadPatch(IReader reader, bool isAlteration)
{
Patch patch = new Patch();
SegmentChange change = new SegmentChange(0, 0, 0, 0, true);
patch.Author = "Ascension/Alteration Patch";
patch.Description = "Ascension/Alteration Patch";
if (isAlteration)
{
//do shitty alteration stuff
byte authorLength = reader.ReadByte();
patch.Author = reader.ReadAscii((int)authorLength);
byte descLength = reader.ReadByte();
patch.Description = reader.ReadAscii((int)descLength);
}
//create ascension patch object and change segment
while (!reader.EOF)
{
//get valuable info
var segmentOffset = reader.ReadUInt32();
var segmentSize = reader.ReadInt32();
var segmentData = reader.ReadBlock(segmentSize);
//Add change data
change.DataChanges.Add(new DataChange(segmentOffset, segmentData));
}
patch.SegmentChanges.Add(change);
return patch;
}
示例8: ThirdGenVersionInfo
public ThirdGenVersionInfo(IReader reader)
{
reader.SeekTo(0x4);
Version = reader.ReadInt32();
reader.SeekTo(0x11C);
BuildString = reader.ReadAscii();
}
示例9: ReadOffsets
private int[] ReadOffsets(IReader reader, Pointer indexTableLocation, int count)
{
reader.SeekTo(indexTableLocation.AsOffset());
int[] offsets = new int[count];
for (int i = 0; i < count; i++)
offsets[i] = reader.ReadInt32();
return offsets;
}
示例10: LoadPatch
public static Patch LoadPatch(IReader reader)
{
int magic = reader.ReadInt32();
if (magic != AssemblyPatchMagic)
throw new InvalidOperationException("Invalid Assembly patch magic");
uint size = reader.ReadUInt32();
byte compression = reader.ReadByte();
if (compression > 0)
throw new InvalidOperationException("Unrecognized patch compression type");
return ReadBlocks(reader, 9, size + 8);
}
示例11: DetectAlignment
static void DetectAlignment(ICacheFile cacheFile, IReader reader, int baseOffset, XElement baseElement, Dictionary<XElement, int> alignsByElem, HashSet<uint> visitedTagBlocks)
{
// Loop through all tag blocks and data references
foreach (var elem in baseElement.Elements())
{
var isTagBlock = (elem.Name.LocalName == "reflexive");
var isDataRef = (elem.Name.LocalName == "dataRef");
if (!isTagBlock && !isDataRef)
continue;
// Read the address
var offset = ParseInteger(elem.Attribute("offset").Value);
var count = 0;
var entrySize = 0;
if (isTagBlock)
{
reader.SeekTo(baseOffset + offset);
count = reader.ReadInt32();
entrySize = ParseInteger(elem.Attribute("entrySize").Value);
}
else
{
reader.SeekTo(baseOffset + offset + 0xC);
}
var addr = reader.ReadUInt32();
if (addr == 0)
continue;
if (isTagBlock && !cacheFile.MetaArea.ContainsBlockPointer(addr, count * entrySize))
continue;
// Only update the alignment if it's less than the currently-guessed alignment
int oldAlign;
var newAlign = GetAlignment(addr);
if (!alignsByElem.TryGetValue(elem, out oldAlign) || newAlign < oldAlign)
alignsByElem[elem] = newAlign;
// If it's a tag block, then recurse into it
if (isTagBlock && !visitedTagBlocks.Contains(addr))
{
visitedTagBlocks.Add(addr);
var blockBaseOffset = cacheFile.MetaArea.PointerToOffset(addr);
for (var i = 0; i < count; i++)
DetectAlignment(cacheFile, reader, blockBaseOffset + i * entrySize, elem, alignsByElem, visitedTagBlocks);
}
}
}
示例12: LoadPatch
public static Patch LoadPatch(IReader reader)
{
// Verify header magic
var magic = reader.ReadInt32();
if (magic != AssemblyPatchMagic)
throw new InvalidOperationException("Invalid Assembly patch magic");
// Read the file size
var size = reader.ReadUInt32();
// Read the compression type
var compression = reader.ReadByte();
if (compression > 0)
throw new InvalidOperationException("Unrecognized patch compression type");
return ReadBlocks(reader, 9, size);
}
示例13: ReadBlocks
private static Patch ReadBlocks(IReader reader, uint startOffset, uint endOffset)
{
var result = new Patch();
var offset = startOffset;
while (offset < endOffset)
{
reader.SeekTo(offset);
var blockId = reader.ReadInt32();
var size = reader.ReadUInt32();
switch (blockId)
{
case AssemblyPatchBlockID.Titl:
ReadPatchInfo(reader, result);
break;
case AssemblyPatchBlockID.Segm:
ReadSegmentChanges(reader, result);
break;
case AssemblyPatchBlockID.Blfc:
ReadBlfInfo(reader, result);
break;
#region Deprecated
case AssemblyPatchBlockID.Meta:
ReadMetaChanges(reader, result);
break;
case AssemblyPatchBlockID.Locl:
ReadLocaleChanges(reader, result);
break;
#endregion Deprecated
}
// Skip to the next block
offset += size;
}
return result;
}
示例14: ReadBlocks
private static Patch ReadBlocks(IReader reader, uint offset, uint endOffset)
{
Patch result = new Patch();
while (offset < endOffset)
{
reader.SeekTo(offset);
int blockId = reader.ReadInt32();
uint size = reader.ReadUInt32();
switch (blockId)
{
case AssemblyPatchBlockID.Titl:
ReadPatchInfo(reader, result);
break;
case AssemblyPatchBlockID.Meta:
ReadMetaChanges(reader, result);
break;
}
// Skip to the next block
offset += size;
}
return result;
}
示例15: ReadDataBlock
private static DataBlock ReadDataBlock(IReader reader, byte version)
{
if (version > 6)
throw new InvalidOperationException("Unrecognized \"data\" block version");
// Block data
uint originalAddress = reader.ReadUInt32();
int entryCount = (version >= 1) ? reader.ReadInt32() : 1;
int align = (version >= 3) ? reader.ReadInt32() : 4;
byte[] data = ReadByteArray(reader);
var block = new DataBlock(originalAddress, entryCount, align, data);
// Address fixups
int numAddressFixups = reader.ReadInt32();
for (int i = 0; i < numAddressFixups; i++)
{
uint dataAddress = reader.ReadUInt32();
int writeOffset = reader.ReadInt32();
block.AddressFixups.Add(new DataBlockAddressFixup(dataAddress, writeOffset));
}
// Tagref fixups
int numTagFixups = reader.ReadInt32();
for (int i = 0; i < numTagFixups; i++)
{
var datum = new DatumIndex(reader.ReadUInt32());
int writeOffset = reader.ReadInt32();
block.TagFixups.Add(new DataBlockTagFixup(datum, writeOffset));
}
// Resource reference fixups
int numResourceFixups = reader.ReadInt32();
for (int i = 0; i < numResourceFixups; i++)
{
var datum = new DatumIndex(reader.ReadUInt32());
int writeOffset = reader.ReadInt32();
block.ResourceFixups.Add(new DataBlockResourceFixup(datum, writeOffset));
}
if (version >= 2)
{
// StringID fixups
int numSIDFixups = reader.ReadInt32();
for (int i = 0; i < numSIDFixups; i++)
{
string str = reader.ReadAscii();
int writeOffset = reader.ReadInt32();
block.StringIDFixups.Add(new DataBlockStringIDFixup(str, writeOffset));
}
}
if (version >= 4)
{
// Shader fixups
int numShaderFixups = reader.ReadInt32();
for (int i = 0; i < numShaderFixups; i++)
{
int writeOffset = reader.ReadInt32();
int shaderDataSize = reader.ReadInt32();
byte[] shaderData = reader.ReadBlock(shaderDataSize);
block.ShaderFixups.Add(new DataBlockShaderFixup(writeOffset, shaderData));
}
}
if (version >= 5)
{
// Unicode string list fixups
int numUnicListFixups = reader.ReadInt32();
for (int i = 0; i < numUnicListFixups; i++)
{
// Version 5 is buggy and doesn't include a language index :x
int languageIndex = i;
if (version >= 6)
languageIndex = reader.ReadInt32();
int writeOffset = reader.ReadInt32();
int numStrings = reader.ReadInt32();
UnicListFixupString[] strings = new UnicListFixupString[numStrings];
for (int j = 0; j < numStrings; j++)
{
string stringId = reader.ReadAscii();
string str = reader.ReadUTF8();
strings[j] = new UnicListFixupString(stringId, str);
}
block.UnicListFixups.Add(new DataBlockUnicListFixup(languageIndex, writeOffset, strings));
}
}
return block;
}