private bool WriteProcessMemory(IntPtr Pointer, byte[] BytesToWrite) { IntPtr nBytes; return(NativeImport.WriteProcessMemory(LoadedProcess.Handle, Pointer, BytesToWrite, BytesToWrite.Length, out nBytes)); }
private IntPtr CallMethod(IntPtr ptr, IntPtr arg) { IntPtr hThreadId; var hThread = NativeImport.CreateRemoteThread(LoadedProcess.Handle, IntPtr.Zero, 0, ptr, arg, 0, out hThreadId); return(hThread); }
internal void LoadAndCallMethod(string Library, string MethodName) { PerformValidationCheck(Library); var LoadedLibraryPTR = Load(Library); var LibraryToLoadCurrentProcPTR = NativeImport.LoadLibrary(Library); var PTRToMethod = NativeImport.GetProcAddress(LibraryToLoadCurrentProcPTR, MethodName); CallMethod(PTRToMethod, IntPtr.Zero); }
private int CallLoadLibraryA(IntPtr PointerToArg) { IntPtr hThreadId; var hThread = NativeImport.CreateRemoteThread(LoadedProcess.Handle, IntPtr.Zero, 0, LoadLibraryPTR, PointerToArg, 0, out hThreadId); NativeImport.WaitForSingleObject(hThread, unchecked ((uint)-1)); uint exitCode; NativeImport.GetExitCodeThread(hThread, out exitCode); return((int)exitCode); }
internal Loader(string ProcessName) { try { LoadedProcess = Process.GetProcessesByName(ProcessName).First(); } catch (Exception) { Console.WriteLine($"Could Not Find Process: {ProcessName}"); Console.Read(); Environment.Exit(0); } Kernel32PTR = NativeImport.LoadLibrary("kernel32"); LoadLibraryPTR = NativeImport.GetProcAddress(Kernel32PTR, "LoadLibraryA"); }
private bool IsLoadedProcessX64() { if (!Environment.Is64BitOperatingSystem) { return(false); } bool isWow64; if (!NativeImport.IsWow64Process(LoadedProcess.Handle, out isWow64)) { isWow64 = false; } return(!isWow64); }
private IntPtr VirtualAllocEx(int size) { return(NativeImport.VirtualAllocEx(LoadedProcess.Handle, IntPtr.Zero, (IntPtr)size, Enums.AllocationType.Commit | Enums.AllocationType.Reserve, Enums.MemoryProtection.ExecuteReadWrite)); }