Hi @Byoungtaek Min ,
Since MSASN1.dll
is likely loaded by the .NET runtime or a system-level component, it is difficult to prevent its loading through application code alone. The SetDefaultDllDirectories
function you’ve tried to use is intended to control the directories searched for DLLs, but it doesn’t prevent DLLs from being loaded if they are required by the runtime or the operating system.
If your concern is about DLL side-loading attacks, ensure that your application is running in a secure environment where untrusted DLLs cannot be placed in directories that are searched by the system. You can also consider using features like Windows Defender Application Control (WDAC) to enforce rules about which DLLs can be loaded by your application.
Best Regards.
Jiachen Li
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.