0% found this document useful (0 votes)
118 views4 pages

Source Code

The document is a Visual Basic .NET program that patches a locked BIOS file by searching for specific patterns and replacing them with new byte values. It provides usage instructions, reads the specified file, checks for Intel signatures, and replaces patterns if found, saving the modified file. The program also includes error handling and user prompts throughout its execution.

Uploaded by

alrpoint0004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
118 views4 pages

Source Code

The document is a Visual Basic .NET program that patches a locked BIOS file by searching for specific patterns and replacing them with new byte values. It provides usage instructions, reads the specified file, checks for Intel signatures, and replaces patterns if found, saving the modified file. The program also includes error handling and user prompts throughout its execution.

Uploaded by

alrpoint0004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Imports System.

Globalization
Imports [Link]
Imports [Link]

Namespace Module8FC8
Public Module Module8FC8
Public Function Main(ByVal args As String()) As Integer
Dim matchFound = False
' If no argument is provided then print usage hint
If [Link] < 1 Then
[Link]("Rex98-8FC8-Patcher" + vbCrLf + "Usage:
Rex_8FC8_patcher.exe <locked [Link]>")
[Link]($"{[Link]}Press any key to exit...")
[Link](True)
Return -1
End If

[Link] = "Rex98-8FC8-Patcher"
[Link] = [Link]
[Link]("Badcaps **Dell-8FC8-Patcher**")
[Link]("@Rex98" + vbCrLf)
[Link](1000)

[Link] = [Link]
[Link]("Pag huwat ky ga patch pa!...in file " + args(0))
' Read the provided file
Dim bytes = [Link](args(0))
' Extract the file name for saving later
Dim filename As String = [Link](args(0))

Dim signo As String = "5AA5F00F03"


Dim findsigno As Byte() = ConvertHexStringToByteArray(signo)

For Each index In SignoAt(bytes, findsigno)


Dim i = index, findIndex = 0
While i < [Link] AndAlso findIndex < [Link]
bytes(i) = findsigno(findIndex)
i += 1
findIndex += 1
End While
[Link] = [Link]
[Link](vbCrLf + "nakit-an ang intel signature sa offset
0x{0:X}", index)
matchFound = True
Next
If matchFound Then
' Nothing to do/save just clear the matchFound flag
matchFound = False
Else
' Probably corrupted or not BIOS dump ( EC dump?...)
[Link] = [Link]
[Link](vbCrLf + "wa nakit-an ang intel signature" +
vbCrLf)
[Link] = [Link]
[Link]($"{[Link]}Pinduta bisan unsang key para
ma exit...")
[Link](True)
Return -1
End If
[Link] = [Link]
[Link](vbCrLf + "Ga check sa unang pattern..." + vbCrLf)
' Match 00FCAA and after that any 2 hexadecimal characters and after
that match 00000000 and after that any 2 ore more hexadecimal characters
Dim firstpattern As String = "^00FCAA([0-9A-Fa-f]{2,4})000000([0-9A-Fa-
f]{2,})$"
' Characters to be replaced
Dim firstrbytes As String = "00FC00"
' Because we have read the file binary(hexadecimal) must convert to
byte array for replace a byte(one character) at once
Dim replacefirst As Byte() = ConvertHexStringToByteArray(firstrbytes)
' Search for offset beginning with the pattern 00FCAA
For Each index In PatternAt(bytes, firstpattern)
Dim i = index, replaceIndex = 0
' Replace first 6 characters with 00FC00 at offset = index
While i < [Link] AndAlso replaceIndex < [Link]
bytes(i) = replacefirst(replaceIndex)
i += 1
replaceIndex += 1
End While
' Print the result...if any...
[Link] = [Link]
[Link]("nakit-an ang pattern sa offset {0:X} og
giilisan.", index)
matchFound = True
Next

If matchFound Then
Try ' Write first pattern findings to file
[Link]("patched_" & filename, bytes)
matchFound = False
Catch ex As Exception
[Link](ex)
[Link]($"{[Link]}Pinduta bisan unsang key
para ma exit...")
[Link](True)
Return -1
End Try
Else
[Link] = [Link]
[Link](vbCrLf + "Wa nakita ang unang patern" + vbCrLf)
End If

[Link] = [Link]
[Link](vbCrLf + "Kalma hapit na!..." + vbCrLf)

Dim secondpattern As String = "^00FDAA([0-9A-Fa-f]{2,4})000000([0-9A-


Fa-f]{2,})$"
Dim secondrbytes As String = "00FD00"
Dim replacesecond As Byte() = ConvertHexStringToByteArray(secondrbytes)

For Each index In PatternAt(bytes, secondpattern)


Dim i = index, replaceIndex = 0

While i < [Link] AndAlso replaceIndex < [Link]


bytes(i) = replacesecond(replaceIndex)
i += 1
replaceIndex += 1
End While
[Link] = [Link]
[Link]("nakit-an ang pattern sa offset {0:X} og
giilisan.", index)
matchFound = True
Next

If matchFound Then
Try
[Link]("patched_" & filename, bytes)
Catch ex As Exception
[Link](ex)
[Link]($"{[Link]}Pinduta bisan unsang key
para ma exit...")
[Link](True)
Return -1
End Try
[Link] = [Link]
[Link](vbCrLf + vbCrLf + "na patched og gi saved as
patched_" + filename + vbCrLf + vbCrLf + "Don't Forget to say Thanks to Rex98 &
Techshack Cebu for this freeware.")
[Link] = [Link]
[Link](vbCrLf + "My Telegram channel link:")
[Link] = [Link]
[Link](vbCrLf + "[Link]
[Link] = [Link]

[Link](vbCrLf + "Buy me a Coffe")


[Link] = [Link]
[Link](vbCrLf + "[Link]
country.x=PH&locale.x=en_US")
[Link](vbCrLf + "Gcash: 09633813409")

[Link] = [Link]
[Link]($"{[Link]}Pinduta bisan unsang key para
ma exit...")
[Link](True)
Return 0
Else
[Link] = [Link]
[Link](vbCrLf + "wa na patch...ky wa makita ang pattern"
+ vbCrLf)
[Link] = [Link]
[Link]($"{[Link]}Pinduta bisan unsang key para
ma exit...")
[Link](True)
Return -1
End If

End Function

' Returns the offset where the searched pattern is found in source string
Private Iterator Function PatternAt(ByVal source As Byte(), ByVal pattern
As String) As IEnumerable(Of Integer)
Dim regex As New Regex(pattern)
For i = 0 To [Link] - 1
Dim source1 As Byte() =
[Link](i).Take([Link]).ToArray()
If [Link](ByteArrayToString(source1)) Then
Yield i
End If
If i >= &H160000 Then Exit For
Next
End Function

' Returns the offset where the Intel signature is found in source string
Private Iterator Function SignoAt(ByVal source As Byte(), ByVal pattern As
Byte()) As IEnumerable(Of Integer)
For i = 0 To [Link] - 1
If [Link](i).Take([Link]).SequenceEqual(pattern) Then
Yield i
End If
If i >= &H1000 Then Exit For
Next
End Function

Private Function ConvertHexStringToByteArray(ByVal hexString As String) As


Byte()
If [Link] Mod 2 <> 0 Then
Throw New
ArgumentException([Link]([Link], "The binary key
cannot have an odd number of digits: {0}", hexString))
End If

Dim data = New Byte([Link] / 2 - 1) {}


For index = 0 To [Link] - 1
Dim byteValue = [Link](index * 2, 2)
data(index) = [Link](byteValue, [Link],
[Link])
Next

Return data
End Function

Private Function ByteArrayToString(byteArray As Byte()) As String


Return [Link](byteArray).Replace("-", "")
End Function

End Module
End Namespace

You might also like