Login
Username:

Password:

Remember me



Lost Password?

Register now!
Sections
Who's Online
56 user(s) are online (50 user(s) are browsing Forums)

Members: 0
Guests: 56

more...
Support us!
Recent OS4 Files
OS4Depot.net
Report message:*
 

Re: Is Forbid() needed for SetMethod()?

Subject: Re: Is Forbid() needed for SetMethod()?
by salass00 on 2019/4/9 12:05:59

Forbid()/Permit() would be needed if the new function acts as a wrapper for the old library function instead of replacing it entirely.

int (*oldFunc)(void);

int newFunc(void) {
    
IExec->DebugPrintF("SomeFunc() calledn");
    return 
oldFunc();
}

/* ... */

    /* Patch SomeFunc() in ISomeLib with newFunc() */
    
IExec->Forbid();
    
oldFunc IExec->DoMethod((struct Interface *)ISomeLiboffsetof(struct SomeLibIFaceSomeFunc), newFunc);
    
IExec->Permit();


Without the Forbid() in the above example newFunc() might be called before oldFunc has been set, leading to an ISI as it tries to jump to a NULL pointer.

If the function in question is supposed to be callable from interrupts then Disable()/Enable() will need to be used instead of Forbid()/Permit().
Powered by XOOPS 2.0 © 2001-2016 The XOOPS Project