예제 #1
0
 // Gets a program node, given a specific process ID.
 int IDebugProgramProvider2.GetProviderProgramNode(enum_PROVIDER_FLAGS Flags, IDebugDefaultPort2 port, AD_PROCESS_ID ProcessId, ref Guid guidEngine, ulong programId,
                                                   out IDebugProgramNode2 programNode)
 {
     // This method is used for Just-In-Time debugging support, which this program provider does not support
     programNode = null;
     return(VSConstants.E_NOTIMPL);
 }
예제 #2
0
        public int GetProviderProcessData(enum_PROVIDER_FLAGS Flags, IDebugDefaultPort2 pPort, AD_PROCESS_ID ProcessId, CONST_GUID_ARRAY EngineFilter, PROVIDER_PROCESS_DATA[] pProcess)
        {
            Log.Debug("ProgramProvider: GetProviderProcessData");

            if (Flags.HasFlag(enum_PROVIDER_FLAGS.PFLAG_GET_PROGRAM_NODES))
            {
                var process = Process.GetProcessById((int) ProcessId.dwProcessId);
                foreach (ProcessModule module in process.Modules)
                {
                    if (module.ModuleName.StartsWith("System.Management.Automation", StringComparison.OrdinalIgnoreCase))
                    {
                        var node = new ScriptProgramNode(new ScriptDebugProcess(pPort, ProcessId.dwProcessId));

                        var programNodes = new[] { Marshal.GetComInterfaceForObject(node, typeof(IDebugProgramNode2)) };

                        var destinationArray = Marshal.AllocCoTaskMem(IntPtr.Size * programNodes.Length);
                        Marshal.Copy(programNodes, 0, destinationArray, programNodes.Length);

                        pProcess[0].Fields = enum_PROVIDER_FIELDS.PFIELD_PROGRAM_NODES;
                        pProcess[0].ProgramNodes.Members = destinationArray;
                        pProcess[0].ProgramNodes.dwCount = (uint)programNodes.Length;

                        return VSConstants.S_OK;
                    }
                }
            }

            return VSConstants.S_FALSE;
        }
 public int GetProviderProgramNode(enum_PROVIDER_FLAGS Flags, IDebugDefaultPort2 pPort, AD_PROCESS_ID ProcessId,
                                   ref Guid guidEngine, ulong programId, out IDebugProgramNode2 ppProgramNode)
 {
     DebugHelper.TraceEnteringMethod();
     ppProgramNode = null;
     return(VSConstants.S_OK);
 }
예제 #4
0
        public int GetProviderProcessData(enum_PROVIDER_FLAGS Flags, IDebugDefaultPort2 pPort, AD_PROCESS_ID ProcessId, CONST_GUID_ARRAY EngineFilter, PROVIDER_PROCESS_DATA[] pProcess)
        {
            Log.Debug("ProgramProvider: GetProviderProcessData");

            if (Flags.HasFlag(enum_PROVIDER_FLAGS.PFLAG_GET_PROGRAM_NODES))
            {
                var process = Process.GetProcessById((int)ProcessId.dwProcessId);
                foreach (ProcessModule module in process.Modules)
                {
                    if (module.ModuleName.StartsWith("System.Management.Automation", StringComparison.OrdinalIgnoreCase))
                    {
                        var node = new ScriptProgramNode(new ScriptDebugProcess(pPort, ProcessId.dwProcessId));

                        var programNodes = new[] { Marshal.GetComInterfaceForObject(node, typeof(IDebugProgramNode2)) };

                        var destinationArray = Marshal.AllocCoTaskMem(IntPtr.Size * programNodes.Length);
                        Marshal.Copy(programNodes, 0, destinationArray, programNodes.Length);

                        pProcess[0].Fields = enum_PROVIDER_FIELDS.PFIELD_PROGRAM_NODES;
                        pProcess[0].ProgramNodes.Members = destinationArray;
                        pProcess[0].ProgramNodes.dwCount = (uint)programNodes.Length;

                        return(VSConstants.S_OK);
                    }
                }
            }

            return(VSConstants.S_FALSE);
        }
        /// <summary>
        /// Allows the process to be notified of port events.
        /// </summary>
        /// <param name="flags">A combination of flags from the <see cref="PROVIDER_FLAGS"/> enumeration.</param>
        /// <param name="port">The port the calling process is running on.</param>
        /// <param name="processId">An <see cref="AD_PROCESS_ID"/> structure holding the ID of the process that contains the program in question.</param>
        /// <param name="engineFilter">An array of GUIDs of debug engines associated with the process.</param>
        /// <param name="guidLaunchingEngine">GUID of the debug engine that launched this process (if any).</param>
        /// <param name="eventCallback">An <see cref="IDebugPortNotify2"/> object that receives the event notifications.</param>
        /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
        /// <remarks>
        /// When a caller wants to remove an event handler established with a previous call to this method,
        /// the caller passes the same parameters as it did the first time but leaves off the PFLAG_REASON_WATCH flag.
        /// </remarks>
        public int WatchForProviderEvents(enum_PROVIDER_FLAGS flags, IDebugDefaultPort2 port, AD_PROCESS_ID processId, CONST_GUID_ARRAY engineFilter, ref Guid guidLaunchingEngine, IDebugPortNotify2 eventCallback)
        {
            /* The following flags are typical for this call:
             *
             *   PFLAG_REMOTE_PORT:             Caller is running on remote machine.
             *   PFLAG_DEBUGGEE:                Caller is currently being debugged (additional information about marshalling is returned for each node).
             *   PFLAG_ATTACHED_TO_DEBUGGEE:    Caller was attached to but not launched by the debugger.
             *   PFLAG_REASON_WATCH:            Caller wants to watch for events. If this flag is not set, then the callback event is removed and the caller no longer receives notifications.
             */

            // make sure this request is relevant to this debug engine
            if (!engineFilter.AsEnumerable().Contains(JavaDebuggerConstants.JavaDebugEngineGuid))
            {
                return(VSConstants.S_OK);
            }

            ProviderRequestData requestData = new ProviderRequestData(flags, port, processId, guidLaunchingEngine, eventCallback);

            if ((flags & enum_PROVIDER_FLAGS.PFLAG_REASON_WATCH) == 0)
            {
                _subscribers.Remove(requestData);
                return(VSConstants.S_OK);
            }

            _subscribers.Add(requestData);
            eventCallback.AddProgramNode(new JavaDebugProgram(port.GetProcess(processId)));
            return(VSConstants.S_OK);
        }
