MCPcopy Create free account
hub / github.com/GrowthEase/GameSentry / readFile

Function readFile

lib/cli/utils/utils.js:44–65  ·  view source on GitHub ↗
(filePath)

Source from the content-addressed store, hash-verified

42 }
43}
44function readFile(filePath) {
45 const ptr_open = Module.findExportByName("libc.so", "open");
46 const open = new NativeFunction(ptr_open, 'int', ['pointer', 'int']);
47 const ptr_read = Module.findExportByName("libc.so", "read");
48 const read = new NativeFunction(ptr_read, 'int', ['int', 'pointer', 'int']);
49 const ptr_close = Module.findExportByName("libc.so", "close");
50 const close = new NativeFunction(ptr_close, 'int', ['int']);
51 const fd = open(Memory.allocUtf8String(filePath), 0);
52 const size = get_file_size(fd);
53 if (size > 0) {
54 const data = Memory.alloc(size + 5);
55 if (read(fd, data, size) < 0) {
56 console.log('[+] Unable to read DLL [!] ' + filePath);
57 close(fd);
58 return {data: null, size: 0};
59 }
60 close(fd);
61 return {data: data, size: size};
62 }else {
63 return {data: null, size: 0};
64 }
65}
66
67function get_file_size(fd) {
68 const statBuff = Memory.alloc(500);

Callers

nothing calls this directly

Calls 3

get_file_sizeFunction · 0.85
readFunction · 0.85
allocMethod · 0.45

Tested by

no test coverage detected