Пример #1
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);
        }
Пример #2
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;
    }
Пример #3
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 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);
        }
Пример #5
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;
        }