• Acolyte of the Butterfly
    Acolyte of the Butterfly
    Georg
    Posts: 110 from 2004/4/7
    Quote:

    NewSense wrote:
    I am just asking if you are willing, and consider it possible, to find a better solution to this conflict? ;-)



    Maybe hack together your own solution?

    Code:

    #include <libraries/commodities.h>
    #include <string.h>
    #include <stdio.h>

    #include <proto/exec.h>

    typedef CxObj * (*CREATECXOBJ_FUNC)(register ULONG type asm("d0"),
    register ULONG arg1 asm("a0"),
    register ULONG arg2 asm("a1"),
    register struct Library *lib asm("a6"));


    CREATECXOBJ_FUNC old_createcxobj;


    #define LVO_CreateCxObj (-6 * 5)

    CxObj * New_CreateCxObj(register ULONG type asm("d0"),
    register ULONG arg1 asm("a0"),
    register ULONG arg2 asm("a1"),
    register struct Library *lib asm("a6"))
    {
    if (type == CX_FILTER)
    {
    if (!strcasecmp((STRPTR)arg1, "f1")) arg1 = (ULONG)"alt f1";
    else if (!strcasecmp((STRPTR)arg1, "f2")) arg1 = (ULONG)"alt f2";
    else if (!strcasecmp((STRPTR)arg1, "f3")) arg1 = (ULONG)"alt f3";
    /* ... */

    }
    return old_createcxobj(type, arg1, arg2, lib);
    }


    int main(void)
    {
    struct Library * lib = OpenLibrary("commodities.library", 0);

    if (lib)
    {
    Forbid();
    old_createcxobj = (CREATECXOBJ_FUNC)SetFunction(lib, LVO_CreateCxObj, (APTR)New_CreateCxObj);
    Permit();

    printf("Patch installedn");

    for(;;)
    {
    CREATECXOBJ_FUNC act_CreateCxObj;

    Wait(SIGBREAKF_CTRL_C);

    Forbid();
    act_CreateCxObj = (CREATECXOBJ_FUNC)SetFunction(lib, LVO_CreateCxObj, (APTR)old_createcxobj);
    if (act_CreateCxObj == New_CreateCxObj)
    {
    Permit();
    break;
    }

    SetFunction(lib, LVO_CreateCxObj, (APTR)act_CreateCxObj);
    Permit();

    printf("Cannot remove patch!n");
    }

    CloseLibrary(lib);
    }
    else
    {
    printf("Cannot open commodities.library!n");
    }

    }


    I don't know if this 68k code compiled into 68k binary would work on MOS (PPC library function replaced with 68k code) unmodified.
  • »20.05.23 - 14:04
    Profile