Compare commits

..

24 Commits

Author SHA1 Message Date
defnotken
172288c755 bumpers
All checks were successful
Tag and Release Lightless / tag-and-release (push) Successful in 1m57s
2026-01-19 18:31:36 -06:00
defnotken
1c17be53d0 Merge branch '2.0.3' into dev 2026-01-19 18:30:42 -06:00
68b4863f52 Merge pull request 'Added CLR fix for gameobject handler' (#142) from clr-fix-attempt into 2.0.3
Reviewed-on: #142
2026-01-20 00:02:58 +00:00
defnotken
e8f598e695 bumpity bump
All checks were successful
Tag and Release Lightless / tag-and-release (push) Successful in 2m7s
2026-01-19 12:36:24 -06:00
defnotken
861a337029 Merge branch '2.0.3' into dev
Some checks failed
Tag and Release Lightless / tag-and-release (push) Has been cancelled
2026-01-19 12:35:29 -06:00
06f89955d3 Merge pull request 'clr-fix-attempt' (#141) from clr-fix-attempt into 2.0.3
Reviewed-on: #141
2026-01-19 18:33:55 +00:00
defnotken
c7a2b679f2 bumpity bump
All checks were successful
Tag and Release Lightless / tag-and-release (push) Successful in 2m2s
2026-01-19 11:23:49 -06:00
defnotken
bec69074a5 Merge branch '2.0.3' into dev 2026-01-19 11:23:23 -06:00
defnotken
ac711d9a43 Bump plugin testing
All checks were successful
Tag and Release Lightless / tag-and-release (push) Successful in 2m19s
2026-01-18 20:53:14 -06:00
defnotken
b875e0c3a1 Merge branch '2.0.3' into dev 2026-01-18 20:51:58 -06:00
defnotken
46e76bbfe6 Merge branch '2.0.3' into dev 2026-01-18 20:29:53 -06:00
cake
3654365f2a bump version
All checks were successful
Tag and Release Lightless / tag-and-release (push) Successful in 2m6s
2026-01-06 14:45:23 +01:00
cake
9b256dd185 Merge branch '2.0.3' into dev 2026-01-06 14:45:02 +01:00
defnotken
223ade39cb another push
All checks were successful
Tag and Release Lightless / tag-and-release (push) Successful in 2m13s
2026-01-05 20:48:24 -06:00
defnotken
5aca9e70b2 Merge branch '2.0.3' into dev 2026-01-05 20:47:38 -06:00
defnotken
92772cf334 dev push
All checks were successful
Tag and Release Lightless / tag-and-release (push) Successful in 2m12s
2026-01-05 20:21:26 -06:00
defnotken
0395e81a9f Merge branch '2.0.3' into dev 2026-01-05 20:17:12 -06:00
defnotken
7734a7bf7e dev build
All checks were successful
Tag and Release Lightless / tag-and-release (push) Successful in 2m8s
2026-01-05 17:42:21 -06:00
defnotken
db2d19bb1e Merge branch '2.0.3' into dev 2026-01-05 17:41:48 -06:00
defnotken
ab305a249c more checks
All checks were successful
Tag and Release Lightless / tag-and-release (push) Successful in 2m7s
2026-01-05 15:48:54 -06:00
defnotken
9d104a9dd8 Merge branch '2.0.3' into dev 2026-01-05 15:42:15 -06:00
defnotken
bcd3bd5ca2 add more checks
All checks were successful
Tag and Release Lightless / tag-and-release (push) Successful in 2m8s
2026-01-05 15:08:26 -06:00
defnotken
c1829a9837 Merge branch '2.0.3' into dev
All checks were successful
Tag and Release Lightless / tag-and-release (push) Successful in 2m14s
2026-01-05 14:48:47 -06:00
defnotken
cca23f6e05 Building Dev
All checks were successful
Tag and Release Lightless / tag-and-release (push) Successful in 2m27s
2026-01-05 10:50:25 -06:00
5 changed files with 20 additions and 54 deletions

View File

@@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<Authors></Authors> <Authors></Authors>
<Company></Company> <Company></Company>
<Version>2.0.3</Version> <Version>2.0.2.81</Version>
<Description></Description> <Description></Description>
<Copyright></Copyright> <Copyright></Copyright>
<PackageProjectUrl>https://github.com/Light-Public-Syncshells/LightlessClient</PackageProjectUrl> <PackageProjectUrl>https://github.com/Light-Public-Syncshells/LightlessClient</PackageProjectUrl>

View File

@@ -127,7 +127,7 @@ public class PlayerDataFactory
{ {
nint basePtr = playerPointer; nint basePtr = playerPointer;
if (!PtrGuard.LooksLikePtr(basePtr, _dalamudUtil.IsWine)) if (!PtrGuard.LooksLikePtr(basePtr))
return true; return true;
nint drawObjAddr = basePtr + _drawObjectOffset; nint drawObjAddr = basePtr + _drawObjectOffset;
@@ -135,10 +135,10 @@ public class PlayerDataFactory
if (!PtrGuard.IsReadable(drawObjAddr, (nuint)IntPtr.Size)) if (!PtrGuard.IsReadable(drawObjAddr, (nuint)IntPtr.Size))
return true; return true;
if (!PtrGuard.TryReadIntPtr(drawObjAddr, _dalamudUtil.IsWine, out var drawObj)) if (!PtrGuard.TryReadIntPtr(drawObjAddr, out var drawObj))
return true; return true;
if (drawObj != 0 && !PtrGuard.LooksLikePtr(drawObj, _dalamudUtil.IsWine)) if (drawObj != 0 && !PtrGuard.LooksLikePtr(drawObj))
return true; return true;
return drawObj == 0; return drawObj == 0;

View File

@@ -180,14 +180,16 @@ public sealed class GameObjectHandler : DisposableMediatorSubscriberBase, IHighP
var nextAddr = _getAddress(); var nextAddr = _getAddress();
if (nextAddr != IntPtr.Zero && !PtrGuard.LooksLikePtr(nextAddr, _dalamudUtil.IsWine)) if (nextAddr != IntPtr.Zero && !PtrGuard.LooksLikePtr(nextAddr))
{ {
Logger.LogWarning("[{this}] _getAddress returned non-pointer: 0x{addr:X}", this, (ulong)nextAddr);
nextAddr = IntPtr.Zero; nextAddr = IntPtr.Zero;
} }
if (nextAddr != IntPtr.Zero && if (nextAddr != IntPtr.Zero &&
!PtrGuard.IsReadable(nextAddr, (nuint)sizeof(FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject))) !PtrGuard.IsReadable(nextAddr, (nuint)sizeof(FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject)))
{ {
Logger.LogWarning("[{this}] Address not readable: 0x{addr:X}", this, (ulong)nextAddr);
nextAddr = IntPtr.Zero; nextAddr = IntPtr.Zero;
} }
@@ -199,7 +201,7 @@ public sealed class GameObjectHandler : DisposableMediatorSubscriberBase, IHighP
var draw = (nint)gameObject->DrawObject; var draw = (nint)gameObject->DrawObject;
if (!PtrGuard.LooksLikePtr(draw, _dalamudUtil.IsWine) || !PtrGuard.IsReadable(draw, (nuint)sizeof(DrawObject))) if (!PtrGuard.LooksLikePtr(draw) || !PtrGuard.IsReadable(draw, (nuint)sizeof(DrawObject)))
draw = 0; draw = 0;
DrawObjectAddress = draw; DrawObjectAddress = draw;
@@ -361,7 +363,7 @@ public sealed class GameObjectHandler : DisposableMediatorSubscriberBase, IHighP
private unsafe bool CompareAndUpdateMainHand(Weapon* weapon) private unsafe bool CompareAndUpdateMainHand(Weapon* weapon)
{ {
var p = (nint)weapon; var p = (nint)weapon;
if (!PtrGuard.LooksLikePtr(p, _dalamudUtil.IsWine) || !PtrGuard.IsReadable(p, (nuint)sizeof(Weapon))) if (!PtrGuard.LooksLikePtr(p) || !PtrGuard.IsReadable(p, (nuint)sizeof(Weapon)))
return false; return false;
bool hasChanges = false; bool hasChanges = false;
@@ -377,7 +379,7 @@ public sealed class GameObjectHandler : DisposableMediatorSubscriberBase, IHighP
private unsafe bool CompareAndUpdateOffHand(Weapon* weapon) private unsafe bool CompareAndUpdateOffHand(Weapon* weapon)
{ {
var p = (nint)weapon; var p = (nint)weapon;
if (!PtrGuard.LooksLikePtr(p, _dalamudUtil.IsWine) || !PtrGuard.IsReadable(p, (nuint)sizeof(Weapon))) if (!PtrGuard.LooksLikePtr(p) || !PtrGuard.IsReadable(p, (nuint)sizeof(Weapon)))
return false; return false;
bool hasChanges = false; bool hasChanges = false;

View File

@@ -5,41 +5,24 @@ namespace LightlessSync.Utils
{ {
public static partial class PtrGuard public static partial class PtrGuard
{ {
private static readonly nuint _hardMinWindows = private const ulong _minLikelyPtr = 0x0000_0001_0000_0000UL;
(nuint)(IntPtr.Size == 8 ? 0x0000000100000000UL : 0x0000000000010000UL); private const ulong _maxUserPtr = 0x0000_7FFF_FFFF_FFFFUL;
private static readonly nuint _hardMaxWindows = private const ulong _aligmentPtr = 0x7UL;
(nuint)(IntPtr.Size == 8 ? 0x00007FFFFFFFFFFFUL : 0x7FFFFFFFUL);
private const nuint _alignmentPtr = 0x7;
private static readonly (nuint min, nuint max) _sysRange = GetSysRange(); public static bool LooksLikePtr(nint p)
private static (nuint min, nuint max) GetSysRange()
{
GetSystemInfo(out var si);
return ((nuint)si.lpMinimumApplicationAddress, (nuint)si.lpMaximumApplicationAddress);
}
private static nuint GetMinAppAddr(bool isWine) => isWine ? _sysRange.min : _hardMinWindows;
private static nuint GetMaxAppAddr(bool isWine) => isWine ? _sysRange.max : _hardMaxWindows;
public static bool LooksLikePtr(nint p, bool isWine = false)
{ {
if (p == 0) return false; if (p == 0) return false;
nuint u = (nuint)p; var u = (ulong)p;
if (u < _minLikelyPtr) return false;
if (u < GetMinAppAddr(isWine)) return false; if (u > _maxUserPtr) return false;
if (u > GetMaxAppAddr(isWine)) return false; if ((u & _aligmentPtr) != 0) return false;
if ((u & _alignmentPtr) != 0) return false;
if ((uint)u == 0x12345679u) return false;
return true; return true;
} }
public static bool TryReadIntPtr(nint addr, out nint value)
public static bool TryReadIntPtr(nint addr, bool isWine, out nint value)
{ {
value = 0; value = 0;
if (!LooksLikePtr(addr, isWine)) if (!LooksLikePtr(addr))
return false; return false;
return ReadProcessMemory(GetCurrentProcess(), addr, out value, (nuint)IntPtr.Size, out nuint bytesRead) return ReadProcessMemory(GetCurrentProcess(), addr, out value, (nuint)IntPtr.Size, out nuint bytesRead)

View File

@@ -32,24 +32,5 @@ namespace LightlessSync.Utils
[DllImport("kernel32.dll")] [DllImport("kernel32.dll")]
internal static extern nint GetCurrentProcess(); internal static extern nint GetCurrentProcess();
[DllImport("kernel32.dll")]
internal static extern void GetSystemInfo(out SystemInfo lpSystemInfo);
[StructLayout(LayoutKind.Sequential)]
internal struct SystemInfo
{
public ushort wProcessorArchitecture;
public ushort wReserved;
public uint dwPageSize;
public nint lpMinimumApplicationAddress;
public nint lpMaximumApplicationAddress;
public nint dwActiveProcessorMask;
public uint dwNumberOfProcessors;
public uint dwProcessorType;
public uint dwAllocationGranularity;
public ushort wProcessorLevel;
public ushort wProcessorRevision;
}
} }
} }