Как всем известно в Battle of immortals разработчиками разрешено запускать не более трех экземпляров игры. Реализуется это ограничение путем попытки создания трех объектов типа mutex при старте игры. В случае, когда все три объекта создать не удалось появляется вот такое окно:
Код решающий данную проблему:
Spoiler
//код оттестирован на руофф клиенте и на момент написания поста работоспособен.
#include <Windows.h>
#include "../externalModules/spliceHookClass.h"
#include "dbgLib.h"
#pragma comment(lib,"../externalModules/libs/spliceHookLib.lib")
typedef HANDLE (WINAPI defCreateMutexW)(LPSECURITY_ATTRIBUTES, BOOL, LPCWSTR);
defCreateMutexW * origFn;
HANDLE WINAPI myCreateMutexW(LPSECURITY_ATTRIBUTES lpMutexAttributes, BOOL bInitialOwner, LPCWSTR lpName)
{
bool instanceMutex = false;
if(lpName)
{
if(!wcscmp(lpName,L"{ADB0D266-9243-4c50-AFC4-D87E575ED003}"))
instanceMutex = true;
else if(!wcscmp(lpName,L"{6F79F71A-C7EA-4033-8B70-93DD9755A586}"))
instanceMutex = true;
else if(!wcscmp(lpName,L"{262F8ED9-08A5-498b-847D-49E537DBCFA1}"))
instanceMutex = true;
if(instanceMutex)
{
SetLastError(0);
return (HANDLE)1024;
}
}
origFn(lpMutexAttributes, bInitialOwner, lpName);
}
void multyWndHack(bool enable)
{
static spliceHook splice;
HMODULE k32Dll = GetModuleHandleA("kernel32.dll");
static bool enabled = false;
if(enable && !enabled)
{
origFn = (defCreateMutexW *)splice.Hook((PTR)GetProcAddress(k32Dll,"CreateMutexW"),(PTR)myCreateMutexW);
if(origFn)
enabled = true;
dbgBreak(!origFn);
}
else if(!enable && enabled)
{
splice.UnHook();
enabled = false;
}
}