Skip to content

Commit

Permalink
Add copyFrom/copyTo and zeroFill apis in NativePointer
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Sep 28, 2024
1 parent 0f81be9 commit 2e1fbec
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions typescript/async/r2papi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,32 @@ export class NativePointer {
this.api = api?? R;
this.addr = ("" + s).trim();
}
/**
* Copy N bytes from current pointer to the destination
*
* @param {string|NativePointer|number} destination address
* @param {string|number} amount of bytes
*/
async copyTo(addr: string|NativePointer|number, size: string|number) : Promise<void> {
this.api.call(`wf ${this.addr} ${size} @ ${addr}`)
}
/**
* Copy N bytes from given address to the current destination
*
* @param {string|NativePointer|number} source address
* @param {string|number} amount of bytes
*/
async copyFrom(addr: string|NativePointer|number, size: string|number) : Promise<void> {
this.api.call(`wf ${addr} ${size} @ ${this.addr}`)
}
/**
* Fill N bytes in this address with zero
*
* @param {string|number} amount of bytes
*/
async zeroFill(size: string|number) : Promise<void> {
this.api.call(`w0 ${size} @ ${this.addr}`)
}
/**
* Filter a string to be used as a valid flag name
*
Expand Down

0 comments on commit 2e1fbec

Please sign in to comment.