Compare commits
24 Commits
clr-fix-at
...
2.0.2.81-D
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
172288c755 | ||
|
|
1c17be53d0 | ||
| 68b4863f52 | |||
|
|
e8f598e695 | ||
|
|
861a337029 | ||
| 06f89955d3 | |||
|
|
c7a2b679f2 | ||
|
|
bec69074a5 | ||
|
|
ac711d9a43 | ||
|
|
b875e0c3a1 | ||
|
|
46e76bbfe6 | ||
|
|
3654365f2a | ||
|
|
9b256dd185 | ||
|
|
223ade39cb | ||
|
|
5aca9e70b2 | ||
|
|
92772cf334 | ||
|
|
0395e81a9f | ||
|
|
7734a7bf7e | ||
|
|
db2d19bb1e | ||
|
|
ab305a249c | ||
|
|
9d104a9dd8 | ||
|
|
bcd3bd5ca2 | ||
|
|
c1829a9837 | ||
|
|
cca23f6e05 |
@@ -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>
|
||||||
|
|||||||
@@ -5,35 +5,19 @@ namespace LightlessSync.Utils
|
|||||||
{
|
{
|
||||||
public static partial class PtrGuard
|
public static partial class PtrGuard
|
||||||
{
|
{
|
||||||
|
private const ulong _minLikelyPtr = 0x0000_0001_0000_0000UL;
|
||||||
|
private const ulong _maxUserPtr = 0x0000_7FFF_FFFF_FFFFUL;
|
||||||
private const ulong _aligmentPtr = 0x7UL;
|
private const ulong _aligmentPtr = 0x7UL;
|
||||||
private static readonly nuint _minAppAddr = (nuint)GetMinAppAddr();
|
|
||||||
private static readonly nuint _maxAppAddr = (nuint)GetMaxAppAddr();
|
|
||||||
|
|
||||||
private static nint GetMinAppAddr()
|
public static bool LooksLikePtr(nint p)
|
||||||
{
|
{
|
||||||
GetSystemInfo(out var si);
|
if (p == 0) return false;
|
||||||
return si.lpMinimumApplicationAddress;
|
var u = (ulong)p;
|
||||||
|
if (u < _minLikelyPtr) return false;
|
||||||
|
if (u > _maxUserPtr) return false;
|
||||||
|
if ((u & _aligmentPtr) != 0) return false;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static nint GetMaxAppAddr()
|
|
||||||
{
|
|
||||||
GetSystemInfo(out var si);
|
|
||||||
return si.lpMaximumApplicationAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool LooksLikePtr(nint p)
|
|
||||||
{
|
|
||||||
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)
|
public static bool TryReadIntPtr(nint addr, out nint value)
|
||||||
{
|
{
|
||||||
value = 0;
|
value = 0;
|
||||||
|
|||||||
@@ -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 SYSTEM_INFO lpSystemInfo);
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
|
||||||
internal struct SYSTEM_INFO
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user