Intel® Software Guard Extensions (Intel® SGX)
Discussion board focused on hardware-based isolation and memory encryption to provide extended code protection in solutions.

Run sgx_create_enclave() from dll

nadiaivc
New Contributor I
1,711 Views

Hello!
Is it possible to run sgx enclave from dll? I have got an .exe application (untrusted module ) that call sgx_create_enclave() and also can call functions from the enclave. But I want to put this untrusted module in different process as dll (so I want this structure: dll (untrusted module) runs dll (enclave)). But it isn't work now... The thread with my LoadLibrary frozes on sgx_create_enclave()

0 Kudos
1 Solution
JesusG_Intel
Moderator
1,614 Views

Hello Nadia,

 

I was able to create an untrusted dll, that interfaces with the enclave, and linked the unstrusted dll with a regular console app and it all worked. I did not use LoadLibrary. Attached are the solution files for your reference. I used absolute paths in the Properties so you will have to modify them.

 

The Untrusted solution contains the Untrusted DLL project and the SGXSDK/SampleEnclave/Enclave project.

Make sure to copy your untrusted dll and enclave.signed.dll to the same location as hello.exe. Set the Debugging/Working Directory to $(OutDir).

I copied the contents from SampleEnclave/app.cpp to Untrusted/dllmain.cpp.

 

Good luck!

 

Sincerely,
Jesus G.
Intel Customer Support

 

View solution in original post

7 Replies
JesusG_Intel
Moderator
1,661 Views

Hello nadia111,


Please describe how you setup the Visual Studio solution for your three projects: the main untrusted executable app, the untrusted dll, and the enclave dll.


Provide:

Screenshots of project properties for C/C++ and Linker.

Screenshot of the solution tree with the projects expanded.


Sincerely,

Jesus G.

Intel Customer Support


0 Kudos
nadiaivc
New Contributor I
1,650 Views

Hello,

Sure. "hello" project is a project with a printing string. In hello.exe I want to inject sgxConsoleApplication.dll (right side). I do injection of sgxConsoleApplication.dll to hello.exe with LoadLibrary.

nadia111_0-1622016323375.png

hello project (the main untrusted executable app)

nadia111_2-1622016613398.png

nadia111_3-1622016623345.png

nadia111_4-1622016671788.png

nadia111_5-1622016688248.png

sgxConsoleApplication (the untrusted dll)

nadia111_7-1622016805765.png

nadia111_8-1622016874597.pngnadia111_9-1622016901699.png

nadia111_10-1622016925379.png

 

EnclaveTest (the enclave dll)

nadia111_11-1622016971812.pngnadia111_12-1622016986852.pngnadia111_13-1622017007059.pngnadia111_14-1622017026980.png

 

 

 

 

 

 

 

 

 

0 Kudos
JesusG_Intel
Moderator
1,631 Views

Thank you for the comprehensive details, Nadia. I am investigating your issue and will respond when I have something useful for you.


Sincerely,

Jesus G.

Intel Customer Support


0 Kudos
nadiaivc
New Contributor I
1,622 Views

Thank you! I will wait for your answer

0 Kudos
JesusG_Intel
Moderator
1,615 Views

Hello Nadia,

 

I was able to create an untrusted dll, that interfaces with the enclave, and linked the unstrusted dll with a regular console app and it all worked. I did not use LoadLibrary. Attached are the solution files for your reference. I used absolute paths in the Properties so you will have to modify them.

 

The Untrusted solution contains the Untrusted DLL project and the SGXSDK/SampleEnclave/Enclave project.

Make sure to copy your untrusted dll and enclave.signed.dll to the same location as hello.exe. Set the Debugging/Working Directory to $(OutDir).

I copied the contents from SampleEnclave/app.cpp to Untrusted/dllmain.cpp.

 

Good luck!

 

Sincerely,
Jesus G.
Intel Customer Support

 

nadiaivc
New Contributor I
1,600 Views

Hello!
I made edits to my project using your sample and it works (yes, it is a "Sucdddess"). I'm so happy! Thank you very much for your time and help!!

0 Kudos
JesusG_Intel
Moderator
1,556 Views

I'm very glad you got it working, Nadia.


This thread has been marked as answered and Intel will no longer monitor this thread. If you want a response from Intel in a follow-up question, please open a new thread.


0 Kudos
Reply