Пример #1
0
        private bool Inject(int pID, string dllLocation)
        {
            int  num  = Form1.OpenProcess(2035711, 1, pID);
            bool flag = num == 0;
            bool result;

            if (flag)
            {
                result = false;
            }
            else
            {
                byte[] bytes = Encoding.ASCII.GetBytes(dllLocation);
                int    num2  = Form1.VirtualAllocEx(num, 0, bytes.Length, 4096, 4);
                bool   flag2 = num2 == 0;
                if (flag2)
                {
                    result = false;
                }
                else
                {
                    string text         = "kernel32.dll";
                    int    moduleHandle = Form1.GetModuleHandle(ref text);
                    string text2        = "LoadLibraryA";
                    int    procAddress  = Form1.GetProcAddress(moduleHandle, ref text2);
                    bool   flag3        = moduleHandle == 0 || procAddress == 0;
                    if (flag3)
                    {
                        result = false;
                    }
                    else
                    {
                        Form1.WriteProcessMemory(num, num2, bytes, bytes.Length, 0U);
                        int  num3  = Form1.CreateRemoteThread(num, 0, 0, procAddress, num2, 0, 0);
                        bool flag4 = num3 == 0;
                        if (flag4)
                        {
                            result = false;
                        }
                        else
                        {
                            Form1.WaitForSingleObject(num3, 5000);
                            Form1.CloseHandle(num3);
                            Form1.CloseHandle(num);
                            result = true;
                        }
                    }
                }
            }
            return(result);
        }