# node-windows-x64

> node windows x64

Latest version **0.0.13** (published 2023-05-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-windows-x64
pnpm add node-windows-x64
yarn add node-windows-x64
bun add node-windows-x64
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.13 |
| Published | 2023-05-31 |
| First published | 2021-02-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 5.2 MB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 9 |
| Author | Ajanuw |
| Maintainers | ajanuw |
| Keywords | windows, windows x64, memory, win32 gui, invoke, asm, asmjit, asmtk, CEAddressString, Ajanuw |

## Links

- npm: https://www.npmjs.com/package/node-windows-x64
- Repository: https://github.com/januwA/node-windows-x64
- Issues: https://github.com/januwA/node-windows-x64/issues
- npm.io page: https://npm.io/package/node-windows-x64

## Dependencies (2)

- [bindings](https://npm.io/package/bindings.md) ^1.5.0
- [node-addon-api](https://npm.io/package/node-addon-api.md) ^6.1.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.0.13 (latest) — 2023-05-31
- 0.0.12 — 2023-05-30
- 0.0.11 — 2023-05-29
- 0.0.10 — 2021-06-05
- 0.0.9 — 2021-04-01
- 0.0.8 — 2021-04-01
- 0.0.7 — 2021-03-28
- 0.0.6 — 2021-02-27
- 0.0.5 — 2021-02-27
- 0.0.4 — 2021-02-27
- 0.0.3 — 2021-02-22
- 0.0.2 — 2021-02-20
- 0.0.1 — 2021-02-19

## README

## node-windows-x64

 Provides some low-level APIs

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

 ## Install
 ```sh
 $ npm i node-windows-x64
 ```

## Example
 ```js
// 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
```js
const r = nw["user32.EnumWindows"]((hwnd, param) => {
  console.log("hwnd: %d, param: %d", hwnd, param);
  return true;
}, 10);

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

## win32 gui
```js
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
```js
const r = nw.aa(
  `
  inc rcx
  mov rax,rcx
  ret
`,
  1
);

console.log(r); // 2
```

## Target
```js
/**
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
```js
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
```js
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'
});
```
```c++
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

---
_Source: https://npm.io/package/node-windows-x64 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
