# Define file path
$filePath = "GameAssembly.dll"
# Define byte patterns and replacements
$patterns = @(
[byte[]](0x8B, 0xCE, 0xE8, 0xA9, 0x19, 0xE7, 0xFF, 0x84, 0xC0, 0x0F, 0x85, 0x4D, 0x01, 0x00, 0x00, 0x48),
[byte[]](0x8B, 0xCE, 0xE8, 0xB9, 0x93, 0x01, 0x00, 0x84, 0xC0, 0x75, 0x0D, 0xFF, 0xC3, 0xEB, 0x88, 0x48),
[byte[]](0xCE, 0xFF, 0x33, 0xC9, 0xE8, 0xC7, 0x8C, 0x11, 0x01, 0x84, 0xC0, 0x0F, 0x84, 0xA8, 0x02, 0x00)
)
$replacements = @(
[byte[]](0x8B, 0xCE, 0xB0, 0x01, 0x90, 0x90, 0x90, 0x84, 0xC0, 0x0F, 0x85, 0x4D, 0x01, 0x00, 0x00, 0x48),
[byte[]](0x8B, 0xCE, 0xB0, 0x01, 0x90, 0x90, 0x90, 0x84, 0xC0, 0x75, 0x0D, 0xFF, 0xC3, 0xEB, 0x88, 0x48),
[byte[]](0xCE, 0xFF, 0x33, 0xC9, 0xB0, 0x01, 0x90, 0x90, 0x90, 0x84, 0xC0, 0x0F, 0x84, 0xA8, 0x02, 0x00)
)
# Check if file exists
if (-Not (Test-Path -Path $filePath)) {
Write-Output "$filePath not found."
exit
}
# Read the file as bytes
$fileBytes = [System.IO.File]::ReadAllBytes($filePath)
$totalBytes = $fileBytes.Length
$patternFound = 0
# Convert byte array to string for faster searching
$fileString = [System.BitConverter]::ToString($fileBytes) -replace "-", " "
# Process each pattern
for ($k = 0; $k -lt $patterns.Length; $k++) {
$patternString = [System.BitConverter]::ToString($patterns[$k]) -replace "-", " "
$replacementString = [System.BitConverter]::ToString($replacements[$k]) -replace "-", " "
# Replace pattern in the string (much faster than byte-by-byte iteration)
if ($fileString -match [regex]::Escape($patternString)) {
$patternFound++
$fileString = $fileString -replace [regex]::Escape($patternString), $replacementString
}
}
# Check if all patterns were found
if ($patternFound -lt $patterns.Length) {
Write-Output "Operation canceled: one or more patterns not found."
exit
}
# Convert back to byte array
$fileBytes = [byte[]]::new($fileString.Length / 3)
$hexPairs = $fileString -split " "
for ($i = 0; $i -lt $hexPairs.Length; $i++) {
$fileBytes[$i] = [Convert]::ToByte($hexPairs[$i], 16)
}
# Write modified bytes back to file
[System.IO.File]::WriteAllBytes($filePath, $fileBytes)
Write-Output "Patterns successfully replaced."