### List Supported WeChat Versions Source: https://context7.com/sunnyyoung/wechattweak/llms.txt Displays the currently installed WeChat version and all versions supported by the WeChatTweak tool. This command helps users verify compatibility before applying patches. ```bash wechattweak versions # Output: # ------ Current version ------ # 32288 # ------ Supported versions ------ # 31927 # 32281 # 32288 # 31960 ``` -------------------------------- ### Install WeChatTweak via Homebrew Source: https://context7.com/sunnyyoung/wechattweak/llms.txt Installs or upgrades the WeChatTweak tool using the Homebrew package manager. This is the recommended method for easy installation and updates. ```bash # Install WeChatTweak brew install sunnyyoung/tap/wechattweak # Update to latest version brew upgrade wechattweak ``` -------------------------------- ### Get WeChat Version - Command.version Source: https://context7.com/sunnyyoung/wechattweak/llms.txt Retrieves the version number of the installed WeChat application. It takes the application's URL as input and returns the version string or throws an error if retrieval fails. Dependencies include Foundation. ```swift import Foundation let appURL = URL(fileURLWithPath: "/Applications/WeChat.app") do { if let version = try await Command.version(app: appURL) { print("WeChat version: (version)") // Output: WeChat version: 32288 } } catch { print("Failed to get version: (error.localizedDescription)") } ``` -------------------------------- ### Install and Use WeChatTweak (Bash) Source: https://github.com/sunnyyoung/wechattweak/blob/master/README.md This snippet demonstrates how to install, update, and apply patches using the WeChatTweak command-line tool. It requires Homebrew for installation and provides commands for patching and checking supported WeChat versions. ```bash # 安装 brew install sunnyyoung/tap/wechattweak # 更新 brew upgrade wechattweak # 执行 Patch wechattweak patch # 查看所有支持的 WeChat 版本 wechattweak versions ``` -------------------------------- ### Build WeChatTweak from Source Source: https://context7.com/sunnyyoung/wechattweak/llms.txt Builds the WeChatTweak tool from its source code. This involves cloning the repository, navigating into the directory, and running the make build command to create a universal binary. ```bash # Clone the repository git clone https://github.com/sunnyyoung/WeChatTweak.git cd WeChatTweak # Build universal binary (arm64 + x86_64) make build # The binary will be available at ./wechattweak ``` -------------------------------- ### Apply Binary Patches - Command.patch Source: https://context7.com/sunnyyoung/wechattweak/llms.txt Applies binary patches to the WeChat application based on a loaded configuration. This function first retrieves the WeChat version, loads the corresponding configuration, and then applies the patches. It handles potential errors like unsupported versions, invalid files, or no matching architectures. Dependencies include Foundation. ```swift import Foundation let appURL = URL(fileURLWithPath: "/Applications/WeChat.app") let configURL = URL(fileURLWithPath: "./config.json") do { // Load configs and find matching version let configs = try await Config.load(url: configURL) let version = try await Command.version(app: appURL) guard let config = configs.first(where: { $0.version == version }) else { throw Tweak.Error.unsupportedVersion } // Apply patches try await Command.patch(app: appURL, config: config) print("Patching complete!") } catch Patcher.Error.invalidFile { print("Error: WeChat binary not found") } catch Patcher.Error.noArchMatched { print("Error: No matching architecture in config") } catch { print("Patch failed: (error.localizedDescription)") } ``` -------------------------------- ### Load Patch Configuration - Config.load Source: https://context7.com/sunnyyoung/wechattweak/llms.txt Loads patch configurations from a local file or a remote URL. It supports loading configurations for specific WeChat versions and finding matching entries based on version strings. Dependencies include Foundation. ```swift import Foundation // Load from local file let localURL = URL(fileURLWithPath: "./config.json") let configs = try await Config.load(url: localURL) // Load from remote URL let remoteURL = URL(string: "https://raw.githubusercontent.com/sunnyyoung/WeChatTweak/refs/heads/master/config.json")! let remoteConfigs = try await Config.load(url: remoteURL) // Find config for specific version let version = "32288" if let matchedConfig = configs.first(where: { $0.version == version }) { print("Found config for version (version)") print("Targets: (matchedConfig.targets.count)") } ``` -------------------------------- ### Patch WeChat Application Source: https://context7.com/sunnyyoung/wechattweak/llms.txt Applies all available tweaks to the WeChat application by modifying its binary. This is the primary command for enabling additional features. It can also accept custom application paths and configuration files. ```bash # Patch default WeChat installation wechattweak patch # Output: # ------ Version ------ # WeChat version: 32288 # ------ Config ------ # Matched config: Config(version: "32288", targets: [...]) # ------ Patch ------ # [arm64] vmaddr=0x100000000, fileoff=0x0, sliceoff=0x4000 # [arm64] patch VA=0x103db34c0, fileoff=0x3db74c0 # Done! # ------ Resign ------ # Done! ``` ```bash # Patch WeChat at custom location wechattweak patch --app /path/to/WeChat.app # Short form wechattweak patch -a ~/Downloads/WeChat.app ``` ```bash # Use local config file wechattweak patch --config ./config.json # Use remote config URL wechattweak patch --config https://example.com/custom-config.json # Combine with custom app path wechattweak patch -a /Applications/WeChat.app -c ./my-config.json ``` -------------------------------- ### Low-Level Binary Patching - Patcher.patch Source: https://context7.com/sunnyyoung/wechattweak/llms.txt Provides low-level binary patching capabilities for Mach-O executables, supporting both FAT (universal) and thin binaries. This function allows direct modification of the binary with specified patch data, including architecture, virtual address, and assembly instructions. It includes error handling for non-64-bit Mach-O files and cases where the virtual address is not found. Dependencies include Foundation. ```swift import Foundation let binaryURL = URL(fileURLWithPath: "/Applications/WeChat.app/Contents/MacOS/WeChat") // Create a Config.Entry manually let config = Config( version: "32288", targets: [ Config.Target( identifier: "revoke", entries: [ Config.Entry(arch: .arm64, addr: 0x103db34c0, asm: Data([0x00, 0x00, 0x80, 0x52, 0xC0, 0x03, 0x5F, 0xD6])) ] ) ] ) do { try Patcher.patch(binary: binaryURL, config: config) // Output: // [arm64] vmaddr=0x100000000, fileoff=0x0, sliceoff=0x4000 // [arm64] patch VA=0x103db34c0, fileoff=0x3db74c0 } catch Patcher.Error.not64BitMachO(let magic) { print("Not a 64-bit Mach-O binary, magic: (String(format: "0x%08x", magic))") } catch Patcher.Error.vaNotFound(let arch, let va) { print("Virtual address (String(format: "0x%llx", va)) not found for (arch)") } ``` -------------------------------- ### WeChatTweak JSON Configuration Structure Source: https://context7.com/sunnyyoung/wechattweak/llms.txt Defines the structure of the JSON configuration file used by WeChatTweak for version-specific patch targets. It includes version numbers, patch identifiers, and assembly instructions for different architectures. ```json [ { "version": "32288", "targets": [ { "identifier": "revoke", "entries": [ { "arch": "arm64", "addr": "103db34c0", "asm": "00008052C0035FD6" } ] }, { "identifier": "multiInstance", "entries": [ { "arch": "arm64", "addr": "1001e1a74", "asm": "20008052C0035FD6" } ] } ] } ] ``` -------------------------------- ### Uninstall WeChatTweak Modifications Source: https://context7.com/sunnyyoung/wechattweak/llms.txt Instructions for removing WeChatTweak modifications by reinstalling the original WeChat application. This process overwrites the patched binary with the official version. It suggests downloading from the official website or Mac App Store, or alternatively, deleting the application and downloading a fresh copy. ```bash # Download and reinstall WeChat from official website # or reinstall via Mac App Store # Alternatively, delete and reinstall rm -rf /Applications/WeChat.app # Then download fresh copy from https://mac.weixin.qq.com/ ``` -------------------------------- ### Re-sign Application - Command.resign Source: https://context7.com/sunnyyoung/wechattweak/llms.txt Re-signs the WeChat application after patching to ensure it can be executed. This is a crucial step to allow the modified application to run on macOS. It handles potential errors during the resigning process, such as command execution failures. Dependencies include Foundation. ```swift import Foundation let appURL = URL(fileURLWithPath: "/Applications/WeChat.app") do { try await Command.resign(app: appURL) print("Application re-signed successfully") } catch Command.Error.executing(let command, let error) { print("Resign failed for command: (command)") print("Error: (error)") } ``` -------------------------------- ### WeChatTweak Patch Identifiers Source: https://context7.com/sunnyyoung/wechattweak/llms.txt Lists the available patch identifiers within the WeChatTweak configuration file, each corresponding to a specific feature that can be modified in the WeChat application. It details the architecture, memory address, and assembly instructions for each patch. ```json { "targets": [ { "identifier": "revoke", "entries": [{"arch": "arm64", "addr": "103db34c0", "asm": "00008052C0035FD6"}] }, { "identifier": "startUpdater", "entries": [{"arch": "arm64", "addr": "1001e9ed0", "asm": "00008052C0035FD6"}] }, { "identifier": "startBackgroundUpdatesCheck", "entries": [{"arch": "arm64", "addr": "1001ecb10", "asm": "00008052C0035FD6"}] }, { "identifier": "checkForUpdates", "entries": [{"arch": "arm64", "addr": "1001ec73c", "asm": "00008052C0035FD6"}] }, { "identifier": "enableAutoUpdate", "entries": [{"arch": "arm64", "addr": "1001ecfc0", "asm": "00008052C0035FD6"}] }, { "identifier": "automaticallyDownloadsUpdates", "entries": [{"arch": "arm64", "addr": "1001f59e0", "asm": "00008052C0035FD6"}] }, { "identifier": "canCheckForUpdate", "entries": [{"arch": "arm64", "addr": "1001f59e0", "asm": "00008052C0035FD6"}] }, { "identifier": "multiInstance", "entries": [{"arch": "arm64", "addr": "1001e1a74", "asm": "20008052C0035FD6"}] } ] } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.