Skip to content

Commit e85560a

Browse files
committed
feat: dynamic function match
1 parent fee90a1 commit e85560a

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

electron/main.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function createWindow() {
3838
if(!cached) {
3939
cached = true;
4040
console.log("Fetched:", details.url);
41-
41+
const script = await fetch(details.url.substring(0,details.url.length-4) + "js").then(res => res.text());
4242
const request = net.request(details.url + "?ayuscript");
4343
let chunks = [];
4444
request.on('response', (response) => {
@@ -49,12 +49,12 @@ function createWindow() {
4949
let buffer = Buffer.concat(chunks);
5050

5151
try {
52-
const parsed = parseRules(buffer, rules);
53-
const parsedFunctions = {};
54-
55-
for (let key in parsed) {
56-
parsedFunctions[key] = parsed[key].substring(5);
57-
}
52+
// const parsed = parseRules(buffer, rules);
53+
// const parsedFunctions = {};
54+
//
55+
// for (let key in parsed) {
56+
// parsedFunctions[key] = parsed[key].substring(5);
57+
// }
5858

5959
const module = Binaryen.readBinary(buffer);
6060

@@ -74,10 +74,10 @@ function createWindow() {
7474

7575
for (let i = 0; i < module.getNumExports(); i++) {
7676
const exp = Binaryen.getExportInfo(module.getExportByIndex(i));
77-
if (exp.name === "kg") {
77+
if (exp.name === /[a-zA-Z]\._main=[a-zA-Z]\.asm\.([a-zA-Z]{2})/.exec(script)[1]) {
7878
main = exp.value;
7979
}
80-
if (exp.name === "Of") {
80+
if (exp.name === /[a-zA-Z]\._malloc=[a-zA-Z]\.asm\.([a-zA-Z]{2})/.exec(script)[1]) {
8181
malloc = exp.value;
8282
}
8383
}

0 commit comments

Comments
 (0)