Introduction

Auto Update mechanism doesn't have to be based on the actual version number (kept in the Version String), but can also base on the Last Modified Date Stamp of the newer version compared to the old one. Target Eye Monitoring System, developed from 2000 until 2010, had such mechanism. The next article in this series is about Target Eye's screen capturing and the third one is about the Shopping List mechanism. Fourth article is about Keyboard Capturing. Fifth article is about the Cover Story mechanism. The sixth article is about hiding files the Target Eye way.

Background

Target Eye Monitoring System, which I have developed 12 years ago, was one of the first surveillance and monitoring tools for capturing activity of remote computers. The following description is taken from the original Business Plan of this venture:

Target Eye Monitoring System

Target Eye is a start-up company whose mission is to develop integrated software solutions for real-time monitoring of remote PCs, which are based on the company’s patent pending technologies (60/204,084 and 60/203,832). Our major product, Target Eye Monitoring System, is a software product that can continuously track, record, playback, analyze and report any activity performed on one or multiple remote PCs, in a way which is undetectable by their users. The software relies on a stream of rapidly captured, compressed full-screen images and continuous keystroke capturing to provide a comprehensive and accurate account of user activities, including local activities which do not generate any network traffic. In this way, the software can track and record activities, which are undetectable by systems relying on network traffic analysis. A smart agent module running on the monitored PCs uses a rule base to send alerts to the monitoring location(s) or perform pre-defined local operations. Monitoring can be performed from multiple locations. Major markets are law-enforcement.

Target Eye Monitoring System was developed with an auto update mechanism. This mechanism allows smooth and silent (un-attendant) execution of the new version instead of the current one.

An historical image: The first version of Target Eye (Apr 2000)

A more recent version (Target Eye 2007)

Target Eye's Building Blocks

There are several terms and building blocks that sums up to the Target Eye Monitoring System:

Target Eye Secret Agent - the covert part of the product that runs on the monitored computer

A Mission - a request to perform an action. There are many possible actions (for example, capturing the screen, as described in an other article of mine or searching and finding files, as described in this article).

Target Eye Compiler - The tool that is used by the Target Eye Operator to customize a Secret Agent for performing specific tasks.

About this article

This article focuses only in one aspect of this product, which is the Auto Update mechanism. This mechanism is used for silently update the Target Eye Secret Agent whenever there is a newer version available on the server.

Creating and Marking Incremental Versions

In order to be able to determine a newer version over the current one, there must be a mechanism to mark the various versions, to increment the version number, and to examine the version of a given executable.

The most common way of doing so is using the "Version String" resource, and to use a prebuild automated tool to promote this string each time the application is built.

I used another method which is based on the list modification date of the executable file. This method has its pros and cons, but can be useful for most cases, since it will allow your end users to get any version of your application that was built after the one that is currently installed.

Before I explain, it is important to mention 2 global variables which are used to build at start:

strRegularLocation

The location and full path of the application when it runs normally (i.e. c:\program files\your app name\your app.exe),

and…

strTemporaryLocation

Another full path to be used for the temporary version downloaded when there is an update.

The reason for doing so it because since the application downloads it's new version, the new version can't be downloaded to its current location, and can't replace itself because while a file is used (or an application is running) the file is locked and can't be moved, deleted or renamed.

char strRegularLocation[256];
char strTemporaryLocation[256];

Filling strRegularLocation and strTemporaryLocation with real values

strRegularLocation is taken simply from __argv[0], provided that we are sure that we aren't running already from the temporary location. We ensure that by using a parameter named "INSTALL" which will be explained later.

strTemporaryLocaiton is built using a common folder and a temporary name combined. We use GetSpecialFolder() to find the path name of this folder in any computer running the application.

Getting the date stamp of current version

To do so, TEGetVersion(), the first building block, is used and returns a CString containing the last modification date of a given file.

We need to define how old should be the current version in order to update it. Again, this approach can be very useful in some cases and less useful in other. For example, if your application involves a database, you might be interested to ensure that the database is always most recent and never older than 3 days.

The TE_Init() function

TE_Init() is used to determine the parameters used when application was executed (Unlike the full version of Target Eye Monitoring System, which is much more complex, in our example, there is one optional parameter – "INSTALL").

if(__argc>1)
{
if(strcmp(__argv[1],"INSTALL")==0)
{
// TE_FirstTime(); -> here you can place code you wish to//be executed only during the first run
}
}
else// No parameters
{
// Delete a temporary version if exists at the temporary location
}

Replacing old with new

In order to quit in a normal fashion, without missing anything we wish to do before quitting, the main even loop contains a check for the value of NeedToQuit, which would normally be FALSE.

BOOL NeedToQuit=FALSE;

When NeedToQuit becomes TRUE, the application will perform any routine required before quitting (for example, saving unsaved work). For example:

Further, the application expects to be executed either with the "INSTALL" parameter as part of the command line, or without it. The following scheme illustrates the flow of an installation of a newer version to a temporary location (the Desktop folder, in our example), up to the moment the temporary file used for it is deleted. This requires several stages:

The Target Eye Cycle

Stage

Ran with Parameter

Ran from location

Description

1

None

Regular

The current (old) version is running before the newer version is available

2

The newer version checks if there is a temporary copy of itself at the temporary location, but there isn't any

3

A newer version is found

4

Newer version is downloaded to a temporary location

5

Newer version runs from the temporary location with the "INSTALL" parameter.

6

Current version quits

7

INSTALL

Temporary

The newer application ran from the temporary location copies itself to the regular location, replacing the old version which quitted (5)

8

The newer version runs the copy located in the regular location and quits.

9

None

Regular

The newer version checks if there is a temporary copy of itself at the temporary location, and deletes it.

Choosing an FTP server for this demo

In order to use the source code that attached to this article, there are predefined settings of a public Secured FTP server available to the public by Chilkat Software, Inc.

Target Eye Monitoring System uses a different and a bit "brutal" approach, which will be explain in details over another article. Basically, Target Eye Monitoring System searches for other instances currently running in memory, and when found, does one of the two following options:

If the instance found is newer, the current running instance quits.

If the instance found is older, the current running instance kills it.

To explain, let's consider the following scenario. An end user had his current copy of software updated to a newer one. A day after, this end user runs the original CD of the software. The version that resides on the original CD, will search for new updates at the FTP server, which is unnecessary. Further, if the application runs constantly (like a monitoring application should), then probably when the CD version is ran, there is also another newer version already running. To address such scenario and other scenarios, we should take the necessary measures to ensure that an application will always be up to date.

Further reading

All materials contained on this article are protected by International copyright law and may not be used, reproduced, distributed, transmitted, displayed, published or broadcast without the prior written permission given by Target Eye LTD (UK). You may not alter or remove any trademark, copyright or other notice from copies of the content.

Share

About the Author

Michael Haephrati, is an entrepreneur, inventor and a musician. Haephrati worked on many ventures starting from HarmonySoft, designing Rashumon, the first Graphical Multi-lingual word processor for Amiga computer. During 1995-1996 he worked as a Contractor with Apple at Cupertino. Worked at a research institute made the fist steps developing the credit scoring field in Israel. He founded Target Scoring and developed a credit scoring system named ThiS, based on geographical statistical data, participating VISA CAL, Isracard, Bank Leumi and Bank Discount (Target Scoring, being the VP Business Development of a large Israeli institute).

During 2000, he founded Target Eye, and developed the first remote PC surveillance and monitoring system, named Target Eye.