Skip to content

Instantly share code, notes, and snippets.

@valstu
Last active August 17, 2022 17:08
Show Gist options
  • Save valstu/9a7877dee0010e65afcc963646fb4b4a to your computer and use it in GitHub Desktop.
Save valstu/9a7877dee0010e65afcc963646fb4b4a to your computer and use it in GitHub Desktop.
@external("env", "_g")
export declare function _g(id: i32, maxiter: i32): i64
@external("env", "accept")
export declare function accept(read_ptr: string, read_len: i32, err: i64): i64
@external("env", "trace")
export declare function TRACE(mread_ptr: string, mread_len: i32, dread_ptr: string, dread_len: i32, as_hex: i32): i64
////////////////////////
function LOG (text: string): void {
TRACE(text, text.length * 2, text, text.length * 2, 0)
}
export function hook(reserved: i32 = 0): i64 {
LOG("Accept.c: Called.");
accept('', 0, 0);
_g(1,1); // every hook needs to import guard function and use it at least once
// unreachable
return 0;
}
import {GUARD, LOG, OK} from './HooksLib'
export function cbak(reserved: i32 = 0): i64 {
return 0
}
export function hook(reserved: i32 = 0): i64 {
GUARD(1, 1)
for (let i = 0; GUARD(10, 10), i < 3; i++) {
LOG('-- :D --')
}
OK('-- :) --')
return 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment