Skip to content
This repository has been archived by the owner on Sep 21, 2021. It is now read-only.

Commit

Permalink
a few changes made in private that really should've been public:
Browse files Browse the repository at this point in the history
  - add IPCMessage.dataArrayBuffer
	- add svcMixin.svcWaitSynchronization
	- add optional length parameter to utils.str2ab
  • Loading branch information
misson20000 committed Oct 27, 2017
1 parent 96d39be commit 6f426bd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
10 changes: 10 additions & 0 deletions exploit/ipc.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ IPCMessage.prototype.datau64 = function () {
return this;
};

IPCMessage.prototype.dataArrayBuffer = function(ab) {
this.dataBuffer = [];
var u32 = new Uint32Array(ab);
for(var i = 0; i < u32.length; i++) {
this.dataBuffer[i] = u32[i];
}

return this;
};

IPCMessage.prototype.addDescriptor = function (da, addr, size, third) {
if (addr instanceof ArrayBuffer || ArrayBuffer.isView(addr)) {
var buf = addr;
Expand Down
6 changes: 6 additions & 0 deletions exploit/svc.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,10 @@ svcMixin.svcReplyAndReceiveWithUserBuffer = function (buf, handles, reply, timeo
return this.svcWithResult(0x44, [handleIdxBuffer, buf, buf.byteLength, handles ? new Uint32Array(handles) : 0, handles ? handles.length : 0, reply, timeout]).replaceValue(handleIdxBuffer[0]);
};

svcMixin.svcWaitSynchronization = function (handles, timeout) {
var handlesBuffer = new Uint32Array(handles);
var handleIdxBuffer = new Uint32Array(1);
return this.svcWithResult(0x18, [handleIdxBuffer, handlesBuffer, handlesBuffer.length, timeout]).replaceValue(handleIdxBuffer[0]);
}

module.exports = svcMixin;
11 changes: 9 additions & 2 deletions exploit/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,15 @@ exports.hexdump = function (name, inp, count) {
}
};

exports.str2ab = function (str) {
var ab = new ArrayBuffer(str.length + 1);
exports.str2ab = function (str, length) {
if(length === undefined) {
length = str.length + 1;
} else {
if(length < str.length + 1) {
throw new Error("buffer is too small to pack string");
}
}
var ab = new ArrayBuffer(length);
var u8 = new Uint8Array(ab);
for (var i = 0; i < str.length; i++) {
u8[i] = str.charCodeAt(i);
Expand Down

0 comments on commit 6f426bd

Please sign in to comment.