Update Kernel::Device field offsets for 7.2

This commit is contained in:
Jade Macho 2025-03-26 14:15:16 +01:00
parent be226771c8
commit 49cba05dd6
Signed by: 0x0ade
GPG key ID: E1960710FE4FBEEF
3 changed files with 37 additions and 8 deletions

View file

@ -29,7 +29,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DalamudPackager" Version="11.0.0" />
<PackageReference Include="DalamudPackager" Version="12.0.0" />
<PackageReference Include="TerraFX.Interop.Windows" Version="10.0.22621.2" />
<Reference Include="FFXIVClientStructs">
<HintPath>$(DalamudLibPath)FFXIVClientStructs.dll</HintPath>

View file

@ -25,6 +25,7 @@ public sealed unsafe class Plugin : IDalamudPlugin
private bool _unloading = false;
private bool _wasEnabled = false;
private HWND _currentHwnd;
private bool _currentHwndMismatch = false;
private RECT _currentClientRect;
private DXVKDWMHackMode _currentDXVKDWMHackMode = DXVKDWMHackMode.Off;
private bool _ignoreConfigChanges = false;
@ -179,7 +180,35 @@ public sealed unsafe class Plugin : IDalamudPlugin
var framework = Framework.Instance();
var win = framework->GameWindow;
_currentHwnd = (HWND) (IntPtr) dev->hWnd;
_currentHwnd = (HWND) win->WindowHandle;
#if CRES_CLEAN
var _dev_hWnd = (IntPtr*) &dev->hWnd;
var _dev_NewWidth = &dev->NewWidth;
var _dev_NewHeight = &dev->NewHeight;
var _dev_RequestResolutionChange = &dev->RequestResolutionChange;
#else
// 7.2
var _dev_hWnd = (nint*) ((nint) dev + 0x1B8);
var _dev_NewWidth = (uint*) ((nint) dev + 0x1B8 + 0x10);
var _dev_NewHeight = (uint*) ((nint) dev + 0x1B8 + 0x14);
var _dev_RequestResolutionChange = &dev->RequestResolutionChange;
#endif
// As a safety measure, don't mess with the structs if we're reading garbage.
// This isn't perfect, but it's better than nothing.
if (_currentHwnd != *_dev_hWnd)
{
if (!_currentHwndMismatch)
{
_currentHwndMismatch = true;
Service.PluginLog.Info($"HWND MISMATCH between GameWindow and Device: {(long) (IntPtr) (_currentHwnd):X16} vs {(long) *_dev_hWnd:X16}");
}
return;
}
_currentHwndMismatch = false;
fixed (RECT* currentClientRectPtr = &_currentClientRect)
{
@ -229,9 +258,9 @@ public sealed unsafe class Plugin : IDalamudPlugin
if (width != dev->Width || height != dev->Height)
{
Service.PluginLog.Info($"Changing graphics resolution from {dev->Width} x {dev->Height} to {width} x {height}");
dev->NewWidth = width;
dev->NewHeight = height;
dev->RequestResolutionChange = 1;
*_dev_NewWidth = width;
*_dev_NewHeight = height;
*_dev_RequestResolutionChange = 1;
Service.PluginLog.Info($"Changing game window from {win->WindowWidth} x {win->WindowHeight} to {width} x {height}");
win->WindowWidth = (int) width;
win->WindowHeight = (int) height;

View file

@ -4,9 +4,9 @@
"net9.0-windows7.0": {
"DalamudPackager": {
"type": "Direct",
"requested": "[11.0.0, )",
"resolved": "11.0.0",
"contentHash": "bjT7XUlhIJSmsE/O76b7weUX+evvGQctbQB8aKXt94o+oPWxHpCepxAGMs7Thow3AzCyqWs7cOpp9/2wcgRRQA=="
"requested": "[12.0.0, )",
"resolved": "12.0.0",
"contentHash": "J5TJLV3f16T/E2H2P17ClWjtfEBPpq3yxvqW46eN36JCm6wR+EaoaYkqG9Rm5sHqs3/nK/vKjWWyvEs/jhKoXw=="
},
"TerraFX.Interop.Windows": {
"type": "Direct",