/// <summary>
        /// Gets information about this module.
        /// </summary>
        /// <param name="dwFields">A combination of flags from the MODULE_INFO_FIELDS enumeration that specify which fields of pInfo are to be filled out.</param>
        /// <param name="pinfo">A MODULE_INFO structure that is filled in with a description of the module.</param>
        /// <returns>
        /// If successful, returns S_OK; otherwise, returns an error code.
        /// </returns>
        public override int GetInfo( enum_MODULE_INFO_FIELDS dwFields, MODULE_INFO[] pinfo )
        {
            Logger.Debug( string.Empty );
            var info = new MODULE_INFO();

            if ( ( dwFields & enum_MODULE_INFO_FIELDS.MIF_NAME ) != 0 )
            {
                info.m_bstrName = FileName;
                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_NAME;
            }

            if ( ( dwFields & enum_MODULE_INFO_FIELDS.MIF_URL ) != 0 )
            {
                info.m_bstrUrl = FileName;
                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_URL;
            }

            if ( ( dwFields & enum_MODULE_INFO_FIELDS.MIF_FLAGS ) != 0 )
            {
                info.m_dwModuleFlags = enum_MODULE_FLAGS.MODULE_FLAG_SYMBOLS;
                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_FLAGS;
            }

            if ( ( dwFields & enum_MODULE_INFO_FIELDS.MIF_URLSYMBOLLOCATION ) != 0 )
            {
                info.m_bstrUrlSymbolLocation = @".\";
                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_URLSYMBOLLOCATION;
            }

            pinfo[0] = info;

            return VSConstants.S_OK;
        }
Exemple #2
0
        public static bool LoadModules(IntPtr hProcess, ListModules ModuleType)
        {
            //Initialize parameters for EPM
            uint cbNeeded = 0;

            Psapi.EnumProcessModulesEx(hProcess, IntPtr.Zero, 0, out cbNeeded, ModuleType);
            long ArraySize = cbNeeded / IntPtr.Size;

            IntPtr[] hModules   = new IntPtr[ArraySize];
            GCHandle GCh        = GCHandle.Alloc(hModules, GCHandleType.Pinned); // Don't forget to free this later
            IntPtr   lphModules = GCh.AddrOfPinnedObject();
            uint     cb         = cbNeeded;

            Psapi.EnumProcessModulesEx(hProcess, lphModules, cb, out cbNeeded, ModuleType);
            for (int i = 0; i < ArraySize; i++)
            {
                MODULE_INFO ModInfo = new MODULE_INFO();
                System.Text.StringBuilder lpFileName       = new System.Text.StringBuilder(256);
                System.Text.StringBuilder lpModuleBaseName = new System.Text.StringBuilder(32);
                Psapi.GetModuleFileNameExW(hProcess, hModules[i], lpFileName, (uint)(lpFileName.Capacity));
                Psapi.GetModuleInformation(hProcess, hModules[i], out ModInfo, (uint)(Marshal.SizeOf(ModInfo)));
                Psapi.GetModuleBaseNameW(hProcess, hModules[i], lpModuleBaseName, (uint)(lpModuleBaseName.Capacity));
                DbgHelp.SymLoadModuleEx(hProcess, IntPtr.Zero, lpFileName.ToString(), lpModuleBaseName.ToString(),
                                        ModInfo.lpBaseOfDll, (int)ModInfo.SizeOfImage, IntPtr.Zero, 0);
            }
            GCh.Free();
            return(false);
        }
Exemple #3
0
        // Gets the MODULE_INFO that describes this module.
        // This is how the debugger obtains most of the information about the module.
        int IDebugModule2.GetInfo(enum_MODULE_INFO_FIELDS dwFields, MODULE_INFO[] infoArray)
        {
            var info = new MODULE_INFO();

            if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_NAME) != 0)
            {
                info.m_bstrName = DebuggedScript.Name;
                Debug.Assert(info.m_bstrName != null);
                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_NAME;
            }
            if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_URL) != 0)
            {
                info.m_bstrUrl = DebuggedScript.Filename;
                Debug.Assert(info.m_bstrUrl != null);
                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_URL;
            }
            if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_LOADORDER) != 0)
            {
                info.m_dwLoadOrder = (uint) DebuggedScript.Id;
                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_LOADORDER;
            }

            infoArray[0] = info;

            return VSConstants.S_OK;
        }
Exemple #4
0
        // Gets the MODULE_INFO that describes this module.
        // This is how the debugger obtains most of the information about the module.
        int IDebugModule2.GetInfo(enum_MODULE_INFO_FIELDS dwFields, MODULE_INFO[] infoArray)
        {
            var info = new MODULE_INFO();

            if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_NAME) != 0)
            {
                info.m_bstrName = this.DebuggedModule.Name;
                Debug.Assert(info.m_bstrName != null);
                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_NAME;
            }
            if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_URL) != 0)
            {
                info.m_bstrUrl = this.DebuggedModule.FileName;
                Debug.Assert(info.m_bstrUrl != null);
                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_URL;
            }
            if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_LOADORDER) != 0)
            {
                info.m_dwLoadOrder  = (uint)this.DebuggedModule.Id;
                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_LOADORDER;
            }

            infoArray[0] = info;

            return(VSConstants.S_OK);
        }
        /// <summary>
        /// Gets information about this module.
        /// </summary>
        /// <param name="dwFields">A combination of flags from the MODULE_INFO_FIELDS enumeration that specify which fields of pInfo are to be filled out.</param>
        /// <param name="pinfo">A MODULE_INFO structure that is filled in with a description of the module.</param>
        /// <returns>
        /// If successful, returns S_OK; otherwise, returns an error code.
        /// </returns>
        public override int GetInfo(enum_MODULE_INFO_FIELDS dwFields, MODULE_INFO[] pinfo)
        {
            Logger.Debug(string.Empty);
            var info = new MODULE_INFO();

            if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_NAME) != 0)
            {
                info.m_bstrName     = FileName;
                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_NAME;
            }

            if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_URL) != 0)
            {
                info.m_bstrUrl      = FileName;
                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_URL;
            }

            if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_FLAGS) != 0)
            {
                info.m_dwModuleFlags = enum_MODULE_FLAGS.MODULE_FLAG_SYMBOLS;
                info.dwValidFields  |= enum_MODULE_INFO_FIELDS.MIF_FLAGS;
            }

            if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_URLSYMBOLLOCATION) != 0)
            {
                info.m_bstrUrlSymbolLocation = @".\";
                info.dwValidFields          |= enum_MODULE_INFO_FIELDS.MIF_URLSYMBOLLOCATION;
            }

            pinfo[0] = info;

            return(VSConstants.S_OK);
        }
