0.0.3 • Published 1 year ago

dll-inject v0.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

dll-inject

Native node addon for dll injection in windows.

Requires a working node-gyp setup to compile the native addon.

Installation

Simply add dll-inject as a dependency in the package.json of your NodeJs Project:

npm install dll-inject

Usage

By process name

const injector = require('dll-inject');

if (injector.isProcessRunning('notepad.exe')) {
    const error = injector.inject('notepad.exe', 'mydll.dll');

    if (!error) {
        console.log('Successfully injected!');
    } else {
        console.log('Injection failed. Error Code:', error);
    }
}

By process id

const injector = require('dll-inject');

if (injector.isProcessRunningPID(1234)) {
    const error = injector.injectPID(1234, 'mydll.dll');

    if (!error) {
        console.log('Successfully injected!');
    } else {
        console.log('Injection failed. Error Code:', error);
    }
}

Error Codes

These codes are returned by the inject() and injectPID() functions as integer values

IntError
0Injection Successfull
1Process is not open
2Getting path name failed
3Buffer too small for path name
4Failed to allocate memory
5Failed to write memory
6Failed to create remote thread to load the DLL

Testing

There is a testdll.dll in the package folder of this project which will just open a new window from the process it was injected in which tells you when the dll is loaded and unloaded. There is also already a test js file in the test folder that you can run with npm test (be aware that for this to work notepad needs to be running and you are inside the package folder when executing npm test)

Inspiration

This package is inspired by the popular package node-dll-injector from mcoot. Since it looked like he discontinued working on the package in 2019 i basically rewrote the whole node native addon with the new v8 api that node-gyp and node js are using and with the new nan package changes. The core mechanic is the same as in the package from @mcoot. So thanks a lot to him ^-^.

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

3 years ago