  
      TCHAR *p_last_slash = _tcsrchr(p_file_path, _T('\\'));
      if (p_last_slash != NULL)
-@@ -1077,6 +1103,62 @@
+@@ -1077,6 +1059,62 @@
      return(refqt_ret);
  }
  

         m_eid(0),
         m_pencryptedppid(NULL)
     {
@@ -196,7 +203,10 @@
     }
 };
 

 
 #ifdef ENABLE_QE3_LOGGING
 /* OCall functions for debug */
@@ -237,17 +289,10 @@
     sgx_get_quote_config_func_t p_sgx_get_quote_config = NULL;
     sgx_free_quote_config_func_t p_sgx_free_quote_config = NULL;
     sgx_ql_config_t *p_pck_cert_config = NULL;
-
-    #ifndef _MSC_VER
-    void *handle = NULL;
+    library_handle_t handle = NULL;
     char *error1 = NULL;
     char *error2 = NULL;
-    #ifndef DISABLE_TRACE
     bool old_libname_used = false;
-    #endif
-    #else
-    HINSTANCE handle;
-    #endif
 
     if((NULL == p_pck_cert_id) ||
        (NULL == p_cert_cpu_svn) ||
@@ -259,26 +304,24 @@
         return SGX_QL_ERROR_INVALID_PARAMETER;
     }
 
-    #ifndef _MSC_VER
-    handle = dlopen(SGX_QL_QUOTE_CONFIG_LIB_FILE_NAME, RTLD_LAZY);
-    if (NULL == handle)
+    handle = load_library(SGX_QL_QUOTE_CONFIG_LIB_FILE_NAME);
+    if (NULL == handle && NULL != SGX_QL_QUOTE_CONFIG_LIB_FILE_NAME_LEGACY)
     {
         ///TODO:
         // This is a temporary solution to make sure the legacy library without a version suffix can be loaded.
         // We shalll remove this when we have a major version change later and drop the backward compatible
         // support for old lib name.
-        #ifndef DISABLE_TRACE
         old_libname_used = true;
-        #endif
-        handle = dlopen(SGX_QL_QUOTE_CONFIG_LIB_FILE_NAME_LEGACY, RTLD_LAZY);
+        handle = load_library(SGX_QL_QUOTE_CONFIG_LIB_FILE_NAME_LEGACY);
     }
