Help in C please...

Discussion in 'Programmer's Corner' started by ¥öK'žy, Mar 28, 2008.

  1. ¥öK'žy

    Thread Starter Member

    Mar 27, 2008
    19
    0
    Hi everyone,
    I have an assignment to make a program in C which has a 5 days trial. So after 5 days since the program installed, it won't work anymore.
    *And we CAN'T crack it just by change the windows date n time.

    I thought it should use time.h but Im a little counfuse in using it...
    Can anyone help me please...

    ps: the program is just a simple program, my problem here is how to make the trial.
     
  2. Dave

    Retired Moderator

    Nov 17, 2003
    6,960
    144
    The simple answer is you do what the software license asks you to do.

    If you are given a time limited trial, and the conditions at the end of the trial are "buy it or stop using it", then that is what you should do.

    You will not get help on this site for circumventing the conditions of software licenses.

    Alternatively you should look at one of the free C-compiler packages, where such restrictions do not exist.

    Dave
     
  3. Salgat

    Active Member

    Dec 23, 2006
    215
    1
    Not to support what he's doing, but I've always been curious, do virtual machines that are reverted to an earlier save reset all time based programs(assuming you don't sync the host's clock with the virtual machine)?
     
  4. Dave

    Retired Moderator

    Nov 17, 2003
    6,960
    144
    The VM is an independent system running on its own (virtual) hardware. It is as if the OS is not running within a VM on a host OS. Therefore the time sync mechanism and behaviour will be the same as any OS. For networked Windows OSes the sync time stamp is to time.windows.com.

    There may be some trick you can do with the VM config, but I'm not aware of it, and I am not sure what effect it would/could have on the virtualised hardware and OS.

    Dave
     
  5. nanovate

    Distinguished Member

    May 7, 2007
    665
    1
    Is the OP saying he wants to crack some software or is he asking how to create a program that implements some function that only allows itself to run for 5 days?
     
  6. 0xFF

    Member

    Feb 26, 2008
    12
    0
    Sounds to me like the OP is trying to learn how to write his own protection routines. It also sounds like a homework assignment.

    I think some are just a little too eager to assume -- and we all know where that gets you.
     
  7. ¥öK'žy

    Thread Starter Member

    Mar 27, 2008
    19
    0

    Hmmm I think we have a misunderstanding here.
    I don't want to crack a program, but I want to MAKE my program have a trial license....
    Sorry if i made you confused...
     
  8. Dave

    Retired Moderator

    Nov 17, 2003
    6,960
    144
    Ahh, right you want to write a programme that has a time limited trial. Apologies for suggesting you wanted to do something such as violating license conditions.

    I'm not the best person to ask, but as far as I know time.h would work if you used the system clock as your time datum - obviously this is open to abuse as you gesture in your OP. If you could use your own timing function (not dependant on the system time) on two independent timers (one with a time at installation time and the other with a calibrated version of the current time). You can then use the difftime function in time.h which will give you a time difference which you can compare against you 5 day datum point.

    I've never done this so cannot offer further advice. Once again apologies for the accusation!

    Dave
     
  9. ¥öK'žy

    Thread Starter Member

    Mar 27, 2008
    19
    0
    That's allright, maybe I should write more clearly next time.
    Anyway thanx for the info.
     
  10. cumesoftware

    Senior Member

    Apr 27, 2007
    1,330
    10
    You can also use the system registry. Once the program detects that the time expired, it will change a specific variable in the registry so that, even if the clock is set back, the program will look at the registry first.

    The registry should contain the date when the program was installed, but also a variable containing a specific number or code. When initialized, the program will check if the code is correct. If not it will close. Then, it will compare the date in the registry with the actual date. Once the time has expired, the program will set the code to a random number (or simply to zeroes) and it will close. Next time, even if the time is set back, the program won't run.

    You can also use the variable code to set other specific number case the user purchases the full license. Thus, the program accepts two codes, one for a trial run mode, and another for the full run mode. The full run mode won't check the dates and will happily continue.

    P.S.: Make sure when the program changes the variable to a random number, it doesn't change it to one of the specific codes by mistake.
     
  11. ¥öK'žy

    Thread Starter Member

    Mar 27, 2008
    19
    0
    Found the idea several days ago. Just wanted to share it....

    Make 3 time variabel and write it to the text file.
    1.Time when installed for the first time
    2.Last time when the program launch
    3.Current time.

    Everytime the program started, get the current time and save it to the Last time.

    if installed time<current time = ERROR.
    if last time < current time= ERROR.
    if current time > installed time + 5days = ERROR

    assuming the program would last for 5 days.

    Thanx for all the information guys, I appreciate it... ^^
     
Loading...