diff --git a/exploit/runNro.js b/exploit/runNro.js index 001042f..ce47b29 100644 --- a/exploit/runNro.js +++ b/exploit/runNro.js @@ -106,7 +106,7 @@ module.exports = (res, args) => { utils.log("closing sm and jumping..."); sc.svcCloseHandle(sc.smHandle).assertOk(); sc.smHandle = undefined; - utils.log("returned " + utils.paddr(sc.call(utils.add2(sc.svcNroBase, 0x80), [libtransistorContext]))); + utils.log("returned " + utils.paddr(sc.call(utils.add2(sc.svcNroBase, 0x80), [0, 0, libtransistorContext]))); var logBufferAddr = [libtransistorContext[6], libtransistorContext[7]]; var logLengthAddr = [libtransistorContext[8], libtransistorContext[9]]; diff --git a/exploit/svc.js b/exploit/svc.js index 867692a..c06b556 100644 --- a/exploit/svc.js +++ b/exploit/svc.js @@ -103,6 +103,23 @@ svcMixin.svcCreateSharedMemory = function (size, permission1, permission2) { return this.svcWithResult(0x50, [handleBuffer, size, permission1, permission2]).replaceValue(handleBuffer[0]); }; +/* + Usages: + svcGetThreadId() + svcGetThreadId(tid) +*/ +svcMixin.svcGetThreadId = function (tid) { + if (tid === undefined) { + tid = 0xffff8000; + } + + if (typeof (tid) === 'number') { tid = [tid, 0]; } + if (!Array.isArray(tid)) { throw new Error('invalid tid type'); } + + var handleBuffer = new Uint32Array(2); + return this.svcWithResult(0x25, [handleBuffer, tid]).replaceValue([handleBuffer[0], handleBuffer[1]]); +}; + /* Usages: svcMapSharedMemory(handle, size)