Use lock guards for mutex locking

This commit is contained in:
momo5502
2016-09-05 21:58:59 +02:00
parent d6ade55958
commit 8fb6ea0b63
6 changed files with 15 additions and 21 deletions

View File

@ -136,11 +136,10 @@ namespace Utils
Hook* Hook::Install(bool unprotect, bool keepUnportected)
{
Hook::StateMutex.lock();
std::lock_guard<std::mutex> _(Hook::StateMutex);
if (!Hook::Initialized || Hook::Installed)
{
Hook::StateMutex.unlock();
return this;
}
@ -159,8 +158,6 @@ namespace Utils
FlushInstructionCache(GetCurrentProcess(), Hook::Place, sizeof(Hook::Buffer));
Hook::StateMutex.unlock();
return this;
}