72 lines
3.8 KiB
Plaintext
72 lines
3.8 KiB
Plaintext
Sample code to call Runtime Modules in C++ Builder XE3 (or more recent)
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
This project is written in C++ Builder XE3 but will work in more recent
|
|
versions (they will upgrade the Project to the latest version). For earlier versions
|
|
you should use the C++ Builder sample.
|
|
|
|
The source files in the project are:
|
|
|
|
File name Folder Description
|
|
apitest.c Samples\c main source code file for C
|
|
dris.h Samples\c contains the DRIS structure
|
|
dlltest_imports.c Samples\c\C++Builder\Runtime contains code to link the correct import library
|
|
dpwin32_borland.lib Samples\c\import_libs contains the function definitions for dpwin32.dll
|
|
dpwin64_borland.a Samples\c\import_libs contains the function definitions for dpwin64.dll
|
|
|
|
Note that the source paths are structured to minimise files. If you want to
|
|
move this project the references to these files will probably be no longer valid.
|
|
|
|
The DllTest project uses the dynamic runtime library (e.g. dpwin32.dll or dpwin64.dll).
|
|
|
|
NB There is no ObjTest project because currently there is no 64-bit static module for 64-bit C++ Builder.
|
|
|
|
The project can compile to both 32-bit and 64-bit platforms and will link the appropriate
|
|
import library. For 32-bit builds you need to protect dpwin32.dll and for 64-bit builds you
|
|
need to protect dpwin64.dll. The protected DLL will need to be in the same folder as your
|
|
compiled program for it to run correctly.
|
|
|
|
The sample code contains 10 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.
|
|
|
|
NB You need to protect dpwin32.dll (dpwin64.dll) and *not* your program.
|
|
Because your program is linked to the DLL it is protected.
|
|
|
|
Note - once dpwin32.dll (dpwin64.dll) is protected you will not be able to debug your program -
|
|
after our API has been called. Our strong anti-debug code will cause the debugger to
|
|
throw an exception. If you do want to debug your code then you can use the debug module:
|
|
dpwin32debug.dll (dpwin64debug.dll), but this should not be used for release. NB You will need
|
|
to link to the dpwin32debug_borland.lib (dpwin64debug_borland.a) import library if you use the
|
|
debug module. Edit dlltest_imports.c to do this.
|
|
(See readme.txt in samples\c for restrictions concerning the debug module).
|
|
|
|
Note - the 32-bit dpwin32_borland.lib was created using Borland's IMPLIB tool. If there is a problem
|
|
with the file we provide you can create your own by running (for example):
|
|
|
|
c:\program files\CodeGear\Rad Studio\5.0\bin\implib import_libs\dpwin32_borland.lib dpwin32.dll
|
|
|
|
(This assumes that the current directory is the Samples\C directory).
|
|
|
|
Note - the 64-bit dpwin64_borland.a was created using Borland's MKEXP tool. If there is a problem
|
|
with the file we provide you can create your own by running (for example):
|
|
(from a RAD Studio Command Prompt)
|
|
|
|
mklib import_libs\dpwin64_borland.lib dpwin64.dll
|
|
|
|
(This assumes that the current directory is the Samples\C directory).
|