Last active
August 17, 2022 17:08
-
-
Save valstu/9a7877dee0010e65afcc963646fb4b4a to your computer and use it in GitHub Desktop.
Revisions
-
valstu revised this gist
Aug 17, 2022 . 2 changed files with 14 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,18 +1,23 @@ @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; } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,8 @@ 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) -
valstu created this gist
Aug 17, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ @external("env", "_g") export declare function GUARD(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 //////////////////////// export function LOG (text: string): void { TRACE(text, text.length * 2, text, text.length * 2, 0) } export function OK (text: string = 'OK'): void { ACCEPT(text, text.length * 2, 0) } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ 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 }