C ++线程以分离进程 [英] C++ thread to separate process

查看:95
本文介绍了C ++线程以分离进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法可以使线程分支到其自己的独立进程中?我知道有CreateProcess函数,但据我所知,您只能使用它运行外部应用程序.我所要求的完全可能吗?

解决方案

可能.

您可以使用虚拟应用程序和CREATE_SUSPENDED标志来调用CreateProcess,这样它就不会立即运行.然后,您可以使用VirtualAllocEx在创建的进程中分配内存空间,并使用WriteProcessMemory将代码和数据写入其中.然后取消运行该进程的操作.

您还可以使用CreateRemoteThread创建在另一个现有进程的上下文中运行的进程.

所以您想做 是可能的,但是在Windows环境中做这并不是一件容易的事,因此您必须有一个很好的理由去做. /p>

Is there any way I can have a thread branch off into its own independent process? I know there's the CreateProcess function but as far as I can tell, you can only run external applications with it. Is what I'm asking for at all possible?

解决方案

It is possible.

You could call CreateProcess with a dummy application and with the CREATE_SUSPENDED flag so it doesn't run immediately. Then you can use VirtualAllocEx to allocate memory space in the created process and WriteProcessMemory to write code and data into it. And then unsuspend the process to run it.

You can also use CreateRemoteThread to create a process running within the context of another existing process.

So what you want to do is possible, but it's really not a simple thing to do in a windows environment so you'd have to have a really good reason to want to do it.

这篇关于C ++线程以分离进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