Finish Resolver
Add cache support.
@@ -3,33 +3,38 @@ using FFXIVClientStructs.Interop;
using PeNet;
using PeNet.Header.Pe;
-Memory<byte> file = new Memory<byte>(File.ReadAllBytes(@"C:\Games\FFXIV\game\ffxiv_dx11.exe"));
+Memory<byte> file = new Memory<byte>(File.ReadAllBytes(@"F:\xiv-dev\ew-exes\ffxiv_dx11_2022.10.26.0000.0000.exe"));
PeFile peHeader = new PeFile(file.Span.ToArray());
ImageSectionHeader textHeader = peHeader.ImageSectionHeaders![0];
ImageSectionHeader rdataHeader = peHeader.ImageSectionHeaders![1];
ImageSectionHeader dataHeader = peHeader.ImageSectionHeaders![2];
+Memory<byte> relocFile = new Memory<byte>(new byte[peHeader.FileSize]);
+
+file.Slice((int)textHeader.PointerToRawData, (int)textHeader.VirtualSize).CopyTo(relocFile.Slice((int)textHeader.VirtualAddress, (int)textHeader.VirtualSize));
+file.Slice((int)rdataHeader.PointerToRawData, (int)rdataHeader.VirtualSize).CopyTo(relocFile.Slice((int)rdataHeader.VirtualAddress, (int)rdataHeader.VirtualSize));
+file.Slice((int)dataHeader.PointerToRawData, (int)dataHeader.VirtualSize).CopyTo(relocFile.Slice((int)dataHeader.VirtualAddress, (int)dataHeader.VirtualSize));
+
unsafe
{
- fixed (byte* bytes = file.Span)
+ fixed (byte* bytes = relocFile.Span)
{
- Console.WriteLine($"Unresolved count: {Resolver.GetInstance.Signatures.Count}");
+ Console.WriteLine($"Unresolved count: {Resolver.GetInstance.Addresses.Count}");
- ResolverTarget target = new ResolverTarget(new IntPtr(bytes), file.Length, (int) textHeader.PointerToRawData,
- (int) textHeader.SizeOfRawData, (int) dataHeader.PointerToRawData, (int) dataHeader.SizeOfRawData,
- (int) rdataHeader.PointerToRawData, (int) rdataHeader.SizeOfRawData);
+ Resolver.GetInstance.SetupSearchSpace(new IntPtr(bytes), relocFile.Length, (int) textHeader.VirtualAddress,
+ (int) textHeader.VirtualSize, (int) dataHeader.VirtualAddress, (int) dataHeader.VirtualSize,
+ (int) rdataHeader.VirtualAddress, (int) rdataHeader.VirtualSize, new FileInfo("test.json"));
var watch = new Stopwatch();
watch.Start();
- Resolver.GetInstance.ResolveWithTarget(target);
+ Resolver.GetInstance.Resolve();
watch.Stop();
Console.WriteLine($"Resolved in {watch.ElapsedMilliseconds}ms");
- Console.WriteLine($"Resolved count: {Resolver.GetInstance.Signatures.Count(sig => sig.Value != 0)}");
-
- //foreach(var sig in Resolver.GetInstance.Signatures)
- // Console.WriteLine($"{sig.Name} {sig.String} {sig.Value:X16}");
+ Console.WriteLine($"Resolved count: {Resolver.GetInstance.Addresses.Count(sig => sig.Value != 0)}");
+ foreach(var address in Resolver.GetInstance.Addresses)
+ Console.WriteLine($"{address.Name} - {address.String} - {address.Value - new UIntPtr(bytes):X16}");
}
}
\ No newline at end of file
