IMAGEHLP_SYMBOL64 and NULL terminator
看到這個,覺得實在應該要記錄一下我的困惑:MSDN » IMAGEHLP_SYMBOL64 Structure。
Windows 的Debug Help Library (dbghelp.dll),是用來幫助我們撰寫 debugger,或針對 PE (Portable Executable) 執行檔做一些特殊處理。IMAGEHLP_SYMBOL64 是 dbghelp.dll 提供的一個結構,搭配 SymGetSymFromAddr64(),可以讓我們從任意的程式執行位址,如當下的 esp、ebp 暫存器的值,取得含括這個位址的 function symbol[1]。白話一點講,就是給定一個位址,得到這個位址位在哪一個函式裡面。再搭配 StackWalk64(),我們就可以取得程式的 backtrace[2]。
不過,查看 IMAGEHLP_SYMBOL64 的 MSDN 頁面,卻看到讓我感到十分困惑的說明:
...
Members
...
MaxNameLength- The maximum length of the string that the Name member can contain, in characters, not including the null-terminating character. Because symbol names can vary in length, this data structure is allocated by the caller. This member is used so the library knows how much memory is available for use by the symbol name.
Name- The decorated or undecorated symbol name. If the buffer is not large enough for the complete name, it is truncated to
MaxNameLengthcharacters, including the null-terminating character.
這是怎樣?一下子 null-terminating character 包含在裡面,一下子又不包含在裡面。



3 Comments
自己寫個小程式去測?
av,
測了一版 Windows,還有千千萬萬版 Windows。XD
Jeff Hung
我的電腦不知為什麼經常有一些程式說找不到DBGHELP
電腦開機的時候它說元件savedump不能運作,因為找不到DBGHELP之類的訊息,我把DBGHELP.dll放到C:\WINDOWS\system32底下之後重開機變了savedump不能運作因為找不到SymGetSymFromAddr64的DBGHELP之類訊息,請問有什麼方法解決?還有有方法防止程式/元件遺失DBGHELP的嗎?(我遺失了window的光碟,除了重新安裝之外有方法解決嗎?T^T
Post a Comment