Calling Licensing API Functions From DllMain

In Windows and .Net, DLLs are loaded at run-time according to the order in which they were linked while building the application. During protection of the application or DLL with Sentinel LDK Envelope, the Licensing API is integrated into the protected application. The Licensing API sometimes calls functions that are external to KERNEL32 from DllMain, which is not recommended by Microsoft. This can cause the protected application to crash, because the protected DLL is loaded and executes before the required setup has been completed.

To prevent this occurrence, Thales recommends that you do one of the following:

>Use the External License Manager (hasp_rt.exe). When using the External License Manager, the Licensing API calls only KERNEL32 functions. This is the preferred solution, and this is the only solution that satisfies the Microsoft recommendation that you call only KERNEL32 functions from DllMain.

>If using the External License Manager is not an option, add the protected DLL at the end of the import list of the application. This problem does not occur when the DLL is loaded with LoadLibrary() as the latest library.

Related Topics

Sentinel License Managers - Overview