zackmark29
Active member
- Joined
- Apr 21, 2020
- Messages
- 28
- Programming Experience
- Beginner
Hi everyone.
I would like to ask how to patch multiple bytes?
I have source code here
It's working actually but my problem is, when I try to patch multiple bytes nothing is happening.
Like in the given code,
When I try to split and patch this first pattern of bytes, Nothing is happening
Private Shared ReadOnly FindHex As Byte() = New Byte() {&H31, &H35}
Private Shared ReadOnly ReplaceHex As Byte() = New Byte() {&H4C, &H6D}
But if this first 2nd pattern of bytes, it worked
Private Shared ReadOnly FindHex2 As Byte() = New Byte() {&H83, &HE0, &HF, &H83, &HC0, &HF}
Private Shared ReadOnly ReplaceHex2 As Byte() = New Byte() {&HB8, &HFF, &HFF, &HFF, &H7F, &H90}
I would like to ask how to patch multiple bytes?
I have source code here
It's working actually but my problem is, when I try to patch multiple bytes nothing is happening.
Like in the given code,
When I try to split and patch this first pattern of bytes, Nothing is happening
Private Shared ReadOnly FindHex As Byte() = New Byte() {&H31, &H35}
Private Shared ReadOnly ReplaceHex As Byte() = New Byte() {&H4C, &H6D}
But if this first 2nd pattern of bytes, it worked
Private Shared ReadOnly FindHex2 As Byte() = New Byte() {&H83, &HE0, &HF, &H83, &HC0, &HF}
Private Shared ReadOnly ReplaceHex2 As Byte() = New Byte() {&HB8, &HFF, &HFF, &HFF, &H7F, &H90}
VB.NET:
Imports System.Runtime.CompilerServices
Imports System.IO
Public Class Form1
Private Shared ReadOnly FindHex As Byte() = New Byte() {&H31, &H35}
Private Shared ReadOnly ReplaceHex As Byte() = New Byte() {&H4C, &H6D}
Private Shared ReadOnly FindHex2 As Byte() = New Byte() {&H83, &HE0, &HF, &H83, &HC0, &HF}
Private Shared ReadOnly ReplaceHex2 As Byte() = New Byte() {&HB8, &HFF, &HFF, &HFF, &H7F, &H90}
<MethodImpl(MethodImplOptions.NoInlining)> Private Shared Function DP(sequence As Byte(), position As String) As Boolean
If position + FindHex.Length > sequence.Length Then
Return False
End If
For i As Integer = 0 To FindHex.Length - 1
If FindHex(i) <> sequence(position + i) Then
Return False
End If
Next
Return True
End Function
<MethodImpl(MethodImplOptions.NoInlining)> Private Shared Function DP2(sequence As Byte(), position As Integer) As Boolean
If position + FindHex2.Length > sequence.Length Then
Return False
End If
For i As Integer = 0 To FindHex2.Length - 1
If FindHex2(i) <> sequence(position + i) Then
Return False
End If
Next
Return True
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim DT As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
Dim FD As Byte() = File.ReadAllBytes(DT & "\IDMCRACK\ORIGINAL.exe")
For F As Integer = 0 To FD.Length - 1
If Not DP(FD, F) Then
Continue For
End If
For R As Integer = 0 To FindHex.Length - 1
FD(F + R) = ReplaceHex(R)
Next
Next
For F As Integer = 0 To FD.Length - 1
If Not DP2(FD, F) Then
Continue For
End If
For R As Integer = 0 To FindHex2.Length - 1
FD(F + R) = ReplaceHex2(R)
Next
Next
If System.IO.File.Exists(DT & "\IDMCRACK\ORIGINAL.exe") Then
System.IO.File.Move(DT & "\IDMCRACK\ORIGINAL.exe", DT & "\IDMCRACK\ORIGINAL_BAK.exe")
File.WriteAllBytes(DT & "\IDMCRACK\ORIGINAL_PATCHED.exe", FD)
Else
'Write Other Codes
End If
End Sub
End Class