Exemple #6
0
        private Core.SModule GetModuleForPredicate(Func <MODULE_INFO, bool> predicate, string errorMessage)
        {
            IEnumDebugModules2 debugModulesEnumerator;

            if (this.runner.CurrentDebugProgram.EnumModules(out debugModulesEnumerator) == S_OK)
            {
                using (new DisposableComReference(debugModulesEnumerator)) {
                    debugModulesEnumerator.Reset();
                    IDebugModule2[] debugModuleArray = new IDebugModule2[1];
                    uint            cModules         = 0;
                    while (debugModulesEnumerator.Next(1, debugModuleArray, ref cModules) == S_OK && cModules > 0)
                    {
                        IDebugModule2 debugModule2 = debugModuleArray[0];
                        using (new DisposableComReference(debugModule2)) {
                            MODULE_INFO[] moduleInfo = new MODULE_INFO[1];
                            if (debugModule2.GetInfo((uint)enum_MODULE_INFO_FIELDS.MIF_NAME | (uint)enum_MODULE_INFO_FIELDS.MIF_LOADADDRESS | (uint)enum_MODULE_INFO_FIELDS.MIF_SIZE, moduleInfo) == S_OK)
                            {
                                if (predicate(moduleInfo[0]))
                                {
                                    return(new Core.SModule()
                                    {
                                        BaseAddress = moduleInfo[0].m_addrLoadAddress, Name = StripModuleSuffix(moduleInfo[0].m_bstrName)
                                    });
                                }
                            }
                        }
                    }
                }
            }

            throw new DebuggerException(errorMessage);
        }
Exemple #7
0
        internal void GetModuleInfo(string moduleName, out string modulePath, out string symbolPath) {
            modulePath = null;
            symbolPath = null;

            IEnumDebugModules2 debugModulesEnumerator;
            if (currentDebugProgram.EnumModules(out debugModulesEnumerator) != S_OK) {
                return;
            }

            using (new DisposableComReference(debugModulesEnumerator)) {
                debugModulesEnumerator.Reset();
                IDebugModule2[] debugModuleArray = new IDebugModule2[1];
                uint moduleCount = 0;
                while (debugModulesEnumerator.Next(1, debugModuleArray, ref moduleCount) == S_OK && moduleCount > 0) {
                    IDebugModule2 debugModule = debugModuleArray[0];
                    using (new DisposableComReference(debugModule)) {
                        MODULE_INFO[] moduleInfo = new MODULE_INFO[1];
                        if (debugModule.GetInfo((uint)(enum_MODULE_INFO_FIELDS.MIF_NAME | enum_MODULE_INFO_FIELDS.MIF_URLSYMBOLLOCATION | enum_MODULE_INFO_FIELDS.MIF_URL), moduleInfo) == S_OK) {
                            if (moduleName.ToLowerInvariant() == System.IO.Path.GetFileNameWithoutExtension(moduleInfo[0].m_bstrName).ToLowerInvariant()) {
                                modulePath = moduleInfo[0].m_bstrUrl;
                                symbolPath = moduleInfo[0].m_bstrUrlSymbolLocation;
                                return;
                            }
                        }
                    }
                }
            }
        }
        public void GetInfoDoesNotNotifyIfModuleIsExcludedButLoaded()
        {
            var excludedModules = new List <string>()
            {
                "excludedModule"
            };
            bool useIncludeList = false;

            _mockSymbolSettingsProvider.GetInclusionSettings().Returns(
                new SymbolInclusionSettings(useIncludeList, excludedModules, new List <string>()));

            _mockModule.GetPlatformFileSpec().GetFilename().Returns("excludedModule");

            _mockModuleUtil.HasSymbolsLoaded(_mockModule).Returns(true);

            var flags      = enum_MODULE_INFO_FIELDS.MIF_DEBUGMESSAGE;
            var moduleInfo = new MODULE_INFO[1];

            int result = _debugModule.GetInfo(flags, moduleInfo);

            Assert.Multiple(() =>
            {
                Assert.That(result, Is.EqualTo(VSConstants.S_OK));
                Assert.That(moduleInfo[0].m_bstrDebugMessage ?? "", Does.Not.Contain("Include"));
                Assert.That(moduleInfo[0].m_bstrDebugMessage ?? "", Does.Not.Contain("Exclude"));
            });
        }
        public void GetInfo()
        {
            ulong  testCodeLoadAddress   = 456;
            ulong  testCodeSize          = 789;
            string testSymbolFile        = "symbol file";
            string testSymbolDirectory   = "c:\\symbol\\dir";
            string testPlatformFile      = "platform file";
            string testPlatformDirectory = "/platform/dir";

            var mockPlatformFileSpec = Substitute.For <SbFileSpec>();

            mockPlatformFileSpec.GetFilename().Returns(testPlatformFile);
            mockPlatformFileSpec.GetDirectory().Returns(testPlatformDirectory);

            var mockSymbolFileSpec = Substitute.For <SbFileSpec>();

            mockSymbolFileSpec.GetFilename().Returns(testSymbolFile);
            mockSymbolFileSpec.GetDirectory().Returns(testSymbolDirectory);

            _mockModule.GetPlatformFileSpec().Returns(mockPlatformFileSpec);
            _mockModule.GetSymbolFileSpec().Returns(mockSymbolFileSpec);
            _mockModule.GetCodeLoadAddress().Returns(testCodeLoadAddress);
            _mockModule.GetCodeSize().Returns(testCodeSize);
            _mockModule.Is64Bit().Returns(true);
            _mockModuleUtil.HasSymbolsLoaded(_mockModule).Returns(true);

            var flags = enum_MODULE_INFO_FIELDS.MIF_NAME | enum_MODULE_INFO_FIELDS.MIF_URL |
                        enum_MODULE_INFO_FIELDS.MIF_URLSYMBOLLOCATION |
                        enum_MODULE_INFO_FIELDS.MIF_LOADADDRESS |
                        enum_MODULE_INFO_FIELDS.MIF_PREFFEREDADDRESS |
                        enum_MODULE_INFO_FIELDS.MIF_SIZE | enum_MODULE_INFO_FIELDS.MIF_LOADORDER |
                        enum_MODULE_INFO_FIELDS.MIF_FLAGS;
            var moduleInfo = new MODULE_INFO[1];

            Assert.Multiple(() =>
            {
                Assert.That(_debugModule.GetInfo(flags, moduleInfo), Is.EqualTo(VSConstants.S_OK));
                Assert.That(moduleInfo[0].dwValidFields, Is.EqualTo(flags));
                Assert.That(moduleInfo[0].m_bstrName, Is.EqualTo(testPlatformFile));
                Assert.That(moduleInfo[0].m_bstrUrl,
                            Is.EqualTo(testPlatformDirectory + "/" + testPlatformFile));
                Assert.That(moduleInfo[0].m_bstrUrlSymbolLocation,
                            Is.EqualTo(testSymbolDirectory + "\\" + testSymbolFile));
                Assert.That(moduleInfo[0].m_addrLoadAddress, Is.EqualTo(testCodeLoadAddress));
                Assert.That(moduleInfo[0].m_dwSize, Is.EqualTo(testCodeSize));
                Assert.That(moduleInfo[0].m_dwLoadOrder, Is.EqualTo(_testLoadOrder));
                Assert.That(moduleInfo[0].m_dwModuleFlags,
                            Is.EqualTo(enum_MODULE_FLAGS.MODULE_FLAG_64BIT |
                                       enum_MODULE_FLAGS.MODULE_FLAG_SYMBOLS));
            });
        }
