« | August 2025 | » | 日 | 一 | 二 | 三 | 四 | 五 | 六 | | | | | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | | | | | | | |
|
|
[Progam]计算DIABLO2存档文件校验码的工具 |
这两天有够糟糕的,居然不复习在打DIABLO2,而且这么老的游戏了我居然还是能玩的很起劲。我因为加错了技能点打算修改过来,可是现在1.12版的DIABLO居然没有一个可以用的修改器,于是只好重操旧业用文本编辑器修改存档了,可是改完以后发现进入不了游戏,显示"无法进入游戏,一般错误档案",于是分析一下存档文件,经过比较后发现应该是加了checksum,所有就到网上搜以下,真的给我发现有人提到了校验的算法。我觉得她写的不知道是什么语言,于是自己给改成了vb.net的程序,由于不是原创的,我就不写什么case study之类的东西了,原作:evilertoaster,地址是http://evilertoaster.wordpress.com/2008/05/19/diablo-2-111-save-file/,
我的计算器在这里下载:
Diablo2 d2s checksum calculator download:
500)this.width=500'>DiabloChecksum.rar
使用方法:解压后里头有两文件夹,bin下的可以直接运行(需要.net framewokr2.0),选择d2s后即可。另外一个文件夹是原代码,供有兴趣的人继续研究。
代码如下:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim savefile As String Dim dialresult As DialogResult dialresult = OpenFileDialog1.ShowDialog If dialresult <> Windows.Forms.DialogResult.OK Then Exit Sub End If
savefile = OpenFileDialog1.FileName Dim srcbytes() As Byte = File.ReadAllBytes(savefile)
srcbytes(12) = 0 srcbytes(13) = 0 srcbytes(14) = 0 srcbytes(15) = 0
Dim checksum(3) As Integer For Each b As Byte In checksum b = 0 Next
Dim boolcarry, temp As Integer boolcarry = 0 temp = 0 For i As Integer = 0 To srcbytes.Length - 1 temp = srcbytes(i) + boolcarry checksum(0) = checksum(0) * 2 + temp checksum(1) = checksum(1) * 2 If checksum(0) > 255 Then checksum(1) = checksum(1) + (checksum(0) - checksum(0) Mod 256) \ 256 checksum(0) = checksum(0) Mod 256 End If
checksum(2) = checksum(2) * 2 If checksum(1) > 255 Then checksum(2) = checksum(2) + (checksum(1) - checksum(1) Mod 256) \ 256 checksum(1) = checksum(1) Mod 256 End If
checksum(3) = checksum(3) * 2 If checksum(2) > 255 Then checksum(3) = checksum(3) + (checksum(2) - checksum(2) Mod 256) \ 256 checksum(2) = checksum(2) Mod 256 End If
If checksum(3) > 255 Then checksum(3) = checksum(3) Mod 256 End If
If (checksum(3) And 128) <> 0 Then
boolcarry = 1 Else boolcarry = 0 End If
Next
Dim bytes(3) As Byte
Dim j As Integer = 0 For Each i As Integer In checksum bytes(j) = CType(i, Byte) j += 1 Next
TextBox1.Text = String.Format("The sum after modification is:{0:x} {1:x} {2:x} {3:x}", bytes(0), bytes(1), bytes(2), bytes(3))
Dim writefile As FileStream = File.Open(savefile, FileMode.Open) writefile.Seek(12, SeekOrigin.Begin) writefile.Write(bytes, 0, 4) writefile.Flush() writefile.Close()
lblmsg.Text = "Check sum bytes is successfully written." End Sub | |
|
|
|
公告 |
Anybody can contact me through Email:

or through instant message messageing
davidxiem@hotmail.com
Thanks Nexodyne for email icon generation. |
统计 |
blog名称: 日志总数:174 评论数量:98 留言数量:-1 访问次数:530943 建立时间:2007年7月20日 | |