refactor
This commit is contained in:
parent
d535ece5a3
commit
707bc2cdf4
26
host/host.cc
26
host/host.cc
@ -13,15 +13,15 @@
|
|||||||
|
|
||||||
HANDLE preventDuplicationMutex;
|
HANDLE preventDuplicationMutex;
|
||||||
|
|
||||||
std::unordered_map<ThreadParameter, TextThread*, ThreadParameterHasher> textThreadsByParams;
|
std::unordered_map<ThreadParameter, TextThread*, ThreadParameterHasher> textThreadsByParams(10);
|
||||||
std::unordered_map<DWORD, ProcessRecord> processRecordsByIds;
|
std::unordered_map<DWORD, ProcessRecord> processRecordsByIds(2);
|
||||||
|
|
||||||
CRITICAL_SECTION hostCs;
|
CRITICAL_SECTION hostCs;
|
||||||
|
|
||||||
ThreadEventCallback onCreate, onRemove;
|
ThreadEventCallback onCreate(nullptr), onRemove(nullptr);
|
||||||
ProcessEventCallback onAttach, onDetach;
|
ProcessEventCallback onAttach(nullptr), onDetach(nullptr);
|
||||||
|
|
||||||
WORD nextThreadNumber;
|
WORD nextThreadNumber(0);
|
||||||
HWND dummyWindow;
|
HWND dummyWindow;
|
||||||
|
|
||||||
#define HOST_LOCK CriticalSectionLocker hostLocker(&hostCs) // Synchronized scope for accessing private data
|
#define HOST_LOCK CriticalSectionLocker hostLocker(&hostCs) // Synchronized scope for accessing private data
|
||||||
@ -45,20 +45,8 @@ namespace Host
|
|||||||
{
|
{
|
||||||
DLLEXPORT bool Start()
|
DLLEXPORT bool Start()
|
||||||
{
|
{
|
||||||
preventDuplicationMutex = CreateMutexW(nullptr, TRUE, ITH_SERVER_MUTEX);
|
InitializeCriticalSection(&hostCs);
|
||||||
if (GetLastError() == ERROR_ALREADY_EXISTS)
|
return true;
|
||||||
{
|
|
||||||
MessageBoxW(nullptr, L"I am sorry that this game is attached by some other VNR ><\nPlease restart the game and try again!", L"Error", MB_ICONERROR);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
InitializeCriticalSection(&hostCs);
|
|
||||||
onAttach = onDetach = nullptr;
|
|
||||||
onCreate = onRemove = nullptr;
|
|
||||||
nextThreadNumber = 0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DLLEXPORT void Open()
|
DLLEXPORT void Open()
|
||||||
|
Loading…
Reference in New Issue
Block a user