万用特征码文件补丁器
程序目的:
程序启动后,默认加载config.prg
,
窗体老虎上,
通过鼠标右键
,可以选择更改配置文件config.prg
,为各种文件进行补丁。
通过鼠标左键
,即可选择目标文件,根据配置文件的特征码修改原文件,达到修改原文件的补丁功能!
有了 此编译程序 !!只要发布或下载 ,获得相应补丁配置文件 config.prg ,即可 对相应文件进行修改补丁 !! |
---|
万用特征码程序补丁器的配置文件config.prg
,可以设置任何目标文件,
第一行为目标文件文件名,
第二行为目标文件版本,
以下其它行,每二行十六进制码
为对应的原始码
与补丁码
。
必须保证特征码的唯一性!!才能保证程序修改正确!!特征码十六进制码空格必须有且只能一个!!
例如config.prg
文件内容如下:
某程序
R1 V11.2.160.168
8B D8 48 85 C0 75 08 8D 43 FF
31 C0 90 90 90 90 90 90 90 90
80 7F 60 00 74 10 45 33 C0 48 8B 57 58 48 8B 4D 98 E8 4F 1C 4F
80 7F 60 00 EB 10 45 33 C0 48 8B 57 58 48 8B 4D 98 E8 4F 1C 4F
04 00 00 85 C0 74 07 BB 01 00 00 00
04 00 00 85 C0 74 00 BB 01 00 00 00
0F B6 C0 85 C0 74 56
0F B6 C0 85 C0 74 00
F3 FF FF 83 F8 FF 75
F3 FF FF 83 F8 FF EB
48 01 00 00 C1 92 35 7C
00 00 10 00 C1 92 35 7C
VB.net代码如下:
Imports System.IO
Imports System.Text
Public Class Form1
Dim TargetFileName As String '目标文件名
Dim TargetFilePathName As String '目标完整文件名
Dim OpenFileDialog1 As New OpenFileDialog '声明打开对话框
Dim SourceHex() As String '原始特征码
Dim PatchHex() As String '补丁特征码
Dim ConfBool As Boolean '是否有配置文件
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim ConfigFile = Application.StartupPath & "\config.prg" '目标特征码配置文件
OpenConfigFile(ConfigFile)
End Sub
Private Sub Form1_MouseClick(sender As Object, e As MouseEventArgs) Handles Me.MouseClick
If e.Button = MouseButtons.Left Then
'鼠标左键对目标文件进行补丁
If Not ConfBool Then Exit Sub
With OpenFileDialog1 '定义打开对话框属性
.Filter = "可执行文件(*.exe)|*.exe|库文件(*.dll)|*.dll|所有文件(*.*)|*.*"
.FilterIndex = 1
.Title = "打开目标文件"
.FileName = TargetFileName
.InitialDirectory = My.Computer.FileSystem.CurrentDirectory '首选当前目录
End With
If OpenFileDialog1.ShowDialog = DialogResult.OK Then
Try
TargetFilePathName = OpenFileDialog1.FileName '完整目标文件名
Dim Pos As Integer = InStrRev(TargetFilePathName, ".") - 1
Dim BakFilePathName As String = Mid(TargetFilePathName, 1, Pos) & "-Bak" & Mid(TargetFilePathName, Pos + 1) '完整备份文件名
Dim FSData() As Byte = File.ReadAllBytes(TargetFilePathName) '目标文件读入字节数组
Rename(TargetFilePathName, BakFilePathName) '目标文件改名备份
Dim PatchNum As Integer = SourceHex.Length - 1 '补丁个数
Dim SourceByte() As Byte '原始特征码字节数组
Dim PatchByte() As Byte '补丁特征码字节数组
For i As Integer = 1 To PatchNum
Dim HexStr() As String = Split(SourceHex(i), " ") '将十六进制特征码按空格拆分为字符串数组
Dim HexNum As Integer = HexStr.Length - 1 '字符串数组个数
ReDim Preserve SourceByte(HexNum)
ReDim Preserve PatchByte(HexNum)
For j As Integer = 0 To HexNum
SourceByte(j) = CByte("&H" & HexStr(j)) '原始特征码转换为字节数组
Next
HexStr = Split(PatchHex(i), " ") '将补丁的十六进制特征码按空格拆分为字符串数组
For k As Integer = 0 To HexNum
PatchByte(k) = CByte("&H" & HexStr(k)) '补丁特征码转换为字节数组
Next
Dim Index As Integer = IndexOf(FSData, SourceByte) '检索原始特征码在程序中的索引位置
If Index <> -1 Then '特征码匹配
Dim P As Integer = 0
Dim Indexs As Integer = Index + PatchByte.Length - 1
For m As Integer = Index To Indexs
FSData(m) = PatchByte(P) '替换特征码
P += 1
Next
End If
Next
File.WriteAllBytes(TargetFilePathName, FSData)
MessageBox.Show("完成程序补丁!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch ex As Exception
MessageBox.Show("配置文件中错误:" & vbCrLf & "1、原始特征码和补丁特征码不匹配,不符合设定!" & vbCrLf & "2、特征码十六进制空格或位数不符合设定!" & vbCrLf & vbCrLf & ex.StackTrace, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
ElseIf e.Button = MouseButtons.Middle Then
AboutBox.Show()
ElseIf e.Button = MouseButtons.Right Then
'鼠标右键打开或更改配置文件
With OpenFileDialog1 '定义打开对话框属性
.Filter = "目标配置文件(*.prg)|*.prg"
.FilterIndex = 1
.Title = "更改目标配置文件"
.InitialDirectory = My.Computer.FileSystem.CurrentDirectory '首选当前目录
End With
If OpenFileDialog1.ShowDialog = DialogResult.OK Then
Dim TargetFilePathName = OpenFileDialog1.FileName
OpenConfigFile(TargetFilePathName)
End If
End If
End Sub
''' <summary>打开或更改配置文件</summary>
''' <param name="ConfigFilePathName">配置文件含完整目录全称</param>
Private Sub OpenConfigFile(ByVal ConfigFilePathName As String)
If File.Exists(ConfigFilePathName) Then
Try
Dim TargetFile As New StreamReader(ConfigFilePathName, Encoding.UTF8)
Dim i As Integer = 0
SourceHex = Nothing
PatchHex = Nothing
Do While TargetFile.Peek() > 0
ReDim Preserve SourceHex(i)
ReDim Preserve PatchHex(i)
SourceHex(i) = TargetFile.ReadLine '读行
PatchHex(i) = TargetFile.ReadLine
i += 1
Loop
TargetFile.Dispose() '注销文件流
TargetFileName = SourceHex(0) '目标文件名
Dim TargetFileVer As String = PatchHex(0) '目标版本
Me.Text = "万用特征码补丁器 [" + TargetFileName + " " + TargetFileVer + "]"
ConfBool = True
Catch ex As Exception
ConfBool = False
MessageBox.Show("配置文件错误:" & vbCrLf & "配置文件非法或不符合设定!" & vbCrLf & vbCrLf & ex.StackTrace, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Else
Me.Text = "万用特征码补丁器 [无配置文件 Config.prg]"
ConfBool = False
End If
End Sub
程序编译后,进程、经过测试,已经完美可靠实用,补丁运行速度快!
编译程序已经上传,压缩包含完整 VB.NET 源代码和编译程序,在下面链接下载
: