Example #1
0
        protected internal override Attribute Read(ClassReader classReader, int offset, int
                                                   length, char[] charBuffer, int codeAttributeOffset, Label[] labels)
        {
            var currentOffset = offset;
            var hashAlgorithm = classReader.ReadUTF8(currentOffset, charBuffer);

            currentOffset += 2;
            var numModules = classReader.ReadUnsignedShort(currentOffset);

            currentOffset += 2;
            var moduleList = new List <string>(numModules);
            var hashList   = new List <byte[]>(numModules);

            for (var i = 0; i < numModules; ++i)
            {
                var module = classReader.ReadModule(currentOffset, charBuffer);
                currentOffset += 2;
                moduleList.Add(module);
                var hashLength = classReader.ReadUnsignedShort(currentOffset);
                currentOffset += 2;
                var hash = new byte[hashLength];
                for (var j = 0; j < hashLength; ++j)
                {
                    hash[j]        = unchecked ((byte)(classReader.ReadByte(currentOffset) & 0xFF));
                    currentOffset += 1;
                }

                hashList.Add(hash);
            }

            return(new ModuleHashesAttribute(hashAlgorithm, moduleList, hashList));
        }