1 Reply Latest reply on Jun 27, 2009 8:54 PM by Chunick

    How to create a demo with time limit?  (timebomb)




      I would like to create a demo of a game I made but want to limit the amount of time it will run once installed.  (30 days).


      Is there an xtra or a straightforward way to do this in lingo?

        • 1. Re: How to create a demo with time limit?  (timebomb)
          Chunick Level 3

          there is no straightforward way to do it in any programming language. I'm currently developing a Director-specific trial version solution, but it's not ready yet for general/commercial use. Are you looking for a free solution or are you willing to pay?


          Trial Versions are used so users can try out your software and then buy it if the software is something they want. So, there are two parts to trial software;

          1. the code that handles the trial version

          2. the code that handles the product serial and registration/licence keys

          The code that handles the trial version needs to be able to do these things:

          1. Keep track of the trial period. This involves recording the first run date/time and incrementing that date/time when the software is launched each subsequent time and comparing that against the trial period.

          2. Protect against backdating - turning back the computer clock to get more trial time.

          3. Protect against uninstall/reinstall.

          Dealing with all three of these issues becomes complicated; let's look at a solution using a licence file. What about a licence file will solve all the issues listed above?

          1. The licence file will contain the First Run Date (FRD), the Last Run Date (LRD), and other specific user and product info.

          2. A licence file should be encrypted to ensure it cannot be tampered with.

          3. A licence file should be moved to the user's AppData (or equivalent) folder by the installer software (such as NSIS). This ensures the first run date is only ever recorded once... what do I mean by this? If your app had to check first before opening and writing to the license file, then someone could easily circumvent the trial version by deleting the file at which point your application would be forced to move/write the licence file again and the user would be able to start the trial over again. Well, the installer only ever runs once. So, if it copies over the licence file during the installation process then our application, when it runs the first time, only has to check if the file is there; if not then the trial has been tampered with, if it's there then read the FRD, and if blank then we can be sure it's writing the FRD for the first and only time.

          4. The file could be hidden to ensure that an un/reinstallation of your software wouldn't circumvent your trial security. Another method is to write to the registry some entry that's obscure or looks like some other info for your software... this is what's called security by obscurity which is frowned upon in the industry, in general, but there's really no way around it in the case of trial software methods.

          5. A licence file can be used as a red-herring if you want to use an obscure/hidden registry entry to save the real trial version information. If that's the case, you should follow the same steps as above and have your installer write the initial registry entries so it cannot be as easily circumvented by your code checks.


          Encryption is a big part of trial version security. If you're using MX2004 or above then you can find javascript ports of some strong encryption algorithms such as AES or RSA. RSA is an asymmetrical (ie public/private key) encryption algorithm whereas AES is a symmetrical (ie. private key) algorithm. The important things to look for in an implementation are ones that will encrypt a variable length string. These implementations use modes to encrypt fixed length chunks of the string, thus making the core encryption algorithm useful in practical situations such as encrypting variable length strings.


          Creating a trial/registration .dir file (trial window) that gets published with the main application .dir file:


          Below, I've outlined these steps so you can see what I mean. I've tested this process and it's solid, AFAIK. Here are the steps:

          1. Create a project and name it movie1. Add a framescript with the 'go the frame' code on it.
          2. Add a label named 'continue' on the frame just after the 'go the frame' framescript.
          3. Add a button, and this code:
          go to frame "continue"
          4. Now, go into the Publish Settings options and go to the 'Files' tab and add any of your other .dir files you want under the 'Additional Files:' heading (the option to Play every movie in list will be checkmarked by default. Leave it like that).
          5. Now, Publish your project and you will have ONE .exe called movie1.exe which contains two .dir files that have been published.
          6. Open your User Temp folder and observe the folder that's created when you run movie1.exe... no temp .dir file is created when you run movie1.exe
          7. Creating another .dir with this code:
          go to frame "continue" of movie("movie1")
          ...does not work as it's looking for a .dir or .dxr or .dcr and will not work with an .exe.


          What this means is you can create a single executable that runs the trial window with all your trial version code and if everything checks out in the licence file then you can go to the main application movie. The trial window can be used to display the trial information, including a registration section, if you like. Google examples of trial version software to get ideas of what should be included in a trial version display.




          AES encryption written in Javascript: http://www.movable-type.co.uk/scripts/aes.html

          DOUG Article I wrote on creating product keys: http://director-online.com/forums/read.php?2,22279,22303#msg-22303

          Block Cipher Modes: http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Counter_.28CTR.29

          AES - Wikipedia: http://en.wikipedia.org/wiki/Advanced_Encryption_Standard

          RSA - http://en.wikipedia.org/wiki/RSA


          Pseudocode for recording and comparing dates

          FRD = First Run Date
          LRD = Last Run Date -- this one would get updated every time the app was run.

          CRD = the systemDate
          NumDays = 30 -- the number of days for trial version

          dateGood = False

          If LRD > CRD Then
          -- the system clock was rolled back
          dateGood = False
          Else If (the systemDate) > (NumDays + FRD) Then
          -- trial version has expired
          dateGood = False
          Else If CRD > LRD Then
          -- everything is ok, so write a new LRD date in registry or wherever else
          dateGood = True
          Else If CRD = (_movie.systemDate) Then
          -- the dates are both good
          dateGood = True
          dateGood = False
          End If

          Typical Place to Write Application data to the Registry:
          eg. HKCU\Software\TRiShield\1.0\