コード例 #1
0
        public void Inject(int pid, string pathToDll, InjectionOptions injectionOptions = null)
        {
            if (pid <= 0)
            {
                throw new ArgumentException("Invalid process pid: " + pid, "pid");
            }
            if (string.IsNullOrWhiteSpace(pathToDll) || !File.Exists(pathToDll))
            {
                throw new ArgumentException($"Cannot access DLL: " { pathToDll } "");
            }
            if (injectionOptions == null)
            {
            }
            injectionOptions = InjectionOptions.Defaults;
            IntPtr processHandle = WinAPI.OpenProcess(WinAPI.ProcessAccessFlags.CreateThread | WinAPI.ProcessAccessFlags.QueryInformation | WinAPI.ProcessAccessFlags.VirtualMemoryOperation | WinAPI.ProcessAccessFlags.VirtualMemoryRead | WinAPI.ProcessAccessFlags.VirtualMemoryWrite, false, pid);

            object[] args = new object[] { pid };
            Utils.CheckForFailure(processHandle == IntPtr.Zero, "Cannot open process with PID: {0}", args);
            IntPtr hHandle = this._injectionStrategy.Inject(processHandle, pathToDll);

            if (injectionOptions.WaitForThreadExit)
            {
                WinAPI.WaitForSingleObject(hHandle, uint.MaxValue);
            }
            WinAPI.CloseHandle(processHandle);
        }
コード例 #2
0
        public void Inject(int pid, string pathToDll, InjectionOptions injectionOptions = null)
        {
            if (pid <= 0)
                throw new ArgumentException("Invalid process pid: " + pid, "pid");

            if (string.IsNullOrWhiteSpace(pathToDll) || !File.Exists(pathToDll))
                throw new ArgumentException(string.Format("Cannot access DLL: \"{0}\"", pathToDll));

            injectionOptions = injectionOptions ?? InjectionOptions.Defaults;

            IntPtr processHandle = WinAPI.OpenProcess(
                WinAPI.ProcessAccessFlags.CreateThread |
                WinAPI.ProcessAccessFlags.QueryInformation |
                WinAPI.ProcessAccessFlags.VirtualMemoryOperation |
                WinAPI.ProcessAccessFlags.VirtualMemoryRead |
                WinAPI.ProcessAccessFlags.VirtualMemoryWrite,
                bInheritHandle: false,
                processId: pid);

            Utils.CheckForFailure(processHandle == IntPtr.Zero, "Cannot open process with PID: {0}", pid);

            IntPtr remoteThreadHandle = _injectionStrategy.Inject(processHandle, pathToDll);
            if (injectionOptions.WaitForThreadExit) {
                WinAPI.WaitForSingleObject(remoteThreadHandle, WinAPI.INFINITE);
            }

            WinAPI.CloseHandle(processHandle);
        }
コード例 #3
0
        public void Inject(int pid, string pathToDll, InjectionOptions injectionOptions = null)
        {
            if (pid <= 0)
            {
                throw new ArgumentException("Invalid process pid: " + pid, "pid");
            }

            if (string.IsNullOrWhiteSpace(pathToDll) || !File.Exists(pathToDll))
            {
                throw new ArgumentException(string.Format("Cannot access DLL: \"{0}\"", pathToDll));
            }

            injectionOptions = injectionOptions ?? InjectionOptions.Defaults;


            IntPtr processHandle = WinAPI.OpenProcess(
                WinAPI.ProcessAccessFlags.CreateThread |
                WinAPI.ProcessAccessFlags.QueryInformation |
                WinAPI.ProcessAccessFlags.VirtualMemoryOperation |
                WinAPI.ProcessAccessFlags.VirtualMemoryRead |
                WinAPI.ProcessAccessFlags.VirtualMemoryWrite,
                bInheritHandle: false,
                processId: pid);

            Utils.CheckForFailure(processHandle == IntPtr.Zero, "Cannot open process with PID: {0}", pid);


            IntPtr remoteThreadHandle = _injectionStrategy.Inject(processHandle, pathToDll);

            if (injectionOptions.WaitForThreadExit)
            {
                WinAPI.WaitForSingleObject(remoteThreadHandle, WinAPI.INFINITE);
            }


            WinAPI.CloseHandle(processHandle);
        }
コード例 #4
0
ファイル: DLLInjector.cs プロジェクト: pwnedcorp/skid
 // Token: 0x06000039 RID: 57 RVA: 0x00004768 File Offset: 0x00002768
 public void Inject(int pid, string pathToDll, InjectionOptions injectionOptions = null)
 {
 }