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?
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.