예제 #1
0
        public StyleDescription(byte[] std, int baseLength, int offset, bool word9)
        {
            _baseLength = baseLength;
            int nameStart = offset + baseLength;
            _infoshort = LittleEndian.GetShort(std, offset);
            offset += LittleEndianConsts.SHORT_SIZE;
            _infoshort2 = LittleEndian.GetShort(std, offset);
            offset += LittleEndianConsts.SHORT_SIZE;
            _infoshort3 = LittleEndian.GetShort(std, offset);
            offset += LittleEndianConsts.SHORT_SIZE;
            _bchUpe = LittleEndian.GetShort(std, offset);
            offset += LittleEndianConsts.SHORT_SIZE;
            _infoshort4 = LittleEndian.GetShort(std, offset);
            offset += LittleEndianConsts.SHORT_SIZE;

            //first byte(s) of variable length section of std is the length of the
            //style name and aliases string
            int nameLength = 0;
            int multiplier = 1;
            if (word9)
            {
                nameLength = LittleEndian.GetShort(std, nameStart);
                multiplier = 2;
                nameStart += LittleEndianConsts.SHORT_SIZE;
            }
            else
            {
                nameLength = std[nameStart];
            }

            try
            {
                _name = Encoding.GetEncoding("UTF-16LE").GetString(std, nameStart, nameLength * multiplier);
            }
            catch (EncoderFallbackException)
            {
                // ignore
            }

            //length then null terminator.
            int grupxStart = ((nameLength + 1) * multiplier) + nameStart;

            // the spec only refers to two possible upxs but it mentions
            // that more may be Added in the future
            int varoffset = grupxStart;
            int numUPX = _numUPX.GetValue(_infoshort3);
            _upxs = new UPX[numUPX];
            for (int x = 0; x < numUPX; x++)
            {
                int upxSize = LittleEndian.GetShort(std, varoffset);
                varoffset += LittleEndianConsts.SHORT_SIZE;

                byte[] upx = new byte[upxSize];
                Array.Copy(std, varoffset, upx, 0, upxSize);
                _upxs[x] = new UPX(upx);
                varoffset += upxSize;


                // the upx will always start on a word boundary.
                if (upxSize % 2 == 1)
                {
                    ++varoffset;
                }

            }


        }
예제 #2
0
        public StyleDescription(byte[] std, int baseLength, int offset, bool word9)
        {
            _baseLength = baseLength;
            int nameStart = offset + baseLength;

            _infoshort  = LittleEndian.GetShort(std, offset);
            offset     += LittleEndianConsts.SHORT_SIZE;
            _infoshort2 = LittleEndian.GetShort(std, offset);
            offset     += LittleEndianConsts.SHORT_SIZE;
            _infoshort3 = LittleEndian.GetShort(std, offset);
            offset     += LittleEndianConsts.SHORT_SIZE;
            _bchUpe     = LittleEndian.GetShort(std, offset);
            offset     += LittleEndianConsts.SHORT_SIZE;
            _infoshort4 = LittleEndian.GetShort(std, offset);
            offset     += LittleEndianConsts.SHORT_SIZE;

            //first byte(s) of variable length section of std is the length of the
            //style name and aliases string
            int nameLength = 0;
            int multiplier = 1;

            if (word9)
            {
                nameLength = LittleEndian.GetShort(std, nameStart);
                multiplier = 2;
                nameStart += LittleEndianConsts.SHORT_SIZE;
            }
            else
            {
                nameLength = std[nameStart];
            }

            try
            {
                _name = Encoding.GetEncoding("UTF-16LE").GetString(std, nameStart, nameLength * multiplier);
            }
            catch (EncoderFallbackException)
            {
                // ignore
            }

            //length then null terminator.
            int grupxStart = ((nameLength + 1) * multiplier) + nameStart;

            // the spec only refers to two possible upxs but it mentions
            // that more may be Added in the future
            int varoffset = grupxStart;
            int numUPX    = _numUPX.GetValue(_infoshort3);

            _upxs = new UPX[numUPX];
            for (int x = 0; x < numUPX; x++)
            {
                int upxSize = LittleEndian.GetShort(std, varoffset);
                varoffset += LittleEndianConsts.SHORT_SIZE;

                byte[] upx = new byte[upxSize];
                Array.Copy(std, varoffset, upx, 0, upxSize);
                _upxs[x]   = new UPX(upx);
                varoffset += upxSize;


                // the upx will always start on a word boundary.
                if (upxSize % 2 == 1)
                {
                    ++varoffset;
                }
            }
        }
예제 #3
0
        public override bool Equals(Object o)
        {
            UPX upx = (UPX)o;

            return(Arrays.Equals(_upx, upx._upx));
        }