Need help for adding hook - General Discussion and Assistance - CHDK Forum  

Need help for adding hook

  • 4 Replies
  • 1818 Views
*

Offline cyril42e

  • ***
  • 111
  • SD1000/Ixus70 1.02a
    • CR-TEKnologies
Need help for adding hook
« on: 27 / June / 2008, 11:07:54 »
Advertisements
From what I have understood, hooks are used to modify the original canon firmware. So I'm trying to add a new hook, but I'm facing several problems.

Hooks seems to be called from the createHook function in platform/generic/main.c (which is itself called by a canon function). What I don't understand is how to choose which hook is called, ie the lines:
Code: [Select]
if (my_ncmp(name, "tInitFileM", 10) == 0)
Where does this "tInitFileM" string come from? I haven't found any occurrence neither in CHDK source code nor in Canon firmware... And also how to tell at which address the hook code should be written? With the labels "locFF8A0000"? Is it just overwriting the original code in RAM (it may create problems with address shifts when code is added)? How to decide which quantity of code to put in the hook (it seems there is a lot more code than needed for the modifications in exisiting hooks)?

Thanks for your help.

*

Offline ewavr

  • ****
  • 1057
  • A710IS
Re: Need help for adding hook
« Reply #1 on: 27 / June / 2008, 11:15:52 »
tInitFileM = task + InitFileModules, maximum length of resulting string is 10 (for VxWorks).
« Last Edit: 27 / June / 2008, 11:17:39 by ewavr »

*

Offline cyril42e

  • ***
  • 111
  • SD1000/Ixus70 1.02a
    • CR-TEKnologies
Re: Need help for adding hook
« Reply #2 on: 27 / June / 2008, 16:32:50 »
Thanks for the information. So it means that we can only replace code in task subroutines? There is indeed  task_MovieRecord and task_CaptSeqTask subroutines labels in the firmware, but I didn't find task_InitFileModules, only a string "InitFileModules" (btw what are strings declared with DCB instruction right before the beginning of some subroutines? function names?).

*

Offline ewavr

  • ****
  • 1057
  • A710IS
Re: Need help for adding hook
« Reply #3 on: 27 / June / 2008, 16:47:43 »
IXUS70 1.02A:
Code: (asm) [Select]
ROM:FF82433C                 LDR     R0, =aInitfilemodules   ; task name
ROM:FF824340                 MOV     R1, #0x19               ; task priority
ROM:FF824344                 MOV     R2, #0x1000             ; task stack size
ROM:FF824348                 LDR     R3, =sub_FF8242BC       ; entry point
....
ROM:FF824358                 MOV     R4, #0                  ; I don't remember what's this
ROM:FF82435C                 STR     R4, [SP]
ROM:FF824360                 BL      CreateTask

So, (sub_)FF8242BC is entry point of 'InitFileModules' task for this camera.


*

Offline cyril42e

  • ***
  • 111
  • SD1000/Ixus70 1.02a
    • CR-TEKnologies
Re: Need help for adding hook
« Reply #4 on: 28 / June / 2008, 03:54:17 »
Thank you very much! I understand better now :)

So I guess that if there is no label task_InitFileModules, it's just because scan-tasks.idc missed it. And if we want to modify some code outside a task, we have to hook all tasks that uses that code, and copy all code on the way between the tasks and the modified subroutine to call the modified subroutine instead of the original code.

 

Related Topics