Exemple #10
0
        public int GetInfo(uint dwFields, MODULE_INFO[] pinfo)
        {
            var info = new MODULE_INFO();

            if ((dwFields & (uint)enum_MODULE_INFO_FIELDS.MIF_NAME) != 0)
            {
                info.m_bstrName     = Path.GetFileName(_engine.SoftDebugger.Session.VirtualMachine.RootDomain.GetEntryAssembly().Location);
                info.dwValidFields |= (uint)enum_MODULE_INFO_FIELDS.MIF_NAME;
            }

            if ((dwFields & (uint)enum_MODULE_INFO_FIELDS.MIF_URL) != 0)
            {
                info.m_bstrUrl      = _engine.SoftDebugger.Session.VirtualMachine.RootDomain.GetEntryAssembly().Location;
                info.dwValidFields |= (uint)enum_MODULE_INFO_FIELDS.MIF_URL;
            }

            if ((dwFields & (uint)enum_MODULE_INFO_FIELDS.MIF_LOADADDRESS) != 0)
            {
                info.m_addrLoadAddress = 0;
                info.dwValidFields    |= (uint)enum_MODULE_INFO_FIELDS.MIF_LOADADDRESS;
            }

            if ((dwFields & (uint)enum_MODULE_INFO_FIELDS.MIF_PREFFEREDADDRESS) != 0)
            {
                info.m_addrPreferredLoadAddress = 0;
                info.dwValidFields |= (uint)enum_MODULE_INFO_FIELDS.MIF_PREFFEREDADDRESS;
            }

            if ((dwFields & (uint)enum_MODULE_INFO_FIELDS.MIF_SIZE) != 0)
            {
                info.m_dwSize       = 0;
                info.dwValidFields |= (uint)enum_MODULE_INFO_FIELDS.MIF_SIZE;
            }

            if ((dwFields & (uint)enum_MODULE_INFO_FIELDS.MIF_LOADORDER) != 0)
            {
                info.m_dwLoadOrder  = 0;
                info.dwValidFields |= (uint)enum_MODULE_INFO_FIELDS.MIF_LOADORDER;
            }

            if ((dwFields & (uint)enum_MODULE_INFO_FIELDS.MIF_FLAGS) != 0)
            {
                info.m_dwModuleFlags = (uint)enum_MODULE_FLAGS.MODULE_FLAG_SYMBOLS;
                info.dwValidFields  |= (uint)enum_MODULE_INFO_FIELDS.MIF_FLAGS;
            }

            pinfo[0] = info;

            return(S_OK);
        }
Exemple #11
0
        public int GetInfo(enum_MODULE_INFO_FIELDS dwFields, MODULE_INFO[] pinfo)
        {
            DLog.Debug(DContext.VSDebuggerComCall, "Module.GetInfo");

            pinfo[0].m_addrLoadAddress = 0;
            pinfo[0].m_addrPreferredLoadAddress = 0;
            pinfo[0].m_bstrDebugMessage = "<none>";
            pinfo[0].m_bstrName = Name;
            pinfo[0].m_bstrUrl = "<unknown>";
            pinfo[0].m_bstrUrlSymbolLocation = "<unknown>";
            pinfo[0].m_bstrVersion = "<unknown>";
            pinfo[0].m_dwLoadOrder = 0;
            pinfo[0].m_dwModuleFlags = 0;
            pinfo[0].m_dwSize = 0;
            pinfo[0].dwValidFields = enum_MODULE_INFO_FIELDS.MIF_ALLFIELDS;

            return VSConstants.S_OK;
        }
Exemple #12
0
        // Gets the MODULE_INFO that describes this module.
        // This is how the debugger obtains most of the information about the module.
        int IDebugModule2.GetInfo(enum_MODULE_INFO_FIELDS dwFields, MODULE_INFO[] infoArray)
        {
            try {
                var info = new MODULE_INFO();

                if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_NAME) != 0) {
                    info.m_bstrName = System.IO.Path.GetFileName(m_script.Name);
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_NAME;
                }
                if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_URL) != 0) {
                    info.m_bstrUrl = m_script.Name;
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_URL;
                }
                infoArray[0] = info;

                return Constants.S_OK;
            } catch (Exception e) {
                return EngineUtils.UnexpectedException(e);
            }
        }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    #region IDebugModule2 Members

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    public override int GetInfo (enum_MODULE_INFO_FIELDS requestedFields, MODULE_INFO [] infoArray)
    {
      // 
      // Retrieve relevant requested data for this module.
      // 

      LoggingUtils.PrintFunction ();

      try
      {
        LoggingUtils.RequireOk (base.GetInfo (requestedFields, infoArray));
        
        return Constants.S_OK;
      }
      catch (Exception e)
      {
        LoggingUtils.HandleException (e);

        return Constants.E_FAIL;
      }
    }
Exemple #14
0
        // Gets the MODULE_INFO that describes this module.
        // This is how the debugger obtains most of the information about the module.
        int IDebugModule2.GetInfo(enum_MODULE_INFO_FIELDS dwFields, MODULE_INFO[] infoArray)
        {
            MODULE_INFO info = new MODULE_INFO();

            if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_NAME) != 0)
            {
                info.m_bstrName = DebuggedModule.Name;
                Debug.Assert(info.m_bstrName != null);
                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_NAME;
            }
            if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_URL) != 0)
            {
                info.m_bstrUrl = DebuggedModule.Filename;
                Debug.Assert(info.m_bstrUrl != null);
                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_URL;
            }
            if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_LOADORDER) != 0)
            {
                info.m_dwLoadOrder  = (uint)this.DebuggedModule.ModuleId;
                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_LOADORDER;
            }
            if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_URLSYMBOLLOCATION) != 0)
            {
                if (ModulePath.IsPythonSourceFile(DebuggedModule.Filename))
                {
                    info.m_bstrUrlSymbolLocation = DebuggedModule.Filename;
                }
                else
                {
                    info.m_bstrUrlSymbolLocation = string.Empty;
                }
                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_URLSYMBOLLOCATION;
            }

            infoArray[0] = info;

            return(VSConstants.S_OK);
        }