예제 #6
0
    // Obtains information about programs running, filtered in a variety of ways.
    int IDebugProgramProvider2.GetProviderProcessData(enum_PROVIDER_FLAGS Flags, IDebugDefaultPort2 port, AD_PROCESS_ID ProcessId, CONST_GUID_ARRAY EngineFilter, PROVIDER_PROCESS_DATA[] processArray) {
      processArray[0] = new PROVIDER_PROCESS_DATA();

      if (Flags.HasFlag(enum_PROVIDER_FLAGS.PFLAG_GET_PROGRAM_NODES)) {
        // The debugger is asking the engine to return the program nodes it can debug. The 
        // sample engine claims that it can debug all processes, and returns exsactly one
        // program node for each process. A full-featured debugger may wish to examine the
        // target process and determine if it understands how to debug it.

        var node = (IDebugProgramNode2)(new AD7ProgramNode(ProcessId.guidProcessId));

        IntPtr[] programNodes = { Marshal.GetComInterfaceForObject(node, typeof(IDebugProgramNode2)) };

        IntPtr destinationArray = Marshal.AllocCoTaskMem(IntPtr.Size * programNodes.Length);
        Marshal.Copy(programNodes, 0, destinationArray, programNodes.Length);

        processArray[0].Fields = enum_PROVIDER_FIELDS.PFIELD_PROGRAM_NODES;
        processArray[0].ProgramNodes.Members = destinationArray;
        processArray[0].ProgramNodes.dwCount = (uint)programNodes.Length;

        return VSConstants.S_OK;
      }

      return VSConstants.S_FALSE;
    }
