示例#1
0
        public static byte[] GetByteArray(PsoFile pso, PsoStructureEntryInfo entry, int offset)
        {
            var aCount   = (entry.ReferenceKey >> 16) & 0x0000FFFF;
            var aBlockId = (int)entry.ReferenceKey & 0x0000FFFF;
            var block    = pso.GetBlock(aBlockId);

            if (block == null)
            {
                return(null);
            }

            //block.Offset

            return(null);
        }
示例#2
0
        public static string GetString(PsoFile pso, CharPointer ptr)
        {
            if (ptr.Count1 == 0)
            {
                return(null);
            }

            var blocki = (int)ptr.PointerDataId;     // (ptr.Pointer & 0xFFF) - 1;
            var offset = (int)ptr.PointerDataOffset; // (ptr.Pointer >> 12) & 0xFFFFF;

            var block = pso.GetBlock(blocki);

            if (block == null)
            {
                return(null);
            }

            var length   = ptr.Count1;
            var lastbyte = offset + length;

            if (lastbyte >= block.Length)
            {
                return(null);
            }

            var data = pso.DataSection?.Data;

            if (data == null)
            {
                return(null);
            }

            var doffset = block.Offset + offset;

            string s = Encoding.ASCII.GetString(data, doffset, length);

            //if (meta.Strings == null) return null;
            //if (offset < 0) return null;
            //if (offset >= meta.Strings.Length) return null;
            //string s = meta.Strings[offset];

            return(s);
        }
示例#3
0
        public static string GetString(PsoFile pso, DataBlockPointer ptr)
        {
            var blocki = (int)ptr.PointerDataId;     // (ptr.Pointer & 0xFFF) - 1;
            var offset = (int)ptr.PointerDataOffset; // (ptr.Pointer >> 12) & 0xFFFFF;

            var block = pso.GetBlock(blocki);

            if (block == null)
            {
                return(null);
            }

            //var length = ptr.Count1;
            //var lastbyte = offset + length;
            //if (lastbyte >= block.Length)
            //{ return null; }

            var data = pso.DataSection?.Data;

            if (data == null)
            {
                return(null);
            }

            //var doffset = block.Offset + offset;

            //string s = Encoding.ASCII.GetString(data, doffset, length);

            StringBuilder sb = new StringBuilder();
            var           o  = block.Offset + offset;
            char          c  = (char)data[o];

            while (c != 0)
            {
                sb.Append(c);
                o++;
                c = (char)data[o];
            }
            var s = sb.ToString();

            return(s);
        }