Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.04 KB | None | 0 0
  1. using System.Diagnostics;
  2. using System;
  3. using System.Windows.Forms;
  4. using System****ntime.InteropServices;
  5.  
  6. namespace Inject_Source_By_CoderNever
  7. {
  8. public partial class Form1 : Form
  9. {
  10. [DllImport("kernel32", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]
  11. public static extern int ReadProcessMemory(int hProcess, int lpBaseAddress, string lpBuffer, int nSize, ref int lpNumberOfBytesWritten);
  12.  
  13. [DllImport("kernel32", EntryPoint = "LoadLibraryA", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]
  14. public static extern int LoadLibrary(string lpLibFileName);
  15.  
  16. [DllImport("kernel32", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]
  17. public static extern int WriteProcessMemory(System.IntPtr hProcess, int lpBaseAddress, string lpBuffer, int nSize, int lpNumberOfBytesWritten);
  18.  
  19. [DllImport("kernel32", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]
  20. public static extern int VirtualAllocEx(System.IntPtr hProcess, int lpAddress, int dwSize, int flAllocationType, int flProtect);
  21.  
  22. [DllImport("kernel32", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]
  23. public static extern int GetProcAddress(int hModule, string lpProcName);
  24.  
  25. [DllImport("kernel32", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]
  26. public static extern int CreateRemoteThread(System.IntPtr hProcess, int lpThreadAttributes, int dwStackSize, int lpStartAddress, int lpParameter, int dwCreationFlags, int lpThreadId);
  27.  
  28. [DllImport("Kernel32", EntryPoint = "GetModuleHandleA", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]
  29. private static extern int GetModuleHandle(string lpModuleName);
  30.  
  31. [DllImport("kernel32.dll")]
  32. public static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId);
  33.  
  34. [DllImport("kernel32", EntryPoint = "CloseHandle")]
  35. private static extern int CloseHandle(System.IntPtr hObject);
  36.  
  37. [DllImport("user32", EntryPoint = "FindWindowA", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]
  38. private static extern int FindWindow(string lpClassName, string lpWindowName);
  39.  
  40. void Inject()
  41. {
  42. System.IntPtr TargetProcessHandle;
  43. int TargetBufferSize;
  44. String pszLibFileRemote;
  45. int pfnStartAddr;
  46. Process[] TargetProcess = Process.GetProcessesByName("Engine");
  47. TargetProcessHandle = OpenProcess(0x1F0FFF, false, TargetProcess[0].Id);
  48. pszLibFileRemote = Application.StartupPath + ("\\DLLNAME.dll");
  49. pfnStartAddr = GetProcAddress(GetModuleHandle("Kernel32.dll"), "LoadLibraryA");
  50. TargetBufferSize = 1 + pszLibFileRemote.Length;
  51. int Rtn;
  52. int LoadLibParamAdr;
  53. LoadLibParamAdr = VirtualAllocEx(TargetProcessHandle, 0, TargetBufferSize, 4096, 4);
  54. Rtn = WriteProcessMemory(TargetProcessHandle, LoadLibParamAdr, pszLibFileRemote, TargetBufferSize, 0);
  55. CreateRemoteThread(TargetProcessHandle, 0, 0, pfnStartAddr, LoadLibParamAdr, 0, 0);
  56. CloseHandle(TargetProcessHandle);
  57. }
  58.  
  59. private void timer1_Tick(object sender, EventArgs e)
  60. {
  61. Process[] TargetProcess = Process.GetProcessesByName("HSUpdate");
  62. if (TargetProcess.Length == 0)
  63. {}else{
  64. Inject();
  65. timer1.Stop();
  66. this.Close();
  67. }}
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement