从模拟线程创建进程
CreateProcess from an impersonated thread
我在系统会话中有一个永远 运行ning 进程 运行ning。我需要在当前标准用户会话中模拟一个线程(让我们称之为 t1
)来访问映射驱动器中的某些文件,以及其他文件操作等。
从模拟线程调用另一个线程(我们称之为 t2
)。 t2
使用 CreateProcess()
创建具有默认值的进程。在系统会话中 t2
运行 秒创建的进程。
我不想知道如何 运行 用户会话中的子进程。相反,我试图理解为什么子进程 运行 在系统会话中,即使调用程序线程在用户会话中。
CreateProcess()
是否使用父进程的令牌而不是线程?
根据 CreateProcess 文档:
Creates a new process and its primary thread. The new process runs in the security context of the calling process.
If the calling process is impersonating another user, the new process uses the token for the calling process, not the impersonation token. To run the new process in the security context of the user represented by the impersonation token, use the CreateProcessAsUser
or CreateProcessWithLogonW
function.
至于您声称 t2
在用户会话中是 运行 因为 t1
在创建 t2
时冒充用户,这是错误的,根据 Creating new threads from an impersonated thread...:
Prior to Windows XP SP2 and Windows Server 2003, the new thread would be assigned the DACL from the impersonation token of the creator if the calling thread is impersonating or from the primary token if it is not. Starting with Windows XP SP2 and Windows Server 2003 the behavior is always the same: the new thread is assigned the DACL from the
primary token regardless of the impersonation state of the caller.
这意味着 t2
实际上是 运行 在系统会话中,而不是用户会话中。 t2
需要根据需要自己模拟用户。
我在系统会话中有一个永远 运行ning 进程 运行ning。我需要在当前标准用户会话中模拟一个线程(让我们称之为 t1
)来访问映射驱动器中的某些文件,以及其他文件操作等。
从模拟线程调用另一个线程(我们称之为 t2
)。 t2
使用 CreateProcess()
创建具有默认值的进程。在系统会话中 t2
运行 秒创建的进程。
我不想知道如何 运行 用户会话中的子进程。相反,我试图理解为什么子进程 运行 在系统会话中,即使调用程序线程在用户会话中。
CreateProcess()
是否使用父进程的令牌而不是线程?
根据 CreateProcess 文档:
Creates a new process and its primary thread. The new process runs in the security context of the calling process.
If the calling process is impersonating another user, the new process uses the token for the calling process, not the impersonation token. To run the new process in the security context of the user represented by the impersonation token, use the
CreateProcessAsUser
orCreateProcessWithLogonW
function.
至于您声称 t2
在用户会话中是 运行 因为 t1
在创建 t2
时冒充用户,这是错误的,根据 Creating new threads from an impersonated thread...:
Prior to Windows XP SP2 and Windows Server 2003, the new thread would be assigned the DACL from the impersonation token of the creator if the calling thread is impersonating or from the primary token if it is not. Starting with Windows XP SP2 and Windows Server 2003 the behavior is always the same: the new thread is assigned the DACL from the primary token regardless of the impersonation state of the caller.
这意味着 t2
实际上是 运行 在系统会话中,而不是用户会话中。 t2
需要根据需要自己模拟用户。