コード例 #1
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);
        }
コード例 #2
0
ファイル: Inject.cs プロジェクト: aevv/osu-sh
 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;
 }
コード例 #3
0
ファイル: Inject.cs プロジェクト: aevv/osu-sh
 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;
 }
コード例 #4
0
ファイル: Form1.cs プロジェクト: mana15/osu-sh
 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);
     }
 }
コード例 #5
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);
        }
コード例 #6
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);
        }
コード例 #7
0
ファイル: Form1.cs プロジェクト: aevv/osu-sh
 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);
     }
 }
コード例 #8
0
ファイル: Inject.cs プロジェクト: aevv/osu-sh
 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;
 }