Skip to content

Instantly share code, notes, and snippets.

@evaristorivi
Created May 9, 2021 11:40
Show Gist options
  • Save evaristorivi/9646d9734c244756ed5ee70199723ab8 to your computer and use it in GitHub Desktop.
Save evaristorivi/9646d9734c244756ed5ee70199723ab8 to your computer and use it in GitHub Desktop.
acs_disable_shadows_patcher.go
package main
import (
"crypto/sha256"
"fmt"
"io/ioutil"
"time"
)
const VERSION = "v0.9"
type BinaryInfo struct {
Version string
FunctionOffset int
Orig string
OrigOpcode byte
Patched string
PatchedOpcode byte
}
func checksum(buf []byte) string {
return fmt.Sprintf("%x", sha256.Sum256(buf))
}
func main() {
versions := []BinaryInfo{
BinaryInfo{
Version: "1.14",
FunctionOffset: 0x273e40,
Orig: "b1a22daf22ce49623a2d779b0f224c6381c59c3166b000385127b5bf6522b8e8",
OrigOpcode: 0x48,
Patched: "abb5feccd36f6f1af527a0f135271d88ffc72e1a0cad23aae1d59e35ce4d3f75",
PatchedOpcode: 0xc3,
},
BinaryInfo{
Version: "1.14.1",
FunctionOffset: 0x274290,
Orig: "fb3fe0bb72ddeb98a873b0a3e46efb7c366a4fbe59c3a18baae072eed48388e8",
OrigOpcode: 0x48,
Patched: "5eab91fcdaa0d5d3e55f49010154b98f7b828743df1efa3e7cd6dc137e733482",
PatchedOpcode: 0xc3,
},
BinaryInfo{
Version: "1.14.2",
FunctionOffset: 0x273f90,
Orig: "27b73890099945b9bf597ed28afb322f87f03349d2bd619dab87bbce09e72178",
OrigOpcode: 0x48,
Patched: "164db25ddc7c650e76403b3835eac0304849e7bc6350486df341f8693f991338",
PatchedOpcode: 0xc3,
},
BinaryInfo{
Version: "1.14.3",
FunctionOffset: 0x274530,
Orig: "d7faa332adf9c4b123d0666d9ce0f56e3be06463d84193ba4a03f3216261d85d",
OrigOpcode: 0x48,
Patched: "4e3267c1fb95c896006b8dc357b77438ad70b72cf12490f4b8653d2083640522",
PatchedOpcode: 0xc3,
},
BinaryInfo{
Version: "1.14.4",
FunctionOffset: 0x273ee0,
Orig: "c258a4b22b33fed749e530224b95f2aa8adfdeae2a0c8b894062f2be14010153",
OrigOpcode: 0x48,
Patched: "245e935a356cdc2bb99c6ee007ea76b82bfb78709c8db4da8155db2b80d3d9ca",
PatchedOpcode: 0xc3,
},
BinaryInfo{
Version: "1.15",
FunctionOffset: 0x20bb60,
Orig: "7de3155a014618d6372cd6e309d1cab110cb02b84812f0a7b3adda10f28fa527",
OrigOpcode: 0x48,
Patched: "aa7517e608e84a9575a21c47add8e7fe330a1afad4b800a256a15a56ad0716ea",
PatchedOpcode: 0xc3,
},
BinaryInfo{
Version: "1.15.1",
FunctionOffset: 0x20bb60,
Orig: "0494054b0a4e4010aa4a73ea6a99f1555af888fd81a45f4a272388d9588719b8",
OrigOpcode: 0x48,
Patched: "74b99fa7127baeb7af04bcecf4deeb63dab609dcd26d7d4143be14039603aa1f",
PatchedOpcode: 0xc3,
},
BinaryInfo{
Version: "1.15.2",
FunctionOffset: 0x20bd40,
Orig: "37cea2d7fb63ae85c4452873c0298b6f2dcb11fefbc0c41a7944f31fd825bf6b",
OrigOpcode: 0x48,
Patched: "0a1a4a147e4e50afba5f361040b37f015a2a3752084180e0dad6b8d4e61f497d",
PatchedOpcode: 0xc3,
},
BinaryInfo{
Version: "1.16",
FunctionOffset: 0x20ca20,
Orig: "ddc498ff9b9f8a85b1ab7b803714c5e6483969bf00cb240c0b89f377b985aaa0",
OrigOpcode: 0x48,
Patched: "b2501b16229eb2cbc137a4389b925337e2a62e1143faddad031219ae98815017",
PatchedOpcode: 0xc3,
},
BinaryInfo{
Version: "1.16.1",
FunctionOffset: 0x20ca20,
Orig: "12ff76a2fc02e377cbe2f5e574be8a0abd9b2142f38306dc44c7c431ca9a74b1",
OrigOpcode: 0x48,
Patched: "9fdbf07e9c751069533ff22067d01366acc7c53109454b9f366fb2b4be39b478",
PatchedOpcode: 0xc3,
},
BinaryInfo{
Version: "1.16.2",
FunctionOffset: 0x20ca20,
Orig: "fcbda28dc363b5fdaf26ec02e79d94bd637048b7aa346611e51387646478e398",
OrigOpcode: 0x48,
Patched: "edf87d99a2f4b4d7f9666ed628b6280b1b7672493290033cd266f416ebc61b91",
PatchedOpcode: 0xc3,
},
BinaryInfo{
Version: "1.16.3",
FunctionOffset: 0x20caa0,
Orig: "ff458820f352faf141e6aafb4bdd85e327d45f51054c7950f224f1ad688c7718",
OrigOpcode: 0x48,
Patched: "6d9b2b9a5e465bba979e201c01957bb124d43006d7a82bf8e914f42f7d52f6d5",
PatchedOpcode: 0xc3,
},
BinaryInfo{
Version: "1.16.4",
FunctionOffset: 0x20caa0,
Orig: "7ceb48f70d76de7954e9270947c4827e44eb620eba6a09b8cec9e5291b41b5c9",
OrigOpcode: 0x48,
Patched: "db2ba9c0adab8c45e487577ad064de05e657943ab8b816e6511b664cfed57ea8",
PatchedOpcode: 0xc3,
},
BinaryInfo{
Version: "1.16.4.v2 / Updated on 03-03-2021",
FunctionOffset: 0x20caa0,
Orig: "365b0d25e79a2079b781ecaac2d262e38a92a89e2b0226fb98e64935c1356711",
OrigOpcode: 0x48,
Patched: "a733024be03b4497753e35cdb94be61810a8b5a266af4aa90a0f7a03d2476cce",
PatchedOpcode: 0xc3,
},
BinaryInfo{
Version: "1.16.4.v3 / Updated on 21-04-2021",
FunctionOffset: 0x20caa0,
Orig: "ab2663f7c15d4129929668960989d6f257b549ed0f23ebe8a06b7afdd36bb872",
OrigOpcode: 0x48,
Patched: "0dc06babaf4ba1e2b5da204d37b59b479a36cf9f46e74c1717694b5a16c815fa",
PatchedOpcode: 0xc3,
},
BinaryInfo{
Version: "1.16.4.v4 / Updated on 05-05-2021",
FunctionOffset: 0x20caa0,
Orig: "ed7b4432c0a634483d1640ef54fe22db577e3f20c048b425584e12787f78366a",
OrigOpcode: 0x48,
Patched: "4da51adb6cea10759a69899cf64e0cbb21463cda8f889b26c52e62731f0e9a40",
PatchedOpcode: 0xc3,
},
}
filename := "acs.exe"
buf, err := ioutil.ReadFile(filename)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("== Assetto Corsa Disable Shadows Patcher", VERSION)
current := checksum(buf)
var info BinaryInfo
for _, i := range versions {
if i.Orig == current || i.Patched == current {
info = i
break
}
}
if info.Version == "" {
fmt.Printf("acs.exe version not supported (only ")
for _, i := range versions {
fmt.Printf("[%s] ", i.Version)
}
fmt.Printf("supported)\n")
} else {
switch current {
case info.Orig:
fmt.Printf(" * found original acs.exe (version %s)\n * patching now..\n", info.Version)
buf[info.FunctionOffset] = info.PatchedOpcode
err = ioutil.WriteFile(filename, buf, 0755)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("= successfully patched")
fmt.Println("\nrestart Assetto Corsa and enjoy VR without flickering shadows")
case info.Patched:
fmt.Printf(" * found patched acs.exe (version %s) \n * reverting back to original..\n", info.Version)
buf[info.FunctionOffset] = info.OrigOpcode
err = ioutil.WriteFile(filename, buf, 0755)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("= successfully reverted back to original acs.exe")
fmt.Println("\nrestart Assetto Corsa and Shadows are rendered again")
}
}
time.Sleep(1 * time.Minute)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment