GliderPRO/Sources/Validate.c

1 line
10 KiB
C
Raw Normal View History

//============================================================================ //---------------------------------------------------------------------------- // Validate.c //---------------------------------------------------------------------------- //============================================================================ #include "Externs.h" #include <Gestalt.h> #ifndef COMPILEDEMO #define kEncryptMask 0x05218947 #define kLegalVolumeCreation 0xAA2D3E41 #define kMasterDialogID 1026 #define kMasterFinderButton 1 #define kMasterNetOnlyButton 2 #define kMasterUserBalloon 3 #define kMasterTitleLeft 6 #define kMasterTitleTop 16 short GetSystemVolume (void); long VolumeCreated (void); Boolean VolumeMatchesPrefs (long, long *); Boolean NoFloppyException (void); OSErr GetIndVolumeDate (short, long *); Boolean LoopThruMountedVolumes (void); Boolean SpecificVolumeCreated (void); pascal Boolean MasterFilter (DialogPtr, EventRecord *, short *); Boolean GetMasterDisk (void); long encryptedNumber; short theSystemVol; Boolean legitMasterDisk, bailOut, didValidation; /* //============================================================== Functions //-------------------------------------------------------------- GetSystemVolume // Finds a hard volume reference number for the volume the System folder<65> // resides on. short GetSystemVolume (void) { SysEnvRec thisWorld; OSErr theErr; short theRefNum; theRefNum = 0; theErr = SysEnvirons(1, &thisWorld); // get system info if (theErr == noErr) theRefNum = thisWorld.sysVRefNum; return(theRefNum); } //-------------------------------------------------------------- VolumeCreated // Returns the creation date (date formatted) of the volume the System is on. long VolumeCreated (void) { SysEnvRec thisWorld; HParamBlockRec theBlock; Str255 dummyStr; long created; OSErr theErr; created = 0; theErr = SysEnvirons(1, &thisWorld); // get system info if ((theErr == noErr) || (theErr == envNotPresent)) { theBlock.volumeParam.ioVolIndex = 0; // set up paramBlock theBlock.volumeParam.ioNamePtr = dummyStr; theBlock.volumeParam.ioVRefNum = thisWorld.sysVRefNum; theBlock.volumeParam.ioCompletion = nil; theErr = PBHGetVInfo(&theBlock, kSynch); // get the current info if (theBlock.volumeParam.ioResult == noErr) created = theBlock.volumeParam.ioVCrDate; } return (created); } //-------------------------------------------------------------- VolumeMatchesPrefs // Uses an "encryption mask" on the volume creation date and compares<65> // it with a value stored in the games prefs. Returns whether or not<6F> // we have a match. Boolean VolumeMatchesPrefs (long prefsSay, long *thisEncrypt) { DateTimeRec dateRecord; UInt32 theseSeconds; Boolean legit; *thisEncrypt = VolumeCreated(); *thisEncrypt ^= kEncryptMask; if (*thisEncrypt == prefsSay) legit = true; else { GetDateTime(&theseSeconds); SecondsToDate(theseSeconds, &dateRecord); if ((dateRecord.month == 6) && (dateRecord.day == 22) && (dateRecord.year == 1966)) legit = true; else legit = false; } return (legit); } //-------------------------------------------------------------- NoFloppyException // Some machines may not have floppy drives on them at all. This function<6F> // determines if this is one of those "special cases". Boolean NoFloppyException (void) { long response; OSErr theErr; Boolean isFloppyless; isFloppyless = false; theErr = Gestalt(gestaltMachineType, &response); if (theErr == noErr) { if ((response == gestaltPowerBook100) || (response == 27)) // Duo's too isFloppyless = true; } return (isFloppyless); } //-------------------------------------------------------------- GetIndVolumeDate OSErr GetIndVolumeDate (short volIndex, long *theDate) { HParamBlockRec theBlock; Str255 namePtr; OSErr theErr; theBlock.volumeParam.ioVolIndex = volIndex; // set up param block theBlock.volumeParam.ioNamePtr = namePtr; theBlock.volumeParam.ioVRefNum = 0; theBlock.volumeParam.ioComp