33 lines
915 B
C#
33 lines
915 B
C#
using Dalamud.Hooking;
|
|
using Dalamud.Utility.Signatures;
|
|
|
|
namespace Screenie;
|
|
|
|
internal unsafe class GameFunctions : IDisposable {
|
|
private Plugin Plugin { get; }
|
|
|
|
private delegate byte TakeScreenshotDelegate(nint a1, nint a2, nint a3);
|
|
|
|
[Signature("E8 ?? ?? ?? ?? 84 C0 75 22 F3 0F 10 05", DetourName = nameof(TakeScreenshotDetour))]
|
|
private Hook<TakeScreenshotDelegate> _takeScreenshotHook;
|
|
|
|
internal GameFunctions(Plugin plugin) {
|
|
this.Plugin = plugin;
|
|
this.Plugin.GameInteropProvider.InitializeFromAttributes(this);
|
|
|
|
this._takeScreenshotHook!.Enable();
|
|
}
|
|
|
|
public void Dispose() {
|
|
this._takeScreenshotHook.Dispose();
|
|
}
|
|
|
|
private byte TakeScreenshotDetour(nint a1, nint a2, nint a3) {
|
|
if (this.Plugin.Config.DisableNativeScreenshots) {
|
|
return 0;
|
|
}
|
|
|
|
return this._takeScreenshotHook.Original(a1, a2, a3);
|
|
}
|
|
}
|