Skip to content

feat: 全解功能 - #2

Draft
Applesaber wants to merge 1 commit into
mainfrom
feature/unlocker
Draft

feat: 全解功能#2
Applesaber wants to merge 1 commit into
mainfrom
feature/unlocker

Conversation

@Applesaber

@Applesaber Applesaber commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

Co-authored-by: MoeGrid MoeGrid@users.noreply.github.com
实现由 @MoeGrid 提供,在此基础上进行了优化并代为提交

Summary by Sourcery

为 CHUNITHM 游戏内容添加一个内存中的 XML 解锁器,并公开必要的平台 API 以支持该功能。

New Features:

  • 引入一个可配置的解锁模块,用于拦截游戏对 XML 的读取,在不修改磁盘文件的情况下解锁角色、乐曲、名牌、语音、活动、地图图标和奖杯。

Enhancements:

  • 将 Windows API 平台模块公开,以便可被新的解锁器使用。

Documentation:

  • 在 README 中记录新的游戏内容解锁功能,说明其行为和适用范围。
Original summary in English

Summary by Sourcery

Add an in-memory XML unlocker for CHUNITHM game content and expose necessary platform APIs to support it.

New Features:

  • Introduce a configurable unlocker module that intercepts game XML reads and unlocks characters, music, nameplates, voices, events, map icons, and trophies without modifying disk files.

Enhancements:

  • Expose the Windows API platform module publicly so it can be used by the new unlocker.

Documentation:

  • Document the new game content unlock feature in the README, explaining its behavior and scope.

Summary by cubic

新增内存 XML 全解功能。拦截只读打开并返回改写后的内容,解锁角色、乐曲、铭牌、语音、活动、小人、称号,且不改磁盘文件。

  • New Features
    • 新增 packages/applechu/src/unlocker,接入 iohook 拦截 CreateFileW/ReadFile,并 hook GetFileSize/GetFileSizeEx,用 NUL 句柄占位、从内存模拟 Read/Seek。
    • 支持按配置 Unlocker 分项开关:unlockChara, unlockMusic, unlockNamePlate, unlockSystemVoice, unlockEvent, unlockMapIcon, unlockTrophy
    • 公开 platform::winapi 以便路径处理;更新 README.md 说明此功能。

Written for commit 511c2a0. Summary will update on new commits.

Review in cubic

Co-authored-by: MoeGrid <MoeGrid@users.noreply.github.com>
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@sourcery-ai

sourcery-ai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Reviewer's Guide

添加一个基于内存的 XML 游戏内容解锁模块用于 CHUNITHM,将其接入 Applechu 平台,并暴露支持该模块所需的 winapi 工具和配置。

内存 XML 解锁流程的时序图

sequenceDiagram
    actor Game
    participant CreateFileW
    participant iohook
    participant unlocker_irp_handler
    participant handle_open
    participant load_modified
    participant std_fs_read as std::fs::read
    participant modify_xml
    participant open_nul_fd as iohook::open_nul_fd

    Game->>CreateFileW: CreateFileW
    CreateFileW->>iohook: Irp(Open)
    iohook->>unlocker_irp_handler: unlocker_irp_handler(Open)
    unlocker_irp_handler->>handle_open: handle_open
    handle_open->>load_modified: load_modified(path, filename, rule_index)
    activate load_modified
    load_modified->>std_fs_read: std::fs::read(path)
    std_fs_read-->>load_modified: raw XML bytes
    load_modified->>modify_xml: modify_xml(text, tag, value)
    modify_xml-->>load_modified: modified String
    load_modified-->>handle_open: modified Vec<u8>
    deactivate load_modified
    handle_open->>open_nul_fd: iohook::open_nul_fd
    open_nul_fd-->>handle_open: fd (NUL handle)
    handle_open-->>unlocker_irp_handler: 1 (success)
    unlocker_irp_handler-->>iohook: Irp(Open) handled
    iohook-->>Game: HANDLE (virtual XML)

    Game->>CreateFileW: ReadFile / GetFileSizeEx
    CreateFileW->>iohook: Irp(Read/Seek)
    iohook->>unlocker_irp_handler: unlocker_irp_handler(Read/Seek)
    unlocker_irp_handler-->>Game: data from FileState (modified XML)
Loading

File-Level Changes

Change Details Files
引入一个 XML 解锁模块,拦截 Windows 文件 I/O,通过在内存中修改 XML 来透明解锁多种 CHUNITHM 游戏内容。
  • 新增解锁模块及其配置段,为角色、乐曲、称号牌、系统语音、活动、地图图标和奖杯等不同内容定义各自的开关。
  • 实现 IRP 处理器,在 iohook 链中挂钩 CreateFile/ReadFile/Seek/Close,使用 NUL 句柄加内部“句柄到缓冲区”的映射来提供修改后的 XML 内容。
  • 添加线程本地的重入保护,并使用 std::fs::read 通过已有的 VFS/路径钩子加载原始 XML 文件,然后在内存中重写标签值。
  • 实现 XML 标签修改逻辑,在保持属性不变的前提下安全替换指定标签的内部文本,跳过自闭合标签和名称不匹配的标签,并为该行为添加单元测试。
  • 为解锁行为添加日志和去重,包括首次拦截以及错误/边界情况。
packages/applechu/src/unlocker/mod.rs
将解锁器接入 crate 并暴露必要的平台 API。
  • 将 winapi 平台模块设为 public,以便解锁器可以访问与 Win32 相关的辅助工具。
  • 在 crate 根中注册解锁模块,通过 config_section 宏进行初始化。
  • 为 GetFileSize/GetFileSizeEx 安装自定义 IAT 钩子,使游戏看到的是修改后内存 XML 的大小,而非底层 NUL 设备的大小。
packages/applechu/src/platform/mod.rs
packages/applechu/src/lib.rs
packages/applechu/src/unlocker/mod.rs
更新文档以说明新的游戏内容解锁功能。
  • 扩展 README 的功能表,新增一行说明:通过内存中的 XML 解锁角色、乐曲、称号牌、语音、活动、地图图标和称号,而无需修改磁盘上的文件。
README.md

Tips and commands

Interacting with Sourcery

  • 触发新的审查: 在 pull request 中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 从审查评论生成 GitHub issue: 通过回复某条审查评论,请求 Sourcery 从该评论创建一个 issue。你也可以在审查评论下回复 @sourcery-ai issue 来从中创建 issue。
  • 生成 pull request 标题: 在 pull request 标题中任意位置写上 @sourcery-ai,即可随时生成标题。你也可以在 pull request 中评论 @sourcery-ai title 来(重新)生成标题。
  • 生成 pull request 摘要: 在 pull request 正文任意位置写上 @sourcery-ai summary,即可在指定位置生成 PR 摘要。你也可以在 pull request 中评论 @sourcery-ai summary 来(重新)生成摘要。
  • 生成审查者指南: 在 pull request 中评论 @sourcery-ai guide,即可随时(重新)生成审查者指南。
  • 解决所有 Sourcery 评论: 在 pull request 中评论 @sourcery-ai resolve,将标记所有 Sourcery 评论为已解决。如果你已经处理了所有评论且不想再看到它们,这会很有用。
  • 关闭所有 Sourcery 审查: 在 pull request 中评论 @sourcery-ai dismiss,以关闭所有现有的 Sourcery 审查。尤其在你想从新的审查开始时很有用——别忘了评论 @sourcery-ai review 来触发新的审查!

Customizing Your Experience

访问你的 dashboard 来:

  • 启用或禁用审查功能,例如 Sourcery 生成的 pull request 摘要、审查者指南等。
  • 更改审查语言。
  • 添加、删除或编辑自定义审查指令。
  • 调整其他审查设置。

Getting Help

Original review guide in English

Reviewer's Guide

Adds an in-memory XML-based game content unlocker module for CHUNITHM, wires it into the Applechu platform, and exposes winapi utilities and configuration required to support it.

Sequence diagram for the in-memory XML unlocker flow

sequenceDiagram
    actor Game
    participant CreateFileW
    participant iohook
    participant unlocker_irp_handler
    participant handle_open
    participant load_modified
    participant std_fs_read as std::fs::read
    participant modify_xml
    participant open_nul_fd as iohook::open_nul_fd

    Game->>CreateFileW: CreateFileW
    CreateFileW->>iohook: Irp(Open)
    iohook->>unlocker_irp_handler: unlocker_irp_handler(Open)
    unlocker_irp_handler->>handle_open: handle_open
    handle_open->>load_modified: load_modified(path, filename, rule_index)
    activate load_modified
    load_modified->>std_fs_read: std::fs::read(path)
    std_fs_read-->>load_modified: raw XML bytes
    load_modified->>modify_xml: modify_xml(text, tag, value)
    modify_xml-->>load_modified: modified String
    load_modified-->>handle_open: modified Vec<u8>
    deactivate load_modified
    handle_open->>open_nul_fd: iohook::open_nul_fd
    open_nul_fd-->>handle_open: fd (NUL handle)
    handle_open-->>unlocker_irp_handler: 1 (success)
    unlocker_irp_handler-->>iohook: Irp(Open) handled
    iohook-->>Game: HANDLE (virtual XML)

    Game->>CreateFileW: ReadFile / GetFileSizeEx
    CreateFileW->>iohook: Irp(Read/Seek)
    iohook->>unlocker_irp_handler: unlocker_irp_handler(Read/Seek)
    unlocker_irp_handler-->>Game: data from FileState (modified XML)
Loading

File-Level Changes

Change Details Files
Introduce an XML unlocker module that intercepts Windows file I/O to transparently unlock various CHUNITHM game content via in-memory XML modification.
  • Add new unlocker module with configuration section defining per-content toggles for characters, music, nameplates, system voices, events, map icons, and trophies.
  • Implement IRP handler that hooks CreateFile/ReadFile/Seek/Close in the iohook chain, using NUL handles plus an internal handle-to-buffer map to serve modified XML content.
  • Add thread-local reentrancy guard and use std::fs::read to load original XML files through existing VFS/path hooks before rewriting tag values in memory.
  • Implement XML tag modification logic that safely replaces specific tag inner text while preserving attributes, skipping self-closing and non-matching tag names, and add unit tests for this behavior.
  • Add logging and deduplication for unlocker activity, including first-time intercepts and error/edge cases.
packages/applechu/src/unlocker/mod.rs
Wire the unlocker into the crate and expose necessary platform APIs.
  • Make the winapi platform module public so the unlocker can access Win32-related helpers.
  • Register the unlocker module in the crate root for initialization via the config_section macro.
  • Install custom IAT hooks for GetFileSize/GetFileSizeEx so the game sees the modified in-memory XML sizes instead of the underlying NUL device size.
packages/applechu/src/platform/mod.rs
packages/applechu/src/lib.rs
packages/applechu/src/unlocker/mod.rs
Update documentation to describe the new game content unlock feature.
  • Extend README feature table with a new row explaining the memory-based XML unlock of characters, music, nameplates, voices, events, map icons, and titles without touching disk files.
README.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant