In the process of implementing a "jump" log to GensKmod (not me, Kaneda), I wanted to know if there is a fixed ram area where appear the "current" function number.
I mean, each time the user jump to the bios, does the bios write the function number (d0) somewhere?
I vaguely remember the function number is written somewhere but i cannot recall where I read that.
If someone recall don't hesitate
Pfew... My english is more and more bad... I wonder what's happen.
Sorry.
all of this because Starcream allows hook on read/write memory but not program section
so I tried to mod i_jsr but Starscream is really hard to understand
I tried to add a call to my function but everything explode since x86 registers are lost with this call...
and I discovered sub68k_context.pc != sub68k_readPC( ), which I don't understand!
sub68k_context.pc contains "Fetch Region pointer + PC value" then you can directly do :
mov eax, [sub68k_context.pc]
to fetch/read the current intruction. This is done for speed reason of course. If you want the real PC value, use ReadPC or unbase pc : sub68k_context.pc - sub68k_context.basePC
I'm not sur about the sub68k_context.basePC variable name since i'm doing it from head :p
32X SH2 cores uses the same type of based PC.
Well, i just had a look in starscream source, here's register value at "alive" (in execution) time :
- esi = based pc
- ebp = fetch base
If you want only the pc value you have to do that :
mov eax, esi ; get based pc
sub eax, ebx ; unbase it --> eax = pc value
so it means my PC value is wrong for a long time (on main 68k part)
thanks for the hint, and now understand better some stuff on Starscream (like the code below)
mov ecx,esi
sub ecx,ebp
mov esi,edx
call _SpyCDBiosCall
it's the code of the jsr + my call
this code is executed the first time but freeze Gens after that..
I suspect the call to the C function SpyCDBiosCall to mod the x86 register
can you confirm this and if yes, how can i backup reg/call/restore reg?
(movem ? push ?)
KanedaFr wrote:so it means my PC value is wrong for a long time (on main 68k part)
thanks for the hint, and now understand better some stuff on Starscream (like the code below)
mov ecx,esi
sub ecx,ebp
mov esi,edx
call _SpyCDBiosCall
it's the code of the jsr + my call
this code is executed the first time but freeze Gens after that..
I suspect the call to the C function SpyCDBiosCall to mod the x86 register
can you confirm this and if yes, how can i backup reg/call/restore reg?
(movem ? push ?)
Seems your _SpyCDBiosCall is using fastcall convention (ecx and edx as parameters).
I do understand you're putting PC in ecx, but what the "mov esi, edx" is supposed to do ? by doing that, you're just erasing the current pc...
Also when you do a function call, you lost your eax, ecx, edx registers values so push them if needed
Expect the registers %eax, %ecx, and %edx, as well as the floating-point stack, to have changed. Standard library functions may modify the %gs register, and the _far* functions may modify %fs. Other registers will be preserved.