-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAntiTimeModification.cs
56 lines (51 loc) · 1.67 KB
/
AntiTimeModification.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System.Threading;
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
public class AntiTimeModification
{
[DllImport("winmm.dll", EntryPoint = "timeGetTime")]
private static extern uint MM_GetTime();
[DllImport("kernel32.dll")]
static extern ulong GetTickCount64();
public static bool IsTimeModified(AntiTimeModificationFunction function)
{
if (function.Equals(AntiTimeModificationFunction.GetTickCount))
{
long tickCount = Environment.TickCount;
Thread.Sleep(500);
long tickCount2 = Environment.TickCount;
return (tickCount2 - tickCount) > 600L;
}
else if (function.Equals(AntiTimeModificationFunction.GetTickCount64))
{
ulong tickCount = GetTickCount64();
Thread.Sleep(500);
ulong tickCount2 = GetTickCount64();
return (tickCount2 - tickCount) > 600L;
}
else if (function.Equals(AntiTimeModificationFunction.QueryPerformanceCounter))
{
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
Thread.Sleep(500);
stopwatch.Stop();
return stopwatch.ElapsedMilliseconds > 600L;
}
else if (function.Equals(AntiTimeModificationFunction.timeGetTime))
{
long milliseconds1 = MM_GetTime();
Thread.Sleep(500);
long milliseconds2 = MM_GetTime();
return (milliseconds2 - milliseconds1) > 600L;
}
return false;
}
}
public enum AntiTimeModificationFunction
{
QueryPerformanceCounter,
GetTickCount,
GetTickCount64,
timeGetTime
}