コード例 #1
0
        private string ReadPString(FileStream str, bool isTest)
        {
            int    p   = MxeParser.GetRealAddress(GetValueAsInt());
            string ret = String.Empty;

            if (p >= str.Length)
            {
                if (!isTest)
                {
                    Console.Out.WriteLine(String.Format(@"Pointer header [{0}] contains overly large pointer [{1}] exceeding source file size. Are you sure this is a pointer? CHECK YOU config.txt FILE! Skipping value.", _header, GetValueAsHex()));
                }
            }
            else if (p > 0)
            {
                List <byte> pbytes = new List <byte>();
                str.Seek(p, SeekOrigin.Begin);
                byte b = (byte)str.ReadByte();
                if (b != 0x0)
                {
                    int pos = p;
                    while (b != 0x0 && pos < str.Length)
                    {
                        pbytes.Add(b);
                        b = (byte)str.ReadByte();
                        pos++;
                    }
                    ret = SourceEncoding.GetString(pbytes.ToArray(), 0, pbytes.Count);
                }
            }

            if (!isTest)
            {
                _pstring      = ret;
                _pstringbytes = new ByteString(p, _pstring.Length);
            }
            return(ret);
        }
コード例 #2
0
 private void ReadBlock(FileStream stream)
 {
     _block = new MxeBlockEntry(this, MxeParser.GetRealAddress(_address));
     _block.ReadBlock(stream);
 }