Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- I wrote this program one evening when I was going through iNES serial numbers
- and I got tired of using ResEdit. This works for iNES 7.7, though it doesn't
- really matter since someone cracked it. It probably won't work for later
- versions since they'll change the hobbling scheme and I have no idea if it works
- on earlier versions (besides, if you're using an earlier version when 7.7 and the serial
- is available there's something wrong.)
- */
- #define rFileNotFoundAlert 128
- #define rUiDoneAlert 129
- #define kQuitButton 1
- // Prototypes
- //______________________________________________________________
- FSSpec GetiNES(void);
- void InitializeToolbox( void );
- void URiNES(void);
- void ZapPrefs(void);
- // Main
- //______________________________________________________________
- void main(void)
- {
- short theItem;
- InitializeToolbox();
- ZapPrefs();
- URiNES();
- theItem=NoteAlert(rUiDoneAlert, nil);
- }
- // Functions
- //______________________________________________________________
- /*
- This just opens the stand open box so you can locate iNES.
- I probably could have used PBCatSearch to do it but I'm too lazy
- do dig through IM to figure out the function calls
- */
- FSSpec GetiNES(void)
- {
- SFTypeList typeList={'APPL',0,0,0}; // why look for anything other than APPLs?
- StandardFileReply theReply;
- StandardGetFile(nil,1,typeList, &theReply);
- if(theReply.sfGood==true){
- return(theReply.sfFile);
- }else{
- SysBeep(1);
- ExitToShell();
- }
- }
- //______________________________________________________________
- /*
- This assumes the prefs file is still invisible, locked, & in the prefs folder.
- If it's not, then the app quits. If it is, it unlocks the file and deletes it.
- This is a little bit of a pain since you have to retype all of your settings
- (but not as much of a pain as unpirating iNES manually. If anyone feels like
- it, they should update this so it fixes the prefs file without deleting it.
- It shouldn't be that hard (look at the a clean pref along with a pirated pref)
- */
- void ZapPrefs()
- {
- short theVolRef;
- long theDirID;
- FSSpec theFSSpec;
- OSErr theError;
- Str255 prefsFileName="\piNES.prefs";
- theError=FindFolder(kOnSystemDisk, kPreferencesFolderType,
- kDontCreateFolder, &theVolRef, &theDirID);
- theError=FSMakeFSSpec(theVolRef,theDirID,prefsFileName,&theFSSpec);
- if(theError==noErr){
- FSpRstFLock(&theFSSpec);
- FSpDelete(&theFSSpec);
- }else{
- StopAlert(rFileNotFoundAlert,nil);
- ExitToShell();
- }
- }
- //______________________________________________________________
- /*
- This removes the actual iNES resource that triggers the hobbling
- mechanism in the application. Since I found iNES sometimes
- creates a resource with id 0 and sometimes with id 1, this checks
- for both. If it doesn't find either, the app quits.
- */
- void URiNES()
- {
- short theFileRefNum;
- Handle theHandle;
- FSSpec theFSSpec;
- ResType theResourceType = 'iNES';
- short theResID0=0;
- short theResID1=1;
- theFSSpec=GetiNES();
- theFileRefNum=FSpOpenResFile( &theFSSpec,fsRdWrPerm);
- if(theFileRefNum== -1){
- StopAlert(rFileNotFoundAlert,nil);
- ExitToShell();
- }
- theHandle=GetResource(theResourceType, theResID0);
- if(theHandle==NULL){
- SysBeep(1);
- }else{
- RemoveResource(theHandle);
- DisposeHandle(theHandle);
- }
- theHandle=GetResource(theResourceType, theResID1);
- if(theHandle==NULL){
- SysBeep(1);
- ExitToShell();
- }else{
- RemoveResource(theHandle);
- DisposeHandle(theHandle);
- }
- }
- //______________________________________________________________
- void InitializeToolbox( void )
- {
- InitGraf( &qd.thePort );
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs( 0L );
- FlushEvents( everyEvent, 0 );
- InitCursor();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement