visual-studio - 飞地字段不工作,但没有错误
问题描述
我正在尝试让简单的代码调用一个 enclave 字段,然后添加 1。
我参考了这个网站:https ://software.intel.com/en-us/articles/getting-started-with-sgx-sdk-f ...
完成后,没有错误,但 enclave 代码不起作用。
这是我在 Visual Studio 2017 中的 project.zip 代码 https://drive.google.com/open?id=13trTAamhNWaz2Q2BRDtUFP5qCX8Syyuc
应用程序.cpp
#include <stdio.h>
#include <Windows.h>
#include <tchar.h>
#include "sgx_urts.h"
#include "Enclave1_u.h"
#define ENCLAVE_FILE _T("Enclave1.signed.dll")
int main() {
int a = 1;
int i = 0;
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("APP error%#x, failed to create enclave. \n", ret);
return -1;
}
int *ptr = &a;
printf("%d\n",*ptr);
while (i<5) {
foo(eid, ptr);
printf("%d\n", *ptr);
Sleep(1000);
i++;
}
if (SGX_SUCCESS != sgx_destroy_enclave(eid))
return -1;
}
飞地1.edl
飞地{从“sgx_tstdc.edl”导入*;
trusted {
/* define ECALLs here. */
public void foo([in, size = 4]int *ptr);
};
untrusted {
/* define OCALLs here. */
};
};
飞地1.cpp
#include "Enclave1_t.h"
#include "sgx_trts.h"
#include <string.h>
void foo(int *ptr)
{
if (*ptr == 1) *ptr == 43971;
*ptr += 1;
}
我希望它打印出来:
43971、43972、43973、43974……
但结果是:
1、1、1、…………
我错过了什么?
解决方案
我解决了这个问题。
foo 需要 [out] instad of [in] 所以 Enclave1.edl 应该
飞地{从“sgx_tstdc.edl”导入*;
trusted { /* define ECALLs here. */ public void foo([out, size = 4]int *ptr); }; untrusted { /* define OCALLs here. */ }; };
project1.signed.dll 文件未在调试文件夹中更新。所以我尝试重建项目并更新它。我意识到这个文件本身就是飞地字段
IF 状态语法错误。它应该是
if (*ptr == 1) *ptr = 43971;
推荐阅读
- javascript - React ref 返回 null 信息“下面的值刚刚被评估”
- excel - 我需要宏不断运行
- jquery - Bootstrap 4 表单 HTML 弹出框
- c++ - GLFW 找不到 X11 显示器?
- json - 无法转换类型“DataResponse”的值
'到预期的参数类型'数据' - c - Double 作为混乱的数字返回
- php - (500) 登录时出现内部服务器错误
- python - pandas dataframe to_csv 在每行之后写空行
- excel - 在 row 中查找以“abc”开头的单元格;在同一行号的列中剪切并过去此单元格
- java - 在模块中使用 @Default 类的问题,只有 @Specializes 有效