winapi - 以编程方式获取另一个进程的环境变量?

标签 winapi linux-kernel

我想从进程B获取进程A的环境变量? 与A、B没有任何关系。 不是系统环境变量,而是已经传递给进程的环境变量!

在 Linux 或 Windows 中

最佳答案

在 Linux 中,您可以通过读取(或映射)/proc/[pid]/environ 来完成此操作。来自 proc(5 ):

/proc/[pid]/environ

This file contains the environment for the process. The entries are separated by null bytes ('\0'), and there may be a null byte at the end. Thus, to print out the environment of process 1, you would do:

      $ (cat /proc/1/environ; echo) | tr '\000' '\n'

关于winapi - 以编程方式获取另一个进程的环境变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11627682/

相关文章:

windows - 在 Windows 中枚举线程

linux-kernel - 内核崩溃 - 不同步 : Requested init/linuxrc failed (error -2)

c - 如何在linux中打印进程的pgd和stack_start值?

c - 无法在 5.8 内核上包含 `linux/config.h`

linux - 如何将 Linux 内核交叉编译为 MIPS 小端主机?

c++ - 如何在 VB.net 中使用 Windows 电源管理 API

c++ - 如何使用 CryptoApi 导入 PKCS#8

c++ - 如何检查已安装的字体样式?

delphi - 在将数据保存到磁盘方面,FlushFileBuffers 与 CloseHandle 然后 CreateFile 一样好吗?

linux - 安全卸载内核模块