|
4 | 4 | # |
5 | 5 |
|
6 | 6 | from inspect import signature, Parameter |
7 | | -from typing import TextIO, Union, Callable |
| 7 | +from typing import TextIO, Union, Callable, IO, List, Optional |
8 | 8 |
|
9 | 9 | from unicorn.arm64_const import UC_ARM64_REG_X8, UC_ARM64_REG_X16 |
10 | 10 | from unicorn.arm_const import UC_ARM_REG_R7 |
|
18 | 18 | from qiling.exception import QlErrorSyscallNotFound |
19 | 19 | from qiling.os.os import QlOs |
20 | 20 | from qiling.os.posix.const import errors |
21 | | -from qiling.utils import QlFileDes, ostype_convert_str, ql_get_module_function, ql_syscall_mapping_function |
| 21 | +from qiling.utils import ostype_convert_str, ql_get_module_function, ql_syscall_mapping_function |
22 | 22 |
|
23 | 23 | from qiling.os.posix.syscall import * |
24 | 24 | from qiling.os.linux.syscall import * |
@@ -58,6 +58,33 @@ class riscv32(riscv.riscv): |
58 | 58 | class riscv64(riscv.riscv): |
59 | 59 | pass |
60 | 60 |
|
| 61 | + |
| 62 | +class QlFileDes: |
| 63 | + def __init__(self): |
| 64 | + self.__fds: List[Optional[IO]] = [None] * NR_OPEN |
| 65 | + |
| 66 | + def __len__(self): |
| 67 | + return len(self.__fds) |
| 68 | + |
| 69 | + def __getitem__(self, idx: int): |
| 70 | + return self.__fds[idx] |
| 71 | + |
| 72 | + def __setitem__(self, idx: int, val: Optional[IO]): |
| 73 | + self.__fds[idx] = val |
| 74 | + |
| 75 | + def __iter__(self): |
| 76 | + return iter(self.__fds) |
| 77 | + |
| 78 | + def __repr__(self): |
| 79 | + return repr(self.__fds) |
| 80 | + |
| 81 | + def save(self): |
| 82 | + return self.__fds |
| 83 | + |
| 84 | + def restore(self, fds): |
| 85 | + self.__fds = fds |
| 86 | + |
| 87 | + |
61 | 88 | class QlOsPosix(QlOs): |
62 | 89 |
|
63 | 90 | def __init__(self, ql: Qiling): |
|
0 commit comments