~quf/no-cutscene-kiseki

361ee3bc896d29102557bf823e2168d2eb8d2928 — Lukas Himbert 1 year, 6 months ago 377f514 trunk
hexhex
3 files changed, 48 insertions(+), 22 deletions(-)

M Cargo.lock
M Cargo.toml
M src/patch.rs
M Cargo.lock => Cargo.lock +30 -5
@@ 152,6 152,12 @@ dependencies = [
]

[[package]]
name = "fallible-iterator"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7"

[[package]]
name = "fltk"
version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 191,10 197,29 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"

[[package]]
name = "hex-literal"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46"
name = "hexhex"
version = "1.0.0"
source = "git+https://git.sr.ht/~quf/hexhex#b8ef1448e96840cfa98558532ec2ca0c442500a7"
dependencies = [
 "hexhex_impl",
 "hexhex_macros",
]

[[package]]
name = "hexhex_impl"
version = "0.1.0"
source = "git+https://git.sr.ht/~quf/hexhex#b8ef1448e96840cfa98558532ec2ca0c442500a7"
dependencies = [
 "fallible-iterator",
]

[[package]]
name = "hexhex_macros"
version = "1.0.0"
source = "git+https://git.sr.ht/~quf/hexhex#b8ef1448e96840cfa98558532ec2ca0c442500a7"
dependencies = [
 "hexhex_impl",
]

[[package]]
name = "no-cutscene-kiseki"


@@ 204,7 229,7 @@ dependencies = [
 "blake2",
 "clap",
 "fltk",
 "hex-literal",
 "hexhex",
 "windows",
]


M Cargo.toml => Cargo.toml +3 -2
@@ 2,18 2,19 @@
name = "no-cutscene-kiseki"
version = "1.0.0"
edition = "2021"
publish = false

[profile.release]
# runtime performance is basically irrelevant, so we optimize for binary size as far as possible.
opt-level = "z"
lto = true
strip = true
#codegen-units = 1
codegen-units = 1

[dependencies]
anyhow = "1.0.71"
blake2 = "0.10.6"
clap = { version = "4.2.5", default-features = false, features = ["std", "derive"] }
fltk = { version = "1.4.2", features = ["no-images", "fltk-bundled"] }
hex-literal = "0.4.1"
hexhex = { git = "https://git.sr.ht/~quf/hexhex", version = "1.0.0" }
windows = { version = "0.48.0", features = [ "Win32_Foundation", "Win32_Security", "Win32_Storage_FileSystem", "Win32_System_Com", "Win32_System_SystemInformation", "Win32_System_Diagnostics_Debug", "Win32_System_Memory", "Win32_System_Threading", "Win32_UI_Shell" ]}

M src/patch.rs => src/patch.rs +15 -15
@@ 1,6 1,6 @@
use crate::win;

use hex_literal::hex;
use hexhex::hex_literal as hex;

use anyhow::Context as _;
use blake2::Digest as _;


@@ 21,8 21,8 @@ impl ExeVersion {

    pub fn expected_blake2b_hash(&self) -> [u8; 64] {
        match self {
            ExeVersion::NisaV1_05En => hex!("bbce84df472cdeefd60464715aadfd7e35ca6a9107da320ea137b9424fc3009a4ecf55090f7a439a1ec4969df02bd190e46dd102c1f9bfbfa18d0b8babc989ff"),
            ExeVersion::NisaV1_05Jp => hex!("2e846b7f10bda3d3ae191d4391b35b879683f73628e9bcb8a93b10448e65ecf22a496e3fe90c06aa140bb75bdfc09965367d4209c6311272e67d9a208104da7d"),
            ExeVersion::NisaV1_05En => *hex!("bbce84df472cdeefd60464715aadfd7e35ca6a9107da320ea137b9424fc3009a4ecf55090f7a439a1ec4969df02bd190e46dd102c1f9bfbfa18d0b8babc989ff"),
            ExeVersion::NisaV1_05Jp => *hex!("2e846b7f10bda3d3ae191d4391b35b879683f73628e9bcb8a93b10448e65ecf22a496e3fe90c06aa140bb75bdfc09965367d4209c6311272e67d9a208104da7d"),
        }
    }
}


