home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 15 / CDACTUAL15.iso / cdactual / program / basic / QBNWS103.ZIP / CLONE.ZIP / CLONE.BAS
Encoding:
BASIC Source File  |  1990-05-23  |  2.4 KB  |  94 lines

  1. DECLARE SUB SetSpecialData (Register$)
  2. DECLARE FUNCTION GetSpecialData$ ()
  3. DECLARE FUNCTION SearchEXE$ (FileName$, Key$, DatLen%)
  4. 'Program to demonstrate cloning keys into .EXE'S
  5.  
  6. DEFINT A-Z
  7.  
  8. DIM SHARED SpotForKey$, BytesToData&
  9.  
  10.   
  11. CLS
  12.   
  13. PRINT "This program lets you enter your name as part of a registration process."
  14. PRINT : PRINT
  15. Nme$ = GetSpecialData$
  16. IF Nme$ = "" THEN
  17.    PRINT "This program is not registered."
  18.    INPUT "Please enter your name: ", Nme$
  19.    Nme$ = RTRIM$(LEFT$(Nme$, 29)) + CHR$(0)  'This makes name 30 or less
  20.    SetSpecialData Nme$                       'and ends it with a null
  21.    PRINT : PRINT "Thank you for registering."
  22.    END                                       'Next time you run it, it will
  23.                                              'display your name
  24. ELSE
  25.    PRINT "This program is registered to "; Nme$
  26.    END
  27. END IF
  28.  
  29. FUNCTION GetSpecialData$ STATIC
  30.  
  31. SpotForKey$ = "ûùÿÖ123456789012345678901234567890"
  32. TempKey$ = LEFT$(SpotForKey$, 4)
  33. DataLen = 30
  34.  
  35. Dat$ = SearchEXE$("CLONE.EXE", TempKey$, DataLen)
  36. Null = INSTR(Dat$, CHR$(0))
  37. IF Null THEN
  38.    GetSpecialData$ = LEFT$(Dat$, (Null - 1))
  39. ELSE
  40.    GetSpecialData$ = ""
  41. END IF
  42.  
  43. END FUNCTION
  44.  
  45. FUNCTION SearchEXE$ (FileName$, Key$, DatLen) STATIC
  46.  
  47. 'The Bytes% variable is the number of bytes to read. If your program is
  48. 'less than 16000 bytes then this routine adjusts accordinly. Also, if
  49. 'a 16000 byte "GET" cuts the marker in two, you don't have to worry about
  50. 'it because we adjust the file pointer accordingly.
  51.  
  52. Bytes = 16000
  53. BytesToData& = 0
  54. Portion& = 1
  55. CountToKey = 0
  56.  
  57. OPEN FileName$ FOR BINARY AS #1
  58. FiSize& = LOF(1)
  59. DO WHILE NOT EOF(1)
  60.    IF Bytes > FiSize& THEN Bytes = FiSize&
  61.    IF Bytes + Portion& > FiSize& THEN Bytes = FiSize& - Portion&
  62.    SEEK #1, Portion&
  63.    A$ = INPUT$(Bytes, 1)
  64.  
  65.    CountToKey = INSTR(A$, Key$)
  66.    IF CountToKey THEN
  67.       BytesToData& = Portion& + CountToKey + LEN(Key$) - 1
  68.       SEEK #1, BytesToData&
  69.       SearchEXE$ = INPUT$(DatLen, 1)
  70.       CLOSE #1
  71.       EXIT FUNCTION
  72.    END IF
  73.  
  74.    Portion& = Bytes + Portion& - LEN(Key$) 'We subtract the key length in case
  75.                                           'it was split by our read
  76. LOOP
  77.  
  78. CLOSE #1
  79. PRINT "Error. Could not find key!"
  80. END
  81.  
  82. END FUNCTION
  83.  
  84. SUB SetSpecialData (Register$)
  85.  
  86. Key$ = LEFT$(SpotForKey$, 4)
  87.  
  88. OPEN "CLONE.EXE" FOR BINARY AS #1
  89. PUT #1, BytesToData&, Register$
  90. CLOSE #1
  91.  
  92. END SUB
  93.  
  94.