-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrainer.cs
More file actions
82 lines (71 loc) · 2.16 KB
/
Copy pathTrainer.cs
File metadata and controls
82 lines (71 loc) · 2.16 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* C# trainer class.
* Author : Cless
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Runtime.InteropServices;
public class Trainer
{
private const int PROCESS_ALL_ACCESS = 0x1F0FFF;
[DllImport("kernel32")]
private static extern int OpenProcess(int AccessType, int InheritHandle, int ProcessId);
[DllImport("kernel32", EntryPoint = "ReadProcessMemory")]
private static extern byte ReadProcessMemoryByte(int Handle, int Address, ref byte Value, int Size, ref int BytesRead);
[DllImport("kernel32")]
private static extern int CloseHandle(int Handle);
[DllImport("user32")]
private static extern int FindWindow(string sClassName, string sAppName);
[DllImport("user32")]
private static extern int GetWindowThreadProcessId(int HWND, out int processId);
public static string CheckGame(string WindowTitle)
{
string result = "";
checked
{
try
{
int Proc;
int HWND = FindWindow(null, WindowTitle);
GetWindowThreadProcessId(HWND, out Proc);
int Handle = OpenProcess(PROCESS_ALL_ACCESS, 0, Proc);
if (Handle != 0)
{
result = "Game is running...";
}
else
{
result = "Game is not running...";
}
CloseHandle(Handle);
}
catch
{ }
}
return result;
}
public static byte ReadByte(Process Proc, int Address)
{
byte Value = 0;
checked
{
try
{
if (Proc != null)
{
int Bytes = 0;
int Handle = OpenProcess(PROCESS_ALL_ACCESS, 0, Proc.Id);
if (Handle != 0)
{
ReadProcessMemoryByte(Handle, Address, ref Value, 2, ref Bytes);
CloseHandle(Handle);
}
}
}
catch
{ }
}
return Value;
}
}