Skip to content

Hook Cleaner removes unwanted compiler-provided exports and functions from a wasm binary to make it (more) suitable for being used as a Hook

Notifications You must be signed in to change notification settings

valstu/hook-cleaner-c

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hook Cleaner Wasm

Hook Cleaner removes unwanted compiler-provided exports and functions from a wasm binary to make it (more) suitable for being used as a Hook. This fork compiles Hook Cleaner to wasm which allows you to use Hook Cleaner directly in browser.

WIP

This project is still being debugged

Requirements

  • emscripten and its dependencies

Build

emcc cleaner.c -o cleaner.js -sEXPORTED_RUNTIME_METHODS=ccall,cwrap,callMain,FS -sMODULARIZE=1 -sEXPORT_NAME=Cleaner -sENVIRONMENT='web' -sEXPORT_ES6=1 -sUSE_ES6_IMPORT_META=1 -sFORCE_FILESYSTEM -sINVOKE_RUN=0 -sALLOW_TABLE_GROWTH -sWASM=1 -sALLOW_MEMORY_GROWTH=1

Use in your webpage

import Cleaner from './cleaner';

// initialize cleaner
const cleaner = await Cleaner({
  locateFile: (file: string) => {
    return file;
  },
});

// Add your file:File eg. from file input to virtual file system
const cleanFile = (file: File) => {
  const buffData = await file.arrayBuffer();
  // create folder where to put file
  cleaner.FS.mkdir("files");
  // create file
  cleaner.FS.createDataFile(
    "/files",
    file.name,
    new Uint8Array(buffData),
    true,
    true
  );
  // call the cleaner main function with filename
  const ok = await cleaner.callMain([`/files/${file.name}`]);
  // cleaner overwrites the cleaned file, let's read it
  const newFileUArr = cleaner.FS.readFile(`/files/${file.name}`);

  // lets remove the file from the file system
  clener.FS.unlink(`/files/${file.name}`);
  // lets remove the directory
  cleaner.FS.rmdir("files");

  // Return file content (UInt8Array)
  return newFileUArr
}

About

Hook Cleaner removes unwanted compiler-provided exports and functions from a wasm binary to make it (more) suitable for being used as a Hook

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 77.2%
  • C 22.1%
  • Other 0.7%