aboutsummaryrefslogtreecommitdiff
path: root/src/ARMeilleure/Translation/PTC/PtcFormatter.cs
diff options
context:
space:
mode:
authorTSRBerry <20988865+TSRBerry@users.noreply.github.com>2023-08-09 23:27:45 +0200
committerGitHub <noreply@github.com>2023-08-09 18:27:45 -0300
commit5e9678c8fad4625026268e457f4c3e23bdc22697 (patch)
treef63ea9b82af78209909a49a84a8cab02c1e8275a /src/ARMeilleure/Translation/PTC/PtcFormatter.cs
parent773e239db7ceb2c55aa15f9787add4430edcdfcf (diff)
Allow access to code memory for exefs mods (#5518)1.1.978
* Allow access to code memory for exefs mods * Add ASLR workaround for Skyline * Hardcode allowCodeMemoryForJit to true
Diffstat (limited to 'src/ARMeilleure/Translation/PTC/PtcFormatter.cs')
-rw-r--r--src/ARMeilleure/Translation/PTC/PtcFormatter.cs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/ARMeilleure/Translation/PTC/PtcFormatter.cs b/src/ARMeilleure/Translation/PTC/PtcFormatter.cs
index ddac3133..60953dcd 100644
--- a/src/ARMeilleure/Translation/PTC/PtcFormatter.cs
+++ b/src/ARMeilleure/Translation/PTC/PtcFormatter.cs
@@ -28,6 +28,26 @@ namespace ARMeilleure.Translation.PTC
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static Dictionary<TKey, TValue> DeserializeAndUpdateDictionary<TKey, TValue>(Stream stream, Func<Stream, TValue> valueFunc, Func<TKey, TValue, (TKey, TValue)> updateFunc) where TKey : struct
+ {
+ Dictionary<TKey, TValue> dictionary = new();
+
+ int count = DeserializeStructure<int>(stream);
+
+ for (int i = 0; i < count; i++)
+ {
+ TKey key = DeserializeStructure<TKey>(stream);
+ TValue value = valueFunc(stream);
+
+ (key, value) = updateFunc(key, value);
+
+ dictionary.Add(key, value);
+ }
+
+ return dictionary;
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static List<T> DeserializeList<T>(Stream stream) where T : struct
{
List<T> list = new();