Example #1
0
        public void ManagedPdbTest()
        {
            using DataTarget dt = TestTargets.AppDomains.LoadFullDump();
            PEModuleInfo clrModule = (PEModuleInfo)dt.EnumerateModules().SingleOrDefault(m => Path.GetFileNameWithoutExtension(m.FileName).Equals("clr", StringComparison.OrdinalIgnoreCase));

            using PEImage img = clrModule.GetPEImage();
            Assert.NotNull(img);

            PdbInfo imgPdb = img.DefaultPdb;

            Assert.NotNull(imgPdb);
            Assert.NotNull(imgPdb.Path);
        }
Example #2
0
        public void FileInfoVersionTest()
        {
            using DataTarget dt = TestTargets.AppDomains.LoadFullDump();
            PEModuleInfo clrModule = (PEModuleInfo)dt.EnumerateModules().SingleOrDefault(m => Path.GetFileNameWithoutExtension(m.FileName).Equals("clr", StringComparison.OrdinalIgnoreCase));

            using PEImage img = clrModule.GetPEImage();
            Assert.NotNull(img);

            FileVersionInfo fileVersion = img.GetFileVersionInfo();

            Assert.NotNull(fileVersion);
            Assert.NotNull(fileVersion.FileVersion);

            ClrInfo clrInfo = dt.ClrVersions[0];

            Assert.Contains(clrInfo.Version.ToString(), fileVersion.FileVersion);
        }
Example #3
0
        public IEnumerable <ModuleInfo> EnumerateModules()
        {
            EnumProcessModules(_process, null, 0, out uint needed);

            IntPtr[] modules = new IntPtr[needed / IntPtr.Size];

            if (!EnumProcessModules(_process, modules, needed, out _))
            {
                throw new InvalidOperationException("Unable to get process modules.");
            }

            List <ModuleInfo> result = new List <ModuleInfo>(modules.Length);

            for (int i = 0; i < modules.Length; i++)
            {
                IntPtr ptr = modules[i];

                StringBuilder sb  = new StringBuilder(1024);
                uint          res = GetModuleFileNameEx(_process, ptr, sb, sb.Capacity);
                DebugOnly.Assert(res != 0);

                ulong baseAddr = (ulong)ptr.ToInt64();
                GetFileProperties(baseAddr, out int filesize, out int timestamp);

                string fileName = sb.ToString();


                Version?version = null;
                if (DataTarget.PlatformFunctions.GetFileVersion(fileName, out int major, out int minor, out int revision, out int patch))
                {
                    version = new Version(major, minor, revision, patch);
                }

                ModuleInfo module = new PEModuleInfo(this, baseAddr, fileName, true, timestamp, filesize, version);
                result.Add(module);
            }

            return(result);
        }