diff --git a/Dalamud/Game/SigScanner.cs b/Dalamud/Game/SigScanner.cs
index 28bb0137b..d6b5a77a3 100644
--- a/Dalamud/Game/SigScanner.cs
+++ b/Dalamud/Game/SigScanner.cs
@@ -134,6 +134,28 @@ namespace Dalamud.Game
return baseAddress + index;
}
+ ///
+ /// Try scanning memory for a signature.
+ ///
+ /// The base address to scan from.
+ /// The amount of bytes to scan.
+ /// The signature to search for.
+ /// The offset, if found.
+ /// true if the signature was found.
+ public static bool TryScan(IntPtr baseAddress, int size, string signature, out IntPtr result)
+ {
+ result = IntPtr.Zero;
+ try
+ {
+ result = Scan(baseAddress, size, signature);
+ return true;
+ }
+ catch (KeyNotFoundException)
+ {
+ return false;
+ }
+ }
+
///
/// Scan for a .data address using a .text function.
/// This is intended to be used with IDA sigs.
@@ -160,6 +182,29 @@ namespace Dalamud.Game
return IntPtr.Add(instrAddr, Marshal.ReadInt32(instrAddr) + 4);
}
+ ///
+ /// 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 IntPtr result, int offset = 0)
+ {
+ result = IntPtr.Zero;
+ try
+ {
+ result = this.GetStaticAddressFromSig(signature, offset);
+ return true;
+ }
+ catch (KeyNotFoundException)
+ {
+ return false;
+ }
+ }
+
///
/// Scan for a byte signature in the .data section.
///
@@ -175,6 +220,26 @@ namespace Dalamud.Game
return scanRet;
}
+ ///
+ /// 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 IntPtr result)
+ {
+ result = IntPtr.Zero;
+ try
+ {
+ result = this.ScanData(signature);
+ return true;
+ }
+ catch (KeyNotFoundException)
+ {
+ return false;
+ }
+ }
+
///
/// Scan for a byte signature in the whole module search area.
///
@@ -190,6 +255,26 @@ namespace Dalamud.Game
return scanRet;
}
+ ///
+ /// 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 IntPtr result)
+ {
+ result = IntPtr.Zero;
+ try
+ {
+ result = this.ScanModule(signature);
+ return true;
+ }
+ catch (KeyNotFoundException)
+ {
+ return false;
+ }
+ }
+
///
/// Resolve a RVA address.
///
@@ -224,6 +309,26 @@ namespace Dalamud.Game
return scanRet;
}
+ ///
+ /// 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 IntPtr result)
+ {
+ result = IntPtr.Zero;
+ try
+ {
+ result = this.ScanText(signature);
+ return true;
+ }
+ catch (KeyNotFoundException)
+ {
+ return false;
+ }
+ }
+
///
/// Free the memory of the copied module search area on object disposal, if applicable.
///