通过HOOK createmutex 来多开程序,比如微信。
FARPROC addrOpenMutexW = NULL;
FARPROC addrCreateMutexW = NULL;
void hookAddr(DWORD dest, DWORD src);
bool __stdcall IsName(wchar_t* name);
void OpenMutexWHook();
void CreateMutexWHook();
void CLoaseMutexHandle();
void hookAddr(DWORD dest, DWORD src)
{
DWORD oldProcect = 0;
VirtualProtect((LPVOID)dest, 5, PAGE_READWRITE, &oldProcect);
*(BYTE*)dest = 0xE9;
*(DWORD*)(dest + 1) = src - dest - 0x5;
VirtualProtect((LPVOID)dest, 5, oldProcect, &oldProcect);
}
__declspec(naked) void OpenMutexWHook()
{
__asm
{
pushad
push [esp+0x20+0xC]
call IsName
test eax,eax
je PASS
mov dword ptr ss:[esp+0x20+0xC],0
PASS:
popad
push ebp
mov ebp,esp
push addrOpenMutexW
add [esp],5
retn
}
}
__declspec(naked) void CreateMutexWHook()
{
__asm
{
pushad
push[esp + 0x20 + 0xC]
call IsName
test eax, eax
je PASS
popad
retn 0xC
PASS :
popad
push ebp
mov ebp, esp
push addrOpenMutexW
add[esp], 5
retn
}
}
bool __stdcall IsName(wchar_t* name)
{
return wcscmp(name, L"_WeChat_App_Instance_Identity_Mutex_Name") == 0 ? true : false;
}