Fix race condition
Fix race condition when renderer was found and we were hooking a library funcmerge-requests/28/head
parent
894300b6f4
commit
4d99b6affd
|
@ -522,6 +522,11 @@ void Renderer_Detector::find_renderer_proc(Renderer_Detector* _this)
|
|||
std::vector<std::string>::const_iterator it = libraries.begin();
|
||||
while (it != libraries.end())
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_this->_found_mutex);
|
||||
if (_this->_renderer_found)
|
||||
break;
|
||||
|
||||
it = std::find_if(it, libraries.end(), [](std::string const& name) {
|
||||
auto x = GetModuleHandle(name.c_str());
|
||||
if (x != NULL)
|
||||
|
@ -535,6 +540,7 @@ void Renderer_Detector::find_renderer_proc(Renderer_Detector* _this)
|
|||
_this->create_hook(it->c_str());
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
}
|
||||
|
@ -824,6 +830,7 @@ extern "C" void* dlsym(void* handle, const char* name)
|
|||
|
||||
void Renderer_Detector::renderer_found(Base_Hook* hook)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_found_mutex);
|
||||
Hook_Manager& hm = Hook_Manager::Inst();
|
||||
|
||||
_renderer_found = true;
|
||||
|
|
|
@ -16,6 +16,7 @@ class Renderer_Detector
|
|||
private:
|
||||
// Variables
|
||||
std::thread* _hook_thread;
|
||||
std::mutex _found_mutex;
|
||||
unsigned int _hook_retries;
|
||||
bool _renderer_found; // Is the renderer hooked ?
|
||||
bool _dx9_hooked;
|
||||
|
@ -70,6 +71,7 @@ class Renderer_Detector
|
|||
{
|
||||
// Variables
|
||||
std::thread* _hook_thread;
|
||||
std::mutex _found_mutex;
|
||||
unsigned int _hook_retries;
|
||||
bool _oglx_hooked;
|
||||
bool _renderer_found; // Is the renderer hooked ?
|
||||
|
|
|
@ -165,7 +165,6 @@ UINT WINAPI Windows_Hook::MyGetRawInputData(HRAWINPUT hRawInput, UINT uiCommand,
|
|||
|
||||
RawMouseEvent(*reinterpret_cast<RAWINPUT*>(pData));
|
||||
|
||||
//memset(pData, 0, *pcbSize);
|
||||
*pcbSize = 0;
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue