public int unject(DLLInformation d) { if (!d.IsInjected) { return(-2); } IntPtr hProcess = OpenProcess((int)(0x000F0000L | 0x00100000L | 0xFFF), false, d.ProcID); if (hProcess == null || hProcess.ToInt32() == -1) { return(1); } uint x = 0; IntPtr loc = new IntPtr(GetProcAddress(GetModuleHandle("KERNEL32.dll"), "FreeLibrary").ToUInt32()); IntPtr hThread = CreateRemoteThread(hProcess, new IntPtr(0), 0, loc, new IntPtr(d.DllHandle), 0, out x); if (hThread == null || hThread.ToInt32() == -1) { return(2); } WaitForSingleObject(hThread, uint.MaxValue); uint exitCode; if (!GetExitCodeThread(hThread, out exitCode)) { return(3); } CloseHandle(hThread); CloseHandle(hProcess); d.IsInjected = false; return(0); }
public int unject(DLLInformation d) { if (!d.IsInjected) { return -2; } IntPtr hProcess = OpenProcess((int)(0x000F0000L | 0x00100000L | 0xFFF), false, d.ProcID); if (hProcess == null || hProcess.ToInt32() == -1) { return 1; } uint x = 0; IntPtr loc = new IntPtr(GetProcAddress(GetModuleHandle("KERNEL32.dll"), "FreeLibrary").ToUInt32()); IntPtr hThread = CreateRemoteThread(hProcess, new IntPtr(0), 0, loc, new IntPtr(d.DllHandle), 0, out x); if (hThread == null || hThread.ToInt32() == -1) { return 2; } WaitForSingleObject(hThread, uint.MaxValue); uint exitCode; if (!GetExitCodeThread(hThread, out exitCode)) { return 3; } CloseHandle(hThread); CloseHandle(hProcess); d.IsInjected = false; return 0; }
public DLLInformation inject(int pid, string dllPath) { DLLInformation d = new DLLInformation(); d.ProcID = pid; IntPtr hProcess = OpenProcess((int)(0x000F0000L | 0x00100000L | 0xFFF), false, pid); d.ErrorCode = commonInject(hProcess, dllPath, ref d); return d; }
private void button1_Click(object sender, EventArgs e) { if (!injected) { if (speed > 1.9) { MessageBox.Show("speed must be below 1.9"); speed = 1.9; } if (speed < 0.1) { MessageBox.Show("speed must be above 0.1"); speed = 0.1; } write(); int code = 8; try { if (osu.HasExited) { Process[] procs = Process.GetProcesses(); foreach (Process p in procs) { if (p.ProcessName == "osu!") { osu = p; } } if (osu.HasExited) { MessageBox.Show("No osu! process found"); return; } } hook = i.inject(osu.Id, dllName); code = hook.ErrorCode; } catch { MessageBox.Show(getError(code)); } if (code != 0) { MessageBox.Show(getError(code)); } else { injected = true; } } else { button2_Click(null, null); button1_Click(null, null); } }
public DLLInformation inject(int pid, string dllPath) { DLLInformation d = new DLLInformation(); d.ProcID = pid; IntPtr hProcess = OpenProcess((int)(0x000F0000L | 0x00100000L | 0xFFF), false, pid); d.ErrorCode = commonInject(hProcess, dllPath, ref d); return(d); }
private int commonInject(IntPtr hProcess, string dllPath, ref DLLInformation d) { if (d == null) { d = new DLLInformation(); } d.DllPath = dllPath; if (hProcess == null || hProcess.ToInt32() == -1) { return(1); } IntPtr memory = VirtualAllocEx(hProcess, new IntPtr(0), (uint)dllPath.Length, AllocationType.Commit, MemoryProtection.ReadWrite); if (memory == null || memory.ToInt32() == 0) { return(2); } UIntPtr p; byte[] data = Encoding.ASCII.GetBytes(dllPath); if (!WriteProcessMemory(hProcess, memory, data, (uint)dllPath.Length, out p)) { return(3); } uint x = 0; IntPtr loc = new IntPtr(GetProcAddress(GetModuleHandle("KERNEL32.DLL"), "LoadLibraryA").ToUInt32()); IntPtr hThread = CreateRemoteThread(hProcess, new IntPtr(0), 0, loc, memory, 0, out x); if (hThread == null || hThread.ToInt32() == -1) { return(4); } WaitForSingleObject(hThread, uint.MaxValue); uint exitCode; if (!GetExitCodeThread(hThread, out exitCode)) { return(5); } d.DllHandle = exitCode; CloseHandle(hThread); VirtualFreeEx(hProcess, memory, dllPath.Length + 1, FreeType.Release); d.IsInjected = true; return(0); }
private int commonInject(IntPtr hProcess, string dllPath, ref DLLInformation d) { if (d == null) d = new DLLInformation(); d.DllPath = dllPath; if (hProcess == null || hProcess.ToInt32() == -1) { return 1; } IntPtr memory = VirtualAllocEx(hProcess, new IntPtr(0), (uint)dllPath.Length, AllocationType.Commit, MemoryProtection.ReadWrite); if (memory == null || memory.ToInt32() == 0) { return 2; } UIntPtr p; byte[] data = Encoding.ASCII.GetBytes(dllPath); if (!WriteProcessMemory(hProcess, memory, data, (uint)dllPath.Length, out p)) { return 3; } uint x = 0; IntPtr loc = new IntPtr(GetProcAddress(GetModuleHandle("KERNEL32.DLL"), "LoadLibraryA").ToUInt32()); IntPtr hThread = CreateRemoteThread(hProcess, new IntPtr(0), 0, loc, memory, 0, out x); if (hThread == null || hThread.ToInt32() == -1) { return 4; } WaitForSingleObject(hThread, uint.MaxValue); uint exitCode; if (!GetExitCodeThread(hThread, out exitCode)) { return 5; } d.DllHandle = exitCode; CloseHandle(hThread); VirtualFreeEx(hProcess, memory, dllPath.Length + 1, FreeType.Release); d.IsInjected = true; return 0; }