Exemple #15
0
 private static MODULE_INFO[] __GetModule(IDebugModuleLoadEvent2 debugEvent)
 {
     if (debugEvent != null)
     {
         var a_Context = (IDebugModule2)null;
         {
             var a_Context1 = "";
             var a_Context2 = 0;
             if (debugEvent.GetModule(out a_Context, ref a_Context1, ref a_Context2) != VSConstants.S_OK)
             {
                 return(null);
             }
         }
         {
             var a_Result = new MODULE_INFO[1];
             if (a_Context.GetInfo(enum_MODULE_INFO_FIELDS.MIF_ALLFIELDS, a_Result) == VSConstants.S_OK)
             {
                 return(a_Result);
             }
         }
     }
     return(null);
 }
Exemple #16
0
 public static extern bool GetModuleInformation(IntPtr hProcess, IntPtr hModule, ref MODULE_INFO lpModInfo, int cb);
        public int GetInfo(enum_MODULE_INFO_FIELDS dwFields, MODULE_INFO[] pinfo)
        {
            Log.Debug("ScriptProgramNode: IDebugModule2.GetInfo");
            if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_NAME) != 0)
            {
                pinfo[0].m_bstrName = FileName;
                pinfo[0].dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_NAME;
            }

            if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_FLAGS) != 0)
            {
                pinfo[0].m_dwModuleFlags = enum_MODULE_FLAGS.MODULE_FLAG_SYMBOLS;
                pinfo[0].dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_FLAGS;
            }

            if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_URLSYMBOLLOCATION) != 0)
            {
                pinfo[0].m_bstrUrlSymbolLocation = @".\";
                pinfo[0].dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_URLSYMBOLLOCATION;
            }

            return VSConstants.S_OK;
        }
Exemple #18
0
        /// <summary>
        /// Gets information about this module. (http://msdn.microsoft.com/en-ca/library/bb161975.aspx)
        /// </summary>
        /// <param name="dwFields"> A combination of flags from the MODULE_INFO_FIELDS enumeration that specify which fields of pInfo
        /// are to be filled out. </param>
        /// <param name="infoArray"> A MODULE_INFO structure that is filled in with a description of the module. </param>
        /// <returns> If successful, returns S_OK; otherwise, returns an error code. </returns>
        int IDebugModule2.GetInfo(enum_MODULE_INFO_FIELDS dwFields, MODULE_INFO[] infoArray)
        {
            try
            {
                MODULE_INFO info = new MODULE_INFO();

                if (dwFields.HasFlag(enum_MODULE_INFO_FIELDS.MIF_NAME))
                {
                    info.m_bstrName     = "";
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_NAME;
                }
                if (dwFields.HasFlag(enum_MODULE_INFO_FIELDS.MIF_URL))
                {
                    info.m_bstrUrl      = "";
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_URL;
                }
                if (dwFields.HasFlag(enum_MODULE_INFO_FIELDS.MIF_LOADADDRESS))
                {
                    info.m_addrLoadAddress = 0;
                    info.dwValidFields    |= enum_MODULE_INFO_FIELDS.MIF_LOADADDRESS;
                }
                if (dwFields.HasFlag(enum_MODULE_INFO_FIELDS.MIF_PREFFEREDADDRESS))
                {
                    // A debugger that actually supports showing the preferred base should crack the PE header and get
                    // that field. This debugger does not do that, so assume the module loaded where it was suppose to.
                    info.m_addrPreferredLoadAddress = 0;
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_PREFFEREDADDRESS;
                }
                if (dwFields.HasFlag(enum_MODULE_INFO_FIELDS.MIF_SIZE))
                {
                    info.m_dwSize       = 0;
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_SIZE;
                }
                if (dwFields.HasFlag(enum_MODULE_INFO_FIELDS.MIF_LOADORDER))
                {
                    info.m_dwLoadOrder  = 0;
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_LOADORDER;
                }
                if (dwFields.HasFlag(enum_MODULE_INFO_FIELDS.MIF_URLSYMBOLLOCATION))
                {
                    info.m_bstrUrlSymbolLocation = "";
                    info.dwValidFields          |= enum_MODULE_INFO_FIELDS.MIF_URLSYMBOLLOCATION;
                }
                if (dwFields.HasFlag(enum_MODULE_INFO_FIELDS.MIF_FLAGS))
                {
                    info.m_dwModuleFlags  = 0;
                    info.m_dwModuleFlags |= (enum_MODULE_FLAGS.MODULE_FLAG_SYMBOLS);
                    info.dwValidFields   |= enum_MODULE_INFO_FIELDS.MIF_FLAGS;
                }
                if (dwFields.HasFlag(enum_MODULE_INFO_FIELDS.MIF_VERSION))
                {
                    info.m_bstrVersion  = "";
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_VERSION;
                }
                if (dwFields.HasFlag(enum_MODULE_INFO_FIELDS.MIF_DEBUGMESSAGE))
                {
                    info.m_bstrDebugMessage = "";
                    info.dwValidFields     |= enum_MODULE_INFO_FIELDS.MIF_DEBUGMESSAGE;
                }

                infoArray[0] = info;

                return(VSConstants.S_OK);
            }
            catch (Exception e)
            {
                return(EngineUtils.UnexpectedException(e));
            }
        }
Exemple #19
0
        // IDebugModule3 represents a module that supports alternate locations of symbols and JustMyCode states.
        // The sample does not support alternate symbol locations or JustMyCode, but it does not display symbol load information 

        // Gets the MODULE_INFO that describes this module.
        // This is how the debugger obtains most of the information about the module.
        int IDebugModule3.GetInfo(enum_MODULE_INFO_FIELDS dwFields, MODULE_INFO[] pinfo) {
            return ((IDebugModule2)this).GetInfo(dwFields, pinfo);
        }
