home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / VISUAL_B / CODIGO_1 / BRANDEXE / USER.FRM (.txt) < prev   
Encoding:
Visual Basic Form  |  1994-01-08  |  6.9 KB  |  190 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. Sub Command1_Click ()
  122.     FiletoImplant$ = SourcePath.tag + "SICONVRT.EXE"    '.EXE file to brand
  123.     NumChars% = 30                          'Maximum # of chars per string
  124.     NumStrings% = 3                         'Number of strings to implant
  125.     For i = 1 To NumStrings%                'Implant the strings
  126.         ImplantString$ = UserText(i - 1).text           'User input
  127.         SearchString$ = String$(NumChars%, 87 + i)      'Start with X
  128.         Branded% = Implant(FiletoImplant$, ImplantString$, SearchString$, NumChars%)
  129.         If Branded% <> True Then
  130.             MsgBox "This copy is already registered to another user.", 48, UserDlg.caption
  131.             UserText(0).SetFocus
  132.             UserText(0).selStart = 0
  133.             UserText(0).selLength = Len(UserText(0).text)
  134.         End If
  135.     Next i
  136.     OutButton.tag = "continue"              'Move on to next step
  137.     UserDlg.Hide
  138. End Sub
  139. Sub Command2_Click ()
  140.     OutButton.tag = "exit"
  141.     UserDlg.Hide
  142. End Sub
  143. Function Implant (FiletoImplant As String, ImplantString As String, SearchString As String, NumChars As Integer) As Integer
  144. 'Brands .EXE file with user information.
  145. 'FiletoImplant - .EXE file to be implanted
  146. 'ImplantString - string to be implanted (e.g., user name)
  147. 'SearchString  - string in the .EXE file to be replaced by ImplantString
  148. '                (e.g., Const UserName$ = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
  149. 'NumChars      - number of characters in SearchString
  150. 'Function returns TRUE if successful, FALSE if not
  151.     Const BlockSize = 32768                 'size of block read from disk
  152.     Dim FileData As String                  'string to hold block read from disk
  153.     Dim NumBlocks As Integer                'number of complete blocks in .EXE file
  154.     Dim LeftOver As Integer                 'amount left in partial block
  155.     Dim FileLength As Long                  'length of .EXE file
  156.     Dim BlockPosn As Integer                'block number to be checked
  157.     Open FiletoImplant For Binary As #1
  158.     FileLength = LOF(1)
  159.     NumBlocks = FileLength \ BlockSize
  160.     LeftOver = FileLength Mod BlockSize
  161.     FileData = String$(BlockSize, 32)
  162.     BlockPosn = 0
  163.     For Index = 1 To NumBlocks              'search the .EXE file for special
  164.         Get #1, , FileData                  'string and record location
  165.         Posn& = InStr(FileData, SearchString)
  166.         If Posn& > 0 Then                   'found it!
  167.             BlockPosn = Index
  168.             Seek 1, Posn& + ((BlockPosn - 1) * BlockSize)
  169.             Exit For
  170.         End If
  171.     Next Index
  172.     If BlockPosn = 0 Then                   'didn't find it in regular blocks
  173.         FileData = ""                       'so look in leftovers
  174.         FileData = String$(LeftOver, 32)
  175.         Get #1, , FileData
  176.         Posn& = InStr(FileData, SearchString)
  177.         If Posn& = 0 Then                   'string still not found
  178.             Close #1
  179.             Implant = False                 'exit function, return FALSE
  180.             Exit Function
  181.         End If
  182.         Seek 1, Posn&                       'found it in leftovers!
  183.     End If
  184.     temp$ = Space$(NumChars)                'temp space for user info
  185.     LSet temp$ = ImplantString
  186.     Put #1, , temp$                         'brand the .EXE file with user info
  187.     Close #1                                'close file if all strings implanted
  188.     Implant = True                          'end the function
  189. End Function
  190.