diff --git a/NovetusLauncher/NovetusLauncher/LauncherFuncs.cs b/NovetusLauncher/NovetusLauncher/LauncherFuncs.cs index 12a0ab0..cee75f4 100644 --- a/NovetusLauncher/NovetusLauncher/LauncherFuncs.cs +++ b/NovetusLauncher/NovetusLauncher/LauncherFuncs.cs @@ -790,6 +790,15 @@ namespace NovetusLauncher RenameWindow(exe, type); } } + + public static void InjectAntiCheat(Process client) + { + if (client.IsRunning() == true) + { + var injector = new DllInjector(); + injector.Inject(client, GlobalVars.BasePath + "\\soda.dll"); + } + } } public static class RichTextBoxExtensions @@ -1921,6 +1930,121 @@ namespace NovetusLauncher } } + public enum DllInjectionResult + { + DllNotFound, + GameProcessNotFound, + InjectionFailed, + Success + } + + public sealed class DllInjector + { + static readonly IntPtr INTPTR_ZERO = (IntPtr)0; + + [DllImport("kernel32.dll", SetLastError = true)] + static extern IntPtr OpenProcess(uint dwDesiredAccess, int bInheritHandle, uint dwProcessId); + + [DllImport("kernel32.dll", SetLastError = true)] + static extern int CloseHandle(IntPtr hObject); + + [DllImport("kernel32.dll", SetLastError = true)] + static extern IntPtr GetProcAddress(IntPtr hModule, string lpProcName); + + [DllImport("kernel32.dll", SetLastError = true)] + static extern IntPtr GetModuleHandle(string lpModuleName); + + [DllImport("kernel32.dll", SetLastError = true)] + static extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr lpAddress, IntPtr dwSize, uint flAllocationType, uint flProtect); + + [DllImport("kernel32.dll", SetLastError = true)] + static extern int WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] buffer, uint size, int lpNumberOfBytesWritten); + + [DllImport("kernel32.dll", SetLastError = true)] + static extern IntPtr CreateRemoteThread(IntPtr hProcess, IntPtr lpThreadAttribute, IntPtr dwStackSize, IntPtr lpStartAddress, + IntPtr lpParameter, uint dwCreationFlags, IntPtr lpThreadId); + + static DllInjector _instance; + + public static DllInjector GetInstance + { + get + { + if (_instance == null) + { + _instance = new DllInjector(); + } + return _instance; + } + } + + public DllInjector() + { + } + + public DllInjectionResult Inject(Process sProcName, string sDllPath) + { + if (!File.Exists(sDllPath)) + { + return DllInjectionResult.DllNotFound; + } + + uint _procId = (uint)sProcName.Id; + + if (_procId == 0) + { + return DllInjectionResult.GameProcessNotFound; + } + + if (!bInject(_procId, sDllPath)) + { + return DllInjectionResult.InjectionFailed; + } + + return DllInjectionResult.Success; + } + + bool bInject(uint pToBeInjected, string sDllPath) + { + IntPtr hndProc = OpenProcess((0x2 | 0x8 | 0x10 | 0x20 | 0x400), 1, pToBeInjected); + + if (hndProc == INTPTR_ZERO) + { + return false; + } + + IntPtr lpLLAddress = GetProcAddress(GetModuleHandle("kernel32.dll"), "LoadLibraryA"); + + if (lpLLAddress == INTPTR_ZERO) + { + return false; + } + + IntPtr lpAddress = VirtualAllocEx(hndProc, (IntPtr)null, (IntPtr)sDllPath.Length, (0x1000 | 0x2000), 0X40); + + if (lpAddress == INTPTR_ZERO) + { + return false; + } + + byte[] bytes = Encoding.ASCII.GetBytes(sDllPath); + + if (WriteProcessMemory(hndProc, lpAddress, bytes, (uint)bytes.Length, 0) == 0) + { + return false; + } + + if (CreateRemoteThread(hndProc, (IntPtr)null, INTPTR_ZERO, lpLLAddress, lpAddress, 0, (IntPtr)null) == INTPTR_ZERO) + { + return false; + } + + CloseHandle(hndProc); + + return true; + } + } + public static class GlobalVars { public static string RootPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); diff --git a/NovetusLauncher/NovetusLauncher/MainForm.cs b/NovetusLauncher/NovetusLauncher/MainForm.cs index fa873f9..e10987d 100644 --- a/NovetusLauncher/NovetusLauncher/MainForm.cs +++ b/NovetusLauncher/NovetusLauncher/MainForm.cs @@ -844,6 +844,7 @@ namespace NovetusLauncher client.Exited += new EventHandler(ClientExited); client.Start(); SecurityFuncs.RenameWindow(client, ScriptGenerator.ScriptType.Client); + //SecurityFuncs.InjectAntiCheat(client); GlobalVars.presence.details = ""; GlobalVars.presence.state = "In " + GlobalVars.SelectedClient + " Game"; GlobalVars.presence.largeImageText = GlobalVars.PlayerName + " | In " + GlobalVars.SelectedClient + " Game"; diff --git a/NovetusLauncher/NovetusLauncher/bin/Release/Mono.Nat.dll b/NovetusLauncher/NovetusLauncher/bin/Release/Mono.Nat.dll new file mode 100644 index 0000000..592850b Binary files /dev/null and b/NovetusLauncher/NovetusLauncher/bin/Release/Mono.Nat.dll differ