简体   繁体   English

XNU入侵Kext

[英]XNU incudes in Kext

I'm working on Kext which should have access to struct proc->p_pid field. 我正在研究Kext,它应该可以访问struct proc->p_pid字段。 The problem is the structure is defined in XNU sources only, so I faced incomplete definition of type 'struct proc' error during compilation. 问题在于结构仅在XNU源中定义,因此在编译过程中我遇到incomplete definition of type 'struct proc'错误的incomplete definition of type 'struct proc'

From my point of view, to include XNU headers into my own project is a bad smelling solution, but what is the alternative way? 从我的角度来看,将XNU标头包含到我自己的项目中是一种不好的解决方案,但是替代方法是什么? Is it to copy and to paste the structure into my own code? 是否可以将结构复制并粘贴到我自己的代码中?

You're supposed to use proc_pid(proc_t) for this. 您应该为此使用proc_pid(proc_t) 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. 如果我做恶行,我只会包括结构的定义,否则我会去寻找功能接口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM