Perhaps one of the best ways to circumvent the ease with which a hacker can BREAK into your programs, is the use of the so-called “turbo” or “hyper” loader. Turbo loaders are machine code routines which change the way in which your computer reads tapes. Most are simply modified versions of the LOAD routine from ROM(or EXROM) with the speed parameters changed. If you have some of the newer Spectrum software, you may already have seen a turbo-loading program.
Turbo-load programs begin with a short BASIC loader, as usual. However, the difference between this mode and normal LOADing then becomes immediately apparent. Instead of the normal loading of a SCREEN$ file, either a short bytes file containing the turbo load routine or, if that routine has been hidden in the BASIC variables, the first section of the program will load. You will probably note that the border patterns associated with this load are different than the normal one. If for example, the normal Sinclair routine was simply speeded up, the yellow and blue stripes appear narrower. If one were to listen to the sound of the tape, (s)he would hear a higher pitched tone sequence than normal. Again, this is due to the higher baud rate being used.
While we normally try to give simple concrete examples of how to implement the protection schemes we’re discussing, re-writting the tape routines is a subject which almost requires a book in itself, if it is to be done right. Further, I haven’t actually done it myself yet and don’t much approve of the practice, for reasons discussed below. For those wishing to pursue the subject further though, the following guidance should prove useful;
1. The tape handling routines can be found in the Spectrum between 04C2(hex) and about 09F0(h). The main entry is at 0605.
2. Speeding up the LOADing and SAVEing process involves reducing the time delays in the ‘SA-BYTES’ and ‘LD-BYTES’ routines. These are established by setting values in the BC register pair in 8 different locations. Some of these are:
Location Normal 2X speed
0519 42 or 43 1B )
051F 3E 16 ) SAVE
052C 31 09 )
etc B0 E1
" B2 E3 )
05CF CB EC ) LOAD
B0 E1 )
etc. (See Logan and O’Hara,”Complete Spectrum ROM Disassembly“)
3. You must relocate the ROM routines to an area in RAM. All absolute adresses in the routines must be replaced with new values, which reflect the offset from their original location. Remember, on the TS2068, the routines are in EXROM. It will probably prove simpler to just use a modified version of the Spectrum routines in either case.
4. Only save the LOAD part of your new tape handling routines with your program. This might make it a little tougher for hackers to use. The really sophisticated ones, of course, will already have produced simple “compare bytes” programs, which will look for three or four key bytes of the Sinclair Load routines, and you would then have to actually write your own tape subroutines to be more secure. The “compare bytes” logic is so simple, unfortuneately, that it can be written in BASIC. The hacker need only select three bytes of the original code, e.g. the three bytes which normally come before 052C, and search your BASIC loader for them, in order to find a reference point in your hyper loader.
To find, for example, the series of bytes for the code:
Mnemonics which is Hex or Decimal Ld b,1 06,01 6,1 dec de 1B 27 ret C9 201
A simple BASIC program would be:
10 Clear 31999: LOAD "" CODE 32000,32000
20 FOR i=32000 to 64000
30 IF PEEK i=6 and PEEK i+1=1 and PEEK i+2=27 and PEEK i+3=201 THEN PRINT "Try the code at ";i
40 NEXT i
5. The easiest way to generate a “turbo” is to use the machine code program which appears in the May 1984 issue of Your Computer Magazine on page 119. Paul Rhodes article, entitled “Qiuckload”, tells you how to achieve speed increases of up to 2.5 times normal, as well as how to slow down a save for even greater reliability. Some of his material is included here. His program is some 1872 bytes of POKEd-in MC.
6. Consider removing the checks for BREAK key pressed, which are in the Timex code. Better yet, add a routine of your own which causes a spectacular crash, if the break key is pressed.
If you have successfully implemented your own hyperloader, only the really dedicated hacker, with access to a disassembler, will be able to “crack” your code. As a bonus, the higher frequencies involved, make it more difficult to copy your program tape-to-tape, so even hardware copies may not work.
That’s not all that may not work, however. It is entirely possible that your new “hyper” tapes may not load, at all, on many users machines. Not only will this frustrate, and possibly discourage customers, but there is a significant potential for excessive service calls and complaints. Either situation is potentially fatal, particularly in the current TS market. Of course, as mentioned in our review of Interface Three, last month, there is no defence against a purely hardware oriented “breaker”.
In our next installment, we’ll take a look at “headerless files”, another way to confuse the unwary.
© COPYRIGHT 1986 P. DONNELLY