@@ 237,20 237,20 @@ pub fn run_and_patch(path: &std::path::Path, version: ExeVersion) -> anyhow::Res
            Patch {
                description: "the part that sets the flag when starting a new cutscene", // or something like that
                offset: 0x14032a5b1,
                expected: &hex!("c6833d3d000000"),          // MOV byte ptr [RBX + 0x3d3d],0x00
                replacement: Some(&hex!("c6833d3d000001")), // MOV byte ptr [RBX + 0x3d3d],0x01
                expected: hex!("c6833d3d000000"),          // MOV byte ptr [RBX + 0x3d3d],0x00
                replacement: Some(hex!("c6833d3d000001")), // MOV byte ptr [RBX + 0x3d3d],0x01
            },
            Patch {
                description: "the part that resets the flag at the end of a skipped scene",
                offset: 0x1403dfda3,
                expected: &hex!("c6803d3d000000"),          // MOV byte ptr [RAX + 0x3d3d],0x00
                replacement: Some(&hex!("c6803d3d000001")), // MOV byte ptr [RAX + 0x3d3d],0x01
                expected: hex!("c6803d3d000000"),          // MOV byte ptr [RAX + 0x3d3d],0x00
                replacement: Some(hex!("c6803d3d000001")), // MOV byte ptr [RAX + 0x3d3d],0x01
            },
            Patch {
                description: "skip flag",
                offset: 0x1416c535d,
                expected: &hex!("00"),
                replacement: Some(&hex!("01")),
                expected: hex!("00"),
                replacement: Some(hex!("01")),
            },
        ],
        ExeVersion::NisaV1_05Jp => &[


@@ 263,20 263,20 @@ pub fn run_and_patch(path: &std::path::Path, version: ExeVersion) -> anyhow::Res
            Patch {
                description: "the part that resets the flag at the end of a skipped scene",
                offset: 0x1403210a1,
                expected: &hex!("c6833d3d000000"),          // MOV byte ptr [RBX + 0x3d3d],0x00
                replacement: Some(&hex!("c6833d3d000001")), // MOV byte ptr [RBX + 0x3d3d],0x01
                expected: hex!("c6833d3d000000"),          // MOV byte ptr [RBX + 0x3d3d],0x00
                replacement: Some(hex!("c6833d3d000001")), // MOV byte ptr [RBX + 0x3d3d],0x01
            },
            Patch {
                description: "cutscene skip flag #2",
                offset: 0x14030acda,
                expected: &hex!("48c7833c3d000000000000"),          // MOV qword ptr [RBX + 0x3d3c],0x00; note that the offset is smaller by one
                replacement: Some(&hex!("48c7833c3d000000010000")), // MOV qword ptr [RBX + 0x3d3c],0x100
                expected: hex!("48c7833c3d000000000000"),          // MOV qword ptr [RBX + 0x3d3c],0x00; note that the offset is smaller by one
                replacement: Some(hex!("48c7833c3d000000010000")), // MOV qword ptr [RBX + 0x3d3c],0x100
            },
            Patch {
                description: "cutscene skip flag #3",
                offset: 0x1403d5943,
                expected: &hex!("c6803d3d000000"),          // MOV byte ptr [RAX + 0x3d3d],0x00
                replacement: Some(&hex!("c6803d3d000001")), // MOV byte ptr [RAX + 0x3d3d],0x01
                expected: hex!("c6803d3d000000"),          // MOV byte ptr [RAX + 0x3d3d],0x00
                replacement: Some(hex!("c6803d3d000001")), // MOV byte ptr [RAX + 0x3d3d],0x01
            },
            Patch {
                description: "skip flag",