ICLRDebuggingLibraryProvider::ProvideLibrary 方法ICLRDebuggingLibraryProvider::ProvideLibrary Method

取得程式庫提供者回呼介面,這個介面可讓您視需要找出並載入 common language runtime (CLR) 版本特定的偵錯工具程式庫。Gets a library provider callback interface that allows common language runtime (CLR) version-specific debugging libraries to be located and loaded on demand.


HRESULT ProvideLibrary(
     [in] const WCHAR* pwszFileName,
     [in] DWORD dwTimestamp,
     [in] DWORD dwSizeOfImage,
     [out] HMODULE* hModule);


在所要求的模組名稱。[in] The name of the module being requested.

在儲存在 PE 檔案的 COFF 檔案標頭中的日期時間戳記。[in] The date time stamp stored in the COFF file header of PE files.

SizeOfImage 儲存在 PE 檔案的 COFF 選擇性檔案標頭中的欄位。[in] The SizeOfImage field stored in the COFF optional file header of PE files.

擴展要求的模組之控制碼。[out] The handle to the requested module.

傳回值Return Value

這個方法會傳回下列特定的 HRESULT,以及表示方法失敗的 HRESULT 錯誤。This method returns the following specific HRESULTs as well as HRESULT errors that indicate method failure.

S_OKS_OK 已成功完成命令。The method completed successfully.



ProvideLibrary 允許偵錯工具提供在偵測特定 CLR 檔案(例如 mscordbi.dll 和 mscordacwks.dll)時所需的模組。ProvideLibrary allows the debugger to provide modules that are needed for debugging specific CLR files such as mscordbi.dll and mscordacwks.dll. 模組控制碼必須維持有效,直到呼叫 ICLRDebugging:: CanUnloadNow 方法指出它們可能會被釋放為止,此時呼叫端必須負責釋放控制碼。The module handles have to remain valid until a call to the ICLRDebugging::CanUnloadNow method indicates that they may be freed, at which point it is the caller’s responsibility to free the handles.

偵錯工具可以使用任何可用的方法來找出或購買偵錯工具模組。The debugger may use any available means to locate or procure the debugging module.


這項功能可讓 API 呼叫端提供包含可執行檔的模組,以及可能的惡意程式碼。This feature allows the API caller to provide modules that contain executable, and possibly malicious, code. 為了安全起見,呼叫端不應該使用 ProvideLibrary 來散發任何不願意自行執行的程式碼。As a security precaution, the caller should not use ProvideLibrary to distribute any code that it is not willing to execute itself.

如果在已發行的程式庫中發現嚴重的安全性問題,例如 mscordbi.dll 或 mscordacwks.dll,則可以修補填充碼以辨識檔案的錯誤版本。If a serious security issue is discovered in an already released library, such as mscordbi.dll or mscordacwks.dll, the shim can be patched to recognize the bad versions of the files. 然後,填充碼可以針對已修補的檔案版本發出要求,並在提供回應任何要求時拒絕錯誤的版本。The shim can then issue requests for the patched versions of the files and reject the bad versions if they are provided in response to any request. 只有當使用者已修補新版本的填充碼時,才會發生此情況。This can occur only if the user has patched to a new version of the shim. 未修補的版本將會保持易受攻擊。Unpatched versions will remain vulnerable.


平台: 請參閱 系統需求Platforms: See System Requirements.

標頭: CorDebug.idl、CorDebug.hHeader: CorDebug.idl, CorDebug.h

程式庫: CorGuids.libLibrary: CorGuids.lib

.NET Framework 版本:自 4 起可用Available since 4.NET Framework Versions: 自 4 起可用Available since 4

另請參閱See also