Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ AllocateStringForNameIndex()

unsafe string System.Resources.ResourceReader.AllocateStringForNameIndex ( int index,
out int dataOffset )
inlineprivate

Definition at line 508 of file ResourceReader.cs.

509 {
510 long num = GetNamePosition(index);
511 int num2;
512 byte[] array;
513 lock (this)
514 {
517 if (num2 < 0)
518 {
519 throw new BadImageFormatException(SR.BadImageFormat_NegativeStringLength);
520 }
521 if (_ums != null)
522 {
523 if (_ums.Position > _ums.Length - num2)
524 {
525 throw new BadImageFormatException(SR.Format(SR.BadImageFormat_ResourcesIndexTooLong, index));
526 }
527 string text = null;
528 char* positionPointer = (char*)_ums.PositionPointer;
529 _ = BitConverter.IsLittleEndian;
530 text = new string(positionPointer, 0, num2 / 2);
531 _ums.Position += num2;
534 {
535 throw new FormatException(SR.Format(SR.BadImageFormat_ResourcesDataInvalidOffset, dataOffset));
536 }
537 return text;
538 }
539 array = new byte[num2];
540 int num3 = num2;
541 while (num3 > 0)
542 {
543 int num4 = _store.Read(array, num2 - num3, num3);
544 if (num4 == 0)
545 {
546 throw new EndOfStreamException(SR.Format(SR.BadImageFormat_ResourceNameCorrupted_NameIndex, index));
547 }
548 num3 -= num4;
549 }
552 {
553 throw new FormatException(SR.Format(SR.BadImageFormat_ResourcesDataInvalidOffset, dataOffset));
554 }
555 }
556 return Encoding.Unicode.GetString(array, 0, num2);
557 }
virtual int ReadInt32()
virtual Stream BaseStream
unsafe int GetNamePosition(int index)
static Encoding Unicode
Definition Encoding.cs:519

References System.Resources.ResourceReader._dataSectionOffset, System.Resources.ResourceReader._nameSectionOffset, System.Resources.ResourceReader._store, System.Resources.ResourceReader._ums, System.array, System.SR.BadImageFormat_NegativeStringLength, System.SR.BadImageFormat_ResourceNameCorrupted_NameIndex, System.SR.BadImageFormat_ResourcesDataInvalidOffset, System.SR.BadImageFormat_ResourcesIndexTooLong, System.IO.BinaryReader.BaseStream, System.SR.Format(), System.Resources.ResourceReader.GetNamePosition(), System.index, System.BitConverter.IsLittleEndian, System.IO.UnmanagedMemoryStream.Length, System.IO.UnmanagedMemoryStream.Position, System.IO.UnmanagedMemoryStream.PositionPointer, System.IO.BinaryReader.Read(), System.IO.BinaryReader.Read7BitEncodedInt(), System.IO.BinaryReader.ReadInt32(), System.text, and System.Text.Encoding.Unicode.