Compare commits
153 Commits
ptr-crash
...
2.1.0.67-D
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8b4274dffd | ||
|
|
571a9df483 | ||
|
|
b3d1e80176 | ||
|
|
0808dae4f1 | ||
|
|
59b2776943 | ||
|
|
b3c35dbfdc | ||
|
|
84a3293f6b | ||
|
|
28db3d6fd2 | ||
| d83ca98008 | |||
| e6df37bcca | |||
| 60d144b881 | |||
|
|
995e11371a | ||
| 5089dbd6c8 | |||
|
|
abc324bf4f | ||
|
|
eee0e072bd | ||
|
|
d8335eb04f | ||
|
|
994335c6b0 | ||
|
|
172288c755 | ||
|
|
1c17be53d0 | ||
| 68b4863f52 | |||
|
|
22fe9901a4 | ||
|
|
cff866dcc2 | ||
|
|
e8f598e695 | ||
|
|
861a337029 | ||
| 06f89955d3 | |||
|
|
367af2c3d0 | ||
|
|
19a238c808 | ||
|
|
c7a2b679f2 | ||
|
|
bec69074a5 | ||
| 7d86b41cee | |||
| 0185e6b534 | |||
|
|
90bf84f8eb | ||
| f27db300ec | |||
| 828be6eb5b | |||
| d039d2fd90 | |||
| e75a371475 | |||
|
|
ac711d9a43 | ||
|
|
b875e0c3a1 | ||
|
|
d6437998ac | ||
|
|
4fa9876c1c | ||
|
|
46e76bbfe6 | ||
| 9dd8e19fb7 | |||
| 5167465d28 | |||
| e8c7539770 | |||
| 54d6a0a1a4 | |||
| b57d54d69c | |||
| 8be0811b4a | |||
| 7c281926a5 | |||
| 6c7e4e6303 | |||
| e2d663cae9 | |||
| 96123d00a2 | |||
|
|
4502cadaeb | ||
| 7f33b6a4ce | |||
| 61f584f059 | |||
| 95d286f990 | |||
|
|
42d6a19db1 | ||
|
|
05f7d256d7 | ||
|
|
058ba504cb | ||
|
|
19966f3828 | ||
|
|
3654365f2a | ||
|
|
9b256dd185 | ||
|
|
d8b9e9cf19 | ||
|
|
ad34d88336 | ||
| 9167bb1afd | |||
|
|
5161c6bad3 | ||
| 59ed03a825 | |||
| ae76efedf8 | |||
| 0e24da75d5 | |||
|
|
223ade39cb | ||
|
|
5aca9e70b2 | ||
|
|
ce28799db3 | ||
|
|
92772cf334 | ||
|
|
0395e81a9f | ||
|
|
9b9010ab8e | ||
|
|
7734a7bf7e | ||
|
|
db2d19bb1e | ||
|
|
032201ed9e | ||
|
|
775b128cf3 | ||
|
|
4bb8db8c03 | ||
|
|
f307c65c66 | ||
|
|
ab305a249c | ||
|
|
9d104a9dd8 | ||
|
|
4eec363cd2 | ||
|
|
d00df84ed6 | ||
|
|
bcd3bd5ca2 | ||
|
|
9048b3bd87 | ||
|
|
c1829a9837 | ||
|
|
a2ed9f8d2b | ||
| 8e08da7471 | |||
|
|
cca23f6e05 | ||
|
|
3205e6e0c3 | ||
|
|
d16e46200d | ||
|
|
5fc13647ae | ||
|
|
39d5d9d7c1 | ||
|
|
c19db58ead | ||
| 30717ba200 | |||
| e0b8070aa8 | |||
| 3241b9222b | |||
| 80b082240f | |||
| b8c8f3dffd | |||
| 543ea6c865 | |||
|
|
de9c9955ef | ||
|
|
2eb0c463e3 | ||
|
|
cd510f93af | ||
|
|
3bbda69699 | ||
|
|
deb7f67e59 | ||
|
|
9ba45670c5 | ||
|
|
f7bb73bcd1 | ||
|
|
4c07162ee3 | ||
|
|
a4d62af73d | ||
|
|
5fba3c01e7 | ||
|
|
df33a0f0a2 | ||
| c439d1c822 | |||
|
|
906dda3885 | ||
|
|
f812b6d09e | ||
| 7e61954541 | |||
|
|
89f59a98f5 | ||
|
|
fb58d8657d | ||
| bbb3375661 | |||
|
|
e95a2c3352 | ||
|
|
a8340c3279 | ||
|
|
e25979e089 | ||
|
|
ca7375b9c3 | ||
|
|
f8752fcb4d | ||
|
|
d1c955c74f | ||
|
|
91e60694ad | ||
|
|
f37fdefddd | ||
|
|
18fa0a47b1 | ||
|
|
9f5cc9e0d1 | ||
|
|
b02db4c1e1 | ||
|
|
d6b31ed5b9 | ||
|
|
9e600bfae0 | ||
|
|
1a73d5a4d9 | ||
|
|
a933330418 | ||
|
|
ea34b18f40 | ||
|
|
67dc215e83 | ||
|
|
baf3869cec | ||
|
|
eeda5aeb66 | ||
|
|
754df95071 | ||
|
|
24fca31606 | ||
|
|
a99c1c01b0 | ||
|
|
85999fab8f | ||
|
|
70745613e1 | ||
|
|
5c8e239a7b | ||
|
|
5eed65149a | ||
|
|
1ab4e2f94b | ||
|
|
f792bc1954 | ||
|
|
ced72ab9eb | ||
|
|
6c1cc77aaa | ||
|
|
5b81caf5a8 | ||
|
|
4e03b381dc | ||
|
|
3222133aa0 | ||
|
|
0ec423e65c |
@@ -3,7 +3,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Authors></Authors>
|
<Authors></Authors>
|
||||||
<Company></Company>
|
<Company></Company>
|
||||||
<Version>2.1.1</Version>
|
<Version>2.1.0.67</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>
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ public class PlayerDataFactory
|
|||||||
{
|
{
|
||||||
nint basePtr = playerPointer;
|
nint basePtr = playerPointer;
|
||||||
|
|
||||||
if (!PtrGuard.LooksLikePtr(basePtr))
|
if (!PtrGuard.LooksLikePtr(basePtr, _dalamudUtil.IsWine))
|
||||||
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, out var drawObj))
|
if (!PtrGuard.TryReadIntPtr(drawObjAddr, _dalamudUtil.IsWine, out var drawObj))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (drawObj != 0 && !PtrGuard.LooksLikePtr(drawObj))
|
if (drawObj != 0 && !PtrGuard.LooksLikePtr(drawObj, _dalamudUtil.IsWine))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return drawObj == 0;
|
return drawObj == 0;
|
||||||
|
|||||||
@@ -174,85 +174,60 @@ public sealed class GameObjectHandler : DisposableMediatorSubscriberBase, IHighP
|
|||||||
|
|
||||||
private unsafe void CheckAndUpdateObject(bool allowPublish)
|
private unsafe void CheckAndUpdateObject(bool allowPublish)
|
||||||
{
|
{
|
||||||
try
|
var prevAddr = Address;
|
||||||
|
var prevDrawObj = DrawObjectAddress;
|
||||||
|
string? nameString = null;
|
||||||
|
|
||||||
|
var nextAddr = _getAddress();
|
||||||
|
|
||||||
|
if (nextAddr != IntPtr.Zero && !PtrGuard.LooksLikePtr(nextAddr, _dalamudUtil.IsWine))
|
||||||
{
|
{
|
||||||
var prevAddr = Address;
|
nextAddr = IntPtr.Zero;
|
||||||
var prevDrawObj = DrawObjectAddress;
|
}
|
||||||
string? nameString = null;
|
|
||||||
|
|
||||||
var nextAddr = _getAddress();
|
if (nextAddr != IntPtr.Zero &&
|
||||||
|
!PtrGuard.IsReadable(nextAddr, (nuint)sizeof(FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject)))
|
||||||
|
{
|
||||||
|
nextAddr = IntPtr.Zero;
|
||||||
|
}
|
||||||
|
|
||||||
if (nextAddr != IntPtr.Zero && !PtrGuard.LooksLikePtr(nextAddr))
|
Address = nextAddr;
|
||||||
|
|
||||||
|
if (Address != IntPtr.Zero)
|
||||||
|
{
|
||||||
|
var gameObject = (FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)Address;
|
||||||
|
var drawObjAddr = (IntPtr)gameObject->DrawObject;
|
||||||
|
DrawObjectAddress = drawObjAddr;
|
||||||
|
EntityId = gameObject->EntityId;
|
||||||
|
|
||||||
|
if (PtrGuard.IsReadable(Address, (nuint)sizeof(Character)))
|
||||||
{
|
{
|
||||||
nextAddr = IntPtr.Zero;
|
var chara = (Character*)Address;
|
||||||
|
nameString = chara->GameObject.NameString;
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(nameString) && !string.Equals(nameString, Name, StringComparison.Ordinal))
|
||||||
|
Name = nameString;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DrawObjectAddress = IntPtr.Zero;
|
||||||
|
EntityId = uint.MaxValue;
|
||||||
|
}
|
||||||
|
|
||||||
if (nextAddr != IntPtr.Zero &&
|
CurrentDrawCondition = (Address != IntPtr.Zero && DrawObjectAddress != IntPtr.Zero)
|
||||||
!PtrGuard.IsReadable(nextAddr, (nuint)sizeof(FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject)))
|
? IsBeingDrawnUnsafe()
|
||||||
{
|
: DrawCondition.DrawObjectZero;
|
||||||
nextAddr = IntPtr.Zero;
|
|
||||||
}
|
|
||||||
|
|
||||||
Address = nextAddr;
|
if (_haltProcessing || !allowPublish) return;
|
||||||
|
|
||||||
if (Address != IntPtr.Zero)
|
bool drawObjDiff = DrawObjectAddress != prevDrawObj;
|
||||||
{
|
bool addrDiff = Address != prevAddr;
|
||||||
var gameObject = (FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)Address;
|
|
||||||
|
|
||||||
var draw = (nint)gameObject->DrawObject;
|
|
||||||
|
|
||||||
if (!PtrGuard.LooksLikePtr(draw) || !PtrGuard.IsReadable(draw, (nuint)sizeof(DrawObject)))
|
|
||||||
draw = 0;
|
|
||||||
|
|
||||||
DrawObjectAddress = draw;
|
|
||||||
EntityId = gameObject->EntityId;
|
|
||||||
|
|
||||||
if (PtrGuard.IsReadable(Address, (nuint)sizeof(Character)))
|
|
||||||
{
|
|
||||||
var chara = (Character*)Address;
|
|
||||||
nameString = chara->GameObject.NameString;
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(nameString) && !string.Equals(nameString, Name, StringComparison.Ordinal))
|
|
||||||
Name = nameString;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DrawObjectAddress = IntPtr.Zero;
|
|
||||||
EntityId = uint.MaxValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
CurrentDrawCondition = (Address != IntPtr.Zero && DrawObjectAddress != IntPtr.Zero)
|
|
||||||
? IsBeingDrawnUnsafe()
|
|
||||||
: DrawCondition.DrawObjectZero;
|
|
||||||
|
|
||||||
if (_haltProcessing || !allowPublish) return;
|
|
||||||
|
|
||||||
bool drawObjDiff = DrawObjectAddress != prevDrawObj;
|
|
||||||
bool addrDiff = Address != prevAddr;
|
|
||||||
|
|
||||||
if (Address == IntPtr.Zero || DrawObjectAddress == IntPtr.Zero)
|
|
||||||
{
|
|
||||||
if (addrDiff || drawObjDiff)
|
|
||||||
{
|
|
||||||
CurrentDrawCondition = DrawCondition.DrawObjectZero;
|
|
||||||
Logger.LogTrace("[{this}] Changed", this);
|
|
||||||
if (_isOwnedObject && ObjectKind != ObjectKind.Player)
|
|
||||||
Mediator.Publish(new ClearCacheForObjectMessage(this));
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!PtrGuard.IsReadable(Address, (nuint)sizeof(Character)) ||
|
|
||||||
!PtrGuard.IsReadable(DrawObjectAddress, (nuint)sizeof(DrawObject)))
|
|
||||||
{
|
|
||||||
Logger.LogTrace("[{this}] Pointers became invalid during update", this);
|
|
||||||
Address = IntPtr.Zero;
|
|
||||||
DrawObjectAddress = IntPtr.Zero;
|
|
||||||
CurrentDrawCondition = DrawCondition.DrawObjectZero;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (Address != IntPtr.Zero && DrawObjectAddress != IntPtr.Zero
|
||||||
|
&& PtrGuard.IsReadable(Address, (nuint)sizeof(Character))
|
||||||
|
&& PtrGuard.IsReadable(DrawObjectAddress, (nuint)sizeof(DrawObject)))
|
||||||
|
{
|
||||||
var chara = (Character*)Address;
|
var chara = (Character*)Address;
|
||||||
var drawObj = (DrawObject*)DrawObjectAddress;
|
var drawObj = (DrawObject*)DrawObjectAddress;
|
||||||
|
|
||||||
@@ -335,11 +310,12 @@ public sealed class GameObjectHandler : DisposableMediatorSubscriberBase, IHighP
|
|||||||
Mediator.Publish(new CreateCacheForObjectMessage(this));
|
Mediator.Publish(new CreateCacheForObjectMessage(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
else if (addrDiff || drawObjDiff)
|
||||||
{
|
{
|
||||||
Address = IntPtr.Zero;
|
|
||||||
DrawObjectAddress = IntPtr.Zero;
|
|
||||||
CurrentDrawCondition = DrawCondition.DrawObjectZero;
|
CurrentDrawCondition = DrawCondition.DrawObjectZero;
|
||||||
|
Logger.LogTrace("[{this}] Changed", this);
|
||||||
|
if (_isOwnedObject && ObjectKind != ObjectKind.Player)
|
||||||
|
Mediator.Publish(new ClearCacheForObjectMessage(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -379,10 +355,7 @@ public sealed class GameObjectHandler : DisposableMediatorSubscriberBase, IHighP
|
|||||||
|
|
||||||
private unsafe bool CompareAndUpdateMainHand(Weapon* weapon)
|
private unsafe bool CompareAndUpdateMainHand(Weapon* weapon)
|
||||||
{
|
{
|
||||||
var p = (nint)weapon;
|
if ((nint)weapon == nint.Zero) return false;
|
||||||
if (!PtrGuard.LooksLikePtr(p) || !PtrGuard.IsReadable(p, (nuint)sizeof(Weapon)))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
bool hasChanges = false;
|
bool hasChanges = false;
|
||||||
hasChanges |= weapon->ModelSetId != MainHandData[0];
|
hasChanges |= weapon->ModelSetId != MainHandData[0];
|
||||||
MainHandData[0] = weapon->ModelSetId;
|
MainHandData[0] = weapon->ModelSetId;
|
||||||
@@ -395,10 +368,7 @@ public sealed class GameObjectHandler : DisposableMediatorSubscriberBase, IHighP
|
|||||||
|
|
||||||
private unsafe bool CompareAndUpdateOffHand(Weapon* weapon)
|
private unsafe bool CompareAndUpdateOffHand(Weapon* weapon)
|
||||||
{
|
{
|
||||||
var p = (nint)weapon;
|
if ((nint)weapon == nint.Zero) return false;
|
||||||
if (!PtrGuard.LooksLikePtr(p) || !PtrGuard.IsReadable(p, (nuint)sizeof(Weapon)))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
bool hasChanges = false;
|
bool hasChanges = false;
|
||||||
hasChanges |= weapon->ModelSetId != OffHandData[0];
|
hasChanges |= weapon->ModelSetId != OffHandData[0];
|
||||||
OffHandData[0] = weapon->ModelSetId;
|
OffHandData[0] = weapon->ModelSetId;
|
||||||
@@ -462,18 +432,11 @@ public sealed class GameObjectHandler : DisposableMediatorSubscriberBase, IHighP
|
|||||||
{
|
{
|
||||||
if (Address == IntPtr.Zero) return DrawCondition.ObjectZero;
|
if (Address == IntPtr.Zero) return DrawCondition.ObjectZero;
|
||||||
if (DrawObjectAddress == IntPtr.Zero) return DrawCondition.DrawObjectZero;
|
if (DrawObjectAddress == IntPtr.Zero) return DrawCondition.DrawObjectZero;
|
||||||
|
|
||||||
if (!PtrGuard.IsReadable(Address, (nuint)sizeof(FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject)))
|
|
||||||
return DrawCondition.ObjectZero;
|
|
||||||
|
|
||||||
var visibilityFlags = ((FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)Address)->RenderFlags;
|
var visibilityFlags = ((FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)Address)->RenderFlags;
|
||||||
if (visibilityFlags != VisibilityFlags.None) return DrawCondition.RenderFlags;
|
if (visibilityFlags != VisibilityFlags.None) return DrawCondition.RenderFlags;
|
||||||
|
|
||||||
if (ObjectKind == ObjectKind.Player)
|
if (ObjectKind == ObjectKind.Player)
|
||||||
{
|
{
|
||||||
if (!PtrGuard.IsReadable(DrawObjectAddress, (nuint)sizeof(CharacterBase)))
|
|
||||||
return DrawCondition.DrawObjectZero;
|
|
||||||
|
|
||||||
var modelInSlotLoaded = (((CharacterBase*)DrawObjectAddress)->HasModelInSlotLoaded != 0);
|
var modelInSlotLoaded = (((CharacterBase*)DrawObjectAddress)->HasModelInSlotLoaded != 0);
|
||||||
if (modelInSlotLoaded) return DrawCondition.ModelInSlotLoaded;
|
if (modelInSlotLoaded) return DrawCondition.ModelInSlotLoaded;
|
||||||
var modelFilesInSlotLoaded = (((CharacterBase*)DrawObjectAddress)->HasModelFilesInSlotLoaded != 0);
|
var modelFilesInSlotLoaded = (((CharacterBase*)DrawObjectAddress)->HasModelFilesInSlotLoaded != 0);
|
||||||
|
|||||||
@@ -5,40 +5,41 @@ namespace LightlessSync.Utils
|
|||||||
{
|
{
|
||||||
public static partial class PtrGuard
|
public static partial class PtrGuard
|
||||||
{
|
{
|
||||||
private const ulong _aligmentPtr = 0x7UL;
|
private static readonly nuint _hardMinWindows =
|
||||||
private static readonly nuint _minAppAddr = (nuint)GetMinAppAddr();
|
(nuint)(IntPtr.Size == 8 ? 0x0000000100000000UL : 0x0000000000010000UL);
|
||||||
private static readonly nuint _maxAppAddr = (nuint)GetMaxAppAddr();
|
private static readonly nuint _hardMaxWindows =
|
||||||
|
(nuint)(IntPtr.Size == 8 ? 0x00007FFFFFFFFFFFUL : 0x7FFFFFFFUL);
|
||||||
|
private const nuint _alignmentPtr = 0x7;
|
||||||
|
|
||||||
private static nint GetMinAppAddr()
|
private static readonly (nuint min, nuint max) _sysRange = GetSysRange();
|
||||||
|
|
||||||
|
private static (nuint min, nuint max) GetSysRange()
|
||||||
{
|
{
|
||||||
GetSystemInfo(out var si);
|
GetSystemInfo(out var si);
|
||||||
return si.lpMinimumApplicationAddress;
|
return ((nuint)si.lpMinimumApplicationAddress, (nuint)si.lpMaximumApplicationAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static nint GetMaxAppAddr()
|
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)
|
||||||
{
|
{
|
||||||
GetSystemInfo(out var si);
|
if (p == 0) return false;
|
||||||
return si.lpMaximumApplicationAddress;
|
nuint u = (nuint)p;
|
||||||
|
|
||||||
|
if (u < GetMinAppAddr(isWine)) return false;
|
||||||
|
if (u > GetMaxAppAddr(isWine)) return false;
|
||||||
|
if ((u & _alignmentPtr) != 0) return false;
|
||||||
|
if ((uint)u == 0x12345679u) return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool LooksLikePtr(nint p)
|
public static bool TryReadIntPtr(nint addr, bool isWine, out nint value)
|
||||||
{
|
|
||||||
if (p == 0) return false;
|
|
||||||
nuint u = (nuint)p;
|
|
||||||
|
|
||||||
if (u < _minAppAddr) return false;
|
|
||||||
if (u > _maxAppAddr) return false;
|
|
||||||
if ((u & _aligmentPtr) != 0) return false;
|
|
||||||
if ((uint)u == 0x12345679u) return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool TryReadIntPtr(nint addr, out nint value)
|
|
||||||
{
|
{
|
||||||
value = 0;
|
value = 0;
|
||||||
|
|
||||||
if (!LooksLikePtr(addr))
|
if (!LooksLikePtr(addr, isWine))
|
||||||
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)
|
||||||
@@ -49,7 +50,7 @@ namespace LightlessSync.Utils
|
|||||||
{
|
{
|
||||||
if (addr == 0 || size == 0) return false;
|
if (addr == 0 || size == 0) return false;
|
||||||
|
|
||||||
if (VirtualQuery(addr, out var mbi, (nuint)Marshal.SizeOf<MEMORY_BASIC_INFORMATION>()) == 0)
|
if (VirtualQuery(addr, out var mbi, (nuint)Marshal.SizeOf<MemoryBasicInformation>()) == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const uint Commit = 0x1000;
|
const uint Commit = 0x1000;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ namespace LightlessSync.Utils
|
|||||||
internal static class PtrGuardMemory
|
internal static class PtrGuardMemory
|
||||||
{
|
{
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
internal struct MEMORY_BASIC_INFORMATION
|
internal struct MemoryBasicInformation
|
||||||
{
|
{
|
||||||
public nint BaseAddress;
|
public nint BaseAddress;
|
||||||
public nint AllocationBase;
|
public nint AllocationBase;
|
||||||
@@ -19,7 +19,7 @@ namespace LightlessSync.Utils
|
|||||||
[DllImport("kernel32.dll", SetLastError = true)]
|
[DllImport("kernel32.dll", SetLastError = true)]
|
||||||
internal static extern nuint VirtualQuery(
|
internal static extern nuint VirtualQuery(
|
||||||
nint lpAddress,
|
nint lpAddress,
|
||||||
out MEMORY_BASIC_INFORMATION lpBuffer,
|
out MemoryBasicInformation lpBuffer,
|
||||||
nuint dwLength);
|
nuint dwLength);
|
||||||
|
|
||||||
[DllImport("kernel32.dll", SetLastError = true)]
|
[DllImport("kernel32.dll", SetLastError = true)]
|
||||||
@@ -34,10 +34,10 @@ namespace LightlessSync.Utils
|
|||||||
internal static extern nint GetCurrentProcess();
|
internal static extern nint GetCurrentProcess();
|
||||||
|
|
||||||
[DllImport("kernel32.dll")]
|
[DllImport("kernel32.dll")]
|
||||||
internal static extern void GetSystemInfo(out SYSTEM_INFO lpSystemInfo);
|
internal static extern void GetSystemInfo(out SystemInfo lpSystemInfo);
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
internal struct SYSTEM_INFO
|
internal struct SystemInfo
|
||||||
{
|
{
|
||||||
public ushort wProcessorArchitecture;
|
public ushort wProcessorArchitecture;
|
||||||
public ushort wReserved;
|
public ushort wReserved;
|
||||||
|
|||||||
Reference in New Issue
Block a user