How we print registers
-
I am trying to access registers using C in linux I am using Linux ver 2.4.7-10. the code is as following
#include #include #define REG mn.uc_mcontext.gregs char *reg[]={"GS", "FS", "ES", "DS","EDI", "ESI", "EBP", "ESP", "EBX", "EDX", "ECX","EAX", "TRAPNO", "ERR", "EIP", "CS", "EFL", "UES P", "SS"}; int abc(void); main() { ucontext_t mn; int i; i = abc(); getcontext(&mn); printf("INT size = %d\n", sizeof(int)); for(i=0;i<19;i++) printf("%s = 0X%X\n", reg[i], REG[REG_GS]); printf("Address of main is =%X\n", main); } int abc(void) { return 1; }
the results areGS = 0X400361E4 FS = 0X0 ES = 0X3 DS = 0XBFFFF970 EDI = 0XBFFFFAA4 ESI = 0X400168E4 EBP = 0XBFFFFA38 ESP = 0XBFFFF8B0 EBX = 0X40169154 EDX = 0XBFFFFAAC ECX = 0X0 EAX = 0X0 TRAPNO = 0X4003E514 ERR = 0X400361E4 EIP = 0X80484D5 CS = 0X3 EFL = 0X40032268 UESP = 0X1 SS = 0X8048180
how i can verify is it corret result? KOKAB WAQAS