MCPcopy Create free account
hub / github.com/M2Team/NanaZip / K7BaseDisableDynamicCodeGeneration

Function K7BaseDisableDynamicCodeGeneration

K7Base/K7BaseMitigations.cpp:97–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95}
96
97EXTERN_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
133EXTERN_C MO_RESULT MOAPI K7BaseDisableChildProcessCreation()
134{

Callers 7

NanaZipInitializeFunction · 0.85
NanaZipInitializeFunction · 0.85
NanaZipInitializeFunction · 0.85
NanaZipInitializeFunction · 0.85
NanaZipInitializeFunction · 0.85
NanaZipInitializeFunction · 0.85
NanaZipInitializeFunction · 0.85

Tested by

no test coverage detected