Example #1
0
        /// <summary>
        /// Detects if a native module represents a CLR and if so provides the debugging interface
        /// and versioning information
        /// </summary>
        /// <param name="moduleBaseAddress">The native base address of a module which might be a CLR</param>
        /// <param name="dataTarget">The process abstraction which can be used for inspection</param>
        /// <param name="libraryProvider">A callback interface for locating version specific debug libraries
        /// such as mscordbi.dll and mscordacwks.dll</param>
        /// <param name="maxDebuggerSupportedVersion">The highest version of the CLR/debugging libraries which
        /// the caller can support</param>
        /// <param name="version">The version of the CLR detected or null if no CLR was detected</param>
        /// <param name="flags">Flags which have additional information about the CLR.
        /// See ClrDebuggingProcessFlags for more details</param>
        /// <returns>The CLR's debugging interface</returns>
        public ICorDebugProcess OpenVirtualProcess(ulong moduleBaseAddress,
                                                   ICorDebugDataTarget dataTarget,
                                                   ICLRDebuggingLibraryProvider libraryProvider,
                                                   Version maxDebuggerSupportedVersion,
                                                   out Version version,
                                                   out ClrDebuggingProcessFlags flags)
        {
            ICorDebugProcess process;
            int hr = TryOpenVirtualProcess(moduleBaseAddress, dataTarget, libraryProvider, maxDebuggerSupportedVersion, out version, out flags, out process);

            if (hr < 0)
            {
                throw new COMException("Failed to OpenVirtualProcess for module at " + moduleBaseAddress + ".", hr);
            }
            return(process);
        }
Example #2
0
        /// <summary>
        /// Version of the above that doesn't throw exceptions on failure
        /// </summary>
        public int TryOpenVirtualProcess(
            ulong moduleBaseAddress,
            ICorDebugDataTarget dataTarget,
            ICLRDebuggingLibraryProvider libraryProvider,
            Version maxDebuggerSupportedVersion,
            out Version version,
            out ClrDebuggingProcessFlags flags,
            out ICorDebugProcess process)
        {
            ClrDebuggingVersion maxSupport = new ClrDebuggingVersion();
            ClrDebuggingVersion clrVersion = new ClrDebuggingVersion();

            maxSupport.StructVersion = 0;
            maxSupport.Major         = (short)maxDebuggerSupportedVersion.Major;
            maxSupport.Minor         = (short)maxDebuggerSupportedVersion.Minor;
            maxSupport.Build         = (short)maxDebuggerSupportedVersion.Build;
            maxSupport.Revision      = (short)maxDebuggerSupportedVersion.Revision;
            object processIface = null;

            clrVersion.StructVersion = 0;
            Guid iid = typeof(ICorDebugProcess).GetGuid();

            int result = _clrDebugging.OpenVirtualProcess(
                moduleBaseAddress,
                dataTarget,
                libraryProvider,
                ref maxSupport,
                ref iid,
                out processIface,
                ref clrVersion,
                out flags);

            // This may be set regardless of success/failure
            version = new Version(clrVersion.Major, clrVersion.Minor, clrVersion.Build, clrVersion.Revision);

            if (result < 0)
            {
                // OpenVirtualProcess failed
                process = null;
                return(result);
            }

            // Success
            process = (ICorDebugProcess)processIface;
            return(0);
        }
Example #3
0
 public CorProcess OpenVirtualProcess(ulong moduleBaseAddress,
     ICorDebugDataTarget dataTarget,
     ICLRDebuggingLibraryProvider libraryProvider,
     Version maxDebuggerSupportedVersion,
     out Version version,
     out ClrDebuggingProcessFlags flags)
 {
     CorProcess process;
     int hr = TryOpenVirtualProcess(moduleBaseAddress, dataTarget, libraryProvider, maxDebuggerSupportedVersion, out version, out flags, out process);
     if (hr < 0)
         throw new COMException("Failed to OpenVirtualProcess for module at " + moduleBaseAddress + ".", hr);
     return process;
 }
Example #4
0
        public int TryOpenVirtualProcess(ulong moduleBaseAddress,
            ICorDebugDataTarget dataTarget,
            ICLRDebuggingLibraryProvider libraryProvider,
            Version maxDebuggerSupportedVersion,
            out Version version,
            out ClrDebuggingProcessFlags flags,
            out CorProcess process)
        {
            ClrDebuggingVersion maxSupport = new ClrDebuggingVersion();
            ClrDebuggingVersion clrVersion = new ClrDebuggingVersion();
            maxSupport.StructVersion = 0;
            maxSupport.Major = (short)maxDebuggerSupportedVersion.Major;
            maxSupport.Minor = (short)maxDebuggerSupportedVersion.Minor;
            maxSupport.Build = (short)maxDebuggerSupportedVersion.Build;
            maxSupport.Revision = (short)maxDebuggerSupportedVersion.Revision;
            object processIface = null;
            clrVersion.StructVersion = 0;
            Guid iid = typeof(ICorDebugProcess).GUID;

            int result = m_CLRDebugging.OpenVirtualProcess(moduleBaseAddress, dataTarget, libraryProvider,
                ref maxSupport, ref iid, out processIface, ref clrVersion, out flags);

            // This may be set regardless of success/failure
            version = new Version(clrVersion.Major, clrVersion.Minor, clrVersion.Build, clrVersion.Revision);

            if (result < 0)
            {
                // OpenVirtualProcess failed
                process = null;
                return result;
            }

            // Success
            process = CorProcess.GetCorProcess((ICorDebugProcess)processIface);
            return 0;
        }