177 lines
9.8 KiB
C
177 lines
9.8 KiB
C
// dapf.h
|
|
// !! this file should not be modified
|
|
|
|
// NB DAPF file is:
|
|
// DINKEYINFO
|
|
// LICENCEINFO (however many are needed)
|
|
// FILEINFO (however many are needed)
|
|
// ALGORITHM (however many are needed)
|
|
// DATAFILEENC (however many are needed)
|
|
|
|
#pragma pack (push,1) // so it is byte-aligned
|
|
|
|
typedef struct DINKEYINFO {
|
|
char Header[4]; // Should be set to "DAPF" ( = DinkeyAdd Parameter File)
|
|
int Version; // version of this structure. Currently 9.
|
|
int SelectedModels; // BIT0 = Dinkey Pro Lite, BIT1 = Dinkey Pro Plus, BIT2 = Dinkey Pro Net etc...
|
|
char ProdCode[12];
|
|
int PerLicence; // 1 = per licence, 0 = per product (default)
|
|
int MaxNetUsers; // product net users, unlimited = -1, no entry = -2
|
|
int RangeSettings; // 0 = any number, 1 = dongle in computer, 2 = range
|
|
unsigned int RangeMin;
|
|
unsigned int RangeMax;
|
|
int NumLicences; // number of LICENCEINFO structures in this DAPF file
|
|
int NumProgs; // number of FILEINFO structures in this DAPF file
|
|
int NumAlgs; // number of ALGORITHM structures in this DAPF file
|
|
int DataSizeType; // 1 = set the zero data size, 0 = use file to initialise data area
|
|
int ZeroDataSize; // size of the data area area in bytes
|
|
char DataFile[256]; // path to data file (0 = no data file)
|
|
int DataAreaSize; // file size in bytes, -1 = file not found
|
|
char szShellMsgs[10][256]; // success, no dongle, expirydate, expiryexecs, warndate, warnexecs, net user limit, other error, background
|
|
char RWAlgorithm[12]; // coded form of rw algorithm (0 = no algorithm)
|
|
int SecOptions; // BIT0: DRIS encryption, BIT1: Data encryption, BIT2: Data enc with alg, BIT3: only secure update codes
|
|
unsigned char SecDRISEncKey[4]; // DRIS encryption parameters (last byte ignored)
|
|
unsigned char SecDataEncKey[4]; // API Data encryption parameters (last byte ignored)
|
|
int ProtectionType; // 0 = software + dongle, 1 = dongle only, 2 = program only
|
|
char DataEncKeyProdCode[12]; // Alternative Product Code used to generate internal encryption keys. Normally set to 0.
|
|
char Notes[256]; // user-defined notes
|
|
int LockDongle; // 0 = don't lock (default), 1 = lock dongle to user's computer
|
|
int Reserved1; // must be 0
|
|
int Reserved2; // must be 0
|
|
unsigned int AdvancedOptions; // BIT0 = do not allow usb-over-network for non-Net dongles, BIT1 = do not check for Software Key at Runtime.
|
|
int NumDataFileEnc; // Number of data files in our encryption list
|
|
} DINKEYINFO;
|
|
|
|
typedef struct LICENCEINFO {
|
|
char LicenceName[256]; // name of licence
|
|
int MaxDays; // -1 = no limit
|
|
int ExpiryDay; // -1 = no limit
|
|
int ExpiryMonth;
|
|
int ExpiryYear;
|
|
int Execs; // -1 = no limit
|
|
int ExecsWarn; // 0 = no warning (just for Shell method)
|
|
int DaysWarn; // 0 = no warning (just for Shell method)
|
|
unsigned int Features;
|
|
int LicenceNetUsers; // unlimited = -1 (-2 = not needed (this is for display only))
|
|
} LICENCEINFO;
|
|
|
|
typedef struct FILEINFO {
|
|
char InputName[256];
|
|
char OutputName[256];
|
|
char CallingProg[256]; // calling program name
|
|
int LicenceIndex; // index (of licence) in the LicenceInfo structure (1-based index. 0 = no selection)
|
|
int Method; // 0-api, 1-shell, 2-shell & api
|
|
int ShellFlags; // same bit flag values as in dris. i.e. 1 = DEC_ONE_EXEC, 4 = START_NET_USER
|
|
int BackGround; // 0=no background, 1=1min, 2=5min, 3=10min, 4=30min, 5=60min
|
|
int OtherShellOptions; // BIT0 = Shell Data Encryption is enabled, BIT1: Extra Anti-Debug is disabled, BIT2: Extra Anti-Piracy is disabled
|
|
char EncFileList[256]; // files (or file types) that the Shell-protected program will treat as encrypted (separated by ':')
|
|
char ExceptList[256]; // files (or file types) that are exceptions to the above list (separated by ':')
|
|
int ExtraAntiPiracy; // 0 = off, 1=min, 10=max
|
|
} FILEINFO;
|
|
|
|
typedef struct ALGORITHM {
|
|
unsigned char Algorithm[12];
|
|
} ALGORITHM;
|
|
|
|
typedef struct DATAFILEENC {
|
|
char InputName[256]; // file name, wild cards are allowed
|
|
char OutputName[256]; // file name (or folder name if input is a wildcard)
|
|
} DATAFILEENC;
|
|
|
|
typedef struct TEMP_SWKEY_INFO {
|
|
int size; // size of this structure (must be initialised)
|
|
unsigned int machineID; // machine ID in (hex) integer form
|
|
int expiry_day; // expiry date of the Software Key
|
|
int expiry_month;
|
|
int expiry_year;
|
|
int dongle_model; // model of the Software Key. See constant values below
|
|
unsigned int dongle_number; // dongle number of the Software Key. 0 = default (random)
|
|
} TEMP_SWKEY_INFO;
|
|
|
|
typedef struct DEMO_SWKEY_INFO {
|
|
int size; // size of this structure (must be initialised)
|
|
int max_days; // max days demo swkey installation is valid (0-60)
|
|
int models; // bitmap of valid dongle models. See constant values below. 0 = default (only use if only one model is selected in DINKEYINFO)
|
|
} DEMO_SWKEY_INFO;
|
|
|
|
typedef void *DAPF_HANDLE; // for DinkeyAdd Module API functions
|
|
|
|
#pragma pack (pop)
|
|
|
|
// constants
|
|
#define DAPF_VERSION 9 // current DAPF version
|
|
|
|
// WriteDAPF API flags
|
|
#define FLAGS_LOSE_FEATURES 1 // means that you can save the DAPF file to an earlier version even if it means losing some new features that have been currently set
|
|
|
|
// AddProtection API action values
|
|
#define ACTION_USE_DAPF_SETTINGS 0 // means you just ignore the action value and use the default dapf settings
|
|
#define ACTION_PROGRAM_DONGLE 1 // program the dongle only
|
|
#define ACTION_PROTECT_SOFTWARE 2 // protect a software file (index indicated by separate parameter)
|
|
#define ACTION_PROGRAM_AND_PROTECT 3 // program the dongle and protect software
|
|
|
|
// AddProtection API flags values
|
|
#define FLAGS_OVERWRITE_OUTPUT 1 // overwrite the output file if it already exists (default is to give an error)
|
|
|
|
// SoftwareKey API flags
|
|
#define FLAGS_OVERWRITE_SWKEY 1 // overwrite an existing swkey with the new one
|
|
#define FLAGS_EXPIRY_DONTCARE 2 // create the Software Key even though the expiry date (or max days) is less than the expiry date of the key itself.
|
|
|
|
// constants for dapf_format in ReadDAPFEx and WriteDAPFEx functions
|
|
#define DAPF_FORMAT_BINARY 1
|
|
#define DAPF_FORMAT_JSON 2
|
|
#define DAPF_FORMAT_JSON_MIN 3 // this value is only used with WriteDAPEx. ReadDAPFEx cannot return this value.
|
|
|
|
// constants for values for dongle_model in the TEMP_SWKEY_INFO structure
|
|
#define SWKEY_MODEL_PRO_LITE 0
|
|
#define SWKEY_MODEL_PRO_PLUS 1
|
|
#define SWKEY_MODEL_PRO_NET 2
|
|
#define SWKEY_MODEL_FD_LITE 3
|
|
#define SWKEY_MODEL_FD_PLUS 4
|
|
#define SWKEY_MODEL_FD_NET 5
|
|
|
|
// constants for models bitmap in the DEMO_SWKEY_INFO structure
|
|
#define SWKEY_BITMAP_DEFAULT 0 // use default value set in DINKEYINFO.SelectedModels
|
|
#define SWKEY_BITMAP_PRO_LITE 1 // BIT0
|
|
#define SWKEY_BITMAP_PRO_PLUS 2 // BIT1
|
|
#define SWKEY_BITMAP_PRO_NET 4 // BIT2
|
|
#define SWKEY_BITMAP_FD_LITE 8 // BIT3
|
|
#define SWKEY_BITMAP_FD_PLUS 16 // BIT4
|
|
#define SWKEY_BITMAP_FD_NET 32 // BIT5
|
|
|
|
#define MAX_LICENCES 255 // max number of licences in a DAPF file
|
|
#define MAX_FILE_INFO 255 // theoretically unlimited but in practice it is easier if we limit it
|
|
#define MAX_USER_ALGS 20 // max number of user algs in DAPF file
|
|
#define MAX_DATA_ENCS 255 // max number of Shell data encryption files in DAPF file
|
|
|
|
// DinkeyAdd module API declarations
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
int WINAPI ReadDAPFEx(char *szFileDAPF, DINKEYINFO *pDinkeyInfo, LICENCEINFO *pLicenceInfo, FILEINFO *pFileInfo, ALGORITHM *pAlgorithms, DATAFILEENC *pDataFileEnc, int *dapf_version, int *dapf_format);
|
|
|
|
DAPF_HANDLE WINAPI LoadDAPF(DINKEYINFO *pDinkeyInfo, LICENCEINFO *pLicenceInfo, FILEINFO *pFileInfo, ALGORITHM *pAlgorithms, DATAFILEENC *pDataFileEnc, int *err_code);
|
|
|
|
DAPF_HANDLE WINAPI LoadDAPFFromFile(char *szFileDAPF, int *err_code);
|
|
|
|
int WINAPI WriteDAPFEx(DAPF_HANDLE handle, char *szFileDAPF, int dapf_format, int dapf_version, int flags);
|
|
|
|
void WINAPI UnloadDAPF(DAPF_HANDLE *handle);
|
|
|
|
int WINAPI AddProtection(DAPF_HANDLE handle, int action, int file_num, int flags, unsigned int *dongle_number);
|
|
|
|
int WINAPI CreateTempSoftwareKey(DAPF_HANDLE handle, TEMP_SWKEY_INFO *swkey_info, int flags);
|
|
|
|
int WINAPI CreateDemoSoftwareKeyTemplate(DAPF_HANDLE handle, DEMO_SWKEY_INFO *swkey_info, int flags);
|
|
|
|
int WINAPI EncryptShellDataFiles(DAPF_HANDLE handle, int file_num, int flags);
|
|
|
|
void WINAPI GetLastMessage(char *szMessage, int buffer_size, int *message_length);
|
|
|
|
int WINAPI GetLastExtendedError(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|