Exemple #20
0
        /// <summary>
        /// Gets information about this module. (http://msdn.microsoft.com/en-ca/library/bb161975.aspx)
        /// </summary>
        /// <param name="dwFields"> A combination of flags from the MODULE_INFO_FIELDS enumeration that specify which fields of pInfo 
        /// are to be filled out. </param>
        /// <param name="infoArray"> A MODULE_INFO structure that is filled in with a description of the module. </param>
        /// <returns> If successful, returns S_OK; otherwise, returns an error code. </returns>
        int IDebugModule2.GetInfo(enum_MODULE_INFO_FIELDS dwFields, MODULE_INFO[] infoArray)
        {
            try
            {
                MODULE_INFO info = new MODULE_INFO();

                if (dwFields.HasFlag(enum_MODULE_INFO_FIELDS.MIF_NAME))
                {
                    info.m_bstrName = "";
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_NAME;
                }
                if (dwFields.HasFlag(enum_MODULE_INFO_FIELDS.MIF_URL))
                {
                    info.m_bstrUrl = "";
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_URL;
                }
                if (dwFields.HasFlag(enum_MODULE_INFO_FIELDS.MIF_LOADADDRESS))
                {
                    info.m_addrLoadAddress = 0;
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_LOADADDRESS;
                }
                if (dwFields.HasFlag(enum_MODULE_INFO_FIELDS.MIF_PREFFEREDADDRESS))
                {
                    // A debugger that actually supports showing the preferred base should crack the PE header and get
                    // that field. This debugger does not do that, so assume the module loaded where it was suppose to.
                    info.m_addrPreferredLoadAddress = 0;
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_PREFFEREDADDRESS;
                }
                if (dwFields.HasFlag(enum_MODULE_INFO_FIELDS.MIF_SIZE))
                {
                    info.m_dwSize = 0;
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_SIZE;
                }
                if (dwFields.HasFlag(enum_MODULE_INFO_FIELDS.MIF_LOADORDER))
                {
                    info.m_dwLoadOrder = 0;
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_LOADORDER;
                }
                if (dwFields.HasFlag(enum_MODULE_INFO_FIELDS.MIF_URLSYMBOLLOCATION))
                {
                    info.m_bstrUrlSymbolLocation = "";
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_URLSYMBOLLOCATION;
                }
                if (dwFields.HasFlag(enum_MODULE_INFO_FIELDS.MIF_FLAGS))
                {
                    info.m_dwModuleFlags = 0;
                    info.m_dwModuleFlags |= (enum_MODULE_FLAGS.MODULE_FLAG_SYMBOLS);
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_FLAGS;
                }
                if (dwFields.HasFlag(enum_MODULE_INFO_FIELDS.MIF_VERSION))
                {
                    info.m_bstrVersion = "";
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_VERSION;
                }
                if (dwFields.HasFlag(enum_MODULE_INFO_FIELDS.MIF_DEBUGMESSAGE))
                {
                    info.m_bstrDebugMessage = "";
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_DEBUGMESSAGE;
                }

                infoArray[0] = info;

                return VSConstants.S_OK;
            }
            catch (Exception e)
            {
                return EngineUtils.UnexpectedException(e);
            }
        }
Exemple #21
0
        public int GetInfo(enum_MODULE_INFO_FIELDS fields, MODULE_INFO[] moduleInfo)
        {
            var        info             = new MODULE_INFO();
            SbFileSpec platformFileSpec = _lldbModule.GetPlatformFileSpec();

            if ((enum_MODULE_INFO_FIELDS.MIF_NAME & fields) != 0)
            {
                if (platformFileSpec != null)
                {
                    info.m_bstrName     = platformFileSpec.GetFilename();
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_NAME;
                }
            }

            // "URL" fills in the "Path" column in the Modules window.
            if ((enum_MODULE_INFO_FIELDS.MIF_URL & fields) != 0)
            {
                // The module paths are for remote files (on Linux).
                if (platformFileSpec != null)
                {
                    info.m_bstrUrl = FileUtil.PathCombineLinux(
                        platformFileSpec.GetDirectory(), platformFileSpec.GetFilename());
                }

                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_URL;
            }

            // "URLSYMBOLLOCATION" fills in the Symbol File Location column.
            if ((enum_MODULE_INFO_FIELDS.MIF_URLSYMBOLLOCATION & fields) != 0)
            {
                if (_moduleUtil.HasSymbolsLoaded(_lldbModule))
                {
                    // The symbol paths are for local files (on Windows).
                    SbFileSpec symbolFileSpec = _lldbModule.GetSymbolFileSpec();
                    if (symbolFileSpec != null)
                    {
                        info.m_bstrUrlSymbolLocation = Path.Combine(
                            symbolFileSpec.GetDirectory(), symbolFileSpec.GetFilename());
                        info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_URLSYMBOLLOCATION;
                    }
                }
            }

            if ((enum_MODULE_INFO_FIELDS.MIF_LOADADDRESS & fields) != 0)
            {
                info.m_addrLoadAddress = _lldbModule.GetCodeLoadAddress();
                info.dwValidFields    |= enum_MODULE_INFO_FIELDS.MIF_LOADADDRESS;
            }

            if ((enum_MODULE_INFO_FIELDS.MIF_PREFFEREDADDRESS & fields) != 0)
            {
                // TODO: Find the actual preferred load address rather than
                // pretending the module is loaded in the right place.
                // We may choose to ignore this, as samples do: extracting the preferred base
                // address from the library / executable seems nontrivial.
                // If m_addrLoadAddress is a different value, VS will show a warning on the icons
                // in the Modules window.
                info.m_addrPreferredLoadAddress = info.m_addrLoadAddress;
                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_PREFFEREDADDRESS;
            }

            if ((enum_MODULE_INFO_FIELDS.MIF_SIZE & fields) != 0)
            {
                info.m_dwSize       = (uint)_lldbModule.GetCodeSize();
                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_SIZE;
            }

            if ((enum_MODULE_INFO_FIELDS.MIF_LOADORDER & fields) != 0)
            {
                info.m_dwLoadOrder  = _loadOrder;
                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_LOADORDER;
            }

            if ((enum_MODULE_INFO_FIELDS.MIF_FLAGS & fields) != 0)
            {
                info.m_dwModuleFlags = 0;
                if (_moduleUtil.HasSymbolsLoaded(_lldbModule))
                {
                    info.m_dwModuleFlags |= enum_MODULE_FLAGS.MODULE_FLAG_SYMBOLS;
                }

                if (_lldbModule.Is64Bit())
                {
                    info.m_dwModuleFlags |= enum_MODULE_FLAGS.MODULE_FLAG_64BIT;
                }

                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_FLAGS;
            }

            if ((enum_MODULE_INFO_FIELDS.MIF_DEBUGMESSAGE & fields) != 0)
            {
                if (!_moduleUtil.HasSymbolsLoaded(_lldbModule))
                {
                    var inclusionSetting = _symbolSettingsProvider.GetInclusionSettings();
                    if (!inclusionSetting.IsModuleIncluded(ModuleName))
                    {
                        info.m_bstrDebugMessage = SymbolInclusionSettings.ModuleExcludedMessage;
                    }
                }

                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_DEBUGMESSAGE;
            }

            moduleInfo[0] = info;
            return(VSConstants.S_OK);
        }
      int IDebugBeforeSymbolSearchEvent2.GetModuleName (out string pbstrModuleName)
      {
        LoggingUtils.PrintFunction ();

        try
        {
          MODULE_INFO [] moduleInfo = new MODULE_INFO [1];

          LoggingUtils.RequireOk (m_debugModule.GetInfo (enum_MODULE_INFO_FIELDS.MIF_NAME, moduleInfo));

          pbstrModuleName = moduleInfo [0].m_bstrName;

          return Constants.S_OK;
        }
        catch (System.Exception e)
        {
          LoggingUtils.HandleException (e);

          pbstrModuleName = string.Empty;

          return Constants.E_FAIL;
        }
      }
      int IDebugModuleLoadEvent2.GetModule (out IDebugModule2 module, ref string debugMessage, ref int fIsLoad)
      {
        LoggingUtils.PrintFunction ();

        module = m_debugModule;

        try
        {
          MODULE_INFO [] moduleInfo = new MODULE_INFO [1];

          LoggingUtils.RequireOk (module.GetInfo (enum_MODULE_INFO_FIELDS.MIF_NAME | enum_MODULE_INFO_FIELDS.MIF_LOADADDRESS, moduleInfo));

          debugMessage = string.Format ("{0}: {1}", ((m_loadModule) ? "Loaded" : "Unloaded"), moduleInfo [0].m_bstrName);

          fIsLoad = (m_loadModule) ? 1 : 0;

          return Constants.S_OK;
        }
        catch (System.Exception e)
        {
          LoggingUtils.HandleException (e);

          return Constants.E_FAIL; 
        }
      }
