on 28/01/02 8:19, George Williams at [EMAIL PROTECTED] wrote:

> Lets says I've located the entry point of a desired function call in a
> PalmOS code resource in a PalmOS application.  For example, I know the exact
> memory address of the function and I know that I can use it as a function
> pointer in my code.  Unfortunately, I don't know the type and number of
> parameters this function takes or what type of value it returns.  This is
> the information I seek.

Use the PalmDebugger, this is the best way to get a disassembly of running
code, unless your function is in a library that you link with CodeWarrior,
in which case you can just disassemble the library with CodeWarrior.

With PalmDebugger, the best way is to get the address of the function from
withing your code then immediately break into the debugger and do:

il 0x45345435

(replace the value above with the "real" address of the function.

Disassembling the function will show code that probably takes parameters
from the stack. If the code uses A6 stack frames, functions begin with a
link a6,#-xxx instructions which reserves space on the stack for local
variables. So if the function does:

    links a6,#-10

it reserves 10 bytes for the local variables. After that, the first
parameter can be accessed at 8(a6), the second parameter at 10(a6) or 12(a6)
depending on the size of the first parameter, etc.

If the code does not use A6 stack frames (i.e. there is no link a6,#-xxx at
beginning of the function), the code uses A7 to access parameters.
Typically, you will see things like:

    movem.l d3-d7/a2-a3/a6,-(a7)
    lea     -30(a7),a7

These instructions save the contents of the register to the stack and
reserve 30 bytes for local variables. This is a total of (30+8*4)=62 bytes
for registers and local variables. This means that 62(a7) is the return
address and parameters begin at 66(a7).

Hope this helps,
Florent.

-- 
Florent Pillet, Code Segment       [EMAIL PROTECTED]
PGP Key: D13C 6DD7 D0E2 7891 4AF9 0111 9514 4753 02F1 4D6D

PowerGlot, the premier localization tool for Mac OS software
   -> PowerGlot Software           http://www.powerglot.com/
Sync Buddy for Mac & PalmOS. FindHack, SymbolHack for PalmOS
   -> ...and other tools... http://perso.wanadoo.fr/fpillet/
BrainForest, outlines & action items for Palm, Mac & Windows
   ->                                http://www.aportis.com/


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to