===============================================================================
=================   Matrix software protection system   =======================
=================                for                    =======================
=================  Microsoft EXCEL 32 bit Applications  =======================
===============================================================================
=================    Copyright (c) TDi GmbH - Germany   =======================
===============================================================================

This file contains instructions for implementing the Matrix security system
into a 32 bit Excel spreadsheet.


Concept:  The scheme used to protect your application is broken into three basic
          parts, as follows:

        o Create a block of code that is inaccessible to the end user that 
          checks for the presence of the security device.

        o If the security device is found then make accessible other functions
          within this secure block of code that are required for your
          application to work.

        o Force the call to the secure block of code upon loading of your
          spreadsheet, and protect this call from being altered or removed.
          Periodically check for the continued presence of the security 
          device to prevent someone from running more than one copy of your
          program with a single device.

-------------------------------------------------------------------------------

Example:

       1. Make a copy of your spreadsheet requiring protection. Always keep a
          copy of the unprotected spreadsheet just in case you accidentally put
          so much protection into the sheet that you are unable to unprotect it
          (e.g. forgetting passwords, creating an infinite loop that auto
          executes and can't be bypassed, etc.).

       2. Open Excel and load your spreadsheet

       3. Switch to the Visual BASIC Editor
          TOOLS -- MACRO -- Visual BASIC Editor (HotKey = ALT-F11)

       4. Use the existing sample module MATRIX.BAS
          INSERT -- MODULE

       5. IF you are using a demonstration device then no code changes are 
          required at this time. However, when you acquire your company 
          unique devices you will have to modify the UserCode.

       6. Create one or more macro functions to perform tasks required by
          your application, similar to the sample one illustrated above. If 
          you already have Visual-Basic code used by your spreadsheet then you
          can make appropriate modifications to the current code, without 
          having to create new functions, etc. Remember to add logic to the
          functions so that they will only work properly if the MATRIX device
          is found. This requires that a call be made to Check_Matrix, either
          within the function you create or in the Auto_Open subroutine.

       7. You can use the demo files located in \MATRIX\SAMPLES\VB.
          Remove not needed functions if you are using the demo files.

          7.1 There are many functions related to the reading and writing of
              the memory in the security device. If you aren't using some of
              these functions they can be deleted from the module in order
              to make it smaller, and thus load faster.

       8. Modify the message "Matrix device not found !" in the Check_Matrix 
          subroutine to suit your needs

       9. A frequent course of action is to kill Excel which can be done by 
          placing the following command in the code:
            Application.DisplayAlerts = FALSE
            Application.Quit

      10. Implement the code to automatically call the security code to check
          for the security device each time your spreadsheet is loaded.

          10.1 Create an 'Auto_Open' subroutine and add code similar to the 
               following:

               Sub Auto_Open
                   Dim ret As Integer

                   '--- Do this for all, but one named sheet in your   
                   '--- workbook must be visible. It is important to keep 
                   '--- in mind that at least one worksheet must be visible 
                   '--- at all times or else Excel will display an error 
                   '--- while attempting to execute a statement that hides 
                   '--- the last remaining visible spreadsheet.
                   Worksheets("SheetName2").Visible = xlSheetVisible
                   Worksheets("SheetName1").Visible = xlSheetVeryHidden

                   '--- Decide on desired action if missing some part of security
                   On Error Goto End_Exit_Err   'Force exit if MATRIX32.DLL not found

                   '*** IMPORTANT STEP ***
                   '--- Add tasks here to force device checking. You may wish to
                   '--- make value assignments to cells referenced in formulas as
                   '--- was done in the demonstration program above.

                   ret = Check_Matrix         'Check if Matrix dongle is present
                   If ret = 1 Then            'If we got here then it's ok to 
                      GoTo Ok_Run             'continue running the spreadsheet
                   Else
                      GoTo End_Exit
                   End If

               End_Exit_Err:
                   MsgBox "MATRIX32.DLL not found !"
               End_Exit:
                   '--- Optional - take whatever action you wish ---
                   Application.DisplayAlerts = FALSE
                   Application.Quit      'This forces Excel to quit

               Ok_Run:                   'Return from Auto_Open to 
                                         'fully operational spreadsheet

                   '--- Optional - use this is the xlVeryHidden code was 
                   '--- used above. Do this for every named sheet in your 
                   '--- workbook. This forces the sheets to be visible.
                   Worksheets("SheetName1").Visible = True 
                   Worksheets("SheetName2").Visible = xlSheetVeryHidden

               End Sub

      11. Return back to Excel from the Visual BASIC Editor.
          FILE -- CLOSE AND RETURN TO MICROSOFT EXCEL (HotKey = Alt-Q).

      12. If you have created new functions, then edit the spreadsheet cells
          to call these new functions. If your checks have been added to 
          existing Visual BASIC code, then perhaps there will be no changes to
          the spreadsheets required.

      13. Save and test your application to confirm that it is behaving the
          way you wish, both with and without the MATRIX device attached.  
          Don't continue with this procedure until you are satisfied at this
          point.  
          FILE -- SAVE

      14. You may wish to convert the security module to an 'AddIn' in order
          to maximize protection of your code. Compiling the code into an 
          Add-In changes it into a form that would be far more difficult to 
          reverse engineer than retaining it in 'raw' form as part of the
          spreadsheet.

      15. Secure the cells in your spreadsheet. Two types of protection are
          available.  All cells in 'protected' spreadsheets are 'Locked' by 
          default, which means they cannot be altered by the end user.  
          Therefore, it is important that you remove the 'Locked' attribute 
          from all cells that are susceptible to end user modification in order
          to make use of the spreadsheet. All cells in protected spreadsheets
          are 'Visible' by default. This means that the user is capable of
          viewing the underlying equations associated with each cell. Far
          greater security can be achieved by removing the end user's ability
          to view the equations. This is done by changing the cell attributes
          to 'Hidden'.

          Select cells requiring protection attribute change.
          FORMAT -- CELLS -- PROTECTION
          Select desired attributes -- OK to change attributes. Please note
          that the new attributes do NOT take effect until such time as the
          spreadsheet protection is added.

          15.1 TOOLS -- PROTECTION -- PROTECT SHEET
               Enter a Password - Make sure you record it in a safe place

      16. Hide the Visual BASIC macro code in such a way that it can't be
          easily unhidden.

      17. Switch to the Visual BASIC Editor
          TOOLS -- MACRO -- Visual BASIC Editor (HotKey = ALT-F11)

      18. Set the properties to hide the Visual BASIC macro code:
          TOOLS - VBA PROJECT PROPERTIES - PROTECTION 
          Check the LOCK PROJECT FOR VIEWING BOX
          Enter a PASSWORD and CONFIRMATION PASSWORD -- OK
          Remember to record your password and save it in a safe place.

      19. Save

      20. Another optional security feature offered by Excel is the 
          'File -- Save As -- Read Only option'. Evaluate to determine the
          appropriateness of this feature for your application.         

      21. The presentation of your protected workbook can be made to resemble
          a new unpopulated workbook when the device or MATRIX32.DLL file is 
          not found through use of the Worksheet. Visible attributes of 'True'
          of xlVeryHidden. It is important to keep in mind that at least one
          worksheet must be visible at all times or else Excel will display
          an error while attempting to execute a statement that hides the last
          remaining visible spreadsheet.

-------------------------------------------------------------------------------
*END*
