Exemple #1
0
 /// <summary>
 /// Gets the thread corresponding to an id.
 /// </summary>
 /// <param name="threadId">The unique identifier of the thread to get.</param>
 /// <returns>A new instance of a <see cref="RemoteThread"/> class.</returns>
 public RemoteThread this[int threadId]
 {
     get
     {
         return(new RemoteThread(MemorySharp, NativeThreads.First(t => t.Id == threadId)));
     }
 }
Exemple #2
0
        /// <summary>
        ///     Creates a thread that runs in the remote process.
        /// </summary>
        /// <param name="address">
        ///     A pointer to the application-defined function to be executed by the thread and represents
        ///     the starting address of the thread in the remote process.
        /// </param>
        /// <param name="isStarted">Sets if the thread must be started just after being created.</param>
        /// <returns>A new instance of the <see cref="RemoteThread" /> class.</returns>
        public IRemoteThread Create(IntPtr address, bool isStarted = true)
        {
            //Create the thread
            var ret = ThreadHelper.NtQueryInformationThread(
                ThreadHelper.CreateRemoteThread(Process.Handle, address, IntPtr.Zero,
                                                ThreadCreationFlags.Suspended));

            // Find the managed object corresponding to this thread
            // TODO (int) cast may be unnecessary and/or problematic. Suggest coming back for proper fix later
            var result = new RemoteThread(Process, NativeThreads.First(t => t.Id == (int)ret.ClientId.UniqueThread));

            // If the thread must be started
            if (isStarted)
            {
                result.Resume();
            }
            return(result);
        }
Exemple #3
0
        public RemoteThread GetThreadById(int id)
        {
            var native = NativeThreads.FirstOrDefault(t => t.Id == id);

            return(native == null ? null : new RemoteThread(m_Process, native));
        }
Exemple #4
0
 /// <summary>
 ///     Gets the thread corresponding to an id.
 /// </summary>
 /// <param name="threadId">The unique identifier of the thread to get.</param>
 /// <returns>A new instance of a <see cref="RemoteThread" /> class.</returns>
 public IRemoteThread this[int threadId]
 {
     get { return(new RemoteThread(_process, NativeThreads.First(t => t.Id == threadId))); }
 }
Exemple #5
0
 /// <summary>
 ///     Gets a thread by its id in the remote process.
 /// </summary>
 /// <param name="id">The id of the thread.</param>
 /// <returns>A new instance of the <see cref="RemoteThread" /> class.</returns>
 public IRemoteThread GetThreadById(int id)
 {
     return(new RemoteThread(_process, NativeThreads.First(t => t.Id == id)));
 }
Exemple #6
0
 /// <summary>
 /// Gets a thread by its id in the remote process.
 /// </summary>
 /// <param name="id">The id of the thread.</param>
 /// <returns>A new instance of the <see cref="RemoteThread"/> class.</returns>
 public RemoteThread GetThreadById(int id)
 {
     return(new RemoteThread(MemorySharp, NativeThreads.First(t => t.Id == id)));
 }