XNU incudes in Kext

限于喜欢 提交于 2019-12-11 03:58:17

问题


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.

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?


回答1:


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.



来源:https://stackoverflow.com/questions/17512950/xnu-incudes-in-kext

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!