2017-01-30 57 views
0

我正在尝试编写一个简单的SGX项目作为开始。所以,我有,我已经差不多从Lars Richter's blog复制此主主机应用程序:加载Enclave时出错:无法使用CreateFile()打开文件

#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; 
} 

它编译罚款(我使用的是英特尔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. 
+1

确实存在Enclave.signed.dll某处sgx_create_enclave会发现它? –

+0

它位于解决方案的调试文件夹中。 –

+0

什么让你觉得sgx_create_enclave(不管那是什么)会在那里找到它? –

回答

1

转到app_test_save项目设置。在调试,改变工作目录$(SolutionDir)调试。这个回答假设这两个项目app_test_saveenclave_test_save属于同一个解决方案。

0

正如尼尔指出,sgx_create_enclave找不到时,正在从Visual Studio的调试器中运行该程序的DLL。当我直接在“Debug”文件夹中运行可执行文件时,它工作正常。

因此,一个简单的技巧,使其在这两种环境的工作是要做到以下几点:

#define ENCLAVE_FILE _T("../Debug/Enclave.signed.dll") 
+0

这种解决方案会导致你在其他地方的问题,因为它假定DLL将永远是相对于工作目录。例如程序可以从C:的根目录运行,如'c:\ Users \ user \ program',dll将在'c:\ .. \ Debug'中找到,这是一个不存在的目录。 – user4581301

+0

在这一点上我不关心生产问题。 –

+0

可以理解,但这些答案只能被其他人阅读,其他人则需要知道这种解决方案可能无法用于他们的案例。 – user4581301

相关问题