XNU入侵Kext [英] XNU incudes in Kext
问题描述
我正在研究Kext,它应该可以访问struct proc->p_pid
字段.问题在于结构仅在XNU源中定义,因此在编译过程中遇到了incomplete definition of type 'struct proc'
错误.
I'm working on Kext which should have access to struct proc->p_pid
field. The problem is the structure is defined in XNU sources only, so I faced incomplete definition of type 'struct proc'
error during compilation.
从我的角度来看,将XNU标头包含到我自己的项目中是一种不好的解决方案,但是替代方法是什么?是要复制结构并将其粘贴到我自己的代码中吗?
From my point of view, to include XNU headers into my own project is a bad smelling solution, but what is the alternative way? Is it to copy and to paste the structure into my own code?
推荐答案
您应该为此使用proc_pid(proc_t)
.该结构是不透明的,因为如果在内核版本之间进行更改,则您的代码可能会访问错误的偏移量.
You're supposed to use proc_pid(proc_t)
for this. The structure is meant to be opaque as, if it gets changed between kernel revisions, your code could be accessing the incorrect offset.
如果我做一些邪恶的事情,我只会包括结构的定义,否则我会去寻找一个功能接口.
I would only include the definitions for structures if I'm doing something nefarious, otherwise I'd go looking for a functional interface.
这篇关于XNU入侵Kext的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!