VERSION 5.00
Begin VB.Form Form2 
   BackColor       =   &H00C0C0C0&
   Caption         =   "INI Template Generator"
   ClientHeight    =   2400
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   10995
   Icon            =   "magic.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   2400
   ScaleWidth      =   10995
   StartUpPosition =   2  'CenterScreen
   Begin VB.CommandButton Command3 
      Caption         =   "Save"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   4200
      TabIndex        =   21
      ToolTipText     =   "Save the information into TEMPLATE.INI file"
      Top             =   1920
      Width           =   5232
   End
   Begin VB.TextBox Text2 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   315
      Left            =   1560
      TabIndex        =   20
      ToolTipText     =   "Insert here the Magic Number (you find it on the message box that appear when you use the magic LMGR's DLL)"
      Top             =   1500
      Width           =   9312
   End
   Begin VB.TextBox Text1 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   315
      Left            =   1560
      TabIndex        =   18
      ToolTipText     =   "Insert here the Vendor Code text (you find it on the title of the message box that appear when you use the magic LMGR's DLL)"
      Top             =   1140
      Width           =   9312
   End
   Begin VB.CommandButton Command2 
      Caption         =   "Make"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   372
      Left            =   120
      TabIndex        =   16
      ToolTipText     =   "Extract all KEYs form magic number"
      Top             =   1920
      Width           =   4032
   End
   Begin VB.CommandButton Command1 
      Caption         =   "Exit"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   372
      Left            =   9480
      TabIndex        =   15
      ToolTipText     =   "Return to main"
      Top             =   1920
      Width           =   1392
   End
   Begin VB.Frame Frame3 
      Caption         =   "Key Info"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   915
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   10812
      Begin VB.TextBox Text4 
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   264
         Left            =   4740
         Locked          =   -1  'True
         TabIndex        =   24
         Text            =   "0"
         ToolTipText     =   "DLL Used"
         Top             =   540
         Width           =   1092
      End
      Begin VB.TextBox Text3 
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   264
         Left            =   6780
         Locked          =   -1  'True
         TabIndex        =   22
         Text            =   "0"
         ToolTipText     =   "Behavior used"
         Top             =   540
         Width           =   1092
      End
      Begin VB.TextBox Text5 
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   264
         Left            =   720
         Locked          =   -1  'True
         TabIndex        =   7
         Text            =   "00000000"
         ToolTipText     =   "Key1 Value"
         Top             =   240
         Width           =   1092
      End
      Begin VB.TextBox Text6 
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   264
         Left            =   2700
         Locked          =   -1  'True
         TabIndex        =   6
         Text            =   "00000000"
         ToolTipText     =   "Key2 Value"
         Top             =   240
         Width           =   1092
      End
      Begin VB.TextBox Text7 
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   264
         Left            =   4740
         Locked          =   -1  'True
         TabIndex        =   5
         Text            =   "00000000"
         ToolTipText     =   "Key3 Value"
         Top             =   240
         Width           =   1092
      End
      Begin VB.TextBox Text8 
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   264
         Left            =   6780
         Locked          =   -1  'True
         TabIndex        =   4
         Text            =   "00000000"
         ToolTipText     =   "Key4 Value"
         Top             =   240
         Width           =   1092
      End
      Begin VB.TextBox Text9 
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   264
         Left            =   8760
         Locked          =   -1  'True
         TabIndex        =   3
         Text            =   "00000000"
         ToolTipText     =   "Key5 Value"
         Top             =   240
         Width           =   1095
      End
      Begin VB.TextBox Text10 
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   264
         Left            =   720
         Locked          =   -1  'True
         TabIndex        =   2
         Text            =   "00000000"
         ToolTipText     =   "Seed1 Value"
         Top             =   540
         Width           =   1092
      End
      Begin VB.TextBox Text11 
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   264
         Left            =   2700
         Locked          =   -1  'True
         TabIndex        =   1
         Text            =   "00000000"
         ToolTipText     =   "Seed2 Value"
         Top             =   540
         Width           =   1092
      End
      Begin VB.Label Label4 
         Caption         =   "Bheavior:"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   192
         Left            =   5940
         TabIndex        =   25
         Top             =   540
         Width           =   792
      End
      Begin VB.Label Label3 
         Caption         =   "Dll:"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   192
         Left            =   4200
         TabIndex        =   23
         Top             =   540
         Width           =   312
      End
      Begin VB.Label Label10 
         Caption         =   "Key1:"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   195
         Left            =   180
         TabIndex        =   14
         Top             =   240
         Width           =   555
      End
      Begin VB.Label Label11 
         Caption         =   "Key2:"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   192
         Left            =   2160
         TabIndex        =   13
         Top             =   240
         Width           =   552
      End
      Begin VB.Label Label12 
         Caption         =   "Key3:"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   192
         Left            =   4200
         TabIndex        =   12
         Top             =   240
         Width           =   552
      End
      Begin VB.Label Label13 
         Caption         =   "Key4:"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   192
         Left            =   6240
         TabIndex        =   11
         Top             =   240
         Width           =   552
      End
      Begin VB.Label Label14 
         Caption         =   "Key5:"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   192
         Left            =   8220
         TabIndex        =   10
         Top             =   240
         Width           =   492
      End
      Begin VB.Label Label15 
         Caption         =   "Seed1:"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   195
         Left            =   60
         TabIndex        =   9
         Top             =   540
         Width           =   615
      End
      Begin VB.Label Label16 
         Caption         =   "Seed2:"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   192
         Left            =   2040
         TabIndex        =   8
         Top             =   540
         Width           =   612
      End
   End
   Begin VB.Label Label2 
      Caption         =   "Magic Number:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   195
      Left            =   180
      TabIndex        =   19
      Top             =   1560
      Width           =   1335
   End
   Begin VB.Label Label1 
      Caption         =   "Vendor Code:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   195
      Left            =   180
      TabIndex        =   17
      Top             =   1200
      Width           =   1215
   End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Form2.Hide
