Skip to content

Instantly share code, notes, and snippets.

@ess7
ess7 / rpr_dump_func.py
Last active November 14, 2021 04:25
Dump NSEEL functions in jsfx.dll
from ctypes import *
import struct
import re
assert RPR_GetAppVersion()[-4:] == '/x64'
def console(s):
RPR_ShowConsoleMsg(str(s) + '\n')
class MODULEINFO(Structure):
@ess7
ess7 / myadd.cpp
Last active November 6, 2021 20:19
Call C function from Reaper JSFX (x86/x64, no hardcoded offsets, 6.x tested)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <reaper_plugin.h>
#include <ns-eel.h>
/*
* If you actually try this, the JS effect that uses the new function should not be the first one loaded,
* otherwise you will get an "undefined 'myadd'" error.
* Workarounds: recompile/reset or add any JS effect before this
@ess7
ess7 / jsfx_dotprod.c
Created October 16, 2018 04:30
JSFX extension: dot product
// params: y0, y1, interleaved x, coeff, n
static EEL_F NSEEL_CGEN_CALL dotprod2(void *opaque, INT_PTR np, EEL_F **parms) {
EEL_F **blocks = (EEL_F **)opaque;
int xofs = *parms[2];
int cofs = *parms[3];
int n = *parms[4];
*parms[0] = 0.0;
*parms[1] = 0.0;
if (unlikely(n <= 0 || xofs < 0 || cofs < 0 ||
@ess7
ess7 / jsfx_addfunc.c
Last active November 4, 2021 06:11
Call C function from Reaper JSFX PoC
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <math.h>
#include "ns-eel.h"
#ifndef I_KNOW_WHAT_I_AM_DOING
#error Hardcoded offsets are for 32-bit 5.95 and possibly other versions
#endif
@ess7
ess7 / thiscall.py
Last active January 31, 2024 10:03
Calling a thiscall DLL function in Python ctypes (x86)
import ctypes
kernel32 = ctypes.windll.kernel32
# __declspec(dllexport) __thiscall int add3(int a, int b, int c) {
# return a + b + c;
# }
_add3 = ctypes.cdll.lib.add3
buf = kernel32.VirtualAlloc(0, 4096, 0x3000, 0x40)