-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Program.cs
116 lines (88 loc) · 5.35 KB
/
Program.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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
using System.Diagnostics;
using System.Net;
using System.Text.Json;
using CSGO_Offset_Dumper.JsonClasses;
using Spectre.Console;
namespace CSGO_Offset_Dumper
{
internal class Program
{
/// <summary>
/// The location of the configuration file the signatures and netvars are saved in.
/// </summary>
const string configFilePath = "config.json";
/// <summary>
/// The Process ID of CSGO
/// </summary>
public static int ProcessID { get; private set; }
/// <summary>
/// Field to get the offset of dwGetAllClasses from the signature scan. (We must start signature scan first before netvar scan because netvars require this signature.
/// </summary>
private static int dwGetAllClassesOffset => Signatures.FirstOrDefault(x => x.Key.Equals("dwGetAllClasses")).Value;
private static Dictionary<string, int> Signatures = new();
private static Dictionary<string, int> Netvars = new();
private const string clientdll = "client.dll";
static void Main(string[] args)
{
Console.Title = "CSGO Offset Dumper C# | Made by KyeOnDiscord";
AppConfig.InitConfig();
AnsiConsole.Write(new FigletText("CSGO Offset Dumper").LeftAligned().Color(Color.Blue));
if (!File.Exists(configFilePath))
{
AnsiConsole.MarkupLine($"[red][[Error]] Could not find {configFilePath}! Downloading config from {AppConfig.CurrentConfig.FallbackConfigURL}![/]");
new WebClient().DownloadFile(AppConfig.CurrentConfig.FallbackConfigURL, configFilePath);
}
Config.Rootobject? config = JsonSerializer.Deserialize<Config.Rootobject>(File.ReadAllText(configFilePath));
AnsiConsole.MarkupLine($"[purple]Loading [green]{config.netvars.Length}[/] netvars and [green]{config.signatures.Length}[/] signatures[/]");
AnsiConsole.MarkupLine($"[grey]Trying to find {config.executable}[/]");
Process[] csgoproc = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(config.executable));
if (csgoproc.Length > 0)
{
ProcessID = csgoproc[0].Id;
AnsiConsole.MarkupLine($"[green]Found {csgoproc[0].ProcessName}.exe -> {ProcessID}[/]");
AnsiConsole.MarkupLine("[grey]Trying to get process handle[/]");
Win32.ProcessHandle = Win32.OpenProcess(0x0008 | 0x0010 | 0x0020, false, ProcessID);
if (Win32.ProcessHandle != IntPtr.Zero)
{
AnsiConsole.MarkupLine($"[green]Found Proccess Handle -> 0x{Win32.ProcessHandle.ToString("X")}[/]");
AnsiConsole.MarkupLine($"[grey]Searching for {clientdll}[/]");
var clientModule = Win32.GetModule((IntPtr)ProcessID, clientdll);
if (clientModule != null)
{
string path = clientModule.Value.szExePath;
AnsiConsole.MarkupLine($"[green]Found {clientdll} -> {path}[/]");
AnsiConsole.MarkupLine($"[grey]Trying to load {clientdll}[/]");
IntPtr internalClientDll = Win32.LoadLibrary(path);
if (internalClientDll != IntPtr.Zero)
{
AnsiConsole.MarkupLine($"[green]Loaded {clientdll} -> 0x{internalClientDll}[/]");
PatternScan.GetSignatureOffsets(config.signatures, ref Signatures);
AnsiConsole.MarkupLine($"[green]Finished getting signatures![/]");
IntPtr dwGetallClassesAddr = internalClientDll + dwGetAllClassesOffset;
var allClasses = dwGetAllClasses.ClassExporter.GetAllClasses(dwGetallClassesAddr);
SDK.Netvar.GetNetvarOffsets(config.netvars, ref Netvars, dwGetallClassesAddr);
AnsiConsole.MarkupLine($"[green]Found [blue]{Netvars.Count}/{config.netvars.Length}[/] netvars and [blue]{Signatures.Count}/{config.signatures.Length}[/] signatures[/]");
//Dumps netvars and signatures
Dumper.DumpCPP(Netvars, Signatures, config.filename);
Dumper.DumpCSharp(Netvars, Signatures, config.filename);
Dumper.DumpJson(Netvars, Signatures, config.filename);
Dumper.DumpTOML(Netvars, Signatures, config.filename);
Dumper.DumpCheatTable(Netvars, Signatures, config.filename, allClasses);
//Dumps all netvar classes
Dumper.DumpJson(allClasses);
Dumper.DumpCPP(allClasses);
AnsiConsole.MarkupLine("");
AnsiConsole.MarkupLine("");
AnsiConsole.MarkupLine($"[bold underline green]Finished![/]");
}
}
}
}
else
{
AnsiConsole.MarkupLine($"[red][[Error]] Could not find {config.executable}! Maybe try opening the game?[/]");
}
Console.ReadLine();
}
}
}