Skip to content

Instantly share code, notes, and snippets.

@101arrowz
Last active December 13, 2025 06:00
Show Gist options
  • Select an option

  • Save 101arrowz/c5ab74bf5b41fd803dcc553d9bb87e9c to your computer and use it in GitHub Desktop.

Select an option

Save 101arrowz/c5ab74bf5b41fd803dcc553d9bb87e9c to your computer and use it in GitHub Desktop.
Hollow Knight aspect ratio patch

This is a script that patches Hollow Knight to play without black borders in arbitrary aspect ratios (16:10, 21:9, 32:9, or even more exotic ones). It uses handcrafted .NET bytecode to support any aspect ratio out of the box; it doesn't need to be modified for any particular monitor. It works on all platforms (Mac, Windows, Linux), and shouldn't conflict with any other settings or modifications. You can still play in windowed, fullscreen, or borderless mode with this modification.

If you're not able to run the script, you can apply the patch manually. See the "patches" variable in the code, which provides the start and end byte offsets for the necessary modifications, as well as the hex you should paste into the region from the start to end offset (inclusive). If you are using an unmodified installation, the original data in that region should be what is called "current" in the code, and you should overwrite it with the "patch" data in the code.

#!/usr/bin/env python
import os
import sys
import shutil
patches = [{
"start": 0x13bf0,
"end": 0x13cfe,
"current": "282003000a6b282103000a6b5b22398ee33f5b0a220000803f027b75030004580b027b710300046f4a1400067b4c1b00040c06220000803f34541202220000803f075a286403000a120206075a286503000a220000803f1202282002000a5922000000405b0d120209286603000a220000803f1202282102000a5922000000405b130412021104286703000a2b5e220000803f065b130512021105075a286403000a1202220000803f075a286503000a220000803f1202282002000a5922000000405b130612021106286603000a220000803f1202282102000a5922000000405b130712021107286703000a027b710300046f4a140006087d4c1b0004027b72030004086f6803000a22398ee33f2a",
"patch": "282003000a6b282103000a6b5b0a220000803f027b75030004580b027b710300046f4a1400067b4c1b00040c120207286403000a120207286503000a220000803f075922000000405b0d120209286603000a120209286703000a027b710300046f4a140006087d4c1b0004027b72030004086f6803000a062a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
}, {
"start": 0x13d7c,
"end": 0x13e6f,
"current": "282003000a6b282103000a6b5b22398ee33f5b0a220000803f027b7b030004580b027b770300046f6903000a0c06220000803f34541202220000803f075a286403000a120206075a286503000a220000803f1202282002000a5922000000405b0d120209286603000a220000803f1202282102000a5922000000405b130412021104286703000a2b5e220000803f065b130512021105075a286403000a1202220000803f075a286503000a220000803f1202282002000a5922000000405b130612021106286603000a220000803f1202282102000a5922000000405b130712021107286703000a027b77030004086f6803000a2a",
"patch": "220000803f027b7b030004580b027b770300046f6903000a0c120207286403000a120207286503000a220000803f075922000000405b0d120209286603000a120209286703000a027b77030004086f6803000a2a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
}]
if len(sys.argv) > 1:
hk_path = sys.argv[1]
else:
hk_path = input("Enter the path to your Hollow Knight installation's Assembly-CSharp.dll file (e.g. C:\\Program Files (x86)\\Steam\\steamapps\\common\\Hollow Knight\\hollow_knight_Data\\Managed\\Assembly-CSharp.dll): ")
if not os.path.exists(hk_path):
print("Path " + hk_path + " does not exist", file=sys.stderr)
sys.exit(1)
with open(hk_path, "r+b") as f:
for patch in patches:
f.seek(patch["start"])
data = f.read(patch["end"] - patch["start"] + 1)
if data != bytes.fromhex(patch["current"]):
print("Provided DLL mismatches expected byte sequence, please use a clean installation", file=sys.stderr)
sys.exit(1)
shutil.copy2(hk_path, hk_path + ".bak")
for patch in patches:
f.seek(patch["start"])
f.write(bytes.fromhex(patch["patch"]))
print("Aspect ratio patch applied successfully; relaunch your game")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment