示例#1
0
        private ModuleInfo CreateModuleInfo(ElfLoadedImage image)
        {
            using ElfFile? file = image.Open();

            int filesize  = 0;
            int timestamp = 0;

            if (file is null)
            {
                using Stream stream = image.AsStream();
                PEImage.ReadIndexProperties(stream, out timestamp, out filesize);
            }

            // It's true that we are setting "IndexFileSize" to be the raw size on linux for Linux modules,
            // but this unblocks some SOS scenarios.
            if (filesize == 0)
            {
                filesize = unchecked ((int)image.Size);
            }

            // We suppress the warning because the function it wants us to use is not available on all ClrMD platforms
#pragma warning disable CA1307 // Specify StringComparison

            // This substitution is for unloaded modules for which Linux appends " (deleted)" to the module name.
            string path = image.FileName.Replace(" (deleted)", "");

#pragma warning restore CA1307 // Specify StringComparison

            // We set buildId to "default" which means we will later lazily evaluate the buildId on demand.
            return(new ModuleInfo(this, (ulong)image.BaseAddress, path, true, filesize, timestamp, buildId: default));
        }