ff14wed / deucalion

Injected Windows library for capturing decoded FFXIV packets
GNU General Public License v3.0
61 stars 5 forks source link

Deucalion hooks conflicting with plugin hooks #23

Closed lmcintyre closed 8 months ago

lmcintyre commented 8 months ago

Don't know if there's a solution for this.

If ACT is opened before the game, it seems to inject deucalion as soon as possible. Because deucalion adds hooks, a plugin attempting to scan for these signatures will fail. However, deucalion injecting after a plugin that uses these signatures seems to function fine. (unless ACT is falling back silently)

Is there any way the two can work together? My code could detect deucalion and fall back to using its IPC, but I have wanted to keep my code operating at the frame level, and deucalion emits packets.

ff14wed commented 8 months ago

The way Deucalion scans for signatures is it scans the binary file as read from disk rather than scanning the executable in memory, so it isn't affected even if another plugin hooks the same functions. Is it possible for your code to do the same?

lmcintyre commented 8 months ago

Is there reference code for something like that? I've tried to do that before but no matter what I did in accounting for the offsets present in the PE header, I was always off by some small amount. Dalamud currently maintains a copy of the module for sig scanning, but I can propose the file-based idea as well since that's probably bulletproof when it comes to multiple applications hooking at the same time.

ff14wed commented 8 months ago

Here's the code where the sig scanning happens in Deucalion: https://github.com/ff14wed/deucalion/blob/e5f127796c93bf99463a1bcb3c766931ef70457f/src/hook/mod.rs#L67-L91

So basically I'm just relying on pelite for its PE reading capabilities. I think .NET has something that would give you the code range as well? https://learn.microsoft.com/en-us/dotnet/api/system.reflection.portableexecutable.peheader?view=net-8.0

Here's how ImageMap works to give correctly aligned sections: https://docs.rs/pelite/latest/src/pelite/mmap/windows.rs.html#24-26

lmcintyre commented 8 months ago

Awesome, thanks. I already had to supercede the Dalamud sigscanner so I can probably work with this well enough.