BTW: I managed to solve this the other day by doing something that the
hackmaster documentation claims won't work, patching a feature manager
call.  Hopefully that doesn't mean this will break under future versions of
hackmaster, but it seems pretty clean for now:

/* Function: MyFtrUnregister()
   ---------------------------
   Patches FtrUnregister() so that I can catch my hack being uninstalled.
 */

Err MyFtrUnregister (DWord creator, UInt featureNum);
Err MyFtrUnregister (DWord creator, UInt featureNum)
{
    Err err;
    FtrUnregisterFn oldTrap = NULL;
    
    err = FtrGet (kMyHackCreatorCode, kMyHackFtrUnregisterID, 
                  (DWord*) &oldTrap);
    if (err) { goto Exit; }

    // WARNING: this relies on the fact that Hackmaster starts
    // disabling at 1000 first and that we are some patch number 
    // greater than 1000.  If the FtrUnregister() patch is the 
    // first one disabled, we will never get called...
    if (creator == kMyCreatorCode && featureNum == 1000) {
        // Uninstall my hack
    }

    err = oldTrap (creator, featureNum);

Exit:
    return err;
}

Reply via email to