/************************************************************************/ /* EasyRequest trapper - deals with requests for nonexistant volumes */ /* V1.0, by Steve Tibbett */ /************************************************************************/ #include #include #include #include #include #include #include #include #include #include #include struct Library *IntuitionBase; struct Library *AslBase; struct Remember *Remember; void MemCleanup(void) { } struct AbortedList { struct AbortedList *Next; char Name[1]; } *AbortedList; void *OrigFunc; /************************************************************************/ /* The new "EasyRequest" */ /************************************************************************/ int __saveds __interrupt __asm NewFunc(register __a0 struct Window *Win, register __a1 struct EasyStruct *EZ, register __a2 ULONG *idcmp, register __a3 ULONG *args) { int Res; int Mine=0; if (strcmp((char *)args[0], "Please insert volume")==0) { struct AbortedList *AL=AbortedList; while (AL) { if (stricmp((char *)AL->Name, (char *)args[1])==0) return(0); AL=AL->Next; }; EZ->es_GadgetFormat="Retry|Assign|Cancel Forever|Cancel"; Mine=1; }; Res=MyFunc(Win, EZ, idcmp, args); if (Mine) { switch (Res) { case 2: { BPTR AsnLock; char buff[80]; char *FullName; struct FileRequester *FR; strcpy(buff, "Assignment for '"); strcat(buff, (char *)args[1]); strcat(buff, "':"); FR=(struct FileRequester *)AslFileRequest(Win, buff, "RAM:", "", 0, &FullName); if (FR) { AsnLock=Lock(FullName, ACCESS_READ); if (AsnLock) AssignLock((char *)args[1], AsnLock); FreeVec(FullName); FreeFileRequest(FR); }; return(1); break; }; case 3: { struct AbortedList *AL=(struct AbortedList *)AllocRemember(&Remember, strlen((char *)args[1])+sizeof(struct AbortedList)+2, MEMF_CLEAR); if (AL) { strcpy(AL->Name, (char *)args[1]); AL->Next=AbortedList; AbortedList=AL; }; }; }; }; return(Res); } main() { void *OurVec; IntuitionBase=OpenLibrary("intuition.library", 36); AslBase=OpenLibrary("asl.library", 36); if (IntuitionBase==0 || AslBase==0) return(10); OrigFunc=SetFunction(IntuitionBase, -0x24c, NewFunc); if (OrigFunc==0) return(15); Wait(SIGBREAKF_CTRL_C); OurVec=SetFunction(IntuitionBase, -0x24c, OrigFunc); if (OurVec!=NewFunc) EasyRequester(NULL, "AssignX Request", "Error removing wedge!\nReboot soon!", "Okay"); FreeRemember(&Remember, TRUE); CloseLibrary(IntuitionBase); CloseLibrary(AslBase); return(0); }