在 Windows 上通过 CreateProcessW() 启动新进程的 UNICODE 环境块是什么样子的?
本质上,我想创建一个新进程并从父进程为其定义环境。我想使用 CreateProcessW
并将(修改后的)UNICODE 环境传递到 lpEnvironment
中,但我不确定与 ANSII 环境块相比内容应该是什么样子。
我真正找到的唯一文档是在 MSDN 上:
请注意,ANSI 环境块是 以两个零字节终止:一个用于 最后一个字符串,还有一个要终止 块。 Unicode 环境块 以四个零字节终止:两个 对于最后一个字符串,还有两个 终止块。
现在我尝试
- 调用
GetEnvironmentStrings
并将其传递给子进程 - 调用
GetEnvironmentStringsW
并将其传递给子进程 - 使用我的附加环境字符串修改这些块并将其传递给
非其中的工作
我真的只能将 lpEnvironment 设置为 NULL 才能使其工作,但现在我必须更改 &恢复我父母的处理环境 - 这是要走的路吗?
(我也设置了CREATE_UNICODE_ENVIRONMENT
)
谁能告诉我UNICODE
环境块有什么特别之处 - 当我只使用ASCII 填充并调用
CreateProcessA()
...
Essentially, I would like to create a new process and define the environment for it from the parent process. I would like to use CreateProcessW
and pass a (modified) UNICODE environment into lpEnvironment
, but I'm not sure what the content should look like compared to an ANSII environment block.
The only documentation I really found is on MSDN:
Note that an ANSI environment block is
terminated by two zero bytes: one for
the last string, one more to terminate
the block. A Unicode environment block
is terminated by four zero bytes: two
for the last string, two more to
terminate the block.
Now I tried to
- call
GetEnvironmentStrings
and pass it on to the child process - call
GetEnvironmentStringsW
and pass it to the child process - modify these blocks with my additional environment strings and pass it on
non of them work
I really only could set lpEnvironment
to NULL
to get it to work, but now I would have to change & revert my parents processing environment - is that the way to go here?
(I also did set CREATE_UNICODE_ENVIRONMENT
)
Could anyone please tell me what is so special about UNICODE
environment blocks - it did work, when I just use ASCII
stuff and call CreateProcessA()
...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果没有代码,我不知道你做错了什么。但这是有效的:
也许这会让你知道自己做错了什么。
I have no idea what you are doing wrong without code. But this works:
Perhaps that will give you an idea of what you are doing wrong.