Exemple #1
0
        /// <summary>
        /// Creates a thread inside another process' context.
        /// </summary>
        /// <param name="hProcess">Handle to the process inside which thread will be created.</param>
        /// <param name="dwStartAddress">Address at which thread will start.</param>
        /// <param name="dwParameter">Parameter that will be passed to the thread.</param>
        /// <param name="dwCreationFlags">Flags that control creation of the thread.</param>
        /// <param name="dwThreadId">[Out] The id of the created thread.</param>
        /// <returns>Returns the handle of the created thread.</returns>
        public static IntPtr CreateRemoteThread(IntPtr hProcess, uint dwStartAddress, uint dwParameter, uint dwCreationFlags, out uint dwThreadId)
        {
            IntPtr hThread, lpThreadId;

            hThread    = Imports.CreateRemoteThread(hProcess, IntPtr.Zero, 0, (IntPtr)dwStartAddress, (IntPtr)dwParameter, dwCreationFlags, out lpThreadId);
            dwThreadId = (uint)lpThreadId;

            return(hThread);
        }