How to load all registers into C struct?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: How to load all registers into C struct?

Post by neon »

Hi,

Just a few comments...

1. push ebx/pop ebx to save/restore ebx on the now working stack around cpuid.
2. with bochs debugger you could just do b <entrypoint>, c, regs to get the value of EBX (with x <addr> to confirm its contents.) Don't underestimate the usefulness of debuggers. You could have gotten the value of EBX in about a minute. Take your time to get comfortable with debuggers right now - don't wait.
3. i typically recommend writing to serial port since emulators and virtual machines can redirect it to a file. That way you can have debug messages and output whatever you want. No need to try to "get the value of a register" when you can just output an entire structure contents through serial and output it to a file.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
Post Reply