检查任何正在运行的二进制文件是 32 位还是 64 位 [英] Check if any running binary is 32 or 64 bit

查看:23
本文介绍了检查任何正在运行的二进制文件是 32 位还是 64 位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以检查应用程序包的二进制进程是在 32 位还是 64 位模式下运行,如 已在此问题中回答,但我可以验证它仅适用于 GUI 进程.

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.

但是,我还需要检查没有 GUI 且不属于捆绑包的进程.

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

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

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?

推荐答案

好的,所以我终于找到答案已经在 SO 这里的方法,对于Carbon.为了现在使用该代码,需要包含:

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:

#include <sys/sysctl.h>

另外,似乎成员到进程结构已经从

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

proc->kp_proc.p_flags 

对此:

proc->kp_proc.p_flag

这篇关于检查任何正在运行的二进制文件是 32 位还是 64 位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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