From 8a6285b77300a3ebd6996abe595eaa1454a5694b Mon Sep 17 00:00:00 2001 From: Nobutaka Mantani <2285962+nmantani@users.noreply.github.com> Date: Mon, 10 Jan 2022 15:19:49 +0900 Subject: [PATCH] Resurrect removed windows_open_flags as windows_x86_open_flags --- qiling/os/posix/const.py | 18 ++++++++++++++++++ qiling/os/posix/const_mapping.py | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/qiling/os/posix/const.py b/qiling/os/posix/const.py index 41703eb25..ba49a938f 100644 --- a/qiling/os/posix/const.py +++ b/qiling/os/posix/const.py @@ -533,6 +533,24 @@ 'O_LARGEFILE': None } +windows_x86_open_flags = { + 'O_RDONLY': 0x0, + 'O_WRONLY': 0x1, + 'O_RDWR': 0x2, + 'O_NONBLOCK': None, + 'O_APPEND': 0x8, + 'O_ASYNC': None, + 'O_SYNC': None, + 'O_NOFOLLOW': None, + 'O_CREAT': 0x100, + 'O_TRUNC': 0x200, + 'O_EXCL': 0x400, + 'O_NOCTTY': None, + 'O_DIRECTORY': None, + 'O_BINARY': 0x8000, + 'O_LARGEFILE': None +} + qnx_arm64_open_flags = { 'O_RDONLY' : 0x00000, 'O_WRONLY' : 0x00001, diff --git a/qiling/os/posix/const_mapping.py b/qiling/os/posix/const_mapping.py index c314bb387..42673b304 100644 --- a/qiling/os/posix/const_mapping.py +++ b/qiling/os/posix/const_mapping.py @@ -64,6 +64,8 @@ def flag_mapping(flags, mapping_name, mapping_from, mapping_to): f = macos_x86_open_flags elif ql.ostype == QL_OS.FREEBSD: f = freebsd_x86_open_flags + elif ql.ostype == QL_OS.WINDOWS: + f = windows_x86_open_flags elif ql.ostype == QL_OS.QNX: f = qnx_arm64_open_flags @@ -73,6 +75,8 @@ def flag_mapping(flags, mapping_name, mapping_from, mapping_to): t = macos_x86_open_flags elif ql.platform_os == QL_OS.FREEBSD: t = freebsd_x86_open_flags + elif ql.platform_os == QL_OS.WINDOWS: + t = windows_x86_open_flags if f == t: return flags