Machine/reg.h missing

Trying to programme a process api wrapper library and was referencing How Debuggers Work: Getting and Setting x86 Registers, Part 1 | Moritz Systems to understand how to copy the register state but the compiler complains of a missing <machine/reg.h> file, anyone know how to fix that?

Hi @zxuiji,

While I have absolutely zero (0) knowledge of this, whatever this refers to, a quick Google search has lead me to this page, which states:

Try including sys/user.h and sys/reg.h ORIG_EAX is defined in reg.h

An so, after searching on my PC, I could see it’s there:

$ locate reg.h

So, according to my (very) limited knowledge, it looks like you have to include /usr/include/sys/reg.h somewhere in your project.

Of course, that’s just according to me, and yours might bee different.

Hope this helps!

Already tried that but it didn’t have the necessary structs defined, namely:

struct reg;
struct fpreg;
struct dbreg;

and the ptrace() docs specifically state machine/reg.h as the expected header for those structures

Yeah, dude. As I mentioned in my reply, I have absolutely zero (0) knowledge of this.

So you could have told me to buzz of in greek for all the sense that made. :wink:

Maybe it helps someone else to help, but that someone is definitely not me.

I appreciate you tried anyways, was more hoping someone who did know what package I would need to install to resolve this would pop in and reply

And it’s still (relatively) early and anything can happen, so let’s hope someone brighter than me ops in to help.

You did realize the referenced article and examples therein are using *bsd (netbsd, freebsd for example) and your Manjaro machine is linux (and therefore not a *bsd)?

I figured being ptrace() they would just use the same library though? Currently seeing what I can do with the sys/reg.h header (not having any luck getting the registers from self - getpid() to be clear - just yet)