@@ -9,31 +9,31 @@ const ref = require('ref')
99const ffi = require ( 'ffi' )
1010const Struct = require ( 'ref-struct' )
1111
12- let RegionInfo = Struct ( {
13- ' protection' : 'uint32' ,
14- ' max_protection' : 'uint32' ,
15- ' inheritance' : 'uint32' ,
16- ' shared' : 'uint32' ,
17- ' reserved' : 'uint32' ,
18- ' offset' : 'ulonglong' ,
19- ' behavior' : 'uint32' ,
20- ' user_wired_count' : 'ushort'
12+ const RegionInfo = Struct ( {
13+ protection : 'uint32' ,
14+ max_protection : 'uint32' ,
15+ inheritance : 'uint32' ,
16+ shared : 'uint32' ,
17+ reserved : 'uint32' ,
18+ offset : 'ulonglong' ,
19+ behavior : 'uint32' ,
20+ user_wired_count : 'ushort'
2121} )
2222
23- let RegionInfoPtr = ref . refType ( RegionInfo )
23+ const RegionInfoPtr = ref . refType ( RegionInfo )
2424
25- let libc = ffi . Library ( 'libc' , {
26- ' mach_task_self' : [ 'uint' , [ ] ] ,
27- ' task_for_pid' : [ 'int' , [ 'uint' , 'int' , '*uint' ] ] ,
28- ' mach_vm_region' : [ 'int' , [ 'uint' , '*ulong' , '*ulong' , 'int' , RegionInfoPtr , '*uint32' , '*uint32' ] ] ,
29- ' mach_vm_read' : [ 'int' , [ 'uint' , 'ulonglong' , 'ulonglong' , '*void' , '*uint32' ] ]
25+ const libc = ffi . Library ( 'libc' , {
26+ mach_task_self : [ 'uint' , [ ] ] ,
27+ task_for_pid : [ 'int' , [ 'uint' , 'int' , '*uint' ] ] ,
28+ mach_vm_region : [ 'int' , [ 'uint' , '*ulong' , '*ulong' , 'int' , RegionInfoPtr , '*uint32' , '*uint32' ] ] ,
29+ mach_vm_read : [ 'int' , [ 'uint' , 'ulonglong' , 'ulonglong' , '*void' , '*uint32' ] ]
3030} )
3131
3232class Memory {
3333 constructor ( pid ) {
34- let taskRef = ref . alloc ( 'uint' , 0 )
35- let mytask = libc . mach_task_self ( )
36- let ret = libc . task_for_pid ( mytask , pid , taskRef )
34+ const taskRef = ref . alloc ( 'uint' , 0 )
35+ const mytask = libc . mach_task_self ( )
36+ const ret = libc . task_for_pid ( mytask , pid , taskRef )
3737 if ( ret !== 0 ) {
3838 throw new Error ( 'task_for_pid error ' + ret )
3939 }
@@ -42,15 +42,15 @@ class Memory {
4242 }
4343
4444 getRegions ( ) {
45- let regions = [ ]
46- let address = ref . alloc ( 'ulong' , 0 )
47- let mapsize = ref . alloc ( 'ulong' , 0 )
48- let name = ref . alloc ( 'uint32' , 0 )
49- let count = ref . alloc ( 'uint32' , RegionInfo . size / 4 )
50- let info = new RegionInfo ( )
45+ const regions = [ ]
46+ const address = ref . alloc ( 'ulong' , 0 )
47+ const mapsize = ref . alloc ( 'ulong' , 0 )
48+ const name = ref . alloc ( 'uint32' , 0 )
49+ const count = ref . alloc ( 'uint32' , RegionInfo . size / 4 )
50+ const info = new RegionInfo ( )
5151
5252 while ( true ) {
53- let ret = libc . mach_vm_region ( this . task , address , mapsize , 9 , info . ref ( ) , count , name )
53+ const ret = libc . mach_vm_region ( this . task , address , mapsize , 9 , info . ref ( ) , count , name )
5454 if ( ret === 1 ) {
5555 break
5656 }
@@ -67,19 +67,19 @@ class Memory {
6767 }
6868
6969 read ( address , length ) {
70- let dataref = ref . alloc ( '*void' )
71- let cnt = ref . alloc ( 'uint32' , 0 )
70+ const dataref = ref . alloc ( '*void' )
71+ const cnt = ref . alloc ( 'uint32' , 0 )
7272
73- let ret = libc . mach_vm_read ( this . task , address , length , dataref , cnt )
73+ const ret = libc . mach_vm_read ( this . task , address , length , dataref , cnt )
7474 if ( ret !== 0 ) {
7575 throw new Error ( 'mach_vm_read error ' + ret )
7676 }
7777 return dataref . readPointer ( 0 , length )
7878 }
7979
8080 readAsync ( address , length ) {
81- let detaref = ref . alloc ( '*void' )
82- let cnt = ref . alloc ( 'uint32' , 0 )
81+ const detaref = ref . alloc ( '*void' )
82+ const cnt = ref . alloc ( 'uint32' , 0 )
8383
8484 return new Promise ( ( resolve , reject ) => {
8585 libc . mach_vm_read . async ( this . task , address , length , detaref , cnt , ( err , ret ) => {
0 commit comments