End Sub

Private Sub Command2_Click()
If Text1.Text = "" Then
    MsgBox "Please fill the Vendor Code Field", vbCritical, "Missing Field"
    End Sub
End If

If Text2.Text = "" Then
    MsgBox "Please fill the Magic Number Field", vbCritical, "Missing Field"
    End Sub
End If

If Len(Text2.Text) <> 80 Then
    MsgBox "The Magic Number Field has a wrong lenght you must type exactly 80 chr", vbCritical, "Missing Field"
    End Sub
End If

a = Text2.Text
sd1 = Mid(a, 7, 2) + Mid(a, 5, 2) + Mid(a, 3, 2) + Mid(a, 1, 2)
sd2 = Mid(a, 15, 2) + Mid(a, 13, 2) + Mid(a, 11, 2) + Mid(a, 9, 2)
k1 = Mid(a, 23, 2) + Mid(a, 21, 2) + Mid(a, 19, 2) + Mid(a, 17, 2)
k2 = Mid(a, 31, 2) + Mid(a, 29, 2) + Mid(a, 27, 2) + Mid(a, 25, 2)
k3 = Mid(a, 39, 2) + Mid(a, 37, 2) + Mid(a, 35, 2) + Mid(a, 33, 2)
k4 = Mid(a, 47, 2) + Mid(a, 45, 2) + Mid(a, 43, 2) + Mid(a, 41, 2)
beHa = Mid(a, 55, 2) + Mid(a, 53, 2) + Mid(a, 51, 2) + Mid(a, 49, 2)
esd1 = Mid(a, 63, 2) + Mid(a, 61, 2) + Mid(a, 59, 2) + Mid(a, 57, 2)
esd2 = Mid(a, 71, 2) + Mid(a, 69, 2) + Mid(a, 67, 2) + Mid(a, 65, 2)
dll = Mid(a, 79, 2) + Mid(a, 77, 2) + Mid(a, 75, 2) + Mid(a, 73, 2)
k5 = "&H" + sd1 Xor "&H" + esd1
k51 = "&H" + sd2 Xor "&H" + esd2

If k5 <> k51 Then MsgBox "This Magic Number is Invalid, please check !!", vbCritical, "Error": End Sub

DoEvents

If beHa = "00000007" Then Text3.Text = "7.0"
If beHa = "00000006" Then Text3.Text = "6.0"
If beHa = "00010006" Then Text3.Text = "6.1"
If beHa = "00000005" Then Text3.Text = "5.0"
If UCase(beHa) = "000C0005" Then Text3.Text = "5.0"
If beHa = "00000105" Then Text3.Text = "5.1"
If beHa = "00000004" Then Text3.Text = "4.0"
If beHa = "00000400" Then Text3.Text = "4.0"
If beHa = "00000003" Then Text3.Text = "3.0"
If Right(dll, 6) = "363233" Then Text4.Text = "326"
If Right(dll, 6) = "353233" Then Text4.Text = "325"
If Right(dll, 6) = "373233" Then Text4.Text = "327"
If Right(dll, 6) = "343233" Then Text4.Text = "324"


If crypted = 1 Then                           ' If database keys are crypted
    mKEY1 = Hex("&H" + k1 Xor &H9112A6C3)
    Text5.Text = Crypt(mKEY1)
    mKEY2 = Hex("&H" + k2 Xor &H42522D24)
    Text6.Text = Crypt(mKEY2)
    mKEY3 = Hex("&H" + k3 Xor &HA3CDEF90)
    Text7.Text = Crypt(mKEY3)
    mKEY4 = Hex("&H" + k4 Xor &H192F3745)
    Text8.Text = Crypt(mKEY4)
    mKEY5 = Hex("&H" + Hex(k5) Xor &HA0B9C8D7)
    Text9.Text = Crypt(mKEY5)
    If Text4.Text = "325" Then
        mSEED1 = Hex("&H" + sd2 Xor &H1199AABB)
        mSEED2 = Hex("&H" + sd1 Xor &H5529DF4E)
        Text10.Text = Crypt(mSEED1)
        Text11.Text = Crypt(mSEED2)
    Else
        mSEED1 = Hex("&H" + sd1 Xor &H1199AABB)
        mSEED2 = Hex("&H" + sd2 Xor &H5529DF4E)
        Text10.Text = Crypt(mSEED1)
        Text11.Text = Crypt(mSEED2)
    End If
    vendorx = Crypt(Text1.Text)
    Text1.Text = vendorx
    
  Else
    Text5.Text = k1
    Text6.Text = k2
    Text7.Text = k3
    Text8.Text = k4
    Text9.Text = Hex(k5)
    If Text4.Text = "325" Then
        Text11.Text = sd1
        Text10.Text = sd2
    Else
        Text10.Text = sd1
        Text11.Text = sd2
    End If
End If


End Sub

Private Sub Command3_Click()
If Text5.Text = "00000000" Then
    MsgBox "Please press generate before", vbCritical, "Error"
    End Sub
End If
filen = FreeFile
Open App.Path + "\TEMPLATE.INI" For Output As #filen
Print #filen, "[Type here the title of the product]"
Print #filen, "Key1=" + Text5.Text
Print #filen, "Key2=" + Text6.Text
Print #filen, "Key3=" + Text7.Text
Print #filen, "Key4=" + Text8.Text
Print #filen, "Key5=" + Text9.Text
Print #filen, "Seed1=" + Text10.Text
Print #filen, "Seed2=" + Text11.Text
Print #filen, "Vendor=" + Text1.Text
Print #filen, "VendorString="
Print #filen, "HostID=ANY"
Print #filen, "Expire=1-jan-0"
Print #filen, "Licenses=0"
Print #filen, "DLLVer=" + Text4.Text
Print #filen, "Behavior=" + Text3.Text
Print #filen, "Checksum=NO"
Print #filen, "Daemon=NO"
Print #filen, "DaemonHost=ANY"
Print #filen, "DaemonIP="
Print #filen, "Special="
Print #filen, "Issuer="
Print #filen, "Feature01=FEATURE Type here the features,Version"
Print #filen, "Info01=Type here the information about this license"
Close #filen
MsgBox "File Save on " + App.Path + "\TEMPLATE.INI", vbInformation, "Saved"
MsgBox "Now you must edit this file and complete the field, then append to current FLEXGEN.INI to use this new keys", vbInformation, "Use"

End Sub

Private Function Crypt(stringa) As String
usci = ""
For r = 1 To Len(stringa)
    a = Asc(Mid(stringa, r, 1)) + 30 + r
    usci = usci + Chr(a)
Next r
Crypt = usci
End Function

Private Sub Form_Load()

End Sub
