| 95 | } |
| 96 | |
| 97 | EXTERN_C MO_RESULT MOAPI K7BaseDisableDynamicCodeGeneration() |
| 98 | { |
| 99 | #ifndef _DEBUG |
| 100 | if (!::K7BaseGetAllowDynamicCodeGenerationPolicy()) |
| 101 | { |
| 102 | PROCESS_MITIGATION_DYNAMIC_CODE_POLICY Policy = {}; |
| 103 | |
| 104 | // Get the current policy state to avoid failing to set the mitigation |
| 105 | // policy when the callers already have set the policy to a more strict |
| 106 | // state. |
| 107 | if (!::GetCurrentProcessMitigationPolicy( |
| 108 | ProcessDynamicCodePolicy, |
| 109 | &Policy, |
| 110 | sizeof(PROCESS_MITIGATION_DYNAMIC_CODE_POLICY))) |
| 111 | { |
| 112 | // We should not trust the policy state if the get call fails, but |
| 113 | // we can still try to set the policy. |
| 114 | Policy = {}; |
| 115 | } |
| 116 | |
| 117 | Policy.ProhibitDynamicCode = 1; |
| 118 | Policy.AllowThreadOptOut = 1; |
| 119 | |
| 120 | if (!::SetProcessMitigationPolicy( |
| 121 | ProcessDynamicCodePolicy, |
| 122 | &Policy, |
| 123 | sizeof(PROCESS_MITIGATION_DYNAMIC_CODE_POLICY))) |
| 124 | { |
| 125 | return MO_RESULT_ERROR_FAIL; |
| 126 | } |
| 127 | } |
| 128 | #endif // _DEBUG |
| 129 | |
| 130 | return MO_RESULT_SUCCESS_OK; |
| 131 | } |
| 132 | |
| 133 | EXTERN_C MO_RESULT MOAPI K7BaseDisableChildProcessCreation() |
| 134 | { |
no test coverage detected