Patch functions while holding the lock

This commit is contained in:
Maschell 2026-05-04 18:57:49 +02:00
parent 795dfd6ca1
commit 8a8725e6f9

View File

@ -38,8 +38,9 @@ FunctionPatcherStatus FPAddFunctionPatch(function_replacement_data_t *function_d
return FUNCTION_PATCHER_RESULT_UNKNOWN_ERROR; return FUNCTION_PATCHER_RESULT_UNKNOWN_ERROR;
} }
{
std::lock_guard lock(gPatchedFunctionsMutex);
auto &functionData = functionDataOpt.value(); auto &functionData = functionDataOpt.value();
// PatchFunction calls OSFatal on fatal errors. // PatchFunction calls OSFatal on fatal errors.
// If this function returns false the target function was not patched // If this function returns false the target function was not patched
// Usually this means the target RPL is not (yet) loaded. // Usually this means the target RPL is not (yet) loaded.
@ -52,8 +53,6 @@ FunctionPatcherStatus FPAddFunctionPatch(function_replacement_data_t *function_d
*outHandle = functionData->getHandle(); *outHandle = functionData->getHandle();
} }
{
std::lock_guard lock(gPatchedFunctionsMutex);
gPatchedFunctions.push_back(std::move(functionData)); gPatchedFunctions.push_back(std::move(functionData));
OSMemoryBarrier(); OSMemoryBarrier();