[英]Error Loading Enclave: Couldn't open file with CreateFile()
我正在嘗試編寫一個簡單的SGX項目作為開始。 因此,我有一個主要的主機應用程序例程,該例程已從Lars Richter的博客中復制而來:
#define ENCLAVE_FILE _T("Enclave.signed.dll")
#include <tchar.h>
#include <cstdio>
#include "sgx_urts.h"
#include "Enclave_u.h"
int main()
{
sgx_enclave_id_t eid;
sgx_status_t ret = SGX_SUCCESS;
sgx_launch_token_t token = { 0 };
int updated = 0;
ret = sgx_create_enclave(ENCLAVE_FILE, SGX_DEBUG_FLAG, &token, &updated, &eid, NULL);
if (ret != SGX_SUCCESS) {
printf("\nApp: error %#x, failed to create enclave.\n", ret);
}
scanf("\n");
return 0;
}
它可以很好地編譯(我將Intel C ++ 17.0編譯器與Visual Studio 2015一起使用),但不會加載該區域。 我收到以下錯誤消息:
[sgx_create_enclavew ..\urts\win\urts.cpp:195] Couldn't open file with CreateFile()
App: error 0x200f, failed to create enclave.
轉到app_test_save項目設置。 在“ 調試”下 ,將工作目錄更改為$(SolutionDir)Debug 。 該答案假定兩個項目app_test_save和enclave_test_save都屬於同一解決方案。
正如Neil指出的那樣,當從Visual Studio的調試器中運行程序時,sgx_create_enclave找不到dll。 當我直接在“ Debug”文件夾中運行可執行文件時,它運行良好。
因此,使其在兩種設置中均可工作的一個簡單技巧就是執行以下操作:
#define ENCLAVE_FILE _T("../Debug/Enclave.signed.dll")
據此: https : //software.intel.com/zh-cn/forums/intel-software-guard-extensions-intel-sgx/topic/623738
如果使用本地SGX調試器,請確保更改指向“ $(OutDir)”而不是“ $(ProjectDir)”的“當前工作目錄”。
配置屬性->調試->工作目錄-> $(OutDir)。
錯誤基本上意味着它無法找到您的.dll文件。 執行dir / a / s查找Enclave.signed.dll,然后適當更改名稱。 創建安全區時,它將生成signed.dll文件。 如果您的安全區名稱為Enclave12,則DLL名稱為Enclave12.signed.dll。 您解決此問題,然后就應該做好了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.