using System; using System.Diagnostics; namespace Dalamud.Game; /// /// A SigScanner facilitates searching for memory signatures in a given ProcessModule. /// public interface ISigScanner { /// /// Gets a value indicating whether or not the search on this module is performed on a copy. /// public bool IsCopy { get; } /// /// Gets a value indicating whether or not the ProcessModule is 32-bit. /// public bool Is32BitProcess { get; } /// /// Gets the base address of the search area. When copied, this will be the address of the copy. /// public IntPtr SearchBase { get; } /// /// Gets the base address of the .text section search area. /// public IntPtr TextSectionBase { get; } /// /// Gets the offset of the .text section from the base of the module. /// public long TextSectionOffset { get; } /// /// Gets the size of the text section. /// public int TextSectionSize { get; } /// /// Gets the base address of the .data section search area. /// public IntPtr DataSectionBase { get; } /// /// Gets the offset of the .data section from the base of the module. /// public long DataSectionOffset { get; } /// /// Gets the size of the .data section. /// public int DataSectionSize { get; } /// /// Gets the base address of the .rdata section search area. /// public IntPtr RDataSectionBase { get; } /// /// Gets the offset of the .rdata section from the base of the module. /// public long RDataSectionOffset { get; } /// /// Gets the size of the .rdata section. /// public int RDataSectionSize { get; } /// /// Gets the ProcessModule on which the search is performed. /// public ProcessModule Module { get; } /// /// Scan for a .data address using a .text function. /// This is intended to be used with IDA sigs. /// Place your cursor on the line calling a static address, and create and IDA sig. /// The signature and offset should not break through instruction boundaries. /// /// The signature of the function using the data. /// The offset from function start of the instruction using the data. /// An IntPtr to the static memory location. public nint GetStaticAddressFromSig(string signature, int offset = 0); /// /// Try scanning for a .data address using a .text function. /// This is intended to be used with IDA sigs. /// Place your cursor on the line calling a static address, and create and IDA sig. /// /// The signature of the function using the data. /// An IntPtr to the static memory location, if found. /// The offset from function start of the instruction using the data. /// true if the signature was found. public bool TryGetStaticAddressFromSig(string signature, out nint result, int offset = 0); /// /// Scan for a byte signature in the .data section. /// /// The signature. /// The real offset of the found signature. public nint ScanData(string signature); /// /// Try scanning for a byte signature in the .data section. /// /// The signature. /// The real offset of the signature, if found. /// true if the signature was found. public bool TryScanData(string signature, out nint result); /// /// Scan for a byte signature in the whole module search area. /// /// The signature. /// The real offset of the found signature. public nint ScanModule(string signature); /// /// Try scanning for a byte signature in the whole module search area. /// /// The signature. /// The real offset of the signature, if found. /// true if the signature was found. public bool TryScanModule(string signature, out nint result); /// /// Resolve a RVA address. /// /// The address of the next instruction. /// The relative offset. /// The calculated offset. public nint ResolveRelativeAddress(nint nextInstAddr, int relOffset); /// /// Scan for a byte signature in the .text section. /// /// The signature. /// The real offset of the found signature. public nint ScanText(string signature); /// /// Try scanning for a byte signature in the .text section. /// /// The signature. /// The real offset of the signature, if found. /// true if the signature was found. public bool TryScanText(string signature, out nint result); }