+
     if (handle) {
         SE_TRACE(SE_TRACE_DEBUG, "Found the Quote's dependent library. %s.\n",
             old_libname_used ? SGX_QL_QUOTE_CONFIG_LIB_FILE_NAME_LEGACY : SGX_QL_QUOTE_CONFIG_LIB_FILE_NAME);
-        p_sgx_get_quote_config = (sgx_get_quote_config_func_t)dlsym(handle, "sgx_ql_get_quote_config");
-        error1 = dlerror();
-        p_sgx_free_quote_config = (sgx_free_quote_config_func_t)dlsym(handle, "sgx_ql_free_quote_config");
-        error2 = dlerror();
+        p_sgx_get_quote_config = (sgx_get_quote_config_func_t)lookup_symbol(handle, "sgx_ql_get_quote_config");
+        error1 = get_lookup_error();
+        p_sgx_free_quote_config = (sgx_free_quote_config_func_t)lookup_symbol(handle, "sgx_ql_free_quote_config");
+        error2 = get_lookup_error();
 
         if ((NULL == error1) &&
              (NULL != p_sgx_get_quote_config) &&
@@ -349,85 +392,8 @@
         }
     }
     if(NULL != handle) {
-        dlclose(handle);
-    }
-    #else
-    handle = LoadLibrary(TEXT(SGX_QL_QUOTE_CONFIG_LIB_FILE_NAME));
-    if (handle != NULL) {
-        SE_TRACE(SE_TRACE_DEBUG, "Found the Quote's dependent library. %s.\n", SGX_QL_QUOTE_CONFIG_LIB_FILE_NAME);
-        p_sgx_get_quote_config = (sgx_get_quote_config_func_t)GetProcAddress(handle, "sgx_ql_get_quote_config");
-        p_sgx_free_quote_config = (sgx_free_quote_config_func_t)GetProcAddress(handle, "sgx_ql_free_quote_config");
-        if ((NULL != p_sgx_get_quote_config) &&
-            (NULL != p_sgx_free_quote_config)){
-            SE_TRACE(SE_TRACE_DEBUG, "Found the sgx_ql_get_quote_config and sgx_ql_free_quote_config API.\n");
-            SE_TRACE(SE_TRACE_DEBUG, "Request the Quote Config data.\n");
-            ret_val = p_sgx_get_quote_config(p_pck_cert_id, &p_pck_cert_config);
-            if (SGX_QL_SUCCESS != ret_val) {
-                SE_TRACE(SE_TRACE_ERROR, "Error returned from the p_sgx_get_quote_config API. 0x%04x\n", ret_val);
-                ret_val = SGX_QL_NO_PLATFORM_CERT_DATA;
-                goto CLEANUP;
-            }
-            if (NULL == p_pck_cert_config) {
-                ret_val = SGX_QL_NO_PLATFORM_CERT_DATA;
-                SE_TRACE(SE_TRACE_ERROR, "p_sgx_get_quote_config returned NULL for p_pck_cert_config.\n");
-                goto CLEANUP;
-            }
-            if (p_pck_cert_config->version != SGX_QL_CONFIG_VERSION_1) {
-                SE_TRACE(SE_TRACE_ERROR, "p_sgx_get_quote_config returned incompatible pck_cert_config version.\n");
-                ret_val = SGX_QL_NO_PLATFORM_CERT_DATA;
-                goto CLEANUP;
-            }
-            if (0 != memcpy_s(p_cert_cpu_svn, sizeof(*p_cert_cpu_svn), &p_pck_cert_config->cert_cpu_svn, sizeof(p_pck_cert_config->cert_cpu_svn))) {
-                ret_val = SGX_QL_ERROR_UNEXPECTED;
-                goto CLEANUP;
-            }
-            *p_cert_pce_isv_svn = p_pck_cert_config->cert_pce_isv_svn;
-            if (NULL == p_cert_data) {
-                // The caller only needs the TCBm and/or the required buffer size.
-                // Return the required buffer size.
-                *p_cert_data_size = p_pck_cert_config->cert_data_size;
-            }
-            else {
-                // The caller wants the TCBm and the required buffer size.
-                if (*p_cert_data_size < p_pck_cert_config->cert_data_size) {
-                    // The buffer passed in to this API is not large enouge to contain the provider library's returned cert data.
-                    // This shouldn't happen since the passed in value should be the result of calling this function
-                    // with the inputted p_cert_data equal to NULL just befor this caller.
-                    SE_TRACE(SE_TRACE_ERROR, "sgx_ql_get_quote_config returned a cert_data_size too large to fit in inputted buffer.\n");
-                    ret_val = SGX_QL_ERROR_INVALID_PARAMETER;
-                    goto CLEANUP;
-                }
-                if (NULL == p_pck_cert_config->p_cert_data) {
-                    SE_TRACE(SE_TRACE_ERROR, "sgx_ql_get_quote_config returned NULL for p_cert_data.\n");
-                    ret_val = SGX_QL_NO_PLATFORM_CERT_DATA;
-                    goto CLEANUP;
-                }
-                // Copy the returned cert data
-                if (0 != memcpy_s(p_cert_data, *p_cert_data_size, p_pck_cert_config->p_cert_data, p_pck_cert_config->cert_data_size)) {
-                    ret_val = SGX_QL_ERROR_UNEXPECTED;
-                    goto CLEANUP;
-                }
-                // Return the number of bytes copied.
-                *p_cert_data_size = p_pck_cert_config->cert_data_size;
-            }
-        }
-        else {
-            SE_TRACE(SE_TRACE_WARNING, "Couldn't find 'sgx_ql_get_quote_config()' and 'sgx_ql_free_quote_config()' in the platform library.\n");
-        }
+        close_library(handle);
     }
-    else {
-        SE_TRACE(SE_TRACE_DEBUG, "Couldn't find the platform library. %s\n");
-    }
-    CLEANUP:
-    if (NULL != p_sgx_free_quote_config) {
-        if (NULL != p_pck_cert_config) {
-            p_sgx_free_quote_config(p_pck_cert_config);
-        }
-    }
-    if (NULL != handle) {
-        FreeLibrary(handle);
-    }
-    #endif
 
     return(ret_val);
 }
@@ -447,24 +413,38 @@
     if(!p_file_name || !p_file_path) {
         return false;
     }
