检查运行的二进制文件是32位还是64位

时间:2022-09-01 10:02:03

It is possible to check if an app bundle's binary process is running in 32 or 64 bit mode, as answered in this question, but I can verify that it only works with GUI processes.

可以检查应用程序包的二进制进程是否在32位或64位模式下运行,如本问题所述,但我可以验证它只适用于GUI进程。

However, I need to also check processes that don't have a GUI and is not part of a bundle.

但是,我还需要检查没有GUI但不属于bundle的进程。

So, programmatically, without calling system functions or other executables, how can I test if any process is running in 32 or 64 bit mode, given the process pid?

因此,在没有调用系统函数或其他可执行文件的情况下,在给定进程pid的情况下,如何测试是否有任何进程在32位或64位模式下运行?

1 个解决方案

#1


1  

Ok, so I finally found the answer was already on SO here, for Carbon. In order to use that code now, this include is required:

好吧,所以我终于发现答案已经在这里,对于Carbon来说。为了现在使用该代码,需要包含以下内容:

#include <sys/sysctl.h>

Also, it appears that the member to the process structure has changed from

此外,似乎流程结构的成员已经改变

proc->kp_proc.p_flags 

to this:

对此:

proc->kp_proc.p_flag

#1


1  

Ok, so I finally found the answer was already on SO here, for Carbon. In order to use that code now, this include is required:

好吧,所以我终于发现答案已经在这里,对于Carbon来说。为了现在使用该代码,需要包含以下内容:

#include <sys/sysctl.h>

Also, it appears that the member to the process structure has changed from

此外,似乎流程结构的成员已经改变

proc->kp_proc.p_flags 

to this:

对此:

proc->kp_proc.p_flag