Find all our projects in development below.
All source code is GNU General Public License (GPL)
Browsing MainForm.frm (9.64 KB)
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form MainForm
BorderStyle = 1 'Fixed Single
Caption = "Executable Info Editor"
ClientHeight = 3990
ClientLeft = 45
ClientTop = 330
ClientWidth = 4815
Icon = "MainForm.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 3990
ScaleWidth = 4815
StartUpPosition = 2 'CenterScreen
Begin VB.CheckBox Check1
Caption = "Use Reverse Info Table R/W"
Height = 375
Left = 120
TabIndex = 9
Top = 3480
Width = 1455
End
Begin VB.CommandButton Command4
Caption = "&Binary Swap"
Enabled = 0 'False
Height = 375
Left = 3240
TabIndex = 2
Top = 3000
Width = 1455
End
Begin VB.CommandButton Command5
Caption = "&Quit"
Height = 375
Left = 3240
TabIndex = 4
Top = 3480
Width = 1455
End
Begin VB.CommandButton Command3
Caption = "&About"
Height = 375
Left = 1680
TabIndex = 3
Top = 3480
Width = 1455
End
Begin VB.CommandButton Command2
Caption = "&Save Exe"
Enabled = 0 'False
Height = 375
Left = 1680
TabIndex = 1
Top = 3000
Width = 1455
End
Begin VB.CommandButton Command1
Caption = "&Open Exe"
Default = -1 'True
Height = 375
Left = 120
TabIndex = 0
Top = 3000
Width = 1455
End
Begin VB.TextBox Text1
Enabled = 0 'False
Height = 2400
Left = 2280
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 8
Top = 360
Width = 2415
End
Begin VB.ListBox List1
Enabled = 0 'False
Height = 2400
ItemData = "MainForm.frx":0442
Left = 120
List = "MainForm.frx":0467
TabIndex = 6
Top = 360
Width = 2055
End
Begin MSComDlg.CommonDialog CommonDialog1
Left = 0
Top = 2760
_ExtentX = 847
_ExtentY = 847
_Version = 393216
CancelError = -1 'True
DefaultExt = "exe"
Filter = "Program Files (*.exe)|*.exe|Dynamic-Link Libraries (*.dll)|*.dll|All Files (*.*)|*.*"
End
Begin VB.Label Label2
Caption = "&Value:"
Height = 255
Left = 2280
TabIndex = 7
Top = 120
Width = 495
End
Begin VB.Label Label1
Caption = "&Item name:"
Height = 255
Left = 120
TabIndex = 5
Top = 120
Width = 855
End
End
Attribute VB_Name = "MainForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim Ver As String
Dim FileBuffer As String
Dim FileInfo(10) As String
Dim OldFileInfo(10) As String
Private Const GRAY = &H8000000F
Private Const WHITE = &H80000005
Function CheckForSpecialChars(ByVal Str As String) As String
Dim i As Long
Dim x As Integer
i = InStr(Str, "$CHR(")
Do While i > 0
If InStr(i + 5, Str, ")$") Then
x = Val(Mid(Str, i + 5, InStr(i + 5, Str, ")$") - i - 5))
Str = Replace(Str, Mid(Str, i, InStr(i + 1, Str, ")$") - i + 2), Chr(x), , 1)
End If
i = InStr(Str, "$CHR(")
Loop
CheckForSpecialChars = Str
End Function
Sub DeleteFile(File As String)
On Error Resume Next
Kill File
End Sub
Function SetExeItemValue(ByVal fBuffer As String, ByVal ItemName As String, ByVal ItemValue As String, Optional bUseRev As Boolean) As String
Dim RawItemName As String
Dim RawItemValue As String
Dim ValStart As Variant
Dim ValEnd As Variant
Dim i As Variant
For i = 1 To Len(ItemName)
RawItemName = RawItemName + Mid(ItemName, i, 1) + Chr(0)
Next i
For i = 1 To Len(ItemValue)
RawItemValue = RawItemValue + Mid(ItemValue, i, 1) + Chr(0)
Next i
If InStr(fBuffer, RawItemName) > 0 Then
If bUseRev Then
ValStart = InStrRev(fBuffer, RawItemName) + Len(RawItemName) + 1
Else
ValStart = InStr(fBuffer, RawItemName) + Len(RawItemName) + 1
End If
For ValStart = ValStart To Len(fBuffer)
If Mid(fBuffer, ValStart, 1) <> Chr(0) Then Exit For
Next ValStart
ValEnd = InStr(ValStart + 1, fBuffer, String(2, Chr(0))) + 1
fBuffer = Left(fBuffer, ValStart - 1) + RawItemValue + Mid(fBuffer, ValEnd)
End If
SetExeItemValue = fBuffer
End Function
Function GetExeItemValue(ByVal fBuffer As String, ByVal ItemName As String, Optional bUseRev As Boolean) As String
Dim RawItemName As String
Dim ItemValue As String
Dim ValStart As Variant
Dim ValLength As Variant
Dim i As Variant
For i = 1 To Len(ItemName)
RawItemName = RawItemName + Mid(ItemName, i, 1) + Chr(0)
Next i
If InStr(fBuffer, RawItemName) > 0 Then
If bUseRev Then
ValStart = InStrRev(fBuffer, RawItemName) + Len(RawItemName) + 1
Else
ValStart = InStr(fBuffer, RawItemName) + Len(RawItemName) + 1
End If
For ValStart = ValStart To Len(fBuffer)
If Mid(fBuffer, ValStart, 1) <> Chr(0) Then Exit For
Next ValStart
ValLength = InStr(ValStart + 1, fBuffer, String(2, Chr(0))) - ValStart
ItemValue = Replace(Mid(fBuffer, ValStart, ValLength), Chr(0), "")
GetExeItemValue = ItemValue
Else
GetExeItemValue = ""
End If
End Function
Private Sub Command1_Click()
On Error GoTo CancelErr
Dim FNum As Integer
Dim i As Variant
FNum = FreeFile
With CommonDialog1
.DialogTitle = "Open Executable"
.ShowOpen
End With
List1.Enabled = False
Text1.Enabled = False
Command2.Enabled = False
Command4.Enabled = False
MousePointer = vbHourglass
Open CommonDialog1.FileName For Binary Access Read As #FNum
FileBuffer = String(LOF(FNum), Chr(0))
Get FNum, , FileBuffer
Close #FNum
For i = 0 To List1.ListCount - 1
FileInfo(i) = GetExeItemValue(FileBuffer, List1.List(i), CBool(Check1.Value))
OldFileInfo(i) = FileInfo(i)
Next i
List1.Enabled = True
Text1.Enabled = True
Command2.Enabled = True
Command4.Enabled = True
List1.SetFocus
List1.ListIndex = 0
CancelErr:
MousePointer = vbDefault
End Sub
Private Sub Command2_Click()
On Error GoTo CancelErr
Dim FNum As Integer
Dim i As Variant
FNum = FreeFile
With CommonDialog1
.DialogTitle = "Save Executable"
.ShowSave
End With
MousePointer = vbHourglass
DeleteFile CommonDialog1.FileName
Open CommonDialog1.FileName For Binary As #FNum
For i = 0 To List1.ListCount - 1
If FileInfo(i) <> "" And FileInfo(i) <> OldFileInfo(i) Then FileBuffer = SetExeItemValue(FileBuffer, List1.List(i), FileInfo(i) + String(Len(OldFileInfo(i)) - Len(FileInfo(i)), Chr(0)), CBool(Check1.Value))
Next i
Put FNum, , FileBuffer
Close #FNum
CancelErr:
MousePointer = vbDefault
End Sub
Private Sub Command3_Click()
MsgBox " Jason's PC Executable Info Editor v" & Ver & vbCrLf & vbCrLf & _
" Created by Jason Java" & vbCrLf & _
" Contact me at jasonspc69@hotmail.com" & vbCrLf & vbCrLf & _
"Copyright � 1999 - 2000 Jason's PC Software", vbOKOnly, "About Executable Info Editor"
End Sub
Private Sub Command4_Click()
Dim Str As String
Dim RStr As String
Dim NewFileBuffer As String
Str = CheckForSpecialChars(InputBox("Enter the string to replace (Special Chars Allowed; Usage: $CHR(x)$): ", "Binary Swap - Step 1"))
If Str = "" Then Exit Sub
RStr = CheckForSpecialChars(InputBox("Enter the replace string (Special Chars Allowed; Usage: $CHR(x)$): ", "Binary Swap - Step 2"))
NewFileBuffer = Replace(FileBuffer, Str, RStr)
If NewFileBuffer <> FileBuffer Then
MsgBox "Binary Swap Successful.", vbExclamation
FileBuffer = NewFileBuffer
Else
MsgBox "Binary Swap Unsuccessful.", vbExclamation
End If
End Sub
Private Sub Command5_Click()
End
End Sub
Private Sub Form_Load()
Ver = App.Major & "." & App.Minor & _
IIf(App.Revision = 0, "", "." & App.Revision)
CommonDialog1.Flags = cdlOFNFileMustExist + cdlOFNOverwritePrompt + cdlOFNLongNames + cdlOFNHideReadOnly
End Sub
Private Sub List1_Click()
If OldFileInfo(List1.ListIndex) = "" Then
Text1.Enabled = False
Text1.BackColor = GRAY
Else
Text1.Enabled = True
Text1.BackColor = WHITE
Text1.MaxLength = Len(OldFileInfo(List1.ListIndex))
End If
Text1.Text = FileInfo(List1.ListIndex)
End Sub
Private Sub Text1_Change()
If Text1.Enabled = True Then FileInfo(List1.ListIndex) = Text1.Text
End Sub