Community
cancel
Showing results for 
Search instead for 
Did you mean: 
mingbo_z_1
Beginner
243 Views

Intel SGX, sgx_create_enclave() never returns if called from dllmain()

Jump to solution

Hello,

SGX API works fine if it's called from a process. I can create an enclave successfully.

But when sgx_create_enclave() is called from dllmain(), it never returns. It eventually calls WaitForSingleObject() and wait there. 

No matter the dll is injected into a process or load by a process.

Thanks :)
uty

0 Kudos
1 Solution
243 Views

I believe this is due to:

Dynamic-Link Library Best Practices https://msdn.microsoft.com/en-us/library/windows/desktop/dn633971(v=vs.85).aspx

"You should never perform the following tasks from within DllMain:
*  Call LoadLibrary or LoadLibraryEx (either directly or indirectly). This can cause a deadlock or a crash."

(edited to fix link)

View solution in original post

3 Replies
Mingbo_Z_
Beginner
243 Views

I installed the latest version of SDK, still got the same problem.

244 Views

I believe this is due to:

Dynamic-Link Library Best Practices https://msdn.microsoft.com/en-us/library/windows/desktop/dn633971(v=vs.85).aspx

"You should never perform the following tasks from within DllMain:
*  Call LoadLibrary or LoadLibraryEx (either directly or indirectly). This can cause a deadlock or a crash."

(edited to fix link)

View solution in original post

Mingbo_Z_
Beginner
243 Views

FRANCISCO C. (Intel) wrote:

I believe this is due to:

Dynamic-Link Library Best Practices https://msdn.microsoft.com/en-us/library/windows/desktop/dn633971(v=vs.85).aspx

"You should never perform the following tasks from within DllMain:
*  Call LoadLibrary or LoadLibraryEx (either directly or indirectly). This can cause a deadlock or a crash."

(edited to fix link)

Thanks for the reply and link :)

I know sgx_create_enclave()  will load xxx.signed.dll at some point.   I want use sgx in some processes which I don't have source code. I guess I have to use sgx_create_enclave() lazily (The first time I need to use enclave).

Thanks :)

Reply