예제 #7
0
        // Obtains information about programs running, filtered in a variety of ways.
        int IDebugProgramProvider2.GetProviderProcessData(enum_PROVIDER_FLAGS Flags, IDebugDefaultPort2 port, AD_PROCESS_ID ProcessId, CONST_GUID_ARRAY EngineFilter, PROVIDER_PROCESS_DATA[] processArray)
        {
            processArray[0] = new PROVIDER_PROCESS_DATA();

            if (Flags.HasFlag(enum_PROVIDER_FLAGS.PFLAG_GET_PROGRAM_NODES))
            {
                // The debugger is asking the engine to return the program nodes it can debug. The
                // sample engine claims that it can debug all processes, and returns exsactly one
                // program node for each process. A full-featured debugger may wish to examine the
                // target process and determine if it understands how to debug it.

                var node = (IDebugProgramNode2)(new AD7ProgramNode(ProcessId.guidProcessId));

                IntPtr[] programNodes = { Marshal.GetComInterfaceForObject(node, typeof(IDebugProgramNode2)) };

                IntPtr destinationArray = Marshal.AllocCoTaskMem(IntPtr.Size * programNodes.Length);
                Marshal.Copy(programNodes, 0, destinationArray, programNodes.Length);

                processArray[0].Fields = enum_PROVIDER_FIELDS.PFIELD_PROGRAM_NODES;
                processArray[0].ProgramNodes.Members = destinationArray;
                processArray[0].ProgramNodes.dwCount = (uint)programNodes.Length;

                return(VSConstants.S_OK);
            }

            return(VSConstants.S_FALSE);
        }
        public int GetProviderProcessData(enum_PROVIDER_FLAGS Flags, IDebugDefaultPort2 pPort, AD_PROCESS_ID ProcessId, CONST_GUID_ARRAY EngineFilter, PROVIDER_PROCESS_DATA[] pProcess)
        {
            Log.Debug("ProgramProvider: GetProviderProcessData");

            try
            {
                if (Flags.HasFlag(enum_PROVIDER_FLAGS.PFLAG_GET_PROGRAM_NODES))
                {
                    if (PowerShellToolsPackage.DebuggingService.IsAttachable(ProcessId.dwProcessId))
                    {
                        var node             = new ScriptProgramNode(new ScriptDebugProcess(pPort, ProcessId.dwProcessId));
                        var programNodes     = new[] { Marshal.GetComInterfaceForObject(node, typeof(IDebugProgramNode2)) };
                        var destinationArray = Marshal.AllocCoTaskMem(IntPtr.Size * programNodes.Length);

                        Marshal.Copy(programNodes, 0, destinationArray, programNodes.Length);
                        pProcess[0].Fields = enum_PROVIDER_FIELDS.PFIELD_PROGRAM_NODES;
                        pProcess[0].ProgramNodes.Members = destinationArray;
                        pProcess[0].ProgramNodes.dwCount = (uint)programNodes.Length;

                        return(VSConstants.S_OK);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Debug("Exception while examining local running process: " + ex.Message);
            }

            return(VSConstants.S_FALSE);
        }
예제 #9
0
 public int GetProviderProgramNode(enum_PROVIDER_FLAGS Flags, IDebugDefaultPort2 pPort, AD_PROCESS_ID ProcessId,
     ref Guid guidEngine, ulong programId, out IDebugProgramNode2 ppProgramNode)
 {
     DebugHelper.TraceEnteringMethod();
     ppProgramNode = null;
     return VSConstants.S_OK;
 }
예제 #10
0
 int IDebugProgramProvider2.GetProviderProcessData(
     enum_PROVIDER_FLAGS Flags,
     IDebugDefaultPort2 pPort,
     AD_PROCESS_ID ProcessId,
     CONST_GUID_ARRAY EngineFilter,
     PROVIDER_PROCESS_DATA[] pProcess)
 {
     return(VSConstants.E_NOTIMPL);
 }
            public ProviderRequestData(enum_PROVIDER_FLAGS flags, IDebugDefaultPort2 port, AD_PROCESS_ID processId, Guid launchingEngine, IDebugPortNotify2 callback)
            {
                _flags = flags;
                _port  = port != null?port.GetPortId() : Guid.Empty;

                _processId       = processId.dwProcessId;
                _launchingEngine = launchingEngine;
                _callback        = callback;
            }
 /// <summary>
 /// Retrieves a list of running programs from a specified process.
 /// </summary>
 /// <param name="Flags">
 /// A combination of flags from the PROVIDER_FLAGS enumeration. The following flags are typical for this call:
 /// 
 /// Flag                         Description
 /// PFLAG_REMOTE_PORT            Caller is running on remote machine. 
 /// PFLAG_DEBUGGEE               Caller is currently being debugged (additional information about marshalling will be returned for each node).
 /// PFLAG_ATTACHED_TO_DEBUGGEE   Caller was attached to but not launched by the debugger.
 /// PFLAG_GET_PROGRAM_NODES      Caller is asking for a list of program nodes to be returned.
 /// </param>
 /// <param name="pPort">The port the calling process is running on.</param>
 /// <param name="ProcessId">An AD_PROCESS_ID structure holding the ID of the process that contains the program in question.</param>
 /// <param name="EngineFilter">An array of GUIDs for debug engines assigned to debug this process (these will be used to filter the programs that are actually returned based on what the supplied engines support; if no engines are specified, then all programs will be returned).</param>
 /// <param name="pProcess">A PROVIDER_PROCESS_DATA structure that is filled in with the requested information.</param>
 /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
 /// <remarks>This method is normally called by a process to obtain a list of programs running in that process. The returned information is a list of IDebugProgramNode2 objects.</remarks>
 public virtual int GetProviderProcessData( enum_PROVIDER_FLAGS Flags,
     IDebugDefaultPort2 pPort,
     AD_PROCESS_ID ProcessId,
     CONST_GUID_ARRAY EngineFilter,
     PROVIDER_PROCESS_DATA[] pProcess)
 {
     Logger.Debug( string.Empty );
     return VSConstants.E_NOTIMPL;
 }
 /// <summary>
 /// Retrieves a list of running programs from a specified process.
 /// </summary>
 /// <param name="Flags">
 /// A combination of flags from the PROVIDER_FLAGS enumeration. The following flags are typical for this call:
 ///
 /// Flag                         Description
 /// PFLAG_REMOTE_PORT            Caller is running on remote machine.
 /// PFLAG_DEBUGGEE               Caller is currently being debugged (additional information about marshalling will be returned for each node).
 /// PFLAG_ATTACHED_TO_DEBUGGEE   Caller was attached to but not launched by the debugger.
 /// PFLAG_GET_PROGRAM_NODES      Caller is asking for a list of program nodes to be returned.
 /// </param>
 /// <param name="pPort">The port the calling process is running on.</param>
 /// <param name="ProcessId">An AD_PROCESS_ID structure holding the ID of the process that contains the program in question.</param>
 /// <param name="EngineFilter">An array of GUIDs for debug engines assigned to debug this process (these will be used to filter the programs that are actually returned based on what the supplied engines support; if no engines are specified, then all programs will be returned).</param>
 /// <param name="pProcess">A PROVIDER_PROCESS_DATA structure that is filled in with the requested information.</param>
 /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
 /// <remarks>This method is normally called by a process to obtain a list of programs running in that process. The returned information is a list of IDebugProgramNode2 objects.</remarks>
 public virtual int GetProviderProcessData(enum_PROVIDER_FLAGS Flags,
                                           IDebugDefaultPort2 pPort,
                                           AD_PROCESS_ID ProcessId,
                                           CONST_GUID_ARRAY EngineFilter,
                                           PROVIDER_PROCESS_DATA[] pProcess)
 {
     Logger.Debug(string.Empty);
     return(VSConstants.E_NOTIMPL);
 }
 /// <summary>
 /// Allows the process to be notified of port events.
 /// </summary>
 /// <param name="Flags">
 /// A combination of flags from the PROVIDER_FLAGS enumeration. The following flags are typical for this call:
 ///
 /// Flag                         Description
 /// PFLAG_REMOTE_PORT            Caller is running on remote machine.
 /// PFLAG_DEBUGGEE               Caller is currently being debugged (additional information about marshalling is returned for each node).
 /// PFLAG_ATTACHED_TO_DEBUGGEE   Caller was attached to but not launched by the debugger.
 /// PFLAG_REASON_WATCH           Caller wants to watch for events. If this flag is not set. then the callback event is removed and the caller no longer receives notifications.
 /// </param>
 /// <param name="pPort">The port the calling process is running on.</param>
 /// <param name="ProcessId">An AD_PROCESS_ID structure holding the ID of the process that contains the program in question.</param>
 /// <param name="EngineFilter">An array of GUIDs of debug engines associated with the process.</param>
 /// <param name="guidLaunchingEngine">GUID of the debug engine that launched this process (if any).</param>
 /// <param name="pEventCallback">An IDebugPortNotify2 object that receives the event notifications.</param>
 /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
 /// <remarks>When a caller wants to remove an event handler that was established with a previous call to this method, the caller passes the same parameters as it did the first time but leaves off the PFLAG_REASON_WATCH flag.</remarks>
 public virtual int WatchForProviderEvents(enum_PROVIDER_FLAGS Flags,
                                           IDebugDefaultPort2 pPort,
                                           AD_PROCESS_ID ProcessId,
                                           CONST_GUID_ARRAY EngineFilter,
                                           ref Guid guidLaunchingEngine,
                                           IDebugPortNotify2 pEventCallback)
 {
     Logger.Debug(string.Empty);
     return(VSConstants.E_NOTIMPL);
 }
예제 #15
0
 int IDebugProgramProvider2.WatchForProviderEvents(
     enum_PROVIDER_FLAGS Flags,
     IDebugDefaultPort2 pPort,
     AD_PROCESS_ID ProcessId,
     CONST_GUID_ARRAY EngineFilter,
     ref Guid guidLaunchingEngine,
     IDebugPortNotify2 pEventCallback)
 {
     return(VSConstants.S_OK);
 }
 /// <summary>
 /// Retrieves the program node for a specific program.
 /// </summary>
 /// <param name="Flags">
 /// A combination of flags from the PROVIDER_FLAGS enumeration. The following flags are typical for this call:
 ///
 /// Flag                         Description
 /// PFLAG_REMOTE_PORT            Caller is running on remote machine.
 /// PFLAG_DEBUGGEE               Caller is currently being debugged (additional information about marshalling will be returned for each node).
 /// PFLAG_ATTACHED_TO_DEBUGGEE   Caller was attached to but not launched by the debugger.
 /// </param>
 /// <param name="pPort">The port the calling process is running on.</param>
 /// <param name="ProcessId">An AD_PROCESS_ID structure holding the ID of the process that contains the program in question.</param>
 /// <param name="guidEngine">GUID of the debug engine that the program is attached to (if any).</param>
 /// <param name="programId">ID of the program for which to get the program node.</param>
 /// <param name="ppProgramNode">An IDebugProgramNode2 object representing the requested program node.</param>
 /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
 public virtual int GetProviderProgramNode(enum_PROVIDER_FLAGS Flags,
                                           IDebugDefaultPort2 pPort,
                                           AD_PROCESS_ID ProcessId,
                                           ref Guid guidEngine,
                                           ulong programId,
                                           out IDebugProgramNode2 ppProgramNode)
 {
     Logger.Debug(string.Empty);
     ppProgramNode = null;
     return(VSConstants.E_NOTIMPL);
 }
예제 #17
0
 int IDebugProgramProvider2.GetProviderProgramNode(
     enum_PROVIDER_FLAGS Flags,
     IDebugDefaultPort2 pPort,
     AD_PROCESS_ID ProcessId,
     ref Guid guidEngine,
     ulong programId,
     out IDebugProgramNode2 ppProgramNode)
 {
     ppProgramNode = null;
     return(VSConstants.E_NOTIMPL);
 }
 /// <summary>
 /// Retrieves the program node for a specific program.
 /// </summary>
 /// <param name="Flags">
 /// A combination of flags from the PROVIDER_FLAGS enumeration. The following flags are typical for this call:
 /// 
 /// Flag                         Description
 /// PFLAG_REMOTE_PORT            Caller is running on remote machine.
 /// PFLAG_DEBUGGEE               Caller is currently being debugged (additional information about marshalling will be returned for each node).
 /// PFLAG_ATTACHED_TO_DEBUGGEE   Caller was attached to but not launched by the debugger.
 /// </param>
 /// <param name="pPort">The port the calling process is running on.</param>
 /// <param name="ProcessId">An AD_PROCESS_ID structure holding the ID of the process that contains the program in question.</param>
 /// <param name="guidEngine">GUID of the debug engine that the program is attached to (if any).</param>
 /// <param name="programId">ID of the program for which to get the program node.</param>
 /// <param name="ppProgramNode">An IDebugProgramNode2 object representing the requested program node.</param>
 /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
 public virtual int GetProviderProgramNode( enum_PROVIDER_FLAGS Flags,
     IDebugDefaultPort2 pPort,
     AD_PROCESS_ID ProcessId,
     ref Guid guidEngine,
     ulong programId,
     out IDebugProgramNode2 ppProgramNode)
 {
     Logger.Debug( string.Empty );
     ppProgramNode = null;
     return VSConstants.E_NOTIMPL;
 }
        /// <summary>
        /// Retrieves the program node for a specific program.
        /// </summary>
        /// <param name="flags">A combination of flags from the <see cref="PROVIDER_FLAGS"/> enumeration.</param>
        /// <param name="port">The port the calling process is running on.</param>
        /// <param name="processId">An <see cref="AD_PROCESS_ID"/> structure holding the ID of the process that contains the program in question.</param>
        /// <param name="guidEngine">GUID of the debug engine that the program is attached to (if any).</param>
        /// <param name="programId">ID of the program for which to get the program node.</param>
        /// <param name="programNode">An <see cref="IDebugProgramNode2"/> object representing the requested program node.</param>
        /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
        public int GetProviderProgramNode(enum_PROVIDER_FLAGS flags, IDebugDefaultPort2 port, AD_PROCESS_ID processId, ref Guid guidEngine, ulong programId, out IDebugProgramNode2 programNode)
        {
            /* The following flags are typical for this call:
             *
             *   PFLAG_REMOTE_PORT:             Caller is running on remote machine.
             *   PFLAG_DEBUGGEE:                Caller is currently being debugged (additional information about marshalling will be returned for each node).
             *   PFLAG_ATTACHED_TO_DEBUGGEE:    Caller was attached to but not launched by the debugger.
             */

            programNode = null;
            return(VSConstants.E_NOTIMPL);
        }
예제 #20
0
        // Obtains information about programs running, filtered in a variety of ways.
        int IDebugProgramProvider2.GetProviderProcessData(enum_PROVIDER_FLAGS Flags, IDebugDefaultPort2 port, AD_PROCESS_ID ProcessId, CONST_GUID_ARRAY EngineFilter, PROVIDER_PROCESS_DATA[] processArray) {

            processArray[0] = new PROVIDER_PROCESS_DATA();

            // we handle creation of the remote program provider ourselves.  This is because we always load our program provider locally which keeps
            // attach working when developing Python Tools and running/debugging from within VS and in the experimental hive.  When we are installed
            // we install into the GAC so these types are available to create and then remote debugging works as well.  When we're running in the
            // experimental hive we are not in the GAC so if we're created outside of VS (e.g. in msvsmon on the local machine) then we can't get
            // at our program provider and debug->attach doesn't work.
            if (port != null && port.QueryIsLocal() == VSConstants.S_FALSE) {
                IDebugCoreServer3 server;
                if (ErrorHandler.Succeeded(port.GetServer(out server))) {
                    IDebugCoreServer90 dbgServer = server as IDebugCoreServer90;
                    if (dbgServer != null) {
                        Guid g = typeof(IDebugProgramProvider2).GUID;
                        IntPtr remoteProviderPunk;

                        int hr = dbgServer.CreateManagedInstanceInServer(typeof(AD7ProgramProvider).FullName, typeof(AD7ProgramProvider).Assembly.FullName, 0, ref g, out remoteProviderPunk);
                        try {
                            if (ErrorHandler.Succeeded(hr)) {
                                var remoteProvider = (IDebugProgramProvider2)Marshal.GetObjectForIUnknown(remoteProviderPunk);
                                return remoteProvider.GetProviderProcessData(Flags, null, ProcessId, EngineFilter, processArray);
                            }
                        } finally {
                            if (remoteProviderPunk != IntPtr.Zero) {
                                Marshal.Release(remoteProviderPunk);
                            }
                        }
                    }
                }
            } else if ((Flags & enum_PROVIDER_FLAGS.PFLAG_GET_PROGRAM_NODES) != 0 ) {
                // The debugger is asking the engine to return the program nodes it can debug. We check
                // each process if it has a python##.dll or python##_d.dll loaded and if it does
                // then we report the program as being a Python process.

                if (DebugAttach.IsPythonProcess((int)ProcessId.dwProcessId)) {
                    IDebugProgramNode2 node = new AD7ProgramNode((int)ProcessId.dwProcessId);

                    IntPtr[] programNodes = { Marshal.GetComInterfaceForObject(node, typeof(IDebugProgramNode2)) };

                    IntPtr destinationArray = Marshal.AllocCoTaskMem(IntPtr.Size * programNodes.Length);
                    Marshal.Copy(programNodes, 0, destinationArray, programNodes.Length);

                    processArray[0].Fields = enum_PROVIDER_FIELDS.PFIELD_PROGRAM_NODES;
                    processArray[0].ProgramNodes.Members = destinationArray;
                    processArray[0].ProgramNodes.dwCount = (uint)programNodes.Length;

                    return VSConstants.S_OK;
                }
            }

            return VSConstants.S_FALSE;
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public int GetProviderProgramNode(enum_PROVIDER_FLAGS Flags, IDebugDefaultPort2 pPort, AD_PROCESS_ID ProcessId, ref Guid guidEngine, ulong programId, out IDebugProgramNode2 ppProgramNode)
        {
            //
            // Retrieves the program node for a specific program. Not implemented.
            //

            LoggingUtils.PrintFunction();

            ppProgramNode = null;

            // This method is used for Just-In-Time debugging support, which this program provider does not support
            return(Constants.E_NOTIMPL);
        }
예제 #22
0
    // Establishes a callback to watch for provider events associated with specific kinds of processes
    int IDebugProgramProvider2.WatchForProviderEvents(enum_PROVIDER_FLAGS Flags, IDebugDefaultPort2 port, AD_PROCESS_ID ProcessId, CONST_GUID_ARRAY EngineFilter, ref Guid guidLaunchingEngine, IDebugPortNotify2 ad7EventCallback) {
      // The sample debug engine is a native debugger, and can therefore always provide a program node
      // in GetProviderProcessData. Non-native debuggers may wish to implement this method as a way
      // of monitoring the process before code for their runtime starts. For example, if implementing a 
      // 'foo script' debug engine, one could attach to a process which might eventually run 'foo script'
      // before this 'foo script' started.
      //
      // To implement this method, an engine would monitor the target process and call AddProgramNode
      // when the target process started running code which was debuggable by the engine. The 
      // enum_PROVIDER_FLAGS.PFLAG_ATTACHED_TO_DEBUGGEE flag indicates if the request is to start
      // or stop watching the process.

      return VSConstants.S_OK;
    }
예제 #23
0
        // Establishes a callback to watch for provider events associated with specific kinds of processes
        int IDebugProgramProvider2.WatchForProviderEvents(enum_PROVIDER_FLAGS Flags, IDebugDefaultPort2 port, AD_PROCESS_ID ProcessId, CONST_GUID_ARRAY EngineFilter, ref Guid guidLaunchingEngine, IDebugPortNotify2 ad7EventCallback)
        {
            // The sample debug engine is a native debugger, and can therefore always provide a program node
            // in GetProviderProcessData. Non-native debuggers may wish to implement this method as a way
            // of monitoring the process before code for their runtime starts. For example, if implementing a
            // 'foo script' debug engine, one could attach to a process which might eventually run 'foo script'
            // before this 'foo script' started.
            //
            // To implement this method, an engine would monitor the target process and call AddProgramNode
            // when the target process started running code which was debuggable by the engine. The
            // enum_PROVIDER_FLAGS.PFLAG_ATTACHED_TO_DEBUGGEE flag indicates if the request is to start
            // or stop watching the process.

            return(VSConstants.S_OK);
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        #region IDebugProgramProvider2 Members

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

        public int GetProviderProcessData(enum_PROVIDER_FLAGS Flags, IDebugDefaultPort2 port, AD_PROCESS_ID ProcessId, CONST_GUID_ARRAY EngineFilter, PROVIDER_PROCESS_DATA [] processArray)
        {
            //
            // Retrieves a list of running programs from a specified process.
            //

            LoggingUtils.PrintFunction();

            try
            {
                processArray [0] = new PROVIDER_PROCESS_DATA();

                if ((Flags & enum_PROVIDER_FLAGS.PFLAG_GET_PROGRAM_NODES) != 0)
                {
                    // The debugger is asking the engine to return the program nodes it can debug. The
                    // sample engine claims that it can debug all processes, and returns exactly one
                    // program node for each process. A full-featured debugger may wish to examine the
                    // target process and determine if it understands how to debug it.

                    IDebugProgramNode2 node = (IDebugProgramNode2)(new DebuggeeProgram(null));

                    IntPtr [] programNodes = { Marshal.GetComInterfaceForObject(node, typeof(IDebugProgramNode2)) };

                    IntPtr destinationArray = Marshal.AllocCoTaskMem(IntPtr.Size * programNodes.Length);

                    Marshal.Copy(programNodes, 0, destinationArray, programNodes.Length);

                    processArray [0].Fields = enum_PROVIDER_FIELDS.PFIELD_PROGRAM_NODES;

                    processArray [0].ProgramNodes.Members = destinationArray;

                    processArray [0].ProgramNodes.dwCount = (uint)programNodes.Length;

                    return(Constants.S_OK);
                }

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

                return(Constants.E_FAIL);
            }
        }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    #region IDebugProgramProvider2 Members

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

    public int GetProviderProcessData (enum_PROVIDER_FLAGS Flags, IDebugDefaultPort2 port, AD_PROCESS_ID ProcessId, CONST_GUID_ARRAY EngineFilter, PROVIDER_PROCESS_DATA [] processArray)
    {
      // 
      // Retrieves a list of running programs from a specified process.
      // 

      LoggingUtils.PrintFunction ();

      try
      {
        processArray [0] = new PROVIDER_PROCESS_DATA ();

        if ((Flags & enum_PROVIDER_FLAGS.PFLAG_GET_PROGRAM_NODES) != 0)
        {
          // The debugger is asking the engine to return the program nodes it can debug. The 
          // sample engine claims that it can debug all processes, and returns exactly one
          // program node for each process. A full-featured debugger may wish to examine the
          // target process and determine if it understands how to debug it.

          IDebugProgramNode2 node = (IDebugProgramNode2)(new DebuggeeProgram (null));

          IntPtr [] programNodes = { Marshal.GetComInterfaceForObject (node, typeof (IDebugProgramNode2)) };

          IntPtr destinationArray = Marshal.AllocCoTaskMem (IntPtr.Size * programNodes.Length);

          Marshal.Copy (programNodes, 0, destinationArray, programNodes.Length);

          processArray [0].Fields = enum_PROVIDER_FIELDS.PFIELD_PROGRAM_NODES;

          processArray [0].ProgramNodes.Members = destinationArray;

          processArray [0].ProgramNodes.dwCount = (uint)programNodes.Length;

          return Constants.S_OK;
        }

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

        return Constants.E_FAIL;
      }
    }
        /// <summary>
        /// Retrieves a list of running programs from a specified process.
        /// </summary>
        /// <param name="flags">A combination of flags from the <see cref="PROVIDER_FLAGS"/> enumeration.</param>
        /// <param name="port">The port the calling process is running on.</param>
        /// <param name="processId">An <see cref="AD_PROCESS_ID"/> structure holding the ID of the process that contains the program in question.</param>
        /// <param name="engineFilter">An array of GUIDs for debug engines assigned to debug this process (these will be used to filter the programs that are actually returned based on what the supplied engines support; if no engines are specified, then all programs will be returned).</param>
        /// <param name="process">A <see cref="PROVIDER_PROCESS_DATA"/> structure that is filled in with the requested information.</param>
        /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
        /// <remarks>
        /// This method is normally called by a process to obtain a list of programs running in that process. The returned information is a list of <see cref="IDebugProgramNode2"/> objects.
        /// </remarks>
        public int GetProviderProcessData(enum_PROVIDER_FLAGS flags, IDebugDefaultPort2 port, AD_PROCESS_ID processId, CONST_GUID_ARRAY engineFilter, PROVIDER_PROCESS_DATA[] process)
        {
            /* The following flags are typical for this call:
             *
             *   PFLAG_REMOTE_PORT:             Caller is running on remote machine.
             *   PFLAG_DEBUGGEE:                Caller is currently being debugged (additional information about marshalling is returned for each node).
             *   PFLAG_ATTACHED_TO_DEBUGGEE:    Caller was attached to but not launched by the debugger.
             *   PFLAG_GET_PROGRAM_NODES:       Caller is asking for a list of program nodes to be returned.
             */

#if false
            // make sure this request is relevant to this debug engine
            if (!engineFilter.AsEnumerable().Contains(JavaDebuggerConstants.JavaDebugEngineGuid))
            {
                return(VSConstants.E_INVALIDARG);
            }
#endif

            return(VSConstants.S_FALSE);
        }
예제 #27
0
 public int GetProviderProcessData(enum_PROVIDER_FLAGS Flags, IDebugDefaultPort2 pPort, AD_PROCESS_ID ProcessId,
                                   CONST_GUID_ARRAY EngineFilter, PROVIDER_PROCESS_DATA[] pProcess)
 {
     DebugHelper.TraceEnteringMethod();
     return(VSConstants.S_OK);
 }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    public int GetProviderProgramNode (enum_PROVIDER_FLAGS Flags, IDebugDefaultPort2 pPort, AD_PROCESS_ID ProcessId, ref Guid guidEngine, ulong programId, out IDebugProgramNode2 ppProgramNode)
    {
      // 
      // Retrieves the program node for a specific program. Not implemented. 
      // 

      LoggingUtils.PrintFunction ();

      ppProgramNode = null;

      // This method is used for Just-In-Time debugging support, which this program provider does not support
      return Constants.E_NOTIMPL; 
    }
 int IDebugProgramProvider2.WatchForProviderEvents(enum_PROVIDER_FLAGS Flags, IDebugDefaultPort2 pPort, AD_PROCESS_ID ProcessId, CONST_GUID_ARRAY EngineFilter, ref Guid guidLaunchingEngine, IDebugPortNotify2 pEventCallback)
 {
   return VSConstants.S_OK;
 }
 int IDebugProgramProvider2.GetProviderProgramNode(enum_PROVIDER_FLAGS Flags, IDebugDefaultPort2 pPort, AD_PROCESS_ID ProcessId, ref Guid guidEngine, ulong programId, out IDebugProgramNode2 ppProgramNode)
 {
   throw new NotImplementedException();
 }
 int IDebugProgramProvider2.GetProviderProcessData(enum_PROVIDER_FLAGS Flags, IDebugDefaultPort2 pPort, AD_PROCESS_ID ProcessId, CONST_GUID_ARRAY EngineFilter, PROVIDER_PROCESS_DATA[] pProcess)
 {
   throw new NotImplementedException();
 }
 /// <summary>
 /// Allows the process to be notified of port events.
 /// </summary>
 /// <param name="Flags">
 /// A combination of flags from the PROVIDER_FLAGS enumeration. The following flags are typical for this call:
 /// 
 /// Flag                         Description
 /// PFLAG_REMOTE_PORT            Caller is running on remote machine.
 /// PFLAG_DEBUGGEE               Caller is currently being debugged (additional information about marshalling is returned for each node).
 /// PFLAG_ATTACHED_TO_DEBUGGEE   Caller was attached to but not launched by the debugger.
 /// PFLAG_REASON_WATCH           Caller wants to watch for events. If this flag is not set. then the callback event is removed and the caller no longer receives notifications.
 /// </param>
 /// <param name="pPort">The port the calling process is running on.</param>
 /// <param name="ProcessId">An AD_PROCESS_ID structure holding the ID of the process that contains the program in question.</param>
 /// <param name="EngineFilter">An array of GUIDs of debug engines associated with the process.</param>
 /// <param name="guidLaunchingEngine">GUID of the debug engine that launched this process (if any).</param>
 /// <param name="pEventCallback">An IDebugPortNotify2 object that receives the event notifications.</param>
 /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
 /// <remarks>When a caller wants to remove an event handler that was established with a previous call to this method, the caller passes the same parameters as it did the first time but leaves off the PFLAG_REASON_WATCH flag.</remarks>
 public virtual int WatchForProviderEvents( enum_PROVIDER_FLAGS Flags,
     IDebugDefaultPort2 pPort,
     AD_PROCESS_ID ProcessId,
     CONST_GUID_ARRAY EngineFilter,
     ref Guid guidLaunchingEngine,
     IDebugPortNotify2 pEventCallback)
 {
     Logger.Debug( string.Empty );
     return VSConstants.E_NOTIMPL;
 }
예제 #33
0
 public int GetProviderProgramNode(enum_PROVIDER_FLAGS Flags, IDebugDefaultPort2 pPort, AD_PROCESS_ID ProcessId, ref Guid guidEngine, ulong programId, out IDebugProgramNode2 ppProgramNode)
 {
     Log.Debug("ProgramProvider: GetProviderProgramNode");
     ppProgramNode = null;
     return VSConstants.S_OK;
 }
예제 #34
0
 public int WatchForProviderEvents(enum_PROVIDER_FLAGS Flags, IDebugDefaultPort2 pPort, AD_PROCESS_ID ProcessId,
     CONST_GUID_ARRAY EngineFilter, ref Guid guidLaunchingEngine, IDebugPortNotify2 pEventCallback)
 {
     DebugHelper.TraceEnteringMethod();
     return VSConstants.S_OK;
 }
예제 #35
0
 public int GetProviderProgramNode(enum_PROVIDER_FLAGS Flags, IDebugDefaultPort2 pPort, AD_PROCESS_ID ProcessId, ref Guid guidEngine, ulong programId, out IDebugProgramNode2 ppProgramNode)
 {
     throw new NotImplementedException();
 }
예제 #36
0
 public int GetProviderProcessData(enum_PROVIDER_FLAGS Flags, IDebugDefaultPort2 pPort, AD_PROCESS_ID ProcessId,
     CONST_GUID_ARRAY EngineFilter, PROVIDER_PROCESS_DATA[] pProcess)
 {
     DebugHelper.TraceEnteringMethod();
     return VSConstants.S_OK;
 }
 public int GetProviderProgramNode(enum_PROVIDER_FLAGS Flags, IDebugDefaultPort2 pPort, AD_PROCESS_ID ProcessId, ref Guid guidEngine, ulong programId, out IDebugProgramNode2 ppProgramNode)
 {
     Log.Debug("ProgramProvider: GetProviderProgramNode");
     ppProgramNode = null;
     return(VSConstants.S_OK);
 }
예제 #38
0
        // Obtains information about programs running, filtered in a variety of ways.
        int IDebugProgramProvider2.GetProviderProcessData(enum_PROVIDER_FLAGS Flags, IDebugDefaultPort2 port, AD_PROCESS_ID ProcessId, CONST_GUID_ARRAY EngineFilter, PROVIDER_PROCESS_DATA[] processArray)
        {
            processArray[0] = new PROVIDER_PROCESS_DATA();

            // we handle creation of the remote program provider ourselves.  This is because we always load our program provider locally which keeps
            // attach working when developing Python Tools and running/debugging from within VS and in the experimental hive.  When we are installed
            // we install into the GAC so these types are available to create and then remote debugging works as well.  When we're running in the
            // experimental hive we are not in the GAC so if we're created outside of VS (e.g. in msvsmon on the local machine) then we can't get
            // at our program provider and debug->attach doesn't work.
            if (port != null && port.QueryIsLocal() == VSConstants.S_FALSE)
            {
                if (ErrorHandler.Succeeded(port.GetServer(out var server)))
                {
                    var dbgServer = server as IDebugCoreServer90;
                    if (dbgServer != null)
                    {
                        var g = typeof(IDebugProgramProvider2).GUID;

                        var hr = dbgServer.CreateManagedInstanceInServer(typeof(AD7ProgramProvider).FullName, typeof(AD7ProgramProvider).Assembly.FullName, 0, ref g, out var remoteProviderPunk);
                        try
                        {
                            if (ErrorHandler.Succeeded(hr))
                            {
                                var remoteProvider = (IDebugProgramProvider2)Marshal.GetObjectForIUnknown(remoteProviderPunk);
                                return(remoteProvider.GetProviderProcessData(Flags, null, ProcessId, EngineFilter, processArray));
                            }
                        }
                        finally
                        {
                            if (remoteProviderPunk != IntPtr.Zero)
                            {
                                Marshal.Release(remoteProviderPunk);
                            }
                        }
                    }
                }
            }
            else if ((Flags & enum_PROVIDER_FLAGS.PFLAG_GET_PROGRAM_NODES) != 0)
            {
                // The debugger is asking the engine to return the program nodes it can debug. We check
                // each process if it has a python##.dll or python##_d.dll loaded and if it does
                // then we report the program as being a Python process.

                /*
                 * if (DebugAttach.IsPythonProcess((int)ProcessId.dwProcessId)) {
                 *  IDebugProgramNode2 node = new AD7ProgramNode((int)ProcessId.dwProcessId);
                 *
                 *  IntPtr[] programNodes = { Marshal.GetComInterfaceForObject(node, typeof(IDebugProgramNode2)) };
                 *
                 *  IntPtr destinationArray = Marshal.AllocCoTaskMem(IntPtr.Size * programNodes.Length);
                 *  Marshal.Copy(programNodes, 0, destinationArray, programNodes.Length);
                 *
                 *  processArray[0].Fields = enum_PROVIDER_FIELDS.PFIELD_PROGRAM_NODES;
                 *  processArray[0].ProgramNodes.Members = destinationArray;
                 *  processArray[0].ProgramNodes.dwCount = (uint)programNodes.Length;
                 *
                 *  return VSConstants.S_OK;
                 * }*/
            }

            return(VSConstants.S_FALSE);
        }
예제 #39
0
 public int GetProviderProgramNode(enum_PROVIDER_FLAGS Flags, IDebugDefaultPort2 pPort, AD_PROCESS_ID ProcessId, ref Guid guidEngine, ulong programId, out IDebugProgramNode2 ppProgramNode)
 {
     ppProgramNode = null;
     return 0;
 }
예제 #40
0
 public int WatchForProviderEvents(enum_PROVIDER_FLAGS Flags, IDebugDefaultPort2 pPort, AD_PROCESS_ID ProcessId,
                                   CONST_GUID_ARRAY EngineFilter, ref Guid guidLaunchingEngine, IDebugPortNotify2 pEventCallback)
 {
     DebugHelper.TraceEnteringMethod();
     return(VSConstants.S_OK);
 }
 /// <summary>
 ///     Obtains information about programs running, filtered in a variety of ways.
 /// </summary>
 /// <param name="flags">The flags.</param>
 /// <param name="port">The port.</param>
 /// <param name="processId">The process identifier.</param>
 /// <param name="engineFilter">The engine filter.</param>
 /// <param name="process">The process.</param>
 /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
 public int GetProviderProcessData(enum_PROVIDER_FLAGS flags, IDebugDefaultPort2 port, AD_PROCESS_ID processId,
                                   CONST_GUID_ARRAY engineFilter, PROVIDER_PROCESS_DATA[] process)
 {
     return(S_FALSE);
 }
예제 #42
0
 public int GetProviderProcessData(enum_PROVIDER_FLAGS Flags, IDebugDefaultPort2 pPort, AD_PROCESS_ID ProcessId, CONST_GUID_ARRAY EngineFilter, PROVIDER_PROCESS_DATA[] pProcess)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 ///     Gets a program node, given a specific process ID.
 /// </summary>
 /// <param name="flags">The flags.</param>
 /// <param name="port">The port.</param>
 /// <param name="processId">The process identifier.</param>
 /// <param name="guidEngine">The unique identifier engine.</param>
 /// <param name="programId">The program identifier.</param>
 /// <param name="programNode">The program node.</param>
 /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
 public int GetProviderProgramNode(enum_PROVIDER_FLAGS flags, IDebugDefaultPort2 port, AD_PROCESS_ID processId,
                                   ref Guid guidEngine, ulong programId, out IDebugProgramNode2 programNode)
 {
     programNode = null;
     return(S_FALSE);
 }
 /// <summary>
 ///     Establishes a callback to watch for provider events associated with specific kinds of processes.
 /// </summary>
 /// <param name="flags">The flags.</param>
 /// <param name="port">The port.</param>
 /// <param name="processId">The process identifier.</param>
 /// <param name="engineFilter">The engine filter.</param>
 /// <param name="guidLaunchingEngine">The unique identifier launching engine.</param>
 /// <param name="eventCallback">The event callback.</param>
 /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
 public int WatchForProviderEvents(enum_PROVIDER_FLAGS flags, IDebugDefaultPort2 port, AD_PROCESS_ID processId,
                                   CONST_GUID_ARRAY engineFilter, ref Guid guidLaunchingEngine, IDebugPortNotify2 eventCallback)
 {
     return(S_OK);
 }
예제 #45
0
 public int GetProviderProcessData(enum_PROVIDER_FLAGS Flags, IDebugDefaultPort2 pPort, AD_PROCESS_ID ProcessId, CONST_GUID_ARRAY EngineFilter, PROVIDER_PROCESS_DATA[] pProcess)
 {
     pProcess[0] = new PROVIDER_PROCESS_DATA();
     return VSConstants.S_OK;
 }
예제 #46
0
 // Gets a program node, given a specific process ID.
 int IDebugProgramProvider2.GetProviderProgramNode(enum_PROVIDER_FLAGS Flags, IDebugDefaultPort2 port, AD_PROCESS_ID ProcessId, ref Guid guidEngine, ulong programId,
                                                   out IDebugProgramNode2 programNode)
 {
     // This method is used for Just-In-Time debugging support, which this program provider does not support
     programNode = null;
     return VSConstants.E_NOTIMPL;
 }
예제 #47
0
 public int GetProviderProcessData(enum_PROVIDER_FLAGS Flags, IDebugDefaultPort2 pPort, AD_PROCESS_ID ProcessId, CONST_GUID_ARRAY EngineFilter, PROVIDER_PROCESS_DATA[] pProcess)
 {
     pProcess[0] = new PROVIDER_PROCESS_DATA();
     return(VSConstants.S_OK);
 }