Re: Program on a flash Drive
- From: "TonySper" <tsperduti@xxxxxxxxxxxxxxxxxxx>
- Date: Thu, 8 Feb 2007 19:54:55 -0500
Cy,
Sounds very good. What I want to do is to install the program on the
flash drive so that you can't copy it to and other drive or computer.
The program has to stay running on the Flash Drive. That is why I an
trying to find out if there is any numbers or serials that a person
can read off of the flash drive and hash that.
Your program is fine if you load the program on to a drive but what if
your program is on a CD and you send it to someone to load on his
computer?? He can also load it on any number of computers. I do not
see where your protection is no matter how you hash it as each time it
gets loaded on a computer it knows where it is going and will execute.
Maybe I am missing something!!!!
TonySper
"Cy Welch" <cywelch@xxxxxxxxx> wrote in message
news:OF2TjJ%23SHHA.4844@xxxxxxxxxxxxxxxxxxxxxxx
TonySper wrote:
Gene,In followup to my earlier response. I am enclosing the two programs I
That is just what I come up with. That's why I was wondering if the
manufacture has put any coding on the flash drives. No matter how
you
put files and hidden data on the drive all a user has to do is copy
the whole flash drive with all the folders to their computer and it
will run as I do not use any absolute drive letters in any of my
programs.
TonySper
"Gene Wirchenko" <genew@xxxxxxxx> wrote in message
news:qlnms299prmas10tt4tcuob3rukn0mkf9g@xxxxxxxxxx
[reordered to chronological]
"Jeff Grippe" <jgrippe@xxxxxxxxxxx> wrote:
"TonySper" <tsperduti@xxxxxxxxxxxxxxxxxxx> wrote in message
news:5kIyh.189$I8.128@xxxxxxxxxxxxxxxxxxxxxxxxx
I would like to install an exe file on to a flash drive and if
someone
copies it from a flash drive to their computer disable it. Does
anyone
know if there is any codes on the flash drive that can be read
using
VFP8 so that each time the program runs it has to compare this
code??
Are you trying to defeat the casual user or the technical
specialist?
You could create a hidden and read only file or folder at the time
of
installation and encrypt the install drive letter (which I assume
will not
be C). Then, if the program is copied to another drive you would
know
and
not start. If it is being moved to another non-c drive you could
update the
installation information (assuming you want to allow the app to be
run on
any machine as long as it is run from the flash drive)
That would cause me trouble. On my main system, my USB memory
stick mounts as G:. On my older system, it mounts as F:. At the
two
university labs that I use, it mounts as E:. Which one do you
consider correct, and why?
justdrive(sys(16))
might be what the OP wants. I warn against such locking though. It
can give the appearance that the program is broken. Once the user
gets the idea that the drive makes the difference (and you might
well
tell him as how else to explain why the program does not work), it
can
be easily defeated with
subst q: c:\
and starting the program from q:.
use to create my protection hash.
First is the code that creates the file on the disk:
CREATE TABLE "a:\license.key" FREE (checksum N(8), licenses N(3))
APPEND BLANK
REPLACE licenses WITH THISFORM.spnNumUsers.VALUE
REPLACE checksum WITH CRC(serialno("A")+STR(licenses))
USE IN license
Now, serialno.prg:
LPARAMETERS tcDriveLetter
* GetVolumeInformation
*
*
*** Declare Local Variables ***
LOCAL i && counter
LOCAL lnDrvType && DRIVETYPE
LOCAL lcDrive && string
LOCAL lnDrive && bitmap of legal drives
* standard declares for WinAPI calls
LOCAL lpRootPathName, ;
lpVolumeNameBuffer, ;
lpVolumeSerialNumber, ;
lpMaximumComponentLength, ;
lpFileSystemFlags, ;
lpFileSystemNameBuffer, ;
nVolumeNameSize, ;
nFileSystemNameSize
*** Declare API calls ***
* GetDriveType() returns numeric type of drive
DECLARE INTEGER GetDriveType IN WIN32API ;
STRING lpRootPathName && address of root path
* GetLogicalDrives() returns a bitmap of
* "legal" logical drives
DECLARE INTEGER GetLogicalDrives in win32api
* GetVolumeInformation() returns volume names, ;
serial numbers, file systems, and other stuff.
DECLARE short GetVolumeInformation IN Win32API ;
STRING lpRootPathName, ;
STRING lpVolumeNameBuffer, ;
INTEGER nVolumeNameSize, ;
STRING lpVolumeSerialNumber, ;
STRING lpMaximumComponentLength, ;
STRING lpFileSystemFlags, ;
STRING lpFileSystemNameBuffer, ;
INTEGER nFileSystemNameSize
* GetDriveType RETURN VALUES:
#DEFINE DRIVE_NONE 0 && Cannot be determined.
#DEFINE DRIVE_BAD 1 && Root directory does not exist.
#DEFINE DRIVE_REMOVABLE 2 && Disk can be removed.
#DEFINE DRIVE_FIXED 3 && Disk cannot be removed.
#DEFINE DRIVE_REMOTE 4 && Drive is remote/network drive.
#DEFINE DRIVE_CDROM 5 && The drive is a CD-ROM drive.
#DEFINE DRIVE_RAMDISK 6 && The drive is a RAM disk.
*** Get bitmap of legal drives ***
lnDrive = GetLogicalDrives()
lcDrive = CHR(ASC(tcDriveLetter))+":\" && translate to letter
(C:)
*!* lcDrive = CHR(ASC("A")+2)+":\" && translate to letter (C:)
* Set the defaults for floppies
lpVolumeNameBuffer = ""
lnDriveType = DRIVE_REMOVABLE
* Skip trying to obtain the name or drive type of
* floppies: this can bring up an untrappable error
* Obtain the Volume Name
STORE SPACE(255) TO lpRootPathName, ;
lpVolumeNameBuffer, ;
lpVolumeSerialNumber, ;
lpMaximumComponentLength, ;
lpFileSystemFlags, ;
lpFileSystemNameBuffer
STORE 255 TO nVolumeNameSize, nFileSystemNameSize
= GetVolumeInformation(lcDrive, ;
@lpVolumeNameBuffer, ;
@nVolumeNameSize, ;
@lpVolumeSerialNumber, ;
@lpMaximumComponentLength, ;
@lpFileSystemFlags, ;
@lpFileSystemNameBuffer, ;
@nFileSystemNameSize )
* Truncate the buffer to the CHR(0) end of string
* or to zero for blank volumes
lpVolumeNameBuffer = LEFT(lpVolumeNameBuffer, ;
AT(CHR(0),lpVolumeNameBuffer)-1)
* Get the volume's drive type
lnDriveType = GetDriveType(lcDrive)
cReturnHex = ""
FOR y = 1 TO LEN(ALLTRIM(lpVolumeSerialNumber))
cStreng = SUBSTR(lpVolumeSerialNumber,y,1)
cBin = Dec2Bin(ASC(cStreng))
cHex = Bin2Hex(cBin)
IF LEN(cHex) = 1
cHex = "0" + cHex
ENDIF
cReturnHex = cHex + cReturnHex
ENDFOR y
*!* WAIT WINDOW "Serialno. "+cReturnHex
RETURN cReturnHex
* Function Bin2Hex
*
* Function to convert BIN to HEX
*
FUNCTION Bin2Hex
PARAMETERS cBin
PRIVATE nBinLen, nZeroLen, cHexValue, nLoopX, cBit, cHex
nBinLen = LEN(cBin)
nZeroLag = ROUND((nBinLen/4)+.49,0)*4 - nBinLen
cBin = REPLICATE("0",nZeroLag)+cBin
cHexValue = ""
FOR nLoopX = 1 TO LEN(cBin) STEP 4
cBit = SUBSTR(cBin,nLoopX,4)
DO CASE
CASE cBit = "0000"
cHex = "0"
CASE cBit = "0001"
cHex = "1"
CASE cBit = "0010"
cHex = "2"
CASE cBit = "0011"
cHex = "3"
CASE cBit = "0100"
cHex = "4"
CASE cBit = "0101"
cHex = "5"
CASE cBit = "0110"
cHex = "6"
CASE cBit = "0111"
cHex = "7"
CASE cBit = "1000"
cHex = "8"
CASE cBit = "1001"
cHex = "9"
CASE cBit = "1010"
cHex = "A"
CASE cBit = "1011"
cHex = "B"
CASE cBit = "1100"
cHex = "C"
CASE cBit = "1101"
cHex = "D"
CASE cBit = "1110"
cHex = "E"
CASE cBit = "1111"
cHex = "F"
ENDCASE
cHexValue = cHexValue + cHex
NEXT
RETURN cHexValue
* End of Function * Bin2Hex() *
* Function Dec2Bin
*
* Function to convert Decimal to BIN
*
FUNCTION Dec2Bin
PARAMETERS nValue
PRIVATE nValue, cBinStr, nRest
cBinStr = ""
DO WHILE .T.
nRest = MOD(nValue,2)
nValue = INT(nValue/2)
cBinStr = STR(nRest,1) + cBinStr
IF nValue = 0
EXIT
ENDIF
ENDDO
RETURN cBinStr
* End of Function * Dec2Bin() *
And here is the CRC.prc that is used by the routine. You have
permision
to use, modify and distribute the routine as you wish:
* Program....: BOBCRC.PRG
* Version....: 1.0
* Author.....: Bob Herguth, Based upon PowerBASIC Code by Coridon
Henshaw
* Date.......: June 9, 1997
* Notice.....: Copyright (c) 1997 MetSYS, Inc. All Rights Reserved.
* Compiler...: FoxPro 2.6a
* Abstract...: 16 and 32 bit CRC calaculator routine for data blocks.
* lcBlockTxt: The text block to calculate a CRC for.
* lcBitLen: A text value ("16" or "32")indicating whether
* to return a 16 or 32 bit CRC.
* Changes....:
PARAMETERS lcBlockTxt, lcBitLen
DO CASE
CASE PARAMETERS() < 1
WAIT WINDOW "Not enough paramters passed to CRC(lcBlockTxt, lcBitLen)
function."
RETURN
CASE PARAMETERS() < 2
lcBitLen = "16"
ENDCASE
IF TYPE("lcBitLen") = "N"
IF lcBitLen = 32
lcBitLen = "32"
ELSE
lcBitLen = "16"
ENDIF
ENDIF
#IF !"Visual"$VERSION()
lnCRC = swcrcbuf(lcBlockTxt)
RETURN lnCRC
#ELSE
DIMENSION laPower[8] && For the 8 laPowers of 2
PRIVATE lnCRC, lnPower, TestBit
lnBitLen = IIF(lcBitLen="32",32773,4129) && 1021 hex (16bit), 8005 hex
(32bit)
* Precalculated values will improve performance in FOR J Code
FOR lnPower = 1 TO 8
laPower(lnPower) = 2^(lnPower-1)
NEXT lnPower
lnCRC = 0 && Reset for Each Text Block
FOR OutLoop = 1 TO LEN(lcBlockTxt) && Calculate for Length of Block
ByteVal = ASC(SUBSTR(lcBlockTxt, OutLoop, 1))
FOR InLoop = 8 TO 1 STEP - 1
TestBit = ((BITAND(lnCRC,32768) = 32768) AND NOT (BITAND(ByteVal,
laPower(InLoop)) = laPower(InLoop))) OR;
(!(BITAND(lnCRC,32768) = 32768) AND (BITAND(ByteVal, laPower(InLoop))
= laPower(InLoop)))
lnCRC = BITAND(lnCRC,32767)*2
IF TestBit
lnCRC = BITXOR(lnCRC,lnBitLen)
ENDIF
NEXT InLoop
NEXT OutLoop
RETURN lnCRC && Return the Word Value
#ENDIF
* Used only in FPW 2.6
FUNCTION BITAND
PARAMETERS A, B
IF INT(A)#A .OR. INT(B)#B
?? CHR(7)
WAIT WINDOW "Binary ANDd error: arguments must be integers!"
RETURN
ENDIF
PRIVATE Retval, Highord, I
Retval = 0
Highord =
MAX(INT(IIF(A>1,LOG(A)*1.442695041,0)),INT(IIF(B>1,LOG(B)*1.442695041,0)))
FOR I = 0 TO Highord
Retval = Retval+IIF(Xd0bit(I,A) .AND. Xd0bit(I,B),2**I,0)
NEXT
RETURN Retval
* Used only in FPW 2.6
FUNCTION BITXOR
PARAMETER A, B
IF INT(A)#A .OR. INT(B)#B
?? CHR(7)
WAIT WINDOW "XOR error: arguments must be integers!"
RETURN -1
ENDIF
PRIVATE Retval, Highord, I
Retval = 0
Highord =
MAX(INT(IIF(A>1,LOG(A)*1.442695041,0)),INT(IIF(B>1,LOG(B)*1.442695041,0)))
FOR I = 0 TO Highord
Retval = Retval+IIF(Xd0bit(I,A)#Xd0bit(I,B),2**I,0)
NEXT
RETURN Retval
FUNCTION Xd0bit
PARAMETER Bitno, A
PRIVATE Remainder, I, Highord
Highord = INT(IIF(A>1,LOG(A)*1.442695041,0))
IF Bitno>Highord
RETURN .F.
ENDIF
FOR I = 0 TO Highord
IF I=Bitno
RETURN IIF(IIF(A=1,1,MOD(A,2))=1,.T.,.F.)
ENDIF
IF A=0
RETURN .F.
ENDIF
A = INT(A/2)
NEXT
--
Cy Welch
Senior Programmer
MetSYS Inc
http://www.metsysinc.com
.
- Follow-Ups:
- Re: Program on a flash Drive
- From: Cy Welch
- Re: Program on a flash Drive
- References:
- Program on a flash Drive
- From: TonySper
- Re: Program on a flash Drive
- From: Jeff Grippe
- Re: Program on a flash Drive
- From: Gene Wirchenko
- Re: Program on a flash Drive
- From: TonySper
- Re: Program on a flash Drive
- From: Cy Welch
- Program on a flash Drive
- Prev by Date: Re: VFP and understanding 'repackaged cursors'
- Next by Date: Re: Good ways to tell why a dbf is locked?
- Previous by thread: Re: Program on a flash Drive
- Next by thread: Re: Program on a flash Drive
- Index(es):
Relevant Pages
|