static public void GetMaximumWardPower() { var assembly = new UnmanagedArray <System.Byte>(); assembly.Add(new System.Byte[1] { 0x51 }); // push rcx assembly.Add(new System.Byte[4] { 0x48, 0x83, 0xEC, 0x40 }); // sub rsp, 40 assembly.Add(new System.Byte[2] { 0x48, 0xB8 }); assembly.Add(Eggstensions.Offsets.FindMaxMagnitudeVisitor.VirtualFunctionTable); // mov rax assembly.Add(new System.Byte[5] { 0x48, 0x89, 0x44, 0x24, 0x20 }); // mov [rsp+20], rax assembly.Add(new System.Byte[2] { 0x31, 0xC0 }); // xor eax, eax assembly.Add(new System.Byte[5] { 0x48, 0x89, 0x44, 0x24, 0x28 }); // mov [rsp+28], rax assembly.Add(new System.Byte[5] { 0xB8, 0xFF, 0xFF, 0xFF, 0xFF }); // mov eax, -1 assembly.Add(new System.Byte[4] { 0xF3, 0x0F, 0x2A, 0xC0 }); // cvtsi2ss xmm0, eax assembly.Add(new System.Byte[6] { 0xF3, 0x0F, 0x11, 0x44, 0x24, 0x30 }); // movss [rsp+30], xmm0 assembly.Add(new System.Byte[5] { 0x48, 0x8D, 0x54, 0x24, 0x20 }); // lea rdx, [rsp+20] assembly.Add(new System.Byte[7] { 0x48, 0x81, 0xC1, 0x98, 0x00, 0x00, 0x00 }); // add rcx, 98 assembly.Add(Assembly.AbsoluteCall(Eggstensions.Offsets.MagicTarget.VisitActiveEffects.ToPointer())); // call MagicTarget.VisitActiveEffects assembly.Add(new System.Byte[6] { 0xF3, 0x0F, 0x10, 0x4C, 0x24, 0x30 }); // movss xmm1, [rsp+30] assembly.Add(new System.Byte[5] { 0x48, 0x8B, 0x4C, 0x24, 0x40 }); // mov rcx, [rsp+40] assembly.Add(Assembly.AbsoluteCall(Eggstensions.Offsets.Actor.SetMaximumWardPower.ToPointer())); // call Actor.SetMaximumWardPower assembly.Add(new System.Byte[5] { 0x48, 0x8B, 0x4C, 0x24, 0x40 }); // mov rcx, [rsp+40] assembly.Add(Assembly.AbsoluteCall(Memory.ReadRelativeCall(ScrambledBugs.Offsets.Patches.AccumulatingMagnitude.GetMaximumWardPower))); // call Actor.GetMaximumWardPower assembly.Add(new System.Byte[4] { 0x48, 0x83, 0xC4, 0x48 }); // add rsp, 48 assembly.Add(new System.Byte[1] { Assembly.Ret }); // ret Trampoline.WriteRelativeCallBranch(ScrambledBugs.Offsets.Patches.AccumulatingMagnitude.GetMaximumWardPower, assembly); /* * Actor* actor; // rcx * * var findMaxMagnitudeVisitor = new FindMaxMagnitudeVisitor(); *(System.IntPtr*)&findMaxMagnitudeVisitor = Eggstensions.Offsets.FindMaxMagnitudeVisitor.VirtualFunctionTable; * findMaxMagnitudeVisitor.FinishedActiveEffect = null; * findMaxMagnitudeVisitor.MaximumMagnitude = -1.0F; * * actor->MagicTarget()->VisitActiveEffects(&findMaxMagnitudeVisitor); * actor->SetMaximumWardPower(findMaxMagnitudeVisitor.MaximumMagnitude); * * return actor->GetMaximumWardPower(); */ }
static public System.Byte[] CanPowerAttack(void *getStaminaCost) { var assembly = new UnmanagedArray <System.Byte>(); assembly.Add(new System.Byte[1] { 0x51 }); // push rcx assembly.Add(new System.Byte[4] { 0x48, 0x83, 0xEC, 0x20 }); // sub rsp, 20 assembly.Add(Assembly.AbsoluteCall(getStaminaCost)); // call ActorValueOwner.GetStaminaCost assembly.Add(new System.Byte[3] { 0x0F, 0x57, 0xC9 }); // xorps xmm1, xmm1 assembly.Add(new System.Byte[3] { 0x0F, 0x2F, 0xC1 }); // comiss xmm0, xmm1 assembly.Add(new System.Byte[2] { 0x76, (5 + 5 + 3 + 6 + 3) + (5 + 2) + (2 + 2) }); // jbe 21 assembly.Add(new System.Byte[5] { 0xBA, 0x1A, 0x00, 0x00, 0x00 }); // mov edx, 1A assembly.Add(new System.Byte[5] { 0x48, 0x8B, 0x4C, 0x24, 0x20 }); // mov rcx, [rsp+20] assembly.Add(new System.Byte[3] { 0x48, 0x8B, 0x01 }); // mov rax, [rcx] assembly.Add(new System.Byte[6] { 0xF3, 0x0F, 0x11, 0x44, 0x24, 0x20 }); // movss [rsp+20], xmm0 assembly.Add(new System.Byte[3] { 0xFF, 0x50, 0x08 }); // call [rax+8] (ActorValueOwner.GetActorValue) assembly.Add(new System.Byte[5] { 0x0F, 0x2F, 0x44, 0x24, 0x20 }); // comiss xmm0, [rsp+20] assembly.Add(new System.Byte[2] { 0x73, 2 + 2 }); // jae 4 assembly.Add(new System.Byte[2] { 0x31, 0xC0 }); // xor eax, eax assembly.Add(new System.Byte[2] { 0xEB, 0x05 }); // jmp 5 assembly.Add(new System.Byte[5] { 0xB8, 0x01, 0x00, 0x00, 0x00 }); // mov eax, 1 assembly.Add(new System.Byte[4] { 0x48, 0x83, 0xC4, 0x28 }); // add rsp, 28 assembly.Add(new System.Byte[1] { Assembly.Ret }); // ret return(assembly); /* * ActorValueOwner* actorValueOwner; // rcx * BGSAttackData* attackData; // rdx * * var staminaCost = actorValueOwner->GetStaminaCost(attackData); * * if (staminaCost <= 0.0F) * { * return true; * } * * var stamina = actorValueOwner->GetActorValue(ActorValue.Stamina); * * if (stamina >= staminaCost) * { * return true; * } * * return false; */ }