namespace XFEWarframe.Client; /// Audited input branches, not a version-dependent unconditional no-slam patch. public sealed record AirSlideHeavyAbi( int InputSelection, int InputContinuation, int QueuedSelection, int QueuedContinuation, int MoveFlagsOffset, int PostureOffset, IReadOnlyDictionary Signatures) { public const int HeavyCommand = 0x103; public const uint InAir = 1u << 15; public static bool ShouldRestore(int command, int attack, uint movement, bool sliding) => command == HeavyCommand && attack is 4 or 5 or 17 && (movement & InAir) != 0 && sliding; public static AirSlideHeavyAbi Resolve(BinaryImage image, uint hashSeed) { var signatures = new Dictionary(); int Unique(string pattern) { var matches = image.Find(pattern); if (matches.Count != 1) throw new InvalidDataException($"Air-slide heavy contract has {matches.Count} candidates: {pattern}"); return matches[0]; } void Snapshot(int rva, int length) => signatures[rva] = image.Read(rva, length); void SameFunction(int a, int b) { if (!image.TryFunctionStart(a, out var first) || !image.TryFunctionStart(b, out var second) || first != second) throw new InvalidDataException("Air-slide heavy branches no longer belong to the same input handler."); } // BL is already the native heavy-combo category. Skip only the subsequent // posture/air override; normal attacks still run the entire original block. var input = Unique("80 7D 89 00 74 10 B3 0A 41 C6 84 24 E8 01 00 00 00 E9 ?? ?? ?? ?? 0F B6 45 8A 84 C0 74 ?? 41 80 BC 24 ED 01 00 00 00"); var continuation = image.RelativeTarget(input + 18); SameFunction(input, continuation); if (new BytePattern("0F B6 5D 8B 80 F3 01 80 C3 04 EB 02 B3 04").Find(image.Read(input - 14, 14)).Count != 1 || new BytePattern("48 8B 4D 97 45 32 FF").Find(image.Read(continuation, 7)).Count != 1) throw new InvalidDataException("Air-slide heavy combo register contract changed."); // At this boundary R15 is a temporary; use the native air/slide locals. var inputStart = image.FunctionStart(input); var handler = image.Read(inputStart, input - inputStart); if (new BytePattern("41 81 FD 03 01 00 00").Find(handler).Count == 0 || new BytePattern("49 8B D7 49 8B CC E8 ?? ?? ?? ??").Find(handler).Count != 1) throw new InvalidDataException("Air-slide heavy input arguments changed."); var slideTests = new BytePattern("41 80 BF ?? ?? ?? ?? 05").Find(handler); if (slideTests is not [var slideAt] || new BytePattern("C6 45 8A 01 49 8B D7 49 8B CC E8 ?? ?? ?? ?? 41 0F B6 8F ?? ?? ?? ?? 88 45 8D").Find(handler).Count != 1) throw new InvalidDataException("Air-slide heavy native frame classifiers changed."); var posture = image.ReadInt(inputStart + slideAt + 3); var queued = Unique("84 C0 0F 85 ?? ?? ?? ?? 0F B6 45 B7 2C 07 3C 02 77 0B 48 83 7D BF 07"); var queuedTarget = Unique("38 9F 1C 03 00 00 B8 11 00 00 00 41 BE 04 00 00 00 44 0F 45 F0 E9 ?? ?? ?? ??"); SameFunction(queued, queuedTarget); var queueStart = image.FunctionStart(queued); var queueCode = image.Read(queueStart, queued - queueStart); if (new BytePattern("41 81 FF 03 01 00 00").Find(queueCode).Count == 0 || new BytePattern("49 8B CD E8 ?? ?? ?? ?? 48 8B 55 5F 48 8B CF").Find(queueCode).Count != 1) throw new InvalidDataException("Air-slide heavy queued arguments changed."); var air = Unique("8B 82 ?? ?? ?? ?? 48 8B DA 0F BA E0 0F 73 15 B0 01"); var moveFlags = image.ReadInt(air + 2); if (moveFlags is < 0x100 or > 0x1000 || (moveFlags & 3) != 0) throw new InvalidDataException("Invalid avatar movement flags."); var airFunction = image.FunctionStart(air); var airCalls = new BytePattern("49 8B D7 49 8B CC E8 ?? ?? ?? ??").Find(handler); if (image.RelativeTarget(inputStart + airCalls.Single() + 7) != airFunction || image.Read(queued - 8, 1)[0] != 0xE8 || image.RelativeTarget(queued - 7) != airFunction) throw new InvalidDataException("Air-slide heavy input and queued movement predicates disagree."); var queuedPosture = new BytePattern("80 B9 ?? ?? ?? ?? 05").Find(image.Read(queueStart, 0x500)); if (posture is < 0x100 or > 0x1000 || queuedPosture is not [var queuedSlide] || image.ReadInt(queueStart + queuedSlide + 2) != posture) throw new InvalidDataException("Input and buffered avatar postures disagree."); Snapshot(input, 39); Snapshot(input - 14, 14); Snapshot(continuation, 7); Snapshot(queued - 8, 31); Snapshot(queuedTarget, 27); Snapshot(air, 17); Snapshot(inputStart + slideAt, 70); Snapshot(queueStart + queuedSlide, 7); return new(input, continuation, queued, queuedTarget, moveFlags, posture, signatures); } }