mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-14 16:34:04 +09:00
decryptpayload to work on negative memory addr
This commit is contained in:
@@ -267,15 +267,18 @@ class VMJSR223Delegate(private val vm: VM) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun toObjectCode(ptr: Int): java.lang.String {
|
fun toObjectCode(ptr: Int): java.lang.String {
|
||||||
val payloadSize = peek(ptr+1).shl(16) or peek(ptr+2).shl(8) or peek(ptr+3)
|
val payloadSize = if (ptr >= 0)
|
||||||
|
peek(ptr+1).shl(16) or peek(ptr+2).shl(8) or peek(ptr+3)
|
||||||
|
else
|
||||||
|
peek(ptr-1).shl(16) or peek(ptr-2).shl(8) or peek(ptr-3)
|
||||||
|
|
||||||
val decrypted = decryptPayload(ptr, payloadSize)
|
val decrypted = decryptPayload(ptr, payloadSize, (ptr < 0))
|
||||||
val image = CompressorDelegate.decomp(decrypted)
|
val image = CompressorDelegate.decomp(decrypted)
|
||||||
return java.lang.String(image)
|
return java.lang.String(image)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun decryptPayload(ptr: Int, payloadSize: Int): ByteArray {
|
private fun decryptPayload(ptr: Int, payloadSize: Int, dec: Boolean): ByteArray {
|
||||||
var key = "00"
|
var key = "00"
|
||||||
var keyBytes = byteArrayOf(0x00)
|
var keyBytes = byteArrayOf(0x00)
|
||||||
var keyCursor = 0
|
var keyCursor = 0
|
||||||
@@ -313,7 +316,9 @@ class VMJSR223Delegate(private val vm: VM) {
|
|||||||
val encrypted = ByteArray(payloadSize)
|
val encrypted = ByteArray(payloadSize)
|
||||||
|
|
||||||
for (outcnt in 0 until payloadSize) {
|
for (outcnt in 0 until payloadSize) {
|
||||||
encrypted[outcnt] = (peek(ptr + 4 + outcnt) xor keyBytes[keyCursor++].toUint()).toByte()
|
encrypted[outcnt] = ((
|
||||||
|
if (!dec) peek(ptr + 4 + outcnt) else peek(ptr - 4 - outcnt))
|
||||||
|
xor keyBytes[keyCursor++].toUint()).toByte()
|
||||||
if (keyCursor >= keyBytes.size) {
|
if (keyCursor >= keyBytes.size) {
|
||||||
getNewKeySeq()
|
getNewKeySeq()
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -44,7 +44,7 @@ public class AppLoader {
|
|||||||
// VM vm = new VM("./assets", 64 << 10, new TheRealWorld(), new VMProgramRom[]{TandemBios.INSTANCE, BasicRom.INSTANCE}, 2, watchdogs);
|
// VM vm = new VM("./assets", 64 << 10, new TheRealWorld(), new VMProgramRom[]{TandemBios.INSTANCE, BasicRom.INSTANCE}, 2, watchdogs);
|
||||||
// VM vm = new VM("./assets", 128 << 10, new TheRealWorld(), new VMProgramRom[]{BasicBios.INSTANCE, WPBios.INSTANCE}, 2, watchdogs);
|
// VM vm = new VM("./assets", 128 << 10, new TheRealWorld(), new VMProgramRom[]{BasicBios.INSTANCE, WPBios.INSTANCE}, 2, watchdogs);
|
||||||
// VM vm = new VM("./assets", 8192 << 10, new TheRealWorld(), new VMProgramRom[]{TsvmBios.INSTANCE}, 8, watchdogs);
|
// VM vm = new VM("./assets", 8192 << 10, new TheRealWorld(), new VMProgramRom[]{TsvmBios.INSTANCE}, 8, watchdogs);
|
||||||
VM vm = new VM("./assets", 8192 << 10, new TheRealWorld(), new VMProgramRom[]{Mon.INSTANCE}, 8, watchdogs);
|
VM vm = new VM("./assets", 8192 << 10, new TheRealWorld(), new VMProgramRom[]{Mon.INSTANCE, HyveRom.INSTANCE}, 8, watchdogs);
|
||||||
// VM vm = new VM("./assets", 8192 << 10, new TheRealWorld(), new VMProgramRom[]{OpenBios.INSTANCE}, 8, watchdogs);
|
// VM vm = new VM("./assets", 8192 << 10, new TheRealWorld(), new VMProgramRom[]{OpenBios.INSTANCE}, 8, watchdogs);
|
||||||
// VM pipvm = new VM("./assets", 4096, new TheRealWorld(), new VMProgramRom[]{PipBios.INSTANCE, PipROM.INSTANCE}, 8, watchdogs);
|
// VM pipvm = new VM("./assets", 4096, new TheRealWorld(), new VMProgramRom[]{PipBios.INSTANCE, PipROM.INSTANCE}, 8, watchdogs);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user