Try calling SetProcessMitigationPolicy function with ProcessSignaturePolicy and PROCESS_MITIGATION_BINARY_SIGNATURE_POLICY structure during process startup.
For example,
PROCESS_MITIGATION_BINARY_SIGNATURE_POLICY policy{};
policy.MicrosoftSignedOnly = TRUE;
if (!SetProcessMitigationPolicy(ProcessSignaturePolicy, &policy, sizeof policy))
{
// Handle error
}
When this is successful, using LoadLibrary to load a non-Microsoft DLL caused the system to display the following -
and GetLastError returned the following right after LoadLibrary failed -