This commit is contained in:
Akash Mozumdar 2018-08-11 14:51:51 -04:00
parent d535ece5a3
commit 707bc2cdf4

View File

@ -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
@ -44,22 +44,10 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID unused)
namespace Host namespace Host
{ {
DLLEXPORT bool Start() DLLEXPORT bool Start()
{
preventDuplicationMutex = CreateMutexW(nullptr, TRUE, ITH_SERVER_MUTEX);
if (GetLastError() == ERROR_ALREADY_EXISTS)
{
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); InitializeCriticalSection(&hostCs);
onAttach = onDetach = nullptr;
onCreate = onRemove = nullptr;
nextThreadNumber = 0;
return true; return true;
} }
}
DLLEXPORT void Open() DLLEXPORT void Open()
{ {