home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / brandexe / user.frm < prev   
Text File  |  1994-01-08  |  7KB  |  203 lines

  1. VERSION 2.00
  2. Begin Form UserDlg 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "UserDlg"
  5.    ClientHeight    =   3495
  6.    ClientLeft      =   1905
  7.    ClientTop       =   2655
  8.    ClientWidth     =   6855
  9.    ControlBox      =   0   'False
  10.    Height          =   3900
  11.    Left            =   1845
  12.    LinkMode        =   1  'Source
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   3495
  17.    ScaleWidth      =   6855
  18.    Top             =   2310
  19.    Width           =   6975
  20.    Begin CommandButton Command2 
  21.       Caption         =   "&Exit Setup"
  22.       Height          =   372
  23.       Left            =   3456
  24.       TabIndex        =   4
  25.       Top             =   2976
  26.       Width           =   1572
  27.    End
  28.    Begin CommandButton Command1 
  29.       Caption         =   "&Continue"
  30.       Default         =   -1  'True
  31.       Height          =   372
  32.       Left            =   1248
  33.       TabIndex        =   3
  34.       Top             =   2976
  35.       Width           =   1572
  36.    End
  37.    Begin TextBox UserText 
  38.       Height          =   375
  39.       Index           =   2
  40.       Left            =   2520
  41.       TabIndex        =   2
  42.       Top             =   1590
  43.       Width           =   3735
  44.    End
  45.    Begin TextBox UserText 
  46.       Height          =   375
  47.       Index           =   1
  48.       Left            =   2520
  49.       TabIndex        =   1
  50.       Top             =   1155
  51.       Width           =   3735
  52.    End
  53.    Begin TextBox UserText 
  54.       Height          =   375
  55.       Index           =   0
  56.       Left            =   2520
  57.       TabIndex        =   0
  58.       Top             =   720
  59.       Width           =   3735
  60.    End
  61.    Begin Label outButton 
  62.       Caption         =   "outButton"
  63.       Height          =   252
  64.       Left            =   5280
  65.       TabIndex        =   8
  66.       Top             =   2976
  67.       Visible         =   0   'False
  68.       Width           =   972
  69.    End
  70.    Begin Label SourcePath 
  71.       Caption         =   "SourcePath"
  72.       Height          =   204
  73.       Left            =   5280
  74.       TabIndex        =   11
  75.       Top             =   2592
  76.       Visible         =   0   'False
  77.       Width           =   972
  78.    End
  79.    Begin Label Label3 
  80.       Caption         =   "To quit Setup, choose the Exit button."
  81.       Height          =   252
  82.       Left            =   1248
  83.       TabIndex        =   7
  84.       Top             =   2496
  85.       Width           =   3612
  86.    End
  87.    Begin Label Label5 
  88.       Alignment       =   1  'Right Justify
  89.       Caption         =   "Serial Number:"
  90.       Height          =   252
  91.       Left            =   840
  92.       TabIndex        =   10
  93.       Top             =   1650
  94.       Width           =   1572
  95.    End
  96.    Begin Label Label4 
  97.       Alignment       =   1  'Right Justify
  98.       Caption         =   "Company:"
  99.       Height          =   252
  100.       Left            =   840
  101.       TabIndex        =   9
  102.       Top             =   1215
  103.       Width           =   1572
  104.    End
  105.    Begin Label Label2 
  106.       Alignment       =   1  'Right Justify
  107.       Caption         =   "Name:"
  108.       Height          =   255
  109.       Left            =   840
  110.       TabIndex        =   6
  111.       Top             =   780
  112.       Width           =   1575
  113.    End
  114.    Begin Label Label1 
  115.       Height          =   492
  116.       Left            =   1248
  117.       TabIndex        =   5
  118.       Top             =   96
  119.       Width           =   5028
  120.    End
  121. End
  122.  
  123.  
  124. Sub Command1_Click ()
  125.     FiletoImplant$ = SourcePath.tag + "SICONVRT.EXE"    '.EXE file to brand
  126.     NumChars% = 30                          'Maximum # of chars per string
  127.     NumStrings% = 3                         'Number of strings to implant
  128.     
  129.     For i = 1 To NumStrings%                'Implant the strings
  130.         ImplantString$ = UserText(i - 1).text           'User input
  131.         SearchString$ = String$(NumChars%, 87 + i)      'Start with X
  132.         Branded% = Implant(FiletoImplant$, ImplantString$, SearchString$, NumChars%)
  133.         If Branded% <> True Then
  134.             MsgBox "This copy is already registered to another user.", 48, UserDlg.caption
  135.             UserText(0).SetFocus
  136.             UserText(0).selStart = 0
  137.             UserText(0).selLength = Len(UserText(0).text)
  138.         End If
  139.     Next i
  140.  
  141.     OutButton.tag = "continue"              'Move on to next step
  142.     UserDlg.Hide
  143. End Sub
  144.  
  145. Sub Command2_Click ()
  146.     OutButton.tag = "exit"
  147.     UserDlg.Hide
  148. End Sub
  149.  
  150. Function Implant (FiletoImplant As String, ImplantString As String, SearchString As String, NumChars As Integer) As Integer
  151. 'Brands .EXE file with user information.
  152. 'FiletoImplant - .EXE file to be implanted
  153. 'ImplantString - string to be implanted (e.g., user name)
  154. 'SearchString  - string in the .EXE file to be replaced by ImplantString
  155. '                (e.g., Const UserName$ = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
  156. 'NumChars      - number of characters in SearchString
  157. 'Function returns TRUE if successful, FALSE if not
  158.  
  159.     Const BlockSize = 32768                 'size of block read from disk
  160.     Dim FileData As String                  'string to hold block read from disk
  161.     Dim NumBlocks As Integer                'number of complete blocks in .EXE file
  162.     Dim LeftOver As Integer                 'amount left in partial block
  163.     Dim FileLength As Long                  'length of .EXE file
  164.     Dim BlockPosn As Integer                'block number to be checked
  165.     
  166.     Open FiletoImplant For Binary As #1
  167.     FileLength = LOF(1)
  168.     NumBlocks = FileLength \ BlockSize
  169.     LeftOver = FileLength Mod BlockSize
  170.     FileData = String$(BlockSize, 32)
  171.     BlockPosn = 0
  172.     
  173.     For Index = 1 To NumBlocks              'search the .EXE file for special
  174.         Get #1, , FileData                  'string and record location
  175.         Posn& = InStr(FileData, SearchString)
  176.         If Posn& > 0 Then                   'found it!
  177.             BlockPosn = Index
  178.             Seek 1, Posn& + ((BlockPosn - 1) * BlockSize)
  179.             Exit For
  180.         End If
  181.     Next Index
  182.     
  183.     If BlockPosn = 0 Then                   'didn't find it in regular blocks
  184.         FileData = ""                       'so look in leftovers
  185.         FileData = String$(LeftOver, 32)
  186.         Get #1, , FileData
  187.         Posn& = InStr(FileData, SearchString)
  188.         If Posn& = 0 Then                   'string still not found
  189.             Close #1
  190.             Implant = False                 'exit function, return FALSE
  191.             Exit Function
  192.         End If
  193.         Seek 1, Posn&                       'found it in leftovers!
  194.     End If
  195.  
  196.     temp$ = Space$(NumChars)                'temp space for user info
  197.     LSet temp$ = ImplantString
  198.     Put #1, , temp$                         'brand the .EXE file with user info
  199.     Close #1                                'close file if all strings implanted
  200.     Implant = True                          'end the function
  201. End Function
  202.  
  203.