shared library loading in-mem

This commit is contained in:
minjaesong
2025-04-19 22:14:36 +09:00
parent 4e063fe08e
commit 111c196e7c
2 changed files with 13 additions and 1 deletions

View File

@@ -9,15 +9,27 @@ let infile = files.open(infilePath)
const metaArea = sys.malloc(12)
infile.pread(metaArea, 12, 0)
let intent = sys.peek(metaArea+4) // 2 for executable, 3 for shared
let addrToLoad = (sys.peek(metaArea+5) << 16) | (sys.peek(metaArea+6) << 8) | (sys.peek(metaArea+7))
const imageSize = (sys.peek(metaArea+9) << 16) | (sys.peek(metaArea+10) << 8) | (sys.peek(metaArea+11))
sys.free(metaArea)
if (addrToLoad == 0)
addrToLoad = sys.malloc(imageSize + 4)
else
sys.forceAlloc(addrToLoad, imageSize + 4)
// if it's a shared library, put it into the global table
if (3 == intent) {
// create the table if it's not there
if (!_G.SO)
_G.SO = {}
let libname = exec_args[1].split("\\").last().substringBeforeLast(".")
_G.SO[libname] = addrToLoad
}
// writes IMAGE_SIZE and the BINARY_IMAGE directly to the memory
infile.pread(addrToLoad, imageSize + 4, 8)
infile.close()

View File

@@ -835,7 +835,7 @@ class GraphicsJSR223Delegate(private val vm: VM) {
score += contrastWeight(yALow, yBLow, deltaLow, 2)
}
return score > 14.0
return score > 4.0
}
fun encodeIpf2(srcPtr: Int, destPtr: Int, width: Int, height: Int, channels: Int, hasAlpha: Boolean, pattern: Int) {