From 14448cfbce4acc8c595b0fa3fdfe20502d19f377 Mon Sep 17 00:00:00 2001 From: Bitl Date: Thu, 10 Oct 2019 05:50:06 -0700 Subject: [PATCH] removed unneeded dll injector --- .../NovetusShared/LauncherFuncs.cs | 115 ------------------ 1 file changed, 115 deletions(-) diff --git a/NovetusLauncher/NovetusShared/LauncherFuncs.cs b/NovetusLauncher/NovetusShared/LauncherFuncs.cs index c698c3e..968b4a9 100644 --- a/NovetusLauncher/NovetusShared/LauncherFuncs.cs +++ b/NovetusLauncher/NovetusShared/LauncherFuncs.cs @@ -2163,121 +2163,6 @@ namespace NovetusShared } } - 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);