User Guide USB Stick CopyStation
21
– 1.3
23
User Guide USB Stick CopyStation
21
– 1.3
22
6.3 Software interface for e.g. external serialization
6.3.1 General Description
The USB Stick CopyStation
21
has an optional software interface for data exchange
with an external application to allow customization of individual memory sticks.
This can be used for a serialization of sticks to protect stick contents such as data files
or programs against unauthorized duplication or usage.
USB Sticks have individual serial numbers in most cases, although these can also be
missing.
If the target application allows to read out this serial number, the application can
check, whether this is an authorized copy or not.
This feature is only available if you have purchased the software option "Serialization"
(Item no.
31AL1854
).
6.3.2 How it works
When this software feature is activated, each memory stick will be shown as logical
drive under Windows XP after it has been programmed and as the case may be has
verified the content, and an external software program is started (see figure below).
Serial number and
logical drive letter of
each memory stick
are passed on to this
program. Please note:
not every memory
stick has an individ-
ual serial number. In
cases with no serial
number, a series of
zeros is transferred.
The external soft-
ware needs to be pro-
grammed by the cus-
tomer according to his needs. This programming can also be done by altec’s
Development Divsion. For instance this program could create specific data files, which
are then copied to the individual memory stick.
This allows an individualization of each memory stick ’s content.
6.3.3 Accessing the memory stick through filesystem calls
When the memory stick has been mapped to the logical drive, the external patch
application can communicate with the memory stick.
The application can use the standard operating system file system calls like fopen()
fread() fwrite() …. With these calls, the application has full access to all files and
subdirectories which reside on the stick. In addition, using special fopen() calls, the
application has also full access to any data on the stick, starting from the first and
ending on the last storage block of the stick.
Example
The example shows, how to access the USB stick through the standard operating
system file system calls.
In this example, the serial number, which is given as a parameter to the application, is
written to a text file named CID.BIN to the USB stick. The name of the logical drive is
taken from the second parameter.
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
int main(int argc, char* argv[])
{
char v_drive_letter, filename[256];
FILE *f1;
int retcode=0;
if (argc == 2) {
// Please note: argv[1] = drive letter and argv[0] = serial number
v_drive_letter = argv[1][0];
// get the drive letter from 2nd parameter
sprintf(filename,"%c:\\CID.BIN",v_drive_letter);
f1 = fopen(filename,"w+");
// open a file on the Virtual Drive and
fwrite(argv[0],1,strlen(argv[0]),f1);
// write the serial number.
fclose(f1);
}
else
retcode = 1;
// inavlid numer of parameters
return retcode;
}