Created
October 5, 2024 16:13
-
-
Save mgedmin/0eb041267cd92b975b81667849f87f32 to your computer and use it in GitHub Desktop.
A rewrite of https://bpa.st/GBRPM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import pathlib | |
import sys | |
old_bytes = bytes([0x80, 0x79, 0x05, 0x00, 0x0f, 0x94, 0xc2]) | |
new_bytes = bytes([0xc6, 0x41, 0x05, 0x01, 0xb2, 0x00, 0x90]) | |
def main(): | |
parser = argparse.ArgumentParser(description="sublime text patcher") | |
parser.add_argument("filename", help="path to sublime text binary") | |
args = parser.parse_args() | |
path = pathlib.Path(args.filename) | |
try: | |
buffer = path.read_bytes() | |
except IOError as e: | |
sys.exit(f"error: failed to open file: {e}") | |
if old_bytes not in buffer: | |
sys.exit('error: byte sequence not found') | |
buffer = buffer.replace(old_bytes, new_bytes) | |
path.rename(path.with_suffix('.orig')) | |
path.write_bytes(buffer) | |
print(f"{path} patched successfully!") | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment