Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

狀況

當您輸入的是位在固定的位址,在 Visual Studio 偵錯工具中的 [監看式] 視窗中的物件的物件名稱時,您會收到類似下列的訊息:

未定義的識別項的 object_name

例如,編譯,並在 x86 為基礎的系統上執行下列程式碼可加以重現這個問題:

Relocate.asm
      .586
      .MODEL FLAT
      PUBLIC _fixed_struct
      _fixed_struct = 04000000h
      END

Main.cpp
#include <Windows.h>

#define SHM_ADDRESS 0x04000000
#define SHM_SIZE_BYTES 1024
#define SHM_NAME L"TEST_NAME"

extern "C"
{
   extern struct fixed_struct_type {
      int a;
      int b;
      int c;
   } fixed_struct;
}

void AttachShm()
{
   HANDLE mapfile = CreateFileMapping(
      INVALID_HANDLE_VALUE,  // current file handle (use System page file)
      NULL,                  // default security (not inheritable)
      PAGE_READWRITE,        // read/write permission
      0,                     // size of File (high-order doubleword)
      SHM_SIZE_BYTES,        // size of File (low-order doubleword)
      SHM_NAME);             // name of mapping object

   MapViewOfFileEx(
      mapfile,               // handle to mapping object
      FILE_MAP_ALL_ACCESS,   // read/write permission
      0,                     // address offset (high-order doubleword)
      0,                     // address offset (low-order doubleword)
      SHM_SIZE_BYTES,        // size of common block
      (LPVOID)SHM_ADDRESS);  // suggested starting address
}

int main(int argc, char* argv[])
{
   AttachShm();

   fixed_struct.a = 30;
   
   // Put a breakpoint on the next line, view fixed_struct.a in watch window
   return 0;
}

原因

在舊版的 Visual Studio 中,偵錯工具會使用相對的地址,而不是絕對位址的所有變數。這會造成位於固定的位址不在目前的堆疊框架的即時範圍的變數。

解決方案

此修正程式只適用於 Visual Studio 的 2015年更新 3。如果您想要檢視絕對位址,您必須使用 Visual Studio 的 2015年更新 3 或更新版本。

此修正程式適用於從 「 Microsoft 下載中心 」 下載:

立即下載修正程式套件。

Microsoft 會掃描有病毒,這個檔案使用的已張貼檔案的日期中的 [可用的最新病毒偵測軟體。檔案儲存在加強保全的伺服器,以避免任何未經授權的更改它。

Need more help?

Want more options?

探索訂閱權益、瀏覽訓練課程、瞭解如何保護您的裝置等等。

社群可協助您詢問並回答問題、提供意見反應,以及聆聽來自具有豐富知識的專家意見。

Was this information helpful?

How satisfied are you with the translation quality?
What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×