Skip to content

Add automated PATCHED section builder for binpatch.txt using MASM#5

Closed
Copilot wants to merge 3 commits into
masterfrom
copilot/add-patch-builder-script
Closed

Add automated PATCHED section builder for binpatch.txt using MASM#5
Copilot wants to merge 3 commits into
masterfrom
copilot/add-patch-builder-script

Conversation

Copilot AI commented Nov 8, 2025

Copy link
Copy Markdown

Automates generation of PATCHED sections in .binpatch.txt files from x64 assembly sources using Microsoft MASM (ml64.exe), integrated into CI/CD workflow.

Changes

Core Implementation

  • build-patch.ps1: PowerShell script that assembles .asm files via ml64.exe, parses COFF object files to extract .text section machine code, and formats as hex bytes (8/line, space-separated uppercase)
  • build-patch.bat: Wrapper script for seamless Windows execution

Workflow Integration

  • Modified .github/workflows/msbuild.yml to run patch builder after MSBuild, before artifact packaging
  • Ensures binpatch.txt files stay synchronized with assembly sources

Documentation

  • README_BUILD_PATCH.md: Usage, requirements (VS2022 + C++ tools), troubleshooting

Example

Given XStoreQueryGameLicenseAsync.asm:

option casemap:none
.code
XStoreQueryGameLicenseAsync proc
    push    rdi
    sub     rsp, 20h
    ; ... more instructions
    ret
XStoreQueryGameLicenseAsync endp
end

Running build-patch.bat -All generates PATCHED section in XStoreQueryGameLicenseAsync.binpatch.txt:

PATCHED
57 48 83 EC 20 48 89 D7
48 31 C0 48 C7 47 18 00
00 00 00 48 89 F9 48 8B
47 10 48 85 C0 74 02 FF
D0 31 C0 48 83 C4 20 5F
C3

Script automatically locates ml64.exe from Visual Studio installations, handles errors gracefully, and cleans up temporary files.

Original prompt

添加脚本,可以自动根据asm构建binpatch.txt的PATCHED部分,使用微软的汇编器,机器码为x64,注意,所有编译运行环境是windows,而且PATCH构建要集成到workflow


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits November 8, 2025 09:14
Co-authored-by: superturtlee <160681686+superturtlee@users.noreply.github.com>
Co-authored-by: superturtlee <160681686+superturtlee@users.noreply.github.com>
@superturtlee superturtlee marked this pull request as ready for review November 8, 2025 09:18
Copilot AI changed the title [WIP] Add script to build binpatch.txt with PATCHED section Add automated PATCHED section builder for binpatch.txt using MASM Nov 8, 2025
Copilot AI requested a review from superturtlee November 8, 2025 09:21
@superturtlee superturtlee deleted the copilot/add-patch-builder-script branch February 7, 2026 18:59
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.

2 participants