Magic Lantern Firmware Wiki
Advertisement

Background[]

We can replace firmware functions with our own.

Replacing tasks[]

TASK_OVERRIDE( gui_main_task, my_gui_main_task );

Replacing GUI event handlers[]

Our custom handler:

int my_handler(void * dialog, int tmpl, gui_event_t event, int arg3, void* arg4, int arg5, int arg6, int code) 
{
    // handle your events here
    int ans = original_handler(dialog, tmpl, event, arg3, arg4, arg5, arg6, code);
    // ... or here
    return ans;
}

How to setup it (put this on "don't click me" for example):

// call this from gui_main_task to avoid race condition when setting our own handler
extern thunk original_handler;
struct gui_task * current = gui_task_list.current;
struct dialog * dialog = current->priv;
if ( dialog->handler == &original_handler)
    dialog->handler = my_handler;

Stubs:

// how to find the original handler in the firmware
DebugMsg(a,b,"StartMyOriginalApp");
CreateDialogBox(0, 0, 0xFF123456 /*original_handler*/, template);
NSTUB(0xff123456, original_handler)

Replacing interrupt handlers[]

register_interrupt('MREQ_ISR', 0x50, my_MREQ_ISR, 0);

Replacing functions from state objects[]

TODO

Replacing CBR (CallBack Routines)[]

TODO (straightforward)
Advertisement