共用方式為


DisassemblyData

 

如需 Visual Studio 2017 的最新文件請參閱 Visual Studio 2017 文件

說明整合式的開發環境 (IDE) 單一的反組譯碼指令,來顯示。

語法

typedef struct tagDisassemblyData {   
   DISASSEMBLY_STREAM_FIELDS dwFields;  
   BSTR                      bstrAddress;  
   BSTR                      bstrAddressOffset;  
   BSTR                      bstrCodeBytes;  
   BSTR                      bstrOpcode;  
   BSTR                      bstrOperands;  
   BSTR                      bstrSymbol;  
   UINT64                    uCodeLocationId;  
   TEXT_POSITION             posBeg;  
   TEXT_POSITION             posEnd;  
   BSTR                      bstrDocumentUrl;  
   DWORD                     dwByteOffset;  
   DISASSEMBLY_FLAGS         dwFlags;  
} DisassemblyData;  
public struct DisassemblyData {   
   public uint          dwFields;  
   public string        bstrAddress;  
   public string        bstrAddressOffset;  
   public string        bstrCodeBytes;  
   public string        bstrOpcode;  
   public string        bstrOperands;  
   public string        bstrSymbol;  
   public ulong         uCodeLocationId;  
   public TEXT_POSITION posBeg;  
   public TEXT_POSITION posEnd;  
   public string        bstrDocumentUrl;  
   public uint          dwByteOffset;  
   public uint          dwFlags;  
};  

Members

dwFields
DISASSEMBLY_STREAM_FIELDS指定填寫的欄位是常數。

bstrAddress
從某個起點 (通常是相關聯的函式的開頭) 開始的位移為位址。

bstrCodeBytes
此指令程式碼位元組。

bstrOpcode
這個指令的 opcode。

bstrOperands
這個指令的運算元。

bstrSymbol
符號名稱,如果有的話,相關聯的位址 (公用符號、 標籤和等等)。

uCodeLocationId
反組譯此行程式碼位置識別碼。 一行的程式碼內容位址是否大於另一個程式碼內容位址,則反組譯的碼的第一個位置識別碼也會大於第二個程式碼位置識別碼。

posBeg
TEXT_POSITION對應於文件中的反組譯碼資料的開始處的位置。

posEnd
TEXT_POSITION對應於文件中的反組譯碼資料結束的位置。

bstrDocumentUrl
可以表示為檔案名稱的文字文件bstrDocumentUrl欄位填入檔案名稱,其中可以找到來源,使用格式file://file name

無法以檔案名稱的文字文件bstrDocumentUrl是文件的唯一識別碼,並且偵錯引擎必須實作GetDocument方法。

這個欄位也可以包含總和檢查碼的其他資訊。 如需詳細資訊,請參閱 < 備註 >。

dwByteOffset
指令是從程式碼行開頭的位元組數目。

dwFlags
DISASSEMBLY_FLAGS常數,指定的旗標的使用中。

備註

每個DisassemblyData結構描述一個反組譯碼指令。 這些結構的陣列會傳回從讀取方法。

TEXT_POSITION結構可用於文字為基礎的文件。 此指令的來源的程式碼範圍填寫僅適用於從陳述式或列,例如產生的第一個指令,當dwByteOffset == 0

對於非文字的文件,文件內容可以從程式碼,取得與bstrDocumentUrl欄位應為 null 的值。 如果bstrDocumentUrl欄位相當於bstrDocumentUrl欄位在上一個DisassemblyData陣列項目,然後設定bstrDocumentUrl為 null 值。

如果dwFlags欄位具有DF_DOCUMENT_CHECKSUM旗標設定,其他的總和檢查碼資訊如下所指向的字串bstrDocumentUrl欄位。 具體而言,null 字串結束字元之後那里遵循識別,依次後面 4 位元組值,指出總和檢查碼中的位元組數目,而且依序接著總和檢查碼位元組的總和檢查碼演算法的 GUID。 如何編碼和解碼的欄位中,請參閱本主題的範例Visual C#。

範例

bstrDocumentUrl欄位只能包含字串以外的其他資訊,如果DF_DOCUMENT_CHECKSUM旗標設定。 建立和讀取此編碼的字串的程序是直接在Visual C++。 不過,在Visual C#,它是另一回事。 對於很好奇,下列範例會示範如何建立編碼的字串,從Visual C#和其中一個方法來解碼的編碼的字串中Visual C#。

