function readFile_2(fileName){
var addr_fopen
=
Module.findExportByName(
"libc.so"
,
"fopen"
);
var addr_fread
=
Module.findExportByName(
"libc.so"
,
"fread"
);
var addr_fseek
=
Module.findExportByName(
"libc.so"
,
"fseek"
);
var addr_ftell
=
Module.findExportByName(
"libc.so"
,
"ftell"
);
var addr_fclose
=
Module.findExportByName(
"libc.so"
,
"fclose"
);
var fopenptr
=
new NativeFunction(addr_fopen,
"pointer"
, [
"pointer"
,
"pointer"
]);
var freadptr
=
new NativeFunction(addr_fread,
'int'
, [
'pointer'
,
'int'
,
'int'
,
'pointer'
]);
var fseekptr
=
new NativeFunction(addr_fseek,
'int'
, [
'pointer'
,
'int'
,
'int'
]);
var ftellptr
=
new NativeFunction(addr_ftell,
"int"
, [
"pointer"
]);
var fcloseptr
=
new NativeFunction(addr_fclose,
"int"
, [
"pointer"
]);
var pf
=
fopenptr(Memory.allocUtf8String(fileName), Memory.allocUtf8String(
"rb"
))
fseekptr(pf,
0
,
2
);
var size
=
fseekptr(fp);
fseekptr(pf,
0
,
0
);
console.log(size)
var databuffer
=
Memory.alloc(size);
freadptr(databuffer,
1
, size, pf);
console.log(databuffer.readByteArray(size))
fcloseptr(
file
);
}
var fileName
=
"/sdcard/test.txt"
readFile_2(fileName);