From a9c7dc4a7c3e414481775778f8ae697407f4488e Mon Sep 17 00:00:00 2001 From: Rutherther Date: Sun, 1 Jan 2023 12:46:29 +0100 Subject: [PATCH] feat(binding): add possibility for last offset in MemoryExtensions --- .../Extensions/MemoryExtensions.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Core/NosSmooth.LocalBinding/Extensions/MemoryExtensions.cs b/src/Core/NosSmooth.LocalBinding/Extensions/MemoryExtensions.cs index 2ed08df4b58ece8fd533fa7e7e178ab06fb66091..0428d58c4632e2e766c292ba3baf96fb91c20fe2 100644 --- a/src/Core/NosSmooth.LocalBinding/Extensions/MemoryExtensions.cs +++ b/src/Core/NosSmooth.LocalBinding/Extensions/MemoryExtensions.cs @@ -19,8 +19,15 @@ public static class MemoryExtensions /// The memory. /// The static address to follow offsets from. /// The offsets, first offset is the 0-th element. + /// The last offset without evaluating a pointer. /// A final address. - public static nuint FollowStaticAddressOffsets(this IMemory memory, int staticAddress, int[] offsets) + public static nuint FollowStaticAddressOffsets + ( + this IMemory memory, + int staticAddress, + int[] offsets, + int lastOffset = 0 + ) { int address = staticAddress; foreach (var offset in offsets) @@ -28,6 +35,6 @@ public static class MemoryExtensions memory.SafeRead((nuint)(address + offset), out address); } - return (nuint)address; + return (nuint)(address + lastOffset); } } \ No newline at end of file