aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Kramkowski <tomasz@kramkow.ski>2026-11-06 19:35:13 +0000
committerTomasz Kramkowski <tomasz@kramkow.ski>2026-11-06 19:35:13 +0000
commit9c15f1058d54fcfbf6aba7ca6c1296e22c31c15f (patch)
treeac6d9c8fea881bf40e72a8c504847ad191c39f70
parentb84e767012fd6c9a47ff140a1616c25dfde3dc70 (diff)
downloadsteamvr-patches-9c15f1058d54fcfbf6aba7ca6c1296e22c31c15f.tar.gz
steamvr-patches-9c15f1058d54fcfbf6aba7ca6c1296e22c31c15f.tar.xz
steamvr-patches-9c15f1058d54fcfbf6aba7ca6c1296e22c31c15f.zip
de-"obfuscate" the generator...
Literally a waste of my time.
-rw-r--r--src/steamvr_patches/__init__.py27
-rw-r--r--src/steamvr_patches/template.py11
2 files changed, 23 insertions, 15 deletions
diff --git a/src/steamvr_patches/__init__.py b/src/steamvr_patches/__init__.py
index be3b696..8ad589a 100644
--- a/src/steamvr_patches/__init__.py
+++ b/src/steamvr_patches/__init__.py
@@ -6,13 +6,10 @@ import hashlib
import sys
import tempfile
import tomllib
-from base64 import b85encode
from importlib.resources import files
from io import BytesIO
-from json import dumps
from pathlib import Path
from typing import Annotated, BinaryIO, Self
-from zlib import compress
from pydantic import BaseModel, ConfigDict, Field, field_validator
@@ -95,9 +92,27 @@ def render(patches: dict[str, dict]) -> str:
placeholder = "PATCH_DATA = {}"
if template.count(placeholder) != 1:
raise ValueError("missing or duplicate runtime patch-table placeholder")
- data = dumps(patches, default=bytes.hex, separators=(",", ":")).encode()
- encoded = b85encode(compress(data, level=9))
- return template.replace(placeholder, f"PATCH_DATA = decode_patch_data({encoded!r})")
+ lines = ["PATCH_DATA = {"]
+ for path, patch in patches.items():
+ lines.append(f" {path!r}: {{")
+ for key in ("original_hash", "patched_hash"):
+ lines.append(f' "{key}": "{patch[key].hex()}",')
+ lines.append(' "edits": [')
+ for offset, replacement in patch["edits"]:
+ data = replacement.hex()
+ line = f' ({offset:#x}, "{data}"),'
+ if len(line) <= 88:
+ lines.append(line)
+ else:
+ lines.extend([" (", f" {offset:#x},"])
+ lines.extend(
+ f' "{data[start : start + 64]}"'
+ for start in range(0, len(data), 64)
+ )
+ lines.append(" ),")
+ lines.extend([" ],", " },"])
+ lines.append("}")
+ return template.replace(placeholder, "\n".join(lines))
def generate(patch_data: Path, input_root: Path) -> str:
diff --git a/src/steamvr_patches/template.py b/src/steamvr_patches/template.py
index 4f88b10..2af1422 100644
--- a/src/steamvr_patches/template.py
+++ b/src/steamvr_patches/template.py
@@ -29,12 +29,9 @@ import stat
import subprocess
import sys
import tempfile
-from base64 import b85decode
from dataclasses import dataclass
from io import BytesIO
-from json import loads as json_loads
from pathlib import Path
-from zlib import decompress
NAME = Path(__file__).name
MARKER = b"Valve, please fix."
@@ -84,12 +81,8 @@ class Patch:
raise ValueError("patched file checksum mismatch")
return patched + MARKER
-
-def decode_patch_data(data: bytes) -> dict:
- return json_loads(decompress(b85decode(data)))
-
-
-# Just to keep the file small, not for obfuscation.
+# Please refer to the source code (linked at the top of this file) if you want
+# to know how this data was generated
PATCH_DATA = {}
PATCHES: dict[str, Patch] = {
path: Patch.from_dict(data) for path, data in PATCH_DATA.items()