Exemple #24
0
        // Gets the MODULE_INFO that describes this module.
        // This is how the debugger obtains most of the information about the module.
        int IDebugModule2.GetInfo(enum_MODULE_INFO_FIELDS dwFields, MODULE_INFO[] infoArray)
        {
            try
            {
                MODULE_INFO info = new MODULE_INFO();

                if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_NAME) != 0)
                {
                    info.m_bstrName     = System.IO.Path.GetFileName(this.DebuggedModule.Name);
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_NAME;
                }
                if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_URL) != 0)
                {
                    info.m_bstrUrl      = this.DebuggedModule.Name;
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_URL;
                }
                if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_LOADADDRESS) != 0)
                {
                    info.m_addrLoadAddress = (ulong)this.DebuggedModule.BaseAddress;
                    info.dwValidFields    |= enum_MODULE_INFO_FIELDS.MIF_LOADADDRESS;
                }
                if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_PREFFEREDADDRESS) != 0)
                {
                    // A debugger that actually supports showing the preferred base should read the PE header and get
                    // that field. This debugger does not do that, so assume the module loaded where it was suppose to.
                    info.m_addrPreferredLoadAddress = (ulong)this.DebuggedModule.BaseAddress;
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_PREFFEREDADDRESS;;
                }
                if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_SIZE) != 0)
                {
                    info.m_dwSize       = (uint)this.DebuggedModule.Size;
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_SIZE;
                }
                if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_LOADORDER) != 0)
                {
                    info.m_dwLoadOrder  = this.DebuggedModule.GetLoadOrder();
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_LOADORDER;
                }
                if (this.Process.LaunchOptions is LocalLaunchOptions localLaunchOptions &&
                    string.IsNullOrWhiteSpace(localLaunchOptions.MIDebuggerServerAddress) && string.IsNullOrWhiteSpace(localLaunchOptions.DebugServer) &&
                    (dwFields & enum_MODULE_INFO_FIELDS.MIF_TIMESTAMP) != 0 &&
                    this.DebuggedModule.Name != null)
                {
                    try
                    {
                        long ft   = File.GetLastWriteTimeUtc(this.DebuggedModule.Name).ToFileTime();
                        uint low  = (uint)(ft & 0xFFFFFFFF);
                        uint high = (uint)((ulong)(ft >> 32));
                        info.m_TimeStamp = new FILETIME()
                        {
                            dwLowDateTime  = low,
                            dwHighDateTime = high
                        };
                        info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_TIMESTAMP;
                    } catch {}
                }
                if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_URLSYMBOLLOCATION) != 0)
                {
                    if (this.DebuggedModule.SymbolsLoaded)
                    {
                        info.m_bstrUrlSymbolLocation = this.DebuggedModule.SymbolPath;
                        info.dwValidFields          |= enum_MODULE_INFO_FIELDS.MIF_URLSYMBOLLOCATION;
                    }
                }
                if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_FLAGS) != 0)
                {
                    info.m_dwModuleFlags = 0;
                    if (this.DebuggedModule.SymbolsLoaded)
                    {
                        info.m_dwModuleFlags |= (enum_MODULE_FLAGS.MODULE_FLAG_SYMBOLS);
                    }

                    if (this.Process.Is64BitArch)
                    {
                        info.m_dwModuleFlags |= enum_MODULE_FLAGS.MODULE_FLAG_64BIT;
                    }

                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_FLAGS;
                }


                infoArray[0] = info;

                return(Constants.S_OK);
            }
            catch (MIException e)
            {
                return(e.HResult);
            }
            catch (Exception e)
            {
                return(EngineUtils.UnexpectedException(e));
            }
        }
Exemple #25
0
        // Gets the MODULE_INFO that describes this module.
        // This is how the debugger obtains most of the information about the module.
        int IDebugModule2.GetInfo(enum_MODULE_INFO_FIELDS dwFields, MODULE_INFO[] infoArray)
        {
            try
            {
                MODULE_INFO info = new MODULE_INFO();

                if (dwFields.HasFlag(enum_MODULE_INFO_FIELDS.MIF_NAME))
                {
                    //info.m_bstrName = System.IO.Path.GetFileName(this.DebuggedModule.Name);
                    info.m_bstrName = "DEADBEEF";
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_NAME;
                }
                if (dwFields.HasFlag(enum_MODULE_INFO_FIELDS.MIF_URL))
                {
                    //info.m_bstrUrl = this.DebuggedModule.Name;
                    info.m_bstrUrl = "DEADBEEF";
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_URL;
                }
                if (dwFields.HasFlag(enum_MODULE_INFO_FIELDS.MIF_LOADADDRESS))
                {
                    //info.m_addrLoadAddress = (ulong)this.DebuggedModule.BaseAddress;
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_LOADADDRESS;
                }
                if (dwFields.HasFlag(enum_MODULE_INFO_FIELDS.MIF_PREFFEREDADDRESS))
                {
                    // A debugger that actually supports showing the preferred base should crack the PE header and get 
                    // that field. This debugger does not do that, so assume the module loaded where it was suppose to.                   
                    //info.m_addrPreferredLoadAddress = (ulong)this.DebuggedModule.BaseAddress;
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_PREFFEREDADDRESS;
                }
                if (dwFields.HasFlag(enum_MODULE_INFO_FIELDS.MIF_SIZE))
                {
                    //info.m_dwSize = this.DebuggedModule.Size;
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_SIZE;
                }
                if (dwFields.HasFlag(enum_MODULE_INFO_FIELDS.MIF_LOADORDER))
                {
                    //info.m_dwLoadOrder = this.DebuggedModule.GetLoadOrder();
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_LOADORDER;
                }
                if (dwFields.HasFlag(enum_MODULE_INFO_FIELDS.MIF_URLSYMBOLLOCATION))
                {
                    //if (this.DebuggedModule.SymbolsLoaded)
                    {
                        //info.m_bstrUrlSymbolLocation = this.DebuggedModule.SymbolPath;
                        info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_URLSYMBOLLOCATION;
                    }
                }
                if (dwFields.HasFlag(enum_MODULE_INFO_FIELDS.MIF_FLAGS))
                {
                    info.m_dwModuleFlags = 0;
                    //if (this.DebuggedModule.SymbolsLoaded)
                    {
                        info.m_dwModuleFlags |= (enum_MODULE_FLAGS.MODULE_FLAG_SYMBOLS);
                    }
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_FLAGS;
                }
                
                
                infoArray[0] = info;

                return VSConstants.S_OK;
            }
            //catch (ComponentException e)
            //{
            //    return e.HResult;
            //}
            catch (Exception e)
            {
                return EngineUtils.UnexpectedException(e);
            }
        }
Exemple #26
0
 int IDebugModule3.GetInfo(enum_MODULE_INFO_FIELDS dwFields, MODULE_INFO[] pinfo) {
     throw new NotImplementedException();
 }
Exemple #27
0
        public int GetInfo(enum_MODULE_INFO_FIELDS dwFields, MODULE_INFO[] pinfo)
        {
            var info = new MODULE_INFO();

            if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_NAME) != 0)
            {
                info.m_bstrName     = System.IO.Path.GetFileName(engine.Session.VirtualMachine.RootDomain.GetEntryAssembly().Location);
                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_NAME;
            }
            if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_URL) != 0)
            {
                info.m_bstrUrl      = engine.Session.VirtualMachine.RootDomain.GetEntryAssembly().Location;
                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_URL;
            }
            if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_LOADADDRESS) != 0)
            {
                info.m_addrLoadAddress = 0;
                info.dwValidFields    |= enum_MODULE_INFO_FIELDS.MIF_LOADADDRESS;
            }
            if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_PREFFEREDADDRESS) != 0)
            {
                info.m_addrPreferredLoadAddress = 0;
                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_PREFFEREDADDRESS;
            }
            if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_SIZE) != 0)
            {
                info.m_dwSize       = 0;
                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_SIZE;
            }
            if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_LOADORDER) != 0)
            {
                info.m_dwLoadOrder  = 0;
                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_LOADORDER;
            }
            if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_URLSYMBOLLOCATION) != 0)
            {
/*
 *              if (this.DebuggedModule.SymbolsLoaded)
 *              {
 *                  info.m_bstrUrlSymbolLocation = this.DebuggedModule.SymbolPath;
 *                  info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_URLSYMBOLLOCATION;
 *              }
 */
            }
            if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_FLAGS) != 0)
            {
                info.m_dwModuleFlags = 0;
//                if (this.DebuggedModule.SymbolsLoaded)
//                {
                info.m_dwModuleFlags |= (enum_MODULE_FLAGS.MODULE_FLAG_SYMBOLS);
//                }

/*
 *              if (this.Process.Is64BitArch)
 *              {
 *                  info.m_dwModuleFlags |= enum_MODULE_FLAGS.MODULE_FLAG_64BIT;
 *              }
 */

                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_FLAGS;
            }

            pinfo[0] = info;

            return(VSConstants.S_OK);
        }
        // Gets the MODULE_INFO that describes this module.
        // This is how the debugger obtains most of the information about the module.
        int IDebugModule2.GetInfo(enum_MODULE_INFO_FIELDS dwFields, MODULE_INFO[] infoArray)
        {
            try
            {
                MODULE_INFO info = new MODULE_INFO();

                if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_NAME) != 0)
                {
                    info.m_bstrName     = System.IO.Path.GetFileName(this.DebuggedModule.Name);
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_NAME;
                }
                if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_URL) != 0)
                {
                    info.m_bstrUrl      = this.DebuggedModule.Name;
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_URL;
                }

                /*if ((dwFields & (uint)enum_MODULE_INFO_FIELDS.MIF_LOADADDRESS) != 0)
                 * {
                 *  info.m_addrLoadAddress = (ulong)this.DebuggedModule.BaseAddress;
                 *  info.dwValidFields |= (uint)enum_MODULE_INFO_FIELDS.MIF_LOADADDRESS;
                 * }
                 * if ((dwFields & (uint)enum_MODULE_INFO_FIELDS.MIF_PREFFEREDADDRESS) != 0)
                 * {
                 *  // A debugger that actually supports showing the preferred base should crack the PE header and get
                 *  // that field. This debugger does not do that, so assume the module loaded where it was suppose to.
                 *  info.m_addrPreferredLoadAddress = (ulong)this.DebuggedModule.BaseAddress;
                 *  info.dwValidFields |= (uint)enum_MODULE_INFO_FIELDS.MIF_PREFFEREDADDRESS; ;
                 * }
                 * if ((dwFields & (uint)enum_MODULE_INFO_FIELDS.MIF_SIZE) != 0)
                 * {
                 *  info.m_dwSize = this.DebuggedModule.Size;
                 *  info.dwValidFields |= (uint)enum_MODULE_INFO_FIELDS.MIF_SIZE;
                 * }
                 * if ((dwFields & (uint)enum_MODULE_INFO_FIELDS.MIF_LOADORDER) != 0)
                 * {
                 *  info.m_dwLoadOrder = this.DebuggedModule.GetLoadOrder();
                 *  info.dwValidFields |= (uint)enum_MODULE_INFO_FIELDS.MIF_LOADORDER;
                 * }
                 * if ((dwFields & (uint)enum_MODULE_INFO_FIELDS.MIF_URLSYMBOLLOCATION) != 0)
                 * {
                 *  if (this.DebuggedModule.SymbolsLoaded)
                 *  {
                 *      info.m_bstrUrlSymbolLocation = this.DebuggedModule.SymbolPath;
                 *      info.dwValidFields |= (uint)enum_MODULE_INFO_FIELDS.MIF_URLSYMBOLLOCATION;
                 *  }
                 * }
                 * if ((dwFields & (uint)enum_MODULE_INFO_FIELDS.MIF_FLAGS) != 0)
                 * {
                 *  info.m_dwModuleFlags = 0;
                 *  if (this.DebuggedModule.SymbolsLoaded)
                 *  {
                 *      info.m_dwModuleFlags |= (uint)(enum_MODULE_FLAGS.MODULE_FLAG_SYMBOLS);
                 *  }
                 *  info.dwValidFields |= (uint)enum_MODULE_INFO_FIELDS.MIF_FLAGS;
                 * }*/


                infoArray[0] = info;

                return(EngineConstants.S_OK);
            }
            catch (ComponentException e)
            {
                return(e.HRESULT);
            }
            catch (Exception e)
            {
                return(EngineUtils.UnexpectedException(e));
            }
        }
        // Token: 0x060000B8 RID: 184 RVA: 0x00003D28 File Offset: 0x00001F28
        public int GetInfo(enum_MODULE_INFO_FIELDS dwFields, MODULE_INFO[] pinfo)
        {
            int result;

            try
            {
                MODULE_INFO module_INFO = default(MODULE_INFO);
                if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_NAME) != 0)
                {
                    module_INFO.m_bstrName     = Path.GetFileName(this.assembly.Location);
                    module_INFO.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_NAME;
                }
                bool flag = false;
                if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_URL) != 0)
                {
                    module_INFO.m_bstrUrl = this.FindLocalLocation(this.assembly);
                    if (!string.IsNullOrEmpty(module_INFO.m_bstrUrl))
                    {
                        flag = true;
                    }
                    module_INFO.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_URL;
                }
                if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_VERSION) != 0)
                {
                    module_INFO.m_bstrVersion  = this.assembly.GetName().Version.ToString();
                    module_INFO.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_VERSION;
                }
                if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_LOADADDRESS) != 0)
                {
                    module_INFO.m_addrLoadAddress = (ulong)this.assembly.GetAssemblyObject().Address;
                    module_INFO.dwValidFields    |= enum_MODULE_INFO_FIELDS.MIF_LOADADDRESS;
                    if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_PREFFEREDADDRESS) != 0)
                    {
                        module_INFO.m_addrPreferredLoadAddress = module_INFO.m_addrLoadAddress;
                        module_INFO.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_PREFFEREDADDRESS;
                    }
                }
                string text = this.FindSymbolLocation(this.assembly);
                if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_URLSYMBOLLOCATION) != 0 && text != null)
                {
                    module_INFO.m_bstrUrlSymbolLocation = text;
                    module_INFO.dwValidFields          |= enum_MODULE_INFO_FIELDS.MIF_URLSYMBOLLOCATION;
                }
                if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_FLAGS) != 0)
                {
                    module_INFO.m_dwModuleFlags = 0;
                    if (text != null)
                    {
                        module_INFO.m_dwModuleFlags |= enum_MODULE_FLAGS.MODULE_FLAG_SYMBOLS;
                    }
                    else if (flag && (dwFields & enum_MODULE_INFO_FIELDS.MIF_DEBUGMESSAGE) != 0)
                    {
                        module_INFO.m_bstrDebugMessage = "Symbols loaded in VM";
                        module_INFO.dwValidFields     |= enum_MODULE_INFO_FIELDS.MIF_DEBUGMESSAGE;
                    }
                    if (this.assembly.GetName().ProcessorArchitecture == ProcessorArchitecture.IA64)
                    {
                        module_INFO.m_dwModuleFlags |= enum_MODULE_FLAGS.MODULE_FLAG_64BIT;
                    }
                    module_INFO.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_FLAGS;
                }
                pinfo[0] = module_INFO;
                result   = 0;
            }
            catch (Exception ex)
            {
                result = ex.HResult;
            }
            return(result);
        }
