Beispiel #1
0
        internal static IReadOnlyDictionary <string, byte[]> GetFilesAndChecksums(this PdbFile pdbFile)
        {
            Argument.IsNotNull(() => pdbFile);

            // const int LastInterestingByte = 47;
            const string FileIndicator = "/src/files/";

            var values = pdbFile.Info.NameToPdbName.Values;

            var results = new Dictionary <string, byte[]>(StringComparer.OrdinalIgnoreCase);

            foreach (var value in values)
            {
                if (!value.Name.StartsWith(FileIndicator))
                {
                    continue;
                }

                var num  = value.Stream;
                var name = value.Name.Substring(FileIndicator.Length);

                // Get last bytes for checksum (it may be MD5 or SHA1)
                var bytes      = pdbFile.ReadStreamBytes(num);
                int hashLength = bytes.Length - 72;
                var checksum   = new byte[hashLength];
                Array.Copy(bytes, bytes.Length - hashLength, checksum, 0, hashLength);
                results.Add(name, checksum);
            }

            return(results);
        }
Beispiel #2
0
        public static IEnumerable <Tuple <string, byte[]> > GetFiles(this PdbFile pdbFile)
        {
            Argument.IsNotNull(() => pdbFile);

            //const int LastInterestingByte = 47;
            const string FileIndicator = "/src/files/";

            var values = pdbFile.Info.NameToPdbName.Values;

            var results = new List <Tuple <string, byte[]> >();

            foreach (var value in values)
            {
                if (!value.Name.Contains(FileIndicator))
                {
                    continue;
                }

                var num  = value.Stream;
                var name = value.Name.Substring(FileIndicator.Length);

                var bytes = pdbFile.ReadStreamBytes(num);
                if (bytes.Length != 88)
                {
                    continue;
                }

                // Get last 16 bytes for checksum
                var buffer = new byte[16];
                for (int i = 72; i < 88; i++)
                {
                    buffer[i - 72] = bytes[i];
                }

                results.Add(new Tuple <string, byte[]>(name, buffer));
            }

            return(results);
        }