### Run Taskboard default example Source: https://github.com/aynakeya/v8asm/blob/main/note/application-fixture.md Runs the Taskboard CLI without arguments to execute the default example covering add, update, query, and undo operations. ```bash node tests/application_fixture/taskboard.cjs ``` -------------------------------- ### Quick start: disassemble and decompile a sample .jsc file Source: https://github.com/aynakeya/v8asm/blob/main/README.md Sets up the Python environment with uv and runs the disassembler on a sample file, outputting JSON, then runs the decompiler on that JSON. Requires uv and the repository root. ```bash uv sync --locked uv run python -m disassembler samples/main.d8.jsc --format json > /tmp/main.disasm.json uv run python -m decompiler /tmp/main.disasm.json ``` -------------------------------- ### Atom 13.4 Example Input Parameters Source: https://github.com/aynakeya/v8asm/blob/main/note/cached-data-and-snapshot.md Lists the input parameters for the current Atom 13.4 example: the JSC file, numeric V8 version, snapshot blob, snapshot version, and static roots flag. ```text JSC:example2/atom.compiled.dist.jsc numeric V8:13.4.114.21 snapshot:example2/v8_context_snapshot.bin snapshot version:13.4.114.21-electron.0 static roots:true ``` -------------------------------- ### List V8 version tags matching 11.x Source: https://github.com/aynakeya/v8asm/blob/main/note/archive/early-bytecode-research.md Command to list git tags that start with '11.' to find available V8 version tags. The example output shows '11.8.172.13'. ```bash git tag -l | grep ^11. # 11.8.172.13 ``` -------------------------------- ### 使用范围参数搜索 V8 版本哈希 Source: https://github.com/aynakeya/v8asm/blob/main/note/checkversion.md 使用 --major-range、--minor-range、--build-range 和 --patch-range 指定搜索范围,范围使用 START:END 且不包含上界。 ```bash uv run python -m checkversion input.jsc \ --major-range 13:14 --minor-range 4:5 \ --build-range 100:130 --patch-range 0:50 ``` -------------------------------- ### Build V8 Bytecode Sleigh Language Module Source: https://github.com/aynakeya/v8asm/blob/main/note/ghidra.md Runs Ghidra's sleigh compiler to build the v8bytecode.sla language module from the .slaspec file. Requires XDG_CONFIG_HOME and JAVA_HOME environment variables, and the GHIDRA_HOME environment variable pointing to the Ghidra installation. ```bash XDG_CONFIG_HOME=/tmp/ghidra-home/.config \ JAVA_HOME=/path/to/jdk \ $GHIDRA_HOME/support/sleigh \ ghidra/v8-bytecode/data/languages/v8bytecode.slaspec \ /tmp/v8bytecode.sla ``` -------------------------------- ### Check Node.js V8 version with node -p process.versions.v8 Source: https://github.com/aynakeya/v8asm/blob/main/note/archive/early-bytecode-research.md Command to print the V8 version used by the current Node.js installation. The example output shows '12.4.254.21-node.26'. ```bash 00:01:14 $ node -p process.versions.v8 12.4.254.21-node.26 ``` -------------------------------- ### Preload capture script on Windows PowerShell Source: https://github.com/aynakeya/v8asm/blob/main/note/capture-cached-data.md Preload the capture script on Windows PowerShell using environment variables and launching the application. The example assumes paths without spaces. ```powershell $env:V8_CACHE_DUMP_DIR = "C:\tmp\v8-cache-dump" $env:NODE_OPTIONS = "--require=C:\src\v8asm\disassembler\capture_cached_data.cjs" & "C:\path\to\application.exe" ``` -------------------------------- ### PrintDiscoveredObjects: Print all discovered objects with segfault handling Source: https://github.com/aynakeya/v8asm/blob/main/note/archive/early-bytecode-research.md Prints all discovered objects to stdout. Installs a SIGSEGV handler that jumps back on faults, prints a marker with the address, and continues. Restores the previous handler after printing. ```cpp void PrintDiscoveredObjects() { v8::internal::OFStream os(stdout); void (*old_handler)(int); old_handler = signal(SIGSEGV, segfault_jumper); for (const auto& pair : discovered_objects_) { auto obj = pair.second; if (sigsetjmp(jump_buffer_, 1) == 0) { currently_printing_obj_addr_ = pair.first; v8::internal::Print(obj, os); currently_printing_obj_addr_ = 0; } else { fflush(stdout); os << std::endl << "!" < input.disasm.txt ``` -------------------------------- ### 编译 core.js 为字节码 Source: https://github.com/aynakeya/v8asm/blob/main/note/archive/early-bytecode-research.md 使用 bytenode 命令行工具将 core.js 编译为 .jsc 字节码文件,生成 core.jsc。 ```bash bytenode --compile core.js ``` -------------------------------- ### 运行 Electron 快照和版本矩阵检查 Source: https://github.com/aynakeya/v8asm/blob/main/note/validation.md 运行两个脚本以检查 Electron 快照和版本矩阵。版本矩阵会从每个 Electron binary 读取 process.versions.v8,只选择 exact numeric V8 的 Electron-flavored v8asm,由该 Electron 运行时生成 bytenode cache,再分别测试 snapshot_blob.bin 和 v8_context_snapshot.bin。 ```bash uv run python tests/decomp_rounds/check_electron_snapshot_round.py uv run python tests/decomp_rounds/check_electron_version_matrix.py ``` -------------------------------- ### 生成语义 fixture(--all 迁移整个 runtime) Source: https://github.com/aynakeya/v8asm/blob/main/note/generated-assets.md 只有迁移整个 runtime 的样例时才显式使用 --all。 ```bash uv run python tests/generate_semantic_fixtures.py --all ``` -------------------------------- ### core.jsc 的十六进制转储 Source: https://github.com/aynakeya/v8asm/blob/main/note/archive/early-bytecode-research.md 使用 xxd 查看 core.jsc 的字节内容,展示编译后的字节码为不可读的二进制数据。 ```bash 03:57:21 $ xxd core.jsc 00000000: 8806 dec0 1477 2c2b 1701 0000 9b61 7c1c .....w,+.....a|. 00000010: 4243 1cd3 b803 0000 0000 0000 0000 0000 BC.............. 00000020: 0124 5403 2407 b460 0000 0000 0600 0000 .$T.$..`........ 00000030: 0108 07bd 0e04 0421 030c 0785 0161 0000 .......!.....a.. 00000040: 0000 0700 0000 0104 0200 0adc 0800 2107 ..............!. 00000050: 4111 2103 0c07 7d01 6000 0000 0001 0000 A.!...}.`....... 00000060: 0001 2454 032c 9060 0000 0000 1800 0000 ..$T.,.`........ 00000070: 0108 9104 1821 0310 9362 0000 0000 0d00 .....!...b...... 00000080: 0000 012c 0300 0aac 070f 4c0d 0f0a 4000 ...,......L...@. 00000090: 0000 2194 2103 1895 6000 0000 0004 0000 ..!.!...`....... ``` -------------------------------- ### 较新的 Electron snapshot 构建参数 Source: https://github.com/aynakeya/v8asm/blob/main/note/environment-and-build.md 较新的 Electron snapshot 可能还需要开启 sandbox 和 static roots。 ```text v8_enable_sandbox=true v8_enable_static_roots=true ``` -------------------------------- ### 加载 V8 构建环境 Source: https://github.com/aynakeya/v8asm/blob/main/note/environment-and-build.md 每次调用 gclient、gn、autoninja 或 V8 辅助工具前先加载环境。 ```bash cd /home/aynakeya/workspace/tmp/v8test source start_env.md cd v8 ``` -------------------------------- ### 查询 binary 版本和构建参数 Source: https://github.com/aynakeya/v8asm/blob/main/note/environment-and-build.md 构建后必须查询 binary 自身报告的版本和参数,因为旧 out/ 目录中的 binary 可能来自上一次 checkout。 ```bash out/<目录>/v8asm version out/<目录>/v8asm build-args ``` -------------------------------- ### Build V8 for Node.js with depot_tools and gn Source: https://github.com/aynakeya/v8asm/blob/main/note/archive/early-bytecode-research.md Commands to clone depot_tools, fetch V8, generate a release build with disassembler and object print enabled, and compile with ninja. The build args disable pointer compression to match Node.js and use release mode to avoid debug-only structures. ```bash cd your_working_dir git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git export PATH="$PWD/depot_tools:$PATH" fetch v8 cd v8 gn gen out/node.x64.release --args='is_debug=false v8_enable_disassembler=true v8_enable_object_print=true v8_enable_pointer_compression=false' # compile may takes years if your computer sucks ninja -C out/debug d8 ``` -------------------------------- ### Run Ghidra headless corpus comparison (compare_corpus.py) Source: https://github.com/aynakeya/v8asm/blob/main/note/ghidra.md Compares all .v8asm.jsc files in a directory using a single Ghidra headless process. Requires GHIDRA_HOME and JAVA_HOME environment variables. Outputs a summary at /tmp/v8asm-ghidra-corpus/summary.md and per-function results under results/. Returns non-zero status on missing Ghidra output, decompilation failure, or bad instruction. ```bash uv run python ghidra/v8-bytecode/tools/compare_corpus.py \ tests/decomp_rounds/out \ --ghidra-home "$GHIDRA_HOME" \ --java-home "$JAVA_HOME" \ -o /tmp/v8asm-ghidra-corpus ``` -------------------------------- ### 生成语义 fixture(指定 Node executable) Source: https://github.com/aynakeya/v8asm/blob/main/note/generated-assets.md 使用已有 runtime 生成 fixture,不改变当前 shell 的 Node。通过 --node 参数指定 Node 可执行文件路径。 ```bash uv run python tests/generate_semantic_fixtures.py \ --node "$HOME/.nvm/versions/node/v20.20.2/bin/node" \ conversion-boundaries iterable-spread ``` -------------------------------- ### 增量重建命令 Source: https://github.com/aynakeya/v8asm/blob/main/note/environment-and-build.md 使用 gn gen 和 autoninja 进行增量重建,指定了多个 V8 构建参数,如启用 pointer compression、sandbox 和 static roots。 ```bash gn gen out/v8asm.13.4.114.21.electron.staticroots.x64.release \ --args='is_debug=false v8_enable_object_print=true v8_enable_disassembler=true v8_enable_pointer_compression=true v8_enable_sandbox=true v8_enable_static_roots=true v8_embedder_string="-electron.0"' autoninja -j10 \ -C out/v8asm.13.4.114.21.electron.staticroots.x64.release \ v8asm ``` -------------------------------- ### 生成语义 fixture(默认 Node 24) Source: https://github.com/aynakeya/v8asm/blob/main/note/generated-assets.md 使用当前 Node 版本(默认 Node 24)生成指定样例的 fixture。生成器会检查 process.versions,不匹配则退出;NODE_OPTIONS 非空时拒绝生成。 ```bash nvm use 24.7.0 uv run python tests/generate_semantic_fixtures.py conversion-boundaries iterable-spread ``` -------------------------------- ### 选择特定函数块 Source: https://github.com/aynakeya/v8asm/blob/main/note/ghidra.md 使用 -i/--block-index 选择具体函数,并输出对应的 bytecode 二进制文件。 ```bash uv run python ghidra/v8-bytecode/tools/extract_bytecode_blob.py input.disasm.txt -i 1 -o input.bytecode.bin ``` -------------------------------- ### Run application fixture tests Source: https://github.com/aynakeya/v8asm/blob/main/note/application-fixture.md Runs the application fixture test suite using unittest discovery. ```bash uv run python -m unittest discover -s tests -p test_application_fixture.py ``` -------------------------------- ### Run lightweight patch and binary cache checks Source: https://github.com/aynakeya/v8asm/blob/main/note/validation.md Runs three scripts to verify patch text, audit patch coverage, and check binary cache metadata. check_patch_text.py confirms key protections and parameter paths; audit_patch_coverage.py reports Node/Electron bin cache coverage (use --strict to require all expected lines have cached binaries); check_bin_cache.py checks binary metadata, build args, and sibling snapshot sources. ```bash uv run python tests/decomp_rounds/check_patch_text.py uv run python tests/decomp_rounds/audit_patch_coverage.py uv run python tests/decomp_rounds/check_bin_cache.py ``` -------------------------------- ### 静态检查命令 Source: https://github.com/aynakeya/v8asm/blob/main/note/environment-and-build.md 小改动先做静态检查。 ```bash uv run python tests/decomp_rounds/check_patch_text.py uv run python tests/decomp_rounds/audit_patch_coverage.py ``` -------------------------------- ### 运行 main.js 的输出 Source: https://github.com/aynakeya/v8asm/blob/main/note/archive/early-bytecode-research.md 运行 main.js 后得到的输出,显示验证失败的结果。 ```text not valid false ``` -------------------------------- ### 引导程序 main.js 加载 .jsc Source: https://github.com/aynakeya/v8asm/blob/main/note/archive/early-bytecode-research.md 通过 require("bytenode") 注册 .jsc 加载支持,然后 require 编译后的 core.jsc 并调用 validate 函数。 ```javascript require("bytenode"); const core = require("./core.jsc"); console.log(core.validate("aaaaa")); ``` -------------------------------- ### Run full diagnostics with default Node Source: https://github.com/aynakeya/v8asm/blob/main/note/application-fixture.md Runs the diagnostic script using the Node from PATH. Compiles source to cache with --no-lazy, then decompiles and executes both. Options: --node, --snapshot-blob, --out. Exit code 0 only if all scenarios pass with no warnings or pipeline errors. ```bash uv run python tests/run_application_fixture.py ``` -------------------------------- ### 生成语义 fixture 的命令 Source: https://github.com/aynakeya/v8asm/blob/main/note/semantic-fixtures.md 使用 Node 24.7.0 和 uv 运行生成脚本及测试。需要先切换 Node 版本,然后生成指定样例并运行单元测试。 ```bash nvm use 24.7.0 uv run python tests/generate_semantic_fixtures.py conversion-boundaries iterable-spread uv run python -m unittest discover -s tests -p test_semantic_equivalence.py ``` -------------------------------- ### 运行聚焦回归测试 Source: https://github.com/aynakeya/v8asm/blob/main/note/validation.md 用于验证控制流改动后的回归测试命令。包含两个命令,分别运行指定的测试模块和发现测试文件。 ```bash uv run python -m unittest tests.test_translator tests.test_semantic_equivalence tests.test_source_recovery tests.test_postprocess uv run python -m unittest discover -s tests -p test_decompiler_file.py ``` -------------------------------- ### Run lightweight Node and self-generated cache matrix Source: https://github.com/aynakeya/v8asm/blob/main/note/validation.md Runs the run_version_matrix.sh script. It enumerates binaries in tests/decomp_rounds/bin_cache/*/v8asm, generates self-cache for each binary requiring strict disasm and source recovery, generates bytenode cache using local nvm Node 18, 20, 22, 24, and requires forced load only when numeric V8 and pointer-compression shapes match. It checks crash signature, raw goto, unknown opcode, and object failure placeholders. ```bash tests/decomp_rounds/run_version_matrix.sh ``` -------------------------------- ### Node 风格构建参数 Source: https://github.com/aynakeya/v8asm/blob/main/note/environment-and-build.md Node 风格通常需要关闭 pointer compression、sandbox 和 static roots。 ```text v8_enable_pointer_compression=false v8_enable_sandbox=false v8_enable_static_roots=false ``` -------------------------------- ### 默认严格拒绝不兼容 cache (bash) Source: https://github.com/aynakeya/v8asm/blob/main/note/cached-data-and-snapshot.md 原生 v8asm 默认严格拒绝不兼容 cache 的命令。 ```bash ./v8asm disasm input.jsc ``` -------------------------------- ### 生成 V8 profile(使用源码包中的 deps/v8) Source: https://github.com/aynakeya/v8asm/blob/main/note/generated-assets.md 读取同版本源码包中解压出的 deps/v8 目录。 ```bash uv run python -m disassembler.generate_profiles \ --v8-source /path/to/node-v20.20.2/deps/v8 \ --root-layout-version 11.3.244.8-node.38 \ --output-dir disassembler/profiles ``` -------------------------------- ### Disassemble with explicit version and snapshot Source: https://github.com/aynakeya/v8asm/blob/main/note/python-disassembler.md Specifies an explicit V8 version and matching startup snapshot for custom Electron or Node runtimes. --version only selects source layout; build flags are not automatically compatible. ```bash uv run python -m disassembler input.jsc \ --version 13.4.114.21 \ --snapshot-blob v8_context_snapshot.bin \ --format json > /tmp/input.disasm.json ``` -------------------------------- ### Version::Hash() 实现 (src/utils/hash.h) Source: https://github.com/aynakeya/v8asm/blob/main/note/archive/early-bytecode-research.md V8 的 Version 类中 Hash() 方法,将 major、minor、build、patch 四个版本号通过 base::hash_combine() 计算为 32 位哈希值。该哈希值用于写入 .jsc 文件的 Header 的 kVersionHashOffset 位置。 ```cpp // src/utils/hash.h // ... class V8_EXPORT Version { public: // ... static uint32_t Hash() { return static_cast( base::hash_combine(major_, minor_, build_, patch_)); } // ... private: static int major_; static int minor_; static int build_; static int patch_; ``` -------------------------------- ### 本机目录和环境约定 Source: https://github.com/aynakeya/v8asm/blob/main/note/environment-and-build.md 列出项目仓库、官方 V8 checkout、环境入口和 depot_tools 的路径约定。 ```text 项目仓库:/home/aynakeya/workspace/v8asm 官方 V8 checkout:/home/aynakeya/workspace/tmp/v8test/v8 环境入口:/home/aynakeya/workspace/tmp/v8test/start_env.md depot_tools:由 start_env.md 设置 ``` -------------------------------- ### Switch V8 version with git checkout and gclient sync Source: https://github.com/aynakeya/v8asm/blob/main/note/archive/early-bytecode-research.md Commands to check out a specific V8 version tag and sync dependencies. After switching, you must rerun the gn gen and ninja build steps. ```bash git checkout gclient sync -D ``` -------------------------------- ### Build V8ASM matrix for all versions Source: https://github.com/aynakeya/v8asm/blob/main/note/validation.md Runs the build_v8asm_matrix.sh script to prove patches still apply and compile. The script must perform exact tag checkout, gclient sync with branch heads and tags, git apply --3way --recount, and autoninja -j10, reusing each line's existing out/ directory. Each artifact must record v8asm version and build-args. ```bash tests/decomp_rounds/build_v8asm_matrix.sh ``` -------------------------------- ### Python 环境初始化与工具帮助 Source: https://github.com/aynakeya/v8asm/blob/main/note/environment-and-build.md 在项目根目录执行,使用 uv 同步依赖并查看三个 Python 工具的帮助。 ```bash uv sync --locked uv run python -m disassembler --help uv run python -m decompiler --help uv run python -m checkversion --help ``` -------------------------------- ### 列出 BytecodeArray 块 Source: https://github.com/aynakeya/v8asm/blob/main/note/ghidra.md 当 disasm.txt 包含多个 BytecodeArray 时,使用 --list-blocks 列出所有块。 ```bash uv run python ghidra/v8-bytecode/tools/extract_bytecode_blob.py input.disasm.txt --list-blocks ``` -------------------------------- ### Run Taskboard async scenario Source: https://github.com/aynakeya/v8asm/blob/main/note/application-fixture.md Runs the Taskboard CLI with the --case async flag to execute the advanced async scenario independently. ```bash node tests/application_fixture/taskboard.cjs --case async ``` -------------------------------- ### 生成 V8 profile(使用 Node 仓库的 root layout) Source: https://github.com/aynakeya/v8asm/blob/main/note/generated-assets.md 当本地有对应 V8 tag 的 Node Git 仓库时,使用 --root-layout-version 指定版本。 ```bash uv run python -m disassembler.generate_profiles \ --v8-repo /path/to/node \ --root-layout-version 11.3.244.8-node.38 \ --output-dir disassembler/profiles ``` -------------------------------- ### 构建矩阵指定行 Source: https://github.com/aynakeya/v8asm/blob/main/note/environment-and-build.md 只重建指定行。 ```bash tests/decomp_rounds/build_v8asm_matrix.sh \ 10.8-electron \ 13.4-electron-staticroots ``` -------------------------------- ### Manual V8 version hash implementation and brute-force Source: https://github.com/aynakeya/v8asm/blob/main/note/archive/early-bytecode-research.md Provides a manual implementation of the V8 hash functions (hash_value_unsigned_32 and hash_combine) and a brute-force function that uses them to find the version tuple matching a given hash. Includes the necessary includes and a Version struct. The hash functions are based on v8/src/utils/version.h and version.cc. ```c #include #include #include // refer to v8/src/utils/version.h // v8/src/utils/version.cc typedef struct { int major; int minor; int build; int patch; } Version; uint32_t hash_value_unsigned_32(uint32_t v) { v = ~v + (v << 15); v = v ^ (v >> 12); v = v + (v << 2); v = v ^ (v >> 4); v = v * 2057; v = v ^ (v >> 16); return v; } static size_t hash_combine(size_t seed, size_t hash) { const uint64_t m = 0xC6A4A7935BD1E995ULL; const uint32_t r = 47; hash *= m; hash ^= hash >> r; hash *= m; seed ^= hash; seed *= m; return seed; } uint32_t calculate_version_hash(int major, int minor, int build, int patch) { uint32_t seed = 0; seed = hash_combine(seed, hash_value_unsigned_32((uint32_t)major)); seed = hash_combine(seed, hash_value_unsigned_32((uint32_t)minor)); seed = hash_combine(seed, hash_value_unsigned_32((uint32_t)build)); seed = hash_combine(seed, hash_value_unsigned_32((uint32_t)patch)); return (uint32_t)seed; } Version bruteforce_v8_version(uint32_t hash) { for (int major = 0; major < 20; ++major) { for (int minor = 0; minor < 20; ++minor) { for (int build = 0; build < 500; ++build) { for (int patch = 0; patch < 200; ++patch) { if (calculate_version_hash(major, minor, build, patch) == hash) { Version found_version = {major, minor, build, patch}; return found_version; } } } } } Version not_found_version = {-1, -1, -1, -1}; return not_found_version; } ``` -------------------------------- ### 生成 Atom 反汇编与反编译结果的命令 Source: https://github.com/aynakeya/v8asm/blob/main/note/decompiler.md 使用 uv run 调用 disassembler 和 decompiler 模块生成 JSON 反汇编结果和反编译后的 JavaScript 文件。该样例用于人工检查真实输入效果,不代替可执行语义 fixture。 ```bash uv run python -m disassembler example2/atom.compiled.dist.jsc \ --version 13.4.114.21 \ --snapshot-blob example2/v8_context_snapshot.bin \ --format json > /tmp/atom.current.disasm.json uv run python -m decompiler /tmp/atom.current.disasm.json \ > atom.compiled.dist.decompiled.current.js ``` -------------------------------- ### 审计 Electron release 覆盖 Source: https://github.com/aynakeya/v8asm/blob/main/note/validation.md 使用官方 stable 覆盖审计脚本,检查 Electron release 的覆盖情况。 ```bash uv run python tests/decomp_rounds/audit_electron_release_coverage.py ``` -------------------------------- ### Build V8ASM matrix for specific versions Source: https://github.com/aynakeya/v8asm/blob/main/note/validation.md Runs the build_v8asm_matrix.sh script for the specified Electron versions (10.8, 13.2, 13.4-electron-staticroots). The script must perform exact tag checkout, gclient sync with branch heads and tags, git apply --3way --recount, and autoninja -j10, reusing each line's existing out/ directory. Each artifact must record v8asm version and build-args. ```bash tests/decomp_rounds/build_v8asm_matrix.sh \ 10.8-electron \ 13.2-electron \ 13.4-electron-staticroots ``` -------------------------------- ### 二进制缓存目录内容 Source: https://github.com/aynakeya/v8asm/blob/main/note/environment-and-build.md 每个目录应包含这些文件。 ```text v8asm snapshot_blob.bin icudtl.dat version.txt build-args.txt ``` -------------------------------- ### 运行完整 Python 测试 Source: https://github.com/aynakeya/v8asm/blob/main/note/validation.md 跨模块的大型修改或准备提交时,运行完整 Python 测试。 ```bash uv run python -m unittest discover -s tests -v ``` -------------------------------- ### hash_combine 和 hash_value_unsigned_impl 实现 (src/base/hashing.h) Source: https://github.com/aynakeya/v8asm/blob/main/note/archive/early-bytecode-research.md V8 的 hash_combine 函数,根据平台位数(32位或64位)使用不同的混合算法。同时包含 hash_value_unsigned_impl 模板函数,用于将整数哈希为 size_t。这些是 Version::Hash() 的底层实现。 ```cpp // src/base/hashing.h V8_INLINE size_t hash_combine(size_t seed, size_t hash) { #if V8_HOST_ARCH_32_BIT const uint32_t c1 = 0xCC9E2D51; const uint32_t c2 = 0x1B873593; hash *= c1; hash = bits::RotateRight32(hash, 15); hash *= c2; seed ^= hash; seed = bits::RotateRight32(seed, 13); seed = seed * 5 + 0xE6546B64; #else const uint64_t m = uint64_t{0xC6A4A7935BD1E995}; const uint32_t r = 47; hash *= m; hash ^= hash >> r; hash *= m; seed ^= hash; seed *= m; #endif // V8_HOST_ARCH_32_BIT return seed; } // ... template V8_INLINE size_t hash_value_unsigned_impl(T v) { switch (sizeof(T)) { case 4: { // "32 bit Mix Functions" v = ~v + (v << 15); // v = (v << 15) - v - 1; v = v ^ (v >> 12); v = v + (v << 2); v = v ^ (v >> 4); v = v * 2057; // v = (v + (v << 3)) + (v << 11); v = v ^ (v >> 16); return static_cast(v); } case 8: { switch (sizeof(size_t)) { case 4: { // "64 bit to 32 bit Hash Functions" v = ~v + (v << 18); // v = (v << 18) - v - 1; v = v ^ (v >> 31); v = v * 21; // v = (v + (v << 2)) + (v << 4); v = v ^ (v >> 11); v = v + (v << 6); v = v ^ (v >> 22); return static_cast(v); } case 8: { // "64 bit Mix Functions" v = ~v + (v << 21); // v = (v << 21) - v - 1; v = v ^ (v >> 24); v = (v + (v << 3)) + (v << 8); // v * 265 v = v ^ (v >> 14); v = (v + (v << 2)) + (v << 4); // v * 21 v = v ^ (v >> 28); v = v + (v << 31); return static_cast(v); } } } } UNREACHABLE(); } // ... template V8_INLINE size_t hash_combine(Ts const&... vs) { return Hasher{}.Combine(vs...); } // ... ``` -------------------------------- ### Run diagnostics with Electron 35.7.5 runtime Source: https://github.com/aynakeya/v8asm/blob/main/note/application-fixture.md Runs the same diagnostic using a specific Electron executable and its matching snapshot blob. The cache's read-only checksum must match the snapshot. The release's snapshot_blob.bin is rejected; only v8_context_snapshot.bin works. ```bash ELECTRON_DIR=/home/aynakeya/workspace/tmp/v8test/electron-cache/v35.7.5-linux-x64 ELECTRON_RUN_AS_NODE=1 uv run python tests/run_application_fixture.py \ --node "$ELECTRON_DIR/electron" \ --snapshot-blob "$ELECTRON_DIR/v8_context_snapshot.bin" \ --out tests/decomp_rounds/out/taskboard-electron-35-numeric-literals ``` -------------------------------- ### Atom 13.4 Static-Roots Binary Path Source: https://github.com/aynakeya/v8asm/blob/main/note/cached-data-and-snapshot.md Path to the 13.4 static-roots build binary used as a native oracle. ```text tests/decomp_rounds/bin_cache/ v8asm.13.4.114.21.electron.staticroots.x64.release/ ``` -------------------------------- ### 二进制缓存目录路径 Source: https://github.com/aynakeya/v8asm/blob/main/note/environment-and-build.md 成功构建的运行文件保存在该目录下。 ```text tests/decomp_rounds/bin_cache/v8asm.<版本与形态>/ ``` -------------------------------- ### Run Ghidra Headless Analysis on V8 Bytecode Source: https://github.com/aynakeya/v8asm/blob/main/note/ghidra.md Runs Ghidra's analyzeHeadless to import a bytecode binary, disassemble with the V8Bytecode processor, and execute the DumpV8Decompile.java script to export listing and decompile results to /tmp/out.txt. Requires the built v8bytecode.sla to be synced with the data/languages directory. ```bash XDG_CONFIG_HOME=/tmp/ghidra-home/.config \ JAVA_HOME=/path/to/jdk \ $GHIDRA_HOME/support/analyzeHeadless /tmp gh-v8-demo \ -import /tmp/input.bytecode.bin \ -processor V8Bytecode:LE:32:default \ -cspec default \ -overwrite \ -scriptPath ghidra/v8-bytecode/ghidra_scripts \ -postScript DumpV8Decompile.java /tmp/out.txt \ -deleteProject ``` -------------------------------- ### 生成语义 fixture Source: https://github.com/aynakeya/v8asm/blob/main/note/validation.md 使用指定的 Node/V8 版本生成 cache,用于语义 fixture。 ```bash uv run python tests/generate_semantic_fixtures.py ``` -------------------------------- ### 切换 V8 tag 的固定流程 Source: https://github.com/aynakeya/v8asm/blob/main/note/environment-and-build.md 切换 V8 tag 后必须同步依赖,再应用对应 patch。禁止省略 gclient sync。 ```bash git checkout <精确的-V8-tag> gclient sync --with_branch_heads --with_tags git apply --3way --recount \ /home/aynakeya/workspace/v8asm/v8patch/<对应-patch> ``` -------------------------------- ### Run semantic equivalence tests Source: https://github.com/aynakeya/v8asm/blob/main/note/application-fixture.md Runs the semantic equivalence test suite using unittest discovery. ```bash uv run python -m unittest discover -s tests -p test_semantic_equivalence.py ``` -------------------------------- ### Run Taskboard with multiple commands Source: https://github.com/aynakeya/v8asm/blob/main/note/application-fixture.md Runs the Taskboard CLI with multiple commands executed sequentially on the same in-memory board. The commands add tasks, mark one done, and list open tasks. ```bash node tests/application_fixture/taskboard.cjs \ 'add "repair parser" --priority=3 --tags=v8,js' \ 'add "review scopes"' 'done T1' 'list --open' ``` -------------------------------- ### 运行 checkversion 模块的多种方式 Source: https://github.com/aynakeya/v8asm/blob/main/note/checkversion.md 提供四种命令行用法:从文件读取哈希、直接输入哈希、计算已知版本哈希、指定 worker 数量。 ```bash uv run python -m checkversion input.jsc ``` ```bash uv run python -m checkversion --hash 0x2b2c7714 ``` ```bash uv run python -m checkversion --calculate 13.6.233.10 ``` ```bash uv run python -m checkversion input.jsc -j 10 ``` -------------------------------- ### Repack and run test copy to capture cache Source: https://github.com/aynakeya/v8asm/blob/main/note/capture-cached-data.md Repack the modified app.asar into a test copy and run it to capture cached data. Do not overwrite the original application; signature or ASAR integrity checks may reject repacking. ```powershell npx @electron/asar pack "C:\tmp\app-unpacked" "C:\tmp\app.asar" Copy-Item "C:\path\to\application-directory" "C:\tmp\application-test" -Recurse Copy-Item "C:\tmp\app.asar" ` "C:\tmp\application-test\resources\app.asar" -Force Remove-Item Env:NODE_OPTIONS -ErrorAction SilentlyContinue $env:V8_CACHE_DUMP_DIR = "C:\tmp\v8-cache-dump" & "C:\tmp\application-test\application.exe" Get-ChildItem "C:\tmp\v8-cache-dump" -Recurse ``` -------------------------------- ### Currently covered V8 versions Source: https://github.com/aynakeya/v8asm/blob/main/note/python-disassembler.md Lists the V8 versions currently covered by profiles. Profile existence only indicates static layout knowledge, not verified samples for every build variant. ```text 10.2.154.4 10.2.154.26 10.8.168.25 11.3.244.8 11.4.183.14 11.9.169.7 12.4.254.12 12.4.254.21 12.9.202.28 13.2.152.41 13.4.114.14 13.4.114.21 13.6.233.8 13.6.233.10 ``` -------------------------------- ### 静态根检查失败错误 (text) Source: https://github.com/aynakeya/v8asm/blob/main/note/cached-data-and-snapshot.md 来自 read-only deserializer 对 V8_STATIC_ROOTS_BOOL 和 snapshot 编码形态的检查错误。正确处理是编译匹配的 v8_enable_static_roots 设置,不要 patch 掉此检查。 ```text Check failed: true == fixed_offset Check failed: false == fixed_offset ``` -------------------------------- ### Custom Node/Electron cache: disassemble with version and snapshot Source: https://github.com/aynakeya/v8asm/blob/main/README.md Disassembles a custom input.jsc with a specific V8 version and snapshot blob, then decompiles the resulting JSON. The snapshot is matched by read-only checksum, not filename; incompatible versions or missing strings cause errors or unresolved references. ```bash uv run python -m disassembler input.jsc \ --version 13.4.114.21 --snapshot-blob v8_context_snapshot.bin \ --format json > /tmp/input.disasm.json uv run python -m decompiler /tmp/input.disasm.json > /tmp/input.decompiled.js ``` -------------------------------- ### Insert preload into loader Source: https://github.com/aynakeya/v8asm/blob/main/note/capture-cached-data.md Insert this preload into the loader before it imports or saves the vm.Script reference. The capture script must run before V8 consumes the cache. ```javascript require(String.raw`C:\src\v8asm\disassembler\capture_cached_data.cjs`); const vm = require("node:vm"); ``` -------------------------------- ### 质量检查指标列表 Source: https://github.com/aynakeya/v8asm/blob/main/note/decompiler.md 列出判断输出质量时需重点检查的四个指标:raw_goto、goto_comments、unknown_comments、undefined_fallbacks。raw_goto 和未知 opcode 应默认保持为零。 ```text raw_goto 实际可执行的 goto offset_... 语句 goto_comments 注释中的未结构化跳转 unknown_comments 未识别 opcode 注释 undefined_fallbacks 对象打印失败占位符 ``` -------------------------------- ### 输出目录示例 Source: https://github.com/aynakeya/v8asm/blob/main/note/environment-and-build.md 列出 v8asm 项目不同兼容形态的输出目录,每个目录对应一个独立的构建配置。 ```text out/v8asm.10.8.node.x64.release out/v8asm.10.8.electron.x64.release out/v8asm.13.2.152.41.electron.x64.release out/v8asm.13.2.152.41.electron.nostaticroots.x64.release out/v8asm.13.4.114.21.electron.staticroots.x64.release out/v8asm.13.6.node24.x64.release ``` -------------------------------- ### 反汇编输入文件并指定完整版本 Source: https://github.com/aynakeya/v8asm/blob/main/note/generated-assets.md 运行时显式使用完整版本,输出 JSON 格式的反汇编结果。 ```bash uv run python -m disassembler input.jsc \ --version 11.3.244.8-node.38 --format json > input.disasm.json ``` -------------------------------- ### Electron 风格构建参数 Source: https://github.com/aynakeya/v8asm/blob/main/note/environment-and-build.md Electron 风格通常需要开启 pointer compression 并设置 embedder string。 ```text v8_enable_pointer_compression=true v8_embedder_string="-electron.0" ``` -------------------------------- ### Pause main process with --inspect-brk Source: https://github.com/aynakeya/v8asm/blob/main/note/capture-cached-data.md Pause the main process with --inspect-brk=9229 when NODE_OPTIONS is disabled. Connect via chrome://inspect at localhost:9229 and run the require command in the console. ```powershell $env:V8_CACHE_DUMP_DIR = "C:\tmp\v8-cache-dump" & "C:\path\to\application.exe" --inspect-brk=9229 ``` -------------------------------- ### Capture output files in PID directory Source: https://github.com/aynakeya/v8asm/blob/main/note/python-disassembler.md Lists the files written to each PID directory by the capture script. The normalized cache is regenerated by the same runtime after V8 accepts the input; raw payload is only written when the header layout is unique. The script does not guess offsets. ```text 0000.input.jsc 应用实际传入 vm.Script 的 buffer 0000.normalized.jsc 接受后由相同 runtime 重新生成的标准 cache 0000.payload.bin 从 normalized cache 精确切出的无 header payload 0000.json V8 版本、文件名、大小和 rejected 状态 ``` -------------------------------- ### 研究模式:--force-incompatible (bash) Source: https://github.com/aynakeya/v8asm/blob/main/note/cached-data-and-snapshot.md 启用 --force-incompatible 的研究模式命令,允许进入真实 deserializer 并打印 mismatch,但仍有多种限制。 ```bash ./v8asm \ --snapshot_blob /path/to/matching-snapshot.bin \ disasm input.jsc \ --force-incompatible ``` -------------------------------- ### Electron 34.3.0 Matching Binary Path Source: https://github.com/aynakeya/v8asm/blob/main/note/cached-data-and-snapshot.md Path to the matching v8asm binary for Electron 34.3.0. ```text tests/decomp_rounds/bin_cache/ v8asm.13.2.152.41.electron.x64.release/v8asm ``` -------------------------------- ### Brute-force V8 version using v8::base::hash_combine Source: https://github.com/aynakeya/v8asm/blob/main/note/archive/early-bytecode-research.md Iterates over plausible major/minor/build/patch ranges and compares the hash_combine result to the target hash. Returns the first matching VersionTuple, or {-1,-1,-1,-1} if none found. Uses the v8::base::hash_combine function directly. ```cpp struct VersionTuple { int major; int minor; int build; int patch; }; VersionTuple bruteforce_v8_version(uint32_t target_hash, int max_major = 20, int max_minor = 20, int max_build = 500, int max_patch = 200) { for (int major = 0; major < max_major; ++major) { for (int minor = 0; minor < max_minor; ++minor) { for (int build = 0; build < max_build; ++build) { for (int patch = 0; patch < max_patch; ++patch) { uint32_t h = static_cast(v8::base::hash_combine(major, minor, build, patch)); if (h == target_hash) { return VersionTuple{major, minor, build, patch}; } } } } } return VersionTuple{-1, -1, -1, -1}; } ``` -------------------------------- ### 核心验证函数 core.js Source: https://github.com/aynakeya/v8asm/blob/main/note/archive/early-bytecode-research.md 定义了一个简单的 license 验证函数,用于演示 JavaScript 代码保护的必要性。该函数直接比较 license 字符串,并输出验证结果。 ```javascript function validate(license) { if (license === "lol_you_will_never_know") { console.log("valid") return true } console.log("not valid") return false; } module.exports = { validate }; ``` -------------------------------- ### Preload capture script on Linux/macOS Source: https://github.com/aynakeya/v8asm/blob/main/note/capture-cached-data.md Preload the capture script on Linux/macOS by setting V8_CACHE_DUMP_DIR and NODE_OPTIONS before launching the Electron app. The script must be loaded before the loader consumes the cache. ```bash V8_CACHE_DUMP_DIR=/tmp/v8-cache-dump \ NODE_OPTIONS="--require=/absolute/path/to/v8asm/disassembler/capture_cached_data.cjs" \ /path/to/electron-app ``` -------------------------------- ### 生成标准 V8 profile Source: https://github.com/aynakeya/v8asm/blob/main/note/generated-assets.md 使用精确 V8 tag 生成标准 profile,不切换 checkout、不改构建缓存。需要本机 C/C++ 预处理器。 ```bash uv run python -m disassembler.generate_profiles \ --v8-repo /path/to/v8 --output-dir disassembler/profiles ``` -------------------------------- ### 使用 disassembler 生成结构化 JSON 并运行 decompiler Source: https://github.com/aynakeya/v8asm/blob/main/note/decompiler.md 推荐输入为 disassembler 生成的结构化 JSON。第一个命令生成 JSON,第二个命令运行反编译器。默认模式执行完整源码恢复。 ```bash uv run python -m disassembler input.jsc \ --version <精确版本> \ --snapshot-blob <匹配的-snapshot> \ --format json > /tmp/input.disasm.json uv run python -m decompiler /tmp/input.disasm.json \ > /tmp/input.decompiled.js ```