Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

node-windows-x64

januwA97MIT0.0.13TypeScript support: included

node windows x64

windows, windows x64, memory, win32 gui, invoke, asm, asmjit, asmtk, CEAddressString, Ajanuw

readme

node-windows-x64

Provides some low-level APIs

Only tested on Windows 10 and Intel 64-bit cpu and vs2019/vs2022

Install

 $ npm i node-windows-x64

Example

// import { node_windows_x64 as nw } from "node-windows-x64";
 const { node_windows_x64: nw } = require("node-windows-x64");

nw.MessageBoxA(0, "body", "title", 3);

Callback

const r = nw["user32.EnumWindows"]((hwnd, param) => {
  console.log("hwnd: %d, param: %d", hwnd, param);
  return true;
}, 10);

console.log("result: ", r);

win32 gui

nw.globalDefine();

const className = "Node Win32 Gui";
const windowName = "window caption";

const wui = new nw.Win32Gui(className, windowName, {
  x: 100,
  y: 100,
  width: 600,
  height: 400,
  style: WS_OVERLAPPEDWINDOW,
});

if (wui.initRegisterClass() && wui.initWindow()) {

  // create a button
  wui.button({
    id: 1,
    windowName: "click me",
    events: {
      click() {
        console.log('button clicked.');
      },
    },
  });

  wui.messageLoop((hWnd, message, wParam, lParam) => {});
}

Auto Asm

const r = nw.aa(
  `
  inc rcx
  mov rax,rcx
  ret
`,
  1
);

console.log(r); // 2

Target

/**
define(address,"Tutorial-i386.exe"+2578F)
define(bytes,29 83 AC 04 00 00)

[ENABLE]
address:
  db 90 90 90 90 90 90

[DISABLE]
address:
  db bytes

*/

const t = nw.createTargetWithName("Tutorial-i386.exe");
if (t.pid && t.hProcess) {

  const address = nw.getAddress(`"Tutorial-i386.exe"+2578F`, t.hProcess);
  const handle = t.setNop(address, 6);
  console.log(handle);

  if (handle.bSuccess) {
    handle.enable();

    setTimeout(() => {
      handle.disable();

      // 如果不在使用handle,那么一定要调用delete函数
      handle.delete();
    }, 1000 * 10);
  }

}

Parameter types and return value types

nw.invoke({
  method: 'dll1.fndll9',
  args: [4.67, 10],
  argsType: ['float', 'int'],
  retType: 'int'
});

nw.invoke({
  method: 'MessageBoxA',
  args: [0, "content", "title", 1],
  argsType: ['int', 'str', 'str', 'int'],
  retType: 'int'
});

nw.invoke({
  method: 'MessageBoxW',
  args: [0, "content", "title", 1],
  argsType: ['int', 'wstr', 'wstr', 'int'],
  retType: 'int'
});

Callback function signature

const result = nw.invoke({
  method: 'dll1.fndll1',
  args: [(...args) => {
    console.log(args); // [ -100, 100, -233, 10, 1.2200000286102295, 7.334, 'char*', 'wchar*' ]
    return 99.99;
  }],
  argsType: ['fn2(int,uint,int64,uintptr,float,double,str,wstr):float'],
  retType: 'float'
});
extern "C" __declspec(dllexport)  float fndll1(
  float (*cb)(int, uint32_t, int64_t, uintptr_t, float, double,const char*, const wchar_t*)
) 
{
    return cb(-100, 100, -233, 10, 1.22, 7.334, "char*", L"wchar*");
}

There are more examples under the "examples" file

changelog

0.0.13 [2023-5-31]

  • feat: Support integer memory read and write
  • feat: Callback function signature

0.0.12 [2023-5-30]

  • feat: Set the return value type of the invoke function
  • feat: The invoke function supports floating point numbers
  • show examples/invoke.md

0.0.11 [2023-5-29]

0.0.10 [2021-5-19]

  • test version
  • feat: CEAddressString ignore case
  • perf: CEAddressString Rewrite the parser (use Flex&Bison)
  • perf: use c++20
  • Remove the (expr) syntax of CEAddressString

0.0.9 [2021-4-1]

  • test version
  • feat: Add "Ex" series of functions, user operation target process memory
  • refactor: The underscore naming style is changed to the camel naming style
  • refactor: "mem" series of functions, delete the "mem" prefix mem_read_byte => readByte

0.0.8 [2021-3-29]

  • test version
  • perf: CEAddressString
  • perf: function getAddress(CEAddressString: string, hProcess?: number): number;
  • feat: class Target
  • feat: function asmBytes(asmString: string): ArrayBuffer;

0.0.7 [2021-2-28]

  • test version
  • perf: Use asmjit to rewrite invoke
  • fix: fix globalDefineScript.js
  • perf: Improve CEAddressString parser

0.0.6 [2021-2-27]

  • test version
  • fix: Fix the error when invoke handles callback

0.0.5 [2021-2-27]

  • test version
  • fix: Fix the error of invoke parameter address offset

0.0.4 [2021-2-27]

  • test version
  • feat: Support parsing CEAddressString
  • feat: add registerSymbol and unregisterSymbol
  • perf: Use asmjit to rewrite the "createCallback" function
  • perf: The module of invoke is now an optional parameter
  • docs: undate invoke docs
  • feat: "nw.mem_*" Series supports CEAddressString
  • feat: Map attributes that do not exist on node_windows_x64 to the invoke function
  • feat: Add "globalDefineScript" script to define a large number of global variables in global
  • feat: win32 gui add more functions to generate controls
  • feat: win32 gui add event listener callback
  • feat: Auto Asm

0.0.3 [2021-2-22]

  • test version
  • feat: asmtk

0.0.2 [2021-2-21]

  • test version
  • feat: asmjit

0.0.1 [2021-2-19]

  • test version
  • feat: invoke
  • feat: win32 gui
  • feat: va_manage
  • feat: mem
  • feat: byte_table
  • feat: tools