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

        public int GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes)
        {
            //
            // Gets the memory bytes for this program.
            //

            LoggingUtils.PrintFunction();

            ppMemoryBytes = null;

            try
            {
                if (AttachedEngine == null)
                {
                    throw new InvalidOperationException();
                }

                return(AttachedEngine.NativeDebugger.NativeProgram.GetMemoryBytes(out ppMemoryBytes));
            }
            catch (Exception e)
            {
                LoggingUtils.HandleException(e);

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

        public override int GetMemoryBytes(out IDebugMemoryBytes2 memoryBytes)
        {
            //
            // Returns the memory bytes for a property value.
            //

            LoggingUtils.PrintFunction();

            return(m_debugger.NativeProgram.GetMemoryBytes(out memoryBytes));
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public int GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes)
        {
            //
            // Gets the memory bytes for this program.
            //

            LoggingUtils.PrintFunction();

            ppMemoryBytes = null;

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

        public virtual int GetMemoryBytes(out IDebugMemoryBytes2 memoryBytes)
        {
            //
            // Returns the memory bytes for a property value.
            //

            LoggingUtils.PrintFunction();

            memoryBytes = null;

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

    public int GetMemoryBytes (out IDebugMemoryBytes2 ppMemoryBytes)
    {
      // 
      // Gets the memory bytes for this program.
      // 

      LoggingUtils.PrintFunction ();

      if (m_debugger.NativeMemoryBytes != null)
      {
        ppMemoryBytes = m_debugger.NativeMemoryBytes;

        return Constants.S_OK;
      }

      ppMemoryBytes = null;

      return Constants.S_GETMEMORYBYTES_NO_MEMORY_BYTES;
    }
        public byte[] ReadMemory(IDebugMemoryContext2 context, IDebugMemoryBytes2 memory, int bytes, int readStep, out int finalRead)
        {
            byte[] result = new byte[bytes];

            int allRead = 0;

            finalRead = 0;
            while (allRead < bytes)
            {
                IDebugMemoryContext2 currentContext = null;
                if (context.Add((ulong)allRead, out currentContext) != VSConstants.S_OK)
                {
                    return(null);
                }

                if (bytes - allRead < readStep)
                {
                    readStep = bytes - allRead;
                }

                byte[] buffer     = new byte[readStep];
                uint   bufferRead = 0;
                uint   unreadable = 0;

                if (memory.ReadAt(currentContext, (uint)readStep, buffer, out bufferRead, ref unreadable) != VSConstants.S_OK)
                {
                    return(null);
                }

                if (bufferRead == 0 && unreadable == readStep)
                {
                    break;
                }

                Buffer.BlockCopy(buffer, 0, result, allRead, (int)bufferRead);
                allRead += (int)bufferRead;
            }

            finalRead = allRead;
            return(result);
        }
Example #7
0
 public int GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes)
 {
     DebugHelper.TraceEnteringMethod();
     ppMemoryBytes = null;
     return(VSConstants.E_NOTIMPL);
 }
 public int GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes)
 {
     ppMemoryBytes = null;
     return(AD7Constants.S_GETMEMORYBYTES_NO_MEMORY_BYTES);
 }
 public int GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes)
 {
     ppMemoryBytes = null;
     return AD7Constants.S_GETMEMORYBYTES_NO_MEMORY_BYTES;
 }
Example #10
0
 int IDebugProgram2.GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes)
 {
     throw new NotImplementedException();
 }
Example #11
0
 int IDebugProperty2.GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes)
 {
     ppMemoryBytes = null;
     return(VSConstants.E_NOTIMPL);
 }
Example #12
0
 int IDebugProperty3.GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes) => IDebugProperty2.GetMemoryBytes(out ppMemoryBytes);
Example #13
0
 // The memory bytes as represented by the IDebugMemoryBytes2 object is for the program's image in memory and not any memory
 // that was allocated when the program was executed.
 public int GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes)
 {
     ppMemoryBytes = this;
     return Constants.S_OK;
 }
Example #14
0
 int IDebugProgram3.GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes)
 {
     return(IDebugProgram2.GetMemoryBytes(out ppMemoryBytes));
 }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    public override int GetMemoryBytes (out IDebugMemoryBytes2 memoryBytes)
    {
      // 
      // Returns the memory bytes for a property value.
      // 

      LoggingUtils.PrintFunction ();

      return m_debugger.NativeProgram.GetMemoryBytes (out memoryBytes);
    }
Example #16
0
        public int Event(IDebugEngine2 engine, IDebugProcess2 process, IDebugProgram2 program, IDebugThread2 thread, IDebugEvent2 debugEvent, ref Guid riidEvent, uint attributes) {
            bool savedProgram = false;
            bool savedThread = false;

            if (riidEvent == processCreateEvent) {
                AD_PROCESS_ID[] pdwProcessId = new AD_PROCESS_ID[1];
                process.GetPhysicalProcessId(pdwProcessId);
                Debug.Assert(!this.attachedProcesses.Contains(pdwProcessId[0].dwProcessId));
                this.attachedProcesses.Add(pdwProcessId[0].dwProcessId);
            } else if (riidEvent == processDestroyEvent) {
                AD_PROCESS_ID[] pdwProcessId = new AD_PROCESS_ID[1];
                process.GetPhysicalProcessId(pdwProcessId);
                Debug.Assert(this.attachedProcesses.Contains(pdwProcessId[0].dwProcessId));
                this.attachedProcesses.Remove(pdwProcessId[0].dwProcessId);
            } else if (riidEvent == breakInEvent && this.currentDebugProgram != program && program != null && thread != null) {
                // Evaluate an expression get access to the memory context and the bitness.
                IDebugProperty2 debugProperty = this.EvaluateExpression(thread, "(void**)0x0 + 1");
                if (debugProperty != null) {
                    using (new DisposableComReference(debugProperty)) {
                        DEBUG_PROPERTY_INFO[] debugPropertyInfo = new DEBUG_PROPERTY_INFO[1];
                        if (debugProperty.GetPropertyInfo((uint)enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_VALUE, 16, evaluateExpressionTimeout, null, 0, debugPropertyInfo) == S_OK) {
                            IDebugMemoryContext2 memoryContext = null;
                            IDebugMemoryBytes2 memoryBytes = null;
                            if (debugProperty.GetMemoryContext(out memoryContext) == S_OK && debugProperty.GetMemoryBytes(out memoryBytes) == S_OK) {
                                DisposableComReference.SetReference(ref this.currentDebugProgram, program);
                                DisposableComReference.SetReference(ref this.currentThread, thread);
                                DisposableComReference.SetReference(ref this.memoryContext, memoryContext);
                                DisposableComReference.SetReference(ref this.memoryBytes, memoryBytes);
                                ulong offset = ulong.Parse(debugPropertyInfo[0].bstrValue.Substring("0x".Length), System.Globalization.NumberStyles.AllowHexSpecifier);

                                // Adjust the memory context and calculate the bitness.
                                this.memoryContext.Subtract(offset, out memoryContext);
                                DisposableComReference.SetReference(ref this.memoryContext, memoryContext);
                                this.isPointer64Bit = (offset == 8);

                                this.engine.NotifyDebuggerStatusChange(DebuggerChangeEventArgs.DebuggerStatus.Detaching);
                                this.engine.DiaLoader.ClearSymbols();
                                savedProgram = true;
                                savedThread = true;
                            } else {
                                DisposableComReference.ReleaseIfNotNull(ref memoryContext);
                                DisposableComReference.ReleaseIfNotNull(ref memoryBytes);
                            }
                        }
                    }
                }
            } else if (riidEvent == stopDebugEvent) {
                // The debugger stopped.  Clear the references.
                DisposableComReference.ReleaseIfNotNull(ref this.currentDebugProgram);
                DisposableComReference.ReleaseIfNotNull(ref this.memoryContext);
                DisposableComReference.ReleaseIfNotNull(ref this.memoryBytes);
                this.engine.NotifyDebuggerStatusChange(DebuggerChangeEventArgs.DebuggerStatus.Detaching);
                this.engine.DiaLoader.ClearSymbols();
            } else if (riidEvent == breakInEvent) {
                // The debugger broke in, notify the client.
                this.engine.NotifyDebuggerStatusChange(DebuggerChangeEventArgs.DebuggerStatus.Break);
            } else if (riidEvent == threadSwitchEvent) {
                // The user switched the current thread.
                DisposableComReference.SetReference(ref this.currentThread, thread);
                savedThread = true;
                if (this.currentThread != null) {
                    uint threadId;
                    thread.GetThreadId(out threadId);
                    this.TargetThreadSystemId = threadId;
                }

                bool processChanged = false;
                if (process != null) {
                    AD_PROCESS_ID[] pdwProcessId = new AD_PROCESS_ID[1];
                    process.GetPhysicalProcessId(pdwProcessId);
                    if (this.TargetProcessSystemId != 0) {
                        if (pdwProcessId[0].dwProcessId != this.TargetProcessSystemId) {
                            this.TargetProcessSystemId = pdwProcessId[0].dwProcessId;
                            processChanged = true;
                        }
                    } else {
                        this.TargetProcessSystemId = pdwProcessId[0].dwProcessId;
                        if (this.TargetProcessSystemId != 0) {
                            processChanged = true;
                        }
                    }
                } else if (this.TargetProcessSystemId != 0) {
                    this.TargetProcessSystemId = 0;
                    processChanged = true;
                }

                if (processChanged) {
                    DisposableComReference.SetReference(ref this.currentDebugProgram, program);
                    savedProgram = true;

                    if (program != null) {
                        // Evaluate an expression get access to the memory context and the bitness.
                        IDebugProperty2 debugProperty = this.EvaluateExpression(thread, "(void**)0x0 + 1");
                        if (debugProperty != null) {
                            using (new DisposableComReference(debugProperty)) {
                                DEBUG_PROPERTY_INFO[] debugPropertyInfo = new DEBUG_PROPERTY_INFO[1];
                                if (debugProperty.GetPropertyInfo((uint)enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_VALUE, 16, evaluateExpressionTimeout, null, 0, debugPropertyInfo) == S_OK) {
                                    IDebugMemoryContext2 memoryContext = null;
                                    IDebugMemoryBytes2 memoryBytes = null;
                                    if ((debugProperty.GetMemoryContext(out memoryContext) == S_OK) && (debugProperty.GetMemoryBytes(out memoryBytes) == S_OK)) {
                                        DisposableComReference.SetReference(ref this.memoryContext, memoryContext);
                                        DisposableComReference.SetReference(ref this.memoryBytes, memoryBytes);
                                        ulong offset = ulong.Parse(debugPropertyInfo[0].bstrValue.Substring("0x".Length), System.Globalization.NumberStyles.AllowHexSpecifier);

                                        // Adjust the memory context and calculate the bitness.
                                        this.memoryContext.Subtract(offset, out memoryContext);
                                        DisposableComReference.SetReference(ref this.memoryContext, memoryContext);
                                        this.isPointer64Bit = (offset == 8);
                                    } else {
                                        DisposableComReference.ReleaseIfNotNull(ref memoryContext);
                                        DisposableComReference.ReleaseIfNotNull(ref memoryBytes);
                                    }
                                }
                            }
                        }

                        this.engine.NotifyDebuggerStatusChange(DebuggerChangeEventArgs.DebuggerStatus.ChangingProcess);
                    }
                } else {
                    this.engine.NotifyDebuggerStatusChange(DebuggerChangeEventArgs.DebuggerStatus.ChangingThread);
                }
            }

            if (!savedProgram) {
                DisposableComReference.ReleaseIfNotNull(ref program);
            }
            if (!savedThread) {
                DisposableComReference.ReleaseIfNotNull(ref thread);
            }
            DisposableComReference.ReleaseIfNotNull(ref engine);
            DisposableComReference.ReleaseIfNotNull(ref process);
            DisposableComReference.ReleaseIfNotNull(ref debugEvent);

            return S_OK;
        }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    public int GetMemoryBytes (out IDebugMemoryBytes2 ppMemoryBytes)
    {
      // 
      // Gets the memory bytes for this program.
      // 

      LoggingUtils.PrintFunction ();

      ppMemoryBytes = null;

      return Constants.S_GETMEMORYBYTES_NO_MEMORY_BYTES;
    }
Example #18
0
 public int GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes)
 {
     DLog.Debug(DContext.VSDebuggerComCall, "IDebugProgram2.GetMemoryBytes");
     ppMemoryBytes = null;
     return VSConstants.E_NOTIMPL;
 }
 /// <summary>
 /// Retrieves the memory bytes occupied by the program. Not implemented. (http://msdn.microsoft.com/en-us/library/bb145291.aspx)
 /// </summary>
 /// <param name="ppMemoryBytes"> Returns an IDebugMemoryBytes2 object that represents the memory bytes of the program. </param>
 /// <returns> Not implemented. </returns>
 public int GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes)
 {
     throw new Exception("The method or operation is not implemented.");
 }
Example #20
0
 public int GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes)
 {
     Log.Debug("Program: GetMemoryBytes");
     ppMemoryBytes = null;
     return VSConstants.E_NOTIMPL;
 }
Example #21
0
 public int GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes)
 {
     throw new NotImplementedException();
 }
 int Microsoft.VisualStudio.Debugger.Interop.IDebugProgram2.GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes)
 {
     ppMemoryBytes = null;
     return Utility.COM_HResults.S_OK;
 }
Example #23
0
 int IDebugProgram3.GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes) {
     return IDebugProgram2.GetMemoryBytes(out ppMemoryBytes);
 }
Example #24
0
 /// <summary>
 /// Gets the memory bytes that compose the value of a property.
 /// </summary>
 /// <param name="ppMemoryBytes">Returns an IDebugMemoryBytes2 object that can be used to retrieve the memory that contains the value of the property.</param>
 /// <returns>If successful, returns S_OK; otherwise returns error code. Returns S_GETMEMORYBYTES_NO_MEMORY_BYTES if there are no memory bytes to retrieve.</returns>
 public virtual int GetMemoryBytes( out IDebugMemoryBytes2 ppMemoryBytes )
 {
     Logger.Debug( string.Empty );
     ppMemoryBytes = null;
     return VSConstants.E_NOTIMPL;
 }
Example #25
0
 public int GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes)
 {
     DLog.Debug(DContext.VSDebuggerComCall, "IDebugProgram2.GetMemoryBytes");
     ppMemoryBytes = null;
     return(VSConstants.E_NOTIMPL);
 }
Example #26
0
 // Get the memory bytes that contains this property
 public void GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes)
 {
     throw new Exception("Not Implemented Yet");
 }
Example #27
0
 // The memory bytes as represented by the IDebugMemoryBytes2 object is for the program's image in memory and not any memory 
 // that was allocated when the program was executed.
 public int GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes) {
     DebugWriteCommand("GetMemoryBytes");
     throw new Exception("The method or operation is not implemented.");
 }
 int Microsoft.VisualStudio.Debugger.Interop.IDebugProgram2.GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes)
 {
     ppMemoryBytes = null;
     return(COM_HResults.S_OK);
 }
 public int GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes)
 {
     Log.Debug("Program: GetMemoryBytes");
     ppMemoryBytes = null;
     return(VSConstants.E_NOTIMPL);
 }
Example #30
0
 public int GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes)
 {
     DLog.Debug(DContext.VSDebuggerComCall, "IDebugProgram2.GetMemoryBytes");
     throw new NotImplementedException();
 }
Example #31
0
 int IDebugProperty3.GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes)
 {
     return(IDebugProperty2.GetMemoryBytes(out ppMemoryBytes));
 }
Example #32
0
 public int GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes)
 {
     DLog.Debug(DContext.VSDebuggerComCall, "IDebugProgram2.GetMemoryBytes");
     throw new NotImplementedException();
 }
Example #33
0
 int IDebugProperty2.GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes)
 {
     Debug.WriteLine("AD7Property - IDebugProperty2::GetMemoryBytes");
     throw new NotImplementedException();
 }
 int IDebugProgram2.GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes)
 {
   Debug.WriteLine("AD7ProgramNode: Entering GetMemoryBytes");
   throw new NotImplementedException();
 }
Example #35
0
 // The memory bytes as represented by the IDebugMemoryBytes2 object is for the program's image in memory and not any memory
 // that was allocated when the program was executed.
 public int GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes)
 {
     throw new Exception("The method or operation is not implemented.");
 }
Example #36
0
 // Get the memory bytes that contains this property
 public  void GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes) {
   throw new Exception("Not Implemented Yet");
 }
Example #37
0
 // Returns the memory bytes for a property value.
 public int GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes) {
     ppMemoryBytes = null;
     return VSConstants.E_NOTIMPL;
 }
Example #38
0
 int IDebugProperty2.GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes) {
     ppMemoryBytes = null;
     return VSConstants.E_NOTIMPL;
 }
Example #39
0
 int IDebugProgram3.GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes)
 {
     throw new NotImplementedException();
 }
Example #40
0
 int IDebugProperty3.GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes) {
     return IDebugProperty2.GetMemoryBytes(out ppMemoryBytes);
 }
Example #41
0
 public int GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes)
 {
     ppMemoryBytes = null;
     return(VSConstants.E_NOTIMPL);
 }
Example #42
0
 public int GetMemoryBytes(out IDebugMemoryBytes2 memoryBytes)
 {
     memoryBytes = Self;
     return(VSConstants.S_OK);
 }
Example #43
0
 public int GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes)
 {
     throw new NotImplementedException();
 }
Example #44
0
 /// <summary>
 /// Retrieves the memory bytes occupied by the program.
 /// </summary>
 /// <param name="ppMemoryBytes">Returns an IDebugMemoryBytes2 object that represents the memory bytes of the program.</param>
 /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
 /// <remarks>
 /// The memory bytes as represented by the IDebugMemoryBytes2 object is for the program's image in memory and not any memory that was allocated when the program was executed.
 /// </remarks>
 public virtual int GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes)
 {
     Logger.Debug(string.Empty);
     ppMemoryBytes = null;
     return(VSConstants.E_NOTIMPL);
 }
Example #45
0
 // The memory bytes as represented by the IDebugMemoryBytes2 object is for the program's image in memory and not any memory
 // that was allocated when the program was executed.
 public int GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes)
 {
     ppMemoryBytes = this;
     return(Constants.S_OK);
 }
Example #46
0
 int IDebugProgram2.GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes)
 {
     Debug.WriteLine("AD7ProgramNode: Entering GetMemoryBytes");
     throw new NotImplementedException();
 }