Exemple #30
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        #region IDebugModule2 Members

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public virtual int GetInfo(enum_MODULE_INFO_FIELDS requestedFields, MODULE_INFO [] infoArray)
        {
            //
            // Retrieve relevant requested data for this module.
            //

            LoggingUtils.PrintFunction();

            try
            {
                infoArray [0] = new MODULE_INFO();

                if ((requestedFields & enum_MODULE_INFO_FIELDS.MIF_NAME) != 0)
                {
                    infoArray [0].m_bstrName = Name;

                    infoArray [0].dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_NAME;
                }

                if ((requestedFields & enum_MODULE_INFO_FIELDS.MIF_URL) != 0)
                {
                    infoArray [0].m_bstrUrl = RemotePath;

                    infoArray [0].dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_URL;
                }

                if ((requestedFields & enum_MODULE_INFO_FIELDS.MIF_VERSION) != 0)
                {
                    infoArray [0].m_bstrVersion = Version;

                    infoArray [0].dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_VERSION;
                }

                if ((requestedFields & enum_MODULE_INFO_FIELDS.MIF_DEBUGMESSAGE) != 0)
                {
                    infoArray [0].m_bstrDebugMessage = RemotePath;

                    infoArray [0].dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_DEBUGMESSAGE;
                }

                if ((requestedFields & enum_MODULE_INFO_FIELDS.MIF_LOADADDRESS) != 0)
                {
                    infoArray [0].m_addrLoadAddress = RemoteLoadAddress;

                    infoArray [0].dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_LOADADDRESS;
                }

                if ((requestedFields & enum_MODULE_INFO_FIELDS.MIF_PREFFEREDADDRESS) != 0)
                {
                    // Assume the module loaded where it was suppose to.

                    infoArray [0].m_addrPreferredLoadAddress = RemoteLoadAddress;

                    infoArray [0].dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_PREFFEREDADDRESS;
                }

                if ((requestedFields & enum_MODULE_INFO_FIELDS.MIF_SIZE) != 0)
                {
                    infoArray [0].m_dwSize = Size;

                    infoArray [0].dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_SIZE;
                }

                if ((requestedFields & enum_MODULE_INFO_FIELDS.MIF_LOADORDER) != 0)
                {
                    infoArray [0].m_dwLoadOrder = 0;

                    infoArray [0].dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_LOADORDER;
                }

                if ((requestedFields & enum_MODULE_INFO_FIELDS.MIF_TIMESTAMP) != 0)
                {
                }

                if ((requestedFields & enum_MODULE_INFO_FIELDS.MIF_URLSYMBOLLOCATION) != 0)
                {
                    infoArray [0].m_bstrUrlSymbolLocation = "file://" + SymbolsPath;

                    infoArray [0].dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_URLSYMBOLLOCATION;
                }

                if ((requestedFields & enum_MODULE_INFO_FIELDS.MIF_FLAGS) != 0)
                {
                    infoArray [0].m_dwModuleFlags = enum_MODULE_FLAGS.MODULE_FLAG_NONE;

                    if (SymbolsLoaded)
                    {
                        infoArray [0].m_dwModuleFlags |= enum_MODULE_FLAGS.MODULE_FLAG_SYMBOLS;
                    }

                    infoArray [0].dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_FLAGS;
                }

                return(Constants.S_OK);
            }
            catch (Exception e)
            {
                LoggingUtils.HandleException(e);

                return(Constants.E_FAIL);
            }
        }
 public int GetInfo(enum_MODULE_INFO_FIELDS dwFields, MODULE_INFO[] pinfo)
 {
     throw new NotImplementedException();
 }