using System;  
using System.Runtime.InteropServices;  
  
namespace MyNamespace  
    class MyClass  
    {  
        string EncodeData(string documentString,  
                          Guid checksumGuid,  
                          byte[] checksumData)  
        {  
            string returnString = documentString;  
  
            if (checksumGuid == null || checksumData == null)  
            {  
                // Nothing more to do. Just return the string.  
                return returnString;  
            }  
  
            returnString += '\0'; // separating null value  
  
            // Add checksum GUID to string.  
            byte[] guidDataArray  = checksumGuid.ToByteArray();  
            int    guidDataLength = guidDataArray.Length;  
            IntPtr pBuffer        = Marshal.AllocCoTaskMem(guidDataLength);  
            for (int i = 0; i < guidDataLength; i++)  
            {  
                Marshal.WriteByte(pBuffer, i, guidDataArray[i]);  
            }  
            // Copy guid data bytes to string as wide characters.  
            // Assumption: sizeof(char) == 2.  
            for (int i = 0; i < guidDataLength; i++)  
            {  
                returnString += (char)Marshal.ReadInt16(pBuffer, i * sizeof(char));  
            }  
  
            // Add checksum count (a 32-bit value).  
            Int32 checksumCount = checksumData.Length;  
            Marshal.StructureToPtr(checksumCount, pBuffer, true);  
            for (int i = 0; i < sizeof(Int32) / sizeof(char); i++)  
            {  
                returnString += (char)Marshal.ReadInt16(pBuffer, i * sizeof(char));  
            }  
  
            // Add checksum data.  
            pBuffer = Marshal.AllocCoTaskMem(checksumCount);  
            for (int i = 0; i < checksumCount; i++)  
            {  
                Marshal.WriteByte(pBuffer, i, checksumData[i]);  
            }  
            for (int i = 0; i < checksumCount / sizeof(char); i++)  
            {  
                returnString += (char)Marshal.ReadInt16(pBuffer, i * sizeof(char));  
            }  
            Marshal.FreeCoTaskMem(pBuffer);  
  
            return returnString;  
        }  
  
        void DecodeData(    string encodedString,  
                        out string documentString,  
                        out Guid   checksumGuid,  
                        out byte[] checksumData)  
       {  
           documentString = String.Empty;  
           checksumGuid = Guid.Empty;  
           checksumData = null;  
  
           IntPtr pBuffer = Marshal.StringToBSTR(encodedString);  
           if (null != pBuffer)  
           {  
               int bufferOffset = 0;  
  
               // Parse string out.  String is assumed to be Unicode.  
               documentString = Marshal.PtrToStringUni(pBuffer);  
               bufferOffset += (documentString.Length + 1) * sizeof(char);  
  
               // Parse Guid out.  
               // Read guid bytes from buffer and store in temporary  
               // buffer that contains only the guid bytes. Then the  
               // Marshal.PtrToStructure() can work properly.  
               byte[] guidDataArray  = checksumGuid.ToByteArray();  
               int    guidDataLength = guidDataArray.Length;  
               IntPtr pGuidBuffer    = Marshal.AllocCoTaskMem(guidDataLength);  
               for (int i = 0; i < guidDataLength; i++)  
               {  
                   Marshal.WriteByte(pGuidBuffer, i,  
                                     Marshal.ReadByte(pBuffer, bufferOffset + i);  
               }  
               bufferOffset += guidDataLength;  
               checksumGuid = (Guid)Marshal.PtrToStructure(pGuidBuffer, typeof(Guid));  
               Marshal.FreeCoTaskMem(pGuidBuffer);  
  
              // Parse out the number of checksum data bytes (always 32-bit value).  
              int dataCount = Marshal.ReadInt32(pBuffer, bufferOffset);  
              bufferOffset += sizeof(Int32);  
  
              // Parse out the checksum data.  
              checksumData = new byte[dataCount];  
              for (int i = 0; i < dataCount; i++)  
              {  
                  checksumData[i] = Marshal.ReadByte(pBuffer, bufferOffset + i);  
              }  
           }  
       }  
    }  
}  

另請參閱

結構和等位
讀取
DISASSEMBLY_STREAM_FIELDS
IDebugCodeContext2
IDebugDocumentContext2
TEXT_POSITION
DISASSEMBLY_FLAGS