mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Merge pull request #584 from ascclemens/try
This commit is contained in:
commit
20f4460e6c
1 changed files with 105 additions and 0 deletions
|
|
@ -134,6 +134,28 @@ namespace Dalamud.Game
|
|||
return baseAddress + index;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Try scanning memory for a signature.
|
||||
/// </summary>
|
||||
/// <param name="baseAddress">The base address to scan from.</param>
|
||||
/// <param name="size">The amount of bytes to scan.</param>
|
||||
/// <param name="signature">The signature to search for.</param>
|
||||
/// <param name="result">The offset, if found.</param>
|
||||
/// <returns>true if the signature was found.</returns>
|
||||
public static bool TryScan(IntPtr baseAddress, int size, string signature, out IntPtr result)
|
||||
{
|
||||
try
|
||||
{
|
||||
result = Scan(baseAddress, size, signature);
|
||||
return true;
|
||||
}
|
||||
catch (KeyNotFoundException)
|
||||
{
|
||||
result = IntPtr.Zero;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="signature">The signature of the function using the data.</param>
|
||||
/// <param name="result">An IntPtr to the static memory location, if found.</param>
|
||||
/// <param name="offset">The offset from function start of the instruction using the data.</param>
|
||||
/// <returns>true if the signature was found.</returns>
|
||||
public bool TryGetStaticAddressFromSig(string signature, out IntPtr result, int offset = 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
result = this.GetStaticAddressFromSig(signature, offset);
|
||||
return true;
|
||||
}
|
||||
catch (KeyNotFoundException)
|
||||
{
|
||||
result = IntPtr.Zero;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scan for a byte signature in the .data section.
|
||||
/// </summary>
|
||||
|
|
@ -175,6 +220,26 @@ namespace Dalamud.Game
|
|||
return scanRet;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Try scanning for a byte signature in the .data section.
|
||||
/// </summary>
|
||||
/// <param name="signature">The signature.</param>
|
||||
/// <param name="result">The real offset of the signature, if found.</param>
|
||||
/// <returns>true if the signature was found.</returns>
|
||||
public bool TryScanData(string signature, out IntPtr result)
|
||||
{
|
||||
try
|
||||
{
|
||||
result = this.ScanData(signature);
|
||||
return true;
|
||||
}
|
||||
catch (KeyNotFoundException)
|
||||
{
|
||||
result = IntPtr.Zero;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scan for a byte signature in the whole module search area.
|
||||
/// </summary>
|
||||
|
|
@ -190,6 +255,26 @@ namespace Dalamud.Game
|
|||
return scanRet;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Try scanning for a byte signature in the whole module search area.
|
||||
/// </summary>
|
||||
/// <param name="signature">The signature.</param>
|
||||
/// <param name="result">The real offset of the signature, if found.</param>
|
||||
/// <returns>true if the signature was found.</returns>
|
||||
public bool TryScanModule(string signature, out IntPtr result)
|
||||
{
|
||||
try
|
||||
{
|
||||
result = this.ScanModule(signature);
|
||||
return true;
|
||||
}
|
||||
catch (KeyNotFoundException)
|
||||
{
|
||||
result = IntPtr.Zero;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolve a RVA address.
|
||||
/// </summary>
|
||||
|
|
@ -224,6 +309,26 @@ namespace Dalamud.Game
|
|||
return scanRet;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Try scanning for a byte signature in the .text section.
|
||||
/// </summary>
|
||||
/// <param name="signature">The signature.</param>
|
||||
/// <param name="result">The real offset of the signature, if found.</param>
|
||||
/// <returns>true if the signature was found.</returns>
|
||||
public bool TryScanText(string signature, out IntPtr result)
|
||||
{
|
||||
try
|
||||
{
|
||||
result = this.ScanText(signature);
|
||||
return true;
|
||||
}
|
||||
catch (KeyNotFoundException)
|
||||
{
|
||||
result = IntPtr.Zero;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Free the memory of the copied module search area on object disposal, if applicable.
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue