EPOC Virus Tutorial

If you haven't heard of EPOC before, then I'll give you the background for it first. The EPOC OS was developed by a company called 'Symbian' and was used on Psion's handheld devices, these days Symbian have now started developing their Operating System for smartphones for example the Nokia 3650. OPL is a lanuage used on epoc for programming, and I see it as the same as the Basic lanuage on PC's.  These days, programming for Symbian's new system requires you to know C++, like Cabair was coded in.

All the code written in this tutorial, was used on a Psion Revo, using EPOC Release 5, Twiddlebit's OPL+ compiler and IDE software.

When you compile your code under OPL+, and then use on other devices we need too define the OPL application, we can do this by using the following function.


APP caption, uid&


caption is the application name, although caption is a string we do not need to enclose it in quotes.

uid& is the application's UID. In the OPL32 Manual it tells us that official reserved UIDs must be used, but this is not the case. UID's are used as a application ID in the menu. So if we say app1 has the UID of 10, and your program app2 has the same, then your program will overwrite app1 in the menu.

When you compile your application using the APP function, it automaticly places your program to the folder C:\System\Apps\YOUAPPNAME\youappname.app and as doing so will add a shortcut to the menu. Now we have abit of knowledge of OPL lets start coding.


APP Orter,666

PROC Main:
 ONERR Next::
   IF EXIST ("C:\System\Apps\test")
      dINIT "Epoc.test"
      dTEXT "","test virus",2
      dTEXT "","by retro",$202
      dBUTTONS "OK", %O | $100
      MKDIR "C:\System\Apps\test\"
      COPY "Orter.app","C:\System\Apps\test\"
      COPY Orter.app","C:\System\Temp\"


This is a sample of the application, all that this code does is copy the application to a folder, which will then show up in the menu, and display a message. I have left out the spreading function for now as I will explain this in another tutorial.

All code has to be in functions, which tells the compiler where the code start and ends, and this can be done with PROC with the name which in the example above I have named it Main and used ENDP to end it.

The command ONERR is self-explanatory, if an error happens than it goto Next::
This command helps the flow of the code and exits itself if an error appears, without displaying error message to the user.

If you compile a simple app in opl, when it is run it always displays a console. We of course don't want this and so to get pass this 'slight' problem we can the use gVISIBLE OFF. This will hide the console window and only show the message box or any other GUI window we wish to display.

You should be-able to figure the next part of the example code. It starts to look for the folder which if you define, and if its there it'll display a message, but if not the app will create a new folder and copy itself to it. As I mentioned before, to display the app in the menu, it needs to in the 'C:\System\App\YouAppName\' folder which it will do.
MKDIR creates the folder which we define and COPY will copy a file to the directory. If you look at the copy command it has two parameters. The first parameter tell it which file we want to copy and the second is where we wish to copy too. So COPY "test.app","C:\System\" will copy the file 'test.app' too the system directory.

 Message Boxes

Displaying message boxes isn't as easy as say the MessageBox command in cpp. All that the sample code below does is display a message box, and as you can see it's quite lengthy.


dINIT "Test Message "
dTEXT "","Hello World arff!",$202
dBUTTONS "OK", %O | $100


dINIT - This initializes the message box, which we give a name too "Test Message"

dTEXT - The first parameter, can be left as null its not needed, but the second line is the text in which we want displayed in the message. The third parameter is used for line info. $202 tells the compile that it's the last line we want to display. If you add the number lines to each parameter.


dINIT "Test Message "
dTEXT "","Hello",3
dTEXT "","World!",2
dTEXT "","arff!",$202
dBUTTONS "OK", %O | $100


dBUTTONS - This command adds the button which we want to display. I'm using the simple OK button but you can rename it too whatever you like. When you use buttons try and remember the following, as it can get abit hard to understand to start with.


1st Parameter

2nd Parameter







RETURN DIALOG - Basic which button is returned.

So after reading this your have a basic understanding on how to code using opl, if you search the web your find very usefully information on this language but the best I've found is the OPL guide which comes along with OPL+

by Retro
10th March 2005