npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

zyue-scan

v1.0.2

Published

通过Nodejs实现一个简单的Cheat Engine的搜索内存功能

Readme

Node.js 内存扫描器

一个高性能的 Windows 进程内存扫描模块,使用 Koffi 调用原生 API 并通过工作线程实现并行扫描。

功能特点

  • 🚀 多线程内存扫描 - 利用多核 CPU 并行扫描,大幅提升扫描速度
  • 🔍 多种数据类型支持 - 支持整数、浮点数、十六进制模式和字符串扫描
  • 📊 智能内存区域检测 - 自动识别可访问内存区域,跳过受保护区域
  • 🔒 安全内存访问 - 正确处理内存访问异常,避免进程崩溃
  • ⏱️ 高性能优化 - 使用大块内存读取减少系统调用,提升扫描效率
  • 🧩 简单易用的 API - 提供直观的方法链式调用

前置依赖

  • Windows 操作系统 (x64 架构)
  • Node.js v14+
  • Python 3.x (用于 Koffi 编译)
  • Visual Studio Build Tools (需包含 C++ 开发组件)

安装 Build Tools 命令:

npm install --global windows-build-tools

快速入门

基本扫描示例

javascript

const MemoryScanner = require('zyue');
(async () => {
    try {
        // 创建扫描器实例
        const scanner = new MemoryScanner();
        // 获取进程ID
        const pid = await scanner.getPid("notepad.exe");
        console.log(`找到进程ID: ${pid}`);

        // 打开进程
        await scanner.open(pid);

        // 扫描整数值
        const intResults = await scanner.scanInt(100);
        console.log("找到的整数地址:", intResults);

        // 扫描浮点值
        const floatResults = await scanner.scanFloat(3.14);
        console.log("找到的浮点数地址:", floatResults);

        // 扫描十六进制模式 (支持通配符 '..')
        const hexResults = await scanner.scanHex("01 02 .. 04");
        console.log("找到的十六进制模式地址:", hexResults);

        // 扫描字符串
        const stringResults = await scanner.scanString("Hello World");
        console.log("找到的字符串地址:", stringResults);

        // 读取内存数据
        if (intResults.length > 0) {
            const address = intResults[0];
            const data = await scanner.readData(address, 4);
            console.log(`地址 ${address} 的数据:`, data);
        }

        // 关闭扫描器
        await scanner.close();
    } catch (err) {
        console.error("发生错误:", err);
    }
})();

高级选项配置

javascript

// 自定义扫描参数
const results = await scanner.scan(123.45, 'float');
// 直接扫描特定类型
const customScanResults = await scanner.scan("搜索值", "类型");

API 参考

new MemoryScanner()

创建新的内存扫描器实例。

async scanner.getPid(processName: string): Promise<number>

通过进程名称获取进程ID。

参数:

  • processName: 进程可执行文件名 (如 "notepad.exe")

返回: 进程ID (数字)

异常: 如果找不到进程会抛出错误

async scanner.open(pid: number): Promise<void>

打开进程句柄准备进行内存扫描。

参数:

  • pid: 要扫描的进程ID

异常: 如果无法打开进程会抛出错误

async scanner.scanInt(value: number): Promise<string[]>

扫描内存中的4字节整数值。

参数:

  • value: 要搜索的整数值

返回: 匹配的内存地址数组 (十六进制字符串格式)

async scanner.scanFloat(value: number): Promise<string[]>

扫描内存中的4字节浮点数值。

参数:

  • value: 要搜索的浮点数值

返回: 匹配的内存地址数组 (十六进制字符串格式)

async scanner.scanHex(pattern: string): Promise<string[]>

扫描内存中的十六进制模式。

参数:

  • pattern: 十六进制搜索模式 (支持 .. 通配符)
    • 示例: "01 A2 .. FF" 匹配 01 A2 任意值 FF

返回: 匹配的内存地址数组 (十六进制字符串格式)

async scanner.scanString(value: string): Promise<string[]>

扫描内存中的UTF-8字符串。

参数:

  • value: 要搜索的字符串

返回: 匹配的内存地址数组 (十六进制字符串格式)

async scanner.scan(value: any, valueType: string, options?: object): Promise<string[]>

通用扫描方法,可指定数据类型和选项。

参数:

  • value: 要搜索的值
  • valueType: 数据类型 ('int', 'float', 'hex', 'string')

返回: 匹配的内存地址数组 (十六进制字符串格式)

async scanner.readData(address: string | number, size: number): Promise<Buffer>

从指定内存地址读取原始数据。

参数:

  • address: 内存地址 (十六进制字符串或数字)
  • size: 要读取的字节数

返回: 包含读取数据的Buffer对象

async scanner.close(): Promise<void>

关闭进程句柄并释放资源。

性能优化建议

  1. 精确匹配模式 - 使用更具体的模式减少误报和扫描时间
  2. 合理设置工作线程 - 内存受限系统可减少工作线程数
  3. 调整块大小 - 大内存进程可增大块大小(8-16MB)提升性能
  4. 及时释放资源 - 扫描完成后调用 close() 释放系统资源
  5. 多次扫描优化 - 首次宽泛扫描后缩小范围进行精确扫描

注意事项与限制

  1. 仅支持 Windows 系统 - 不能在 Linux 或 macOS 上使用
  2. 需要管理员权限 - 扫描某些系统进程可能需要提升权限
  3. 64位进程支持 - 仅支持64位目标进程的内存扫描
  4. 内存保护限制 - 只能扫描已提交且可读的内存区域
  5. 防作弊系统兼容性 - 扫描某些游戏进程可能触发反作弊系统

工作原理

  1. 使用 Windows API 枚举进程内存区域
  2. 过滤出可访问的内存区域
  3. 将内存区域分割分配给多个工作线程
  4. 每个工作线程读取内存块并进行模式匹配
  5. 汇总所有工作线程的结果并返回

贡献指南

欢迎提交 Pull Request 和改进建议:

  1. Fork 仓库
  2. 创建特性分支 (git checkout -b feature/improvement)
  3. 提交更改 (git commit -am 'Add some feature')
  4. 推送分支 (git push origin feature/improvement)
  5. 创建 Pull Request

许可证

MIT 许可证 - 开源免费使用