[panda-users] Access to registers

Manolis Stamatogiannakis mstamat at gmail.com
Wed Apr 25 09:08:25 EDT 2018


I don't believe R_AH is directly accessible through cpu->regs. cpu->regs
contains the full length registers.
By checking the definitions in target/i386/cpu.h, cpu->regs[R_AH] will
return the value of the ESP register.

#define R_ESP 4
...
#define R_AH 4

To get the value of R_AH, you should probably use cpu->regs[R_EAX] and
extract the appropriate bits from it.

M.


2018-04-25 14:37 GMT+02:00 alessandro mantovani <alk13 at hotmail.it>:

> Hi all,
>
>
> I'm writing a plugin which needs to read values contained in registers of
> an x86 architecture. In particular I need to access to 'AH' and 'AL'
> registers from a "translate_insn" callback correcly registered. If I access
> the registers through:
>
>
> #ifdef TARGET_I386
> CPUArchState * cpu = (CPUArchState*) env;
> target_ulong reg_ah = cpu->regs[R_AH];
> target_ulong reg_al = cpu->regs[R_AL];
> ....
> #endif
>
> The problem is that if I print variables "reg_ah" and "reg_al" I always
> collect the same value for 'AH' and the same value for 'AL'. It is like if
> the plugin doesn't flush. So if the first read value is '0xabcd' for 'AH'
> all the following callbacks will print that register 'AH' contains
> '0xabcd'.
> In addition to this, it is strange (in my opinion) that if I do:
>
> printf("value of ah: " TARGET_FMT_lx "\n", cpu->regs[R_AH]);
>
> It prints a value which is bigger than an 8-bit number. Registers 'AH' and
> 'AL' have both size 8 bit , so I would expect that I can get 0xff at
> maximum. Maybe I must enable something to correctly access to registers?
>
> Thanks,
>
> elmanto
>
>
>
>
> _______________________________________________
> panda-users mailing list
> panda-users at mit.edu
> http://mailman.mit.edu/mailman/listinfo/panda-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.mit.edu/pipermail/panda-users/attachments/20180425/6c8bda8e/attachment.html


More information about the panda-users mailing list