mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-07 19:51:51 +09:00
it does work if you load compiled hypervisor
This commit is contained in:
@@ -1,9 +1,26 @@
|
||||
if (exec_args[1] === undefined) {
|
||||
println("Usage: compile myfile.js")
|
||||
println("The compiled file will be myfile.bin")
|
||||
println("Usage: compile -le/-lo myfile.js")
|
||||
println(" The compiled and linked file will be myfile.out")
|
||||
return 1
|
||||
}
|
||||
const filenameWithoutExt = exec_args[1].substringBeforeLast(".")
|
||||
_G.shell.execute(`gzip -c ${exec_args[1]} | writeto ${filenameWithoutExt}.gz`)
|
||||
_G.shell.execute(`enc ${filenameWithoutExt}.gz ${filenameWithoutExt}.bin`)
|
||||
_G.shell.execute(`rm ${filenameWithoutExt}.gz`)
|
||||
|
||||
// with linking
|
||||
if (exec_args[2]) {
|
||||
const filenameWithoutExt = exec_args[2].substringBeforeLast(".")
|
||||
const tempFilename = generateRandomHashStr(32)
|
||||
|
||||
_G.shell.execute(`gzip -c ${exec_args[2]} | writeto ${tempFilename}.gz`)
|
||||
_G.shell.execute(`enc ${tempFilename}.gz ${tempFilename}.bin`)
|
||||
_G.shell.execute(`rm ${tempFilename}.gz`)
|
||||
|
||||
_G.shell.execute(`link -${exec_args[1][2]} ${tempFilename}.bin`)
|
||||
_G.shell.execute(`mv ${tempFilename}.out ${filenameWithoutExt}.out`)
|
||||
_G.shell.execute(`rm ${tempFilename}.bin`)
|
||||
}
|
||||
// with no linking
|
||||
else {
|
||||
const filenameWithoutExt = exec_args[1].substringBeforeLast(".")
|
||||
_G.shell.execute(`gzip -c ${exec_args[1]} | writeto ${filenameWithoutExt}.gz`)
|
||||
_G.shell.execute(`enc ${filenameWithoutExt}.gz ${filenameWithoutExt}.bin`)
|
||||
_G.shell.execute(`rm ${filenameWithoutExt}.gz`)
|
||||
}
|
||||
|
||||
14
assets/disk0/home/hdk/free.js
Normal file
14
assets/disk0/home/hdk/free.js
Normal file
@@ -0,0 +1,14 @@
|
||||
if (exec_args[1] === undefined) {
|
||||
println("Usage: free ptr_in_hex")
|
||||
println(" This will free the pointer loaded using 'load'")
|
||||
return 1
|
||||
}
|
||||
|
||||
// check for CUM header
|
||||
const ptr = parseInt(exec_args[1], 16)
|
||||
const magic = sys.peek(ptr)
|
||||
|
||||
if (magic != 0xA5) return 1
|
||||
|
||||
|
||||
sys.free(ptr)
|
||||
@@ -12,7 +12,8 @@ if (magic != 0xA5) return 1
|
||||
|
||||
|
||||
const source = sys.toObjectCode(ptr)
|
||||
const wrapper = new Function("exec_args", `const g={exec_args};with(g){${source}}`);
|
||||
//const wrapper = new Function("exec_args", `const g={exec_args};with(g){${source}}`);
|
||||
const wrapper = new Function("_BIOS", "_G", "_TVDOS", "exec_args", source)
|
||||
const newArgs = ["@ptr:"+ptr].concat(exec_args.slice(2))
|
||||
|
||||
wrapper(newArgs)
|
||||
wrapper(_BIOS, _G, _TVDOS, newArgs)
|
||||
Reference in New Issue
Block a user