  int do_ecall(const int fn, const void *ocall_table, const void *ms, CTrustThread *trust_thread);
  int do_ocall(const bridge_fn_t bridge, void *ms);
  
-@@ -388,7 +386,15 @@
+@@ -112,19 +110,21 @@
+ 
+ sgx_status_t CEnclave::initialize(const se_file_t& file, const sgx_enclave_id_t enclave_id, void * const start_addr, const uint64_t enclave_size, const uint32_t tcs_policy, const uint32_t enclave_version, const uint32_t tcs_min_pool)
+ {
+-    uint32_t name_len = file.name_len;
+-    if (file.unicode)
+-        name_len *= (uint32_t)sizeof(wchar_t);
+-
+-    const int buf_len = name_len + 4; //+4, because we need copy the charactor of string end ('\0').;
+-
+-    m_enclave_info.lpFileName = calloc(1, buf_len);
+-    if (m_enclave_info.lpFileName == NULL)
+-        return SGX_ERROR_OUT_OF_MEMORY;
+-
+-    memcpy_s(m_enclave_info.lpFileName, name_len, file.name, name_len);
+-    m_enclave_info.unicode = file.unicode?0:1;
+-    m_enclave_info.file_name_size = name_len;
++    if (file.name != NULL) {
++        uint32_t name_len = file.name_len;
++        if (file.unicode)
++            name_len *= (uint32_t)sizeof(wchar_t);
++
++        const int buf_len = name_len + 4; //+4, because we need copy the charactor of string end ('\0').;
++
++        m_enclave_info.lpFileName = calloc(1, buf_len);
++        if (m_enclave_info.lpFileName == NULL)
++            return SGX_ERROR_OUT_OF_MEMORY;
++
++        memcpy_s(m_enclave_info.lpFileName, name_len, file.name, name_len);
++        m_enclave_info.unicode = file.unicode?0:1;
++        m_enclave_info.file_name_size = name_len;
++    }
+ 
+     m_enclave_info.struct_version = DEBUG_INFO_STRUCT_VERSION;
+ 
+@@ -388,7 +388,15 @@
      return &m_enclave_info;
  }
  

diff -Nur common/inc/sgx_urts.h common/inc/sgx_urts.h
--- common/inc/sgx_urts.h
+++ common/inc/sgx_urts.h
@@ -96,6 +96,8 @@
 
 sgx_status_t SGXAPI sgx_destroy_enclave(const sgx_enclave_id_t enclave_id);
 

 #include "sgx_error.h"
 #include "sgx_urts.h"
 #include "sgx_uswitchless.h"
@@ -102,6 +103,47 @@
     return ret;
 }
 
+extern "C" sgx_status_t __sgx_create_enclave_from_buffer_ex(
+        uint8_t *buffer,
+        size_t buffer_size,
+        const int debug,
+        sgx_launch_token_t *launch_token,
+        int *launch_token_updated,
+        sgx_enclave_id_t *enclave_id,
+        sgx_misc_attribute_t *misc_attr,
+        const uint32_t ex_features,
+        void* ex_features_p[32])
+{
+    sgx_status_t ret = SGX_SUCCESS;
+
+    // Only true or false is valid
+    if (TRUE != debug &&  FALSE != debug)
+    {
+        return SGX_ERROR_INVALID_PARAMETER;
+    }
+
+    if (!_check_ex_params_(ex_features, ex_features_p))
+    {
+        return SGX_ERROR_INVALID_PARAMETER;
+    }
+
+    se_file_t file = {NULL, 0, false};
+    ret = _create_enclave_from_buffer_ex(
+        buffer, buffer_size, !!debug, file, NULL, launch_token,
+        launch_token_updated, enclave_id, misc_attr, ex_features,
+        ex_features_p);
+    if (SGX_SUCCESS != ret && misc_attr)
+    {
+        sgx_misc_attribute_t plat_cap;
+        memset(&plat_cap, 0, sizeof(plat_cap));
+        get_enclave_creator()->get_plat_cap(&plat_cap);
+        memcpy_s(misc_attr, sizeof(sgx_misc_attribute_t), &plat_cap,
+                 sizeof(sgx_misc_attribute_t));
+    }
+
+    return ret;
+}
+
 extern "C" sgx_status_t sgx_create_enclave(const char *file_name, 
                                            const int debug, 
                                            sgx_launch_token_t *launch_token, 
@@ -113,6 +155,21 @@
 }
 
 
+extern "C" sgx_status_t sgx_create_enclave_from_buffer(
+        uint8_t *buffer,
+        size_t buffer_size,
+        const int debug,
+        sgx_launch_token_t *launch_token,
+        int *launch_token_updated,
+        sgx_enclave_id_t *enclave_id,
+        sgx_misc_attribute_t *misc_attr)
+{
+    return __sgx_create_enclave_from_buffer_ex(
+        buffer, buffer_size, debug, launch_token, launch_token_updated,
+        enclave_id, misc_attr, 0, NULL);
+}
+
+
 extern "C"  sgx_status_t sgx_create_enclave_ex(const char *file_name,
                                                const int debug,
                                                sgx_launch_token_t *launch_token,
@@ -145,3 +202,20 @@
     return __sgx_create_enclave_ex(file_name, debug, launch_token,
         launch_token_updated, enclave_id, misc_attr, ex_features, ex_features_p);
 }
