Esempio n. 1
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);
        }
        /// <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).GUID;

            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;
        }