When is it necessary to suspend wow's main thread before injecting and executing a codecave function? Or is it mandatory? Can some functions cause problems? On some occasions, this locks up the wow client.
Code:
ProcessThread wowMainThread = SThread.GetMainThread(clientProcess.Id);
IntPtr hThread = SThread.OpenThread(wowMainThread.Id);
uint movement = client.AllocateMemory(0x1024);
client.Asm.Clear();
client.Asm.AddLine("mov ebx, [{0}]", ObjectManager.staticClientConnection);
client.Asm.AddLine("add ebx, {0}", ObjectManager.objectManagerOffset);
client.Asm.AddLine("mov ebx, [ebx]");
client.Asm.AddLine("fs mov eax, [0x2C]");
client.Asm.AddLine("mov eax, [eax]");
client.Asm.AddLine("add eax, 0x8");
client.Asm.AddLine("mov dword [eax], ebx");
client.Asm.AddLine("mov eax, {0}", System.Environment.TickCount);
client.Asm.AddLine("mov ecx, {0}", client.ReadUInt((uint)WowOffsets.CInputControl));
client.Asm.AddLine("push {0}", 0);
client.Asm.AddLine("push eax");
client.Asm.AddLine("push {0}", 1);
client.Asm.AddLine("push {0}", (uint)Flag);
client.Asm.AddLine("call {0}", (uint)WowOffsets.CGInputControl__SetControlBit_0);
client.Asm.AddLine("retn");
SThread.SuspendThread(hThread);
client.Asm.InjectAndExecute(movement);
SThread.ResumeThread(hThread);
client.FreeMemory(movement);