64 lines
3.0 KiB
Plaintext
64 lines
3.0 KiB
Plaintext
DllTest - sample code to call dpwin32.dll in Visual Basic
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
This project is written in Visual Basic 6.0 but will the code will also
|
|
work in version 5.0 (but you will have to create your own project).
|
|
|
|
For VB.net code please look in the vb.net folder.
|
|
|
|
The source files in the project are:
|
|
|
|
File name Folder Description
|
|
Form1.frm Samples\vb main source code file for VB
|
|
dris.bas Samples\vb contains the DRIS structure & function declarations
|
|
|
|
The idea is to include the dris.bas file in your project and use/modify which ever
|
|
functions from form1.frm you feel are appropriate.
|
|
|
|
The sample code contains 13 functions. You will not need to use all these
|
|
functions in your code. Just use which ever functions are most appropriate
|
|
and customise in your own way. The sample code is just a guide. You should
|
|
implement the protection in a stronger way using the techniques described in
|
|
the "Increasing your Protection" chapter of the manual.
|
|
|
|
Code marked with !!!! are places where you should customise the sample code so
|
|
that it will work properly:
|
|
|
|
* Change the MY_SDSN value to the value of your SDSN
|
|
* Change the MY_PRODCODE value to the Product Code in the dongle
|
|
* Change the MyAlgorithm code (if you call a user algorithm)
|
|
* Change the CryptDRIS code (if you encrypt the DRIS)
|
|
* Change the CryptApiData (if you encrypt Data you send to our API)
|
|
* Change the MyRWAlgorithm code (if encrypt Data you send to our API using the R/W algorithm)
|
|
|
|
You will also probably want to replace our error messages with your own.
|
|
|
|
Note - you should protect dpwin32.dll and not your program. Because your program
|
|
is linked to the DLL it is protected.
|
|
|
|
Note - to run the project from the IDE you will need to place the protected
|
|
dpwin32.dll in the 32-bit Windows System folder*. For release you can place
|
|
dpwin32.dll in the folder of the compiled executable or in the Windows System folder.
|
|
The former is generally considered better as it is easier to install.
|
|
|
|
It is also recommended that you rename dpwin32.dll to a name of your choice. In
|
|
this case you will need to modify the dll name in the dris.bas file.
|
|
|
|
Special Note for using Algorithms in Visual Basic
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
The algorithms are calculated on 32-bit integers (Long in VB). It is quite possible for
|
|
the MyAlgorithm and MyRWAlgorithm functions to overflow if the values provided are too big.
|
|
In the dongle the algorithms can never overflow - if the answer is too big then the high part
|
|
of the answer is ignored. In practical terms:
|
|
|
|
When you are using the r/w algorithm it is best not to pass random 32-bit integers. It is
|
|
better to restrict the variables to 24-bit to avoid the possibility of overflows.
|
|
|
|
When using a user algorithm it will behave exactly as the corresponding MyAlgorithm function
|
|
will in VB except it will not give overflow errors.
|
|
|
|
~~~~~~~~~~~~~~~~~
|
|
* Windows System folder for 32-bit dlls is:
|
|
c:\windows\system32 32-bit Windows
|
|
c:\windows\sysWOW64 64-bit Windows |