MCPcopy Create free account
hub / github.com/qilingframework/qiling / my_syscall_write

Function my_syscall_write

examples/hello_arm_linux_custom_syscall.py:14–33  ·  view source on GitHub ↗
(ql: Qiling, fd: int, buf: int, count: int)

Source from the content-addressed store, hash-verified

12# customized system calls always use the same arguments list as the original ones,
13# but with a Qiling instance as first argument
14def my_syscall_write(ql: Qiling, fd: int, buf: int, count: int):
15 try:
16 # read data from emulated memory
17 data = ql.mem.read(buf, count)
18
19 # select the emulated file object that corresponds to the requested
20 # file descriptor
21 fobj = ql.os.fd[fd]
22
23 # write the data into the file object, if it supports write operations
24 if hasattr(fobj, 'write'):
25 fobj.write(data)
26 except:
27 ret = -1
28 else:
29 ret = count
30
31 ql.log.info(f'my_syscall_write({fd}, {buf:#x}, {count}) = {ret}')
32
33 return ret
34
35if __name__ == "__main__":
36 ql = Qiling([r'rootfs/arm_linux/bin/arm_hello'], r'rootfs/arm_linux', verbose=QL_VERBOSE.DEBUG)

Callers

nothing calls this directly

Calls 2

readMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected