Skip to content

Commit e8b8dd6

Browse files
authored
Merge pull request #1064 from nmantani/fix-windows-flag-mapping
Fix ql_open_flag_mapping for Linux binary emulation on Windows
2 parents 7a4653d + 8a6285b commit e8b8dd6

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

qiling/os/posix/const.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,24 @@
533533
'O_LARGEFILE': None
534534
}
535535

536+
windows_x86_open_flags = {
537+
'O_RDONLY': 0x0,
538+
'O_WRONLY': 0x1,
539+
'O_RDWR': 0x2,
540+
'O_NONBLOCK': None,
541+
'O_APPEND': 0x8,
542+
'O_ASYNC': None,
543+
'O_SYNC': None,
544+
'O_NOFOLLOW': None,
545+
'O_CREAT': 0x100,
546+
'O_TRUNC': 0x200,
547+
'O_EXCL': 0x400,
548+
'O_NOCTTY': None,
549+
'O_DIRECTORY': None,
550+
'O_BINARY': 0x8000,
551+
'O_LARGEFILE': None
552+
}
553+
536554
qnx_arm64_open_flags = {
537555
'O_RDONLY' : 0x00000,
538556
'O_WRONLY' : 0x00001,

qiling/os/posix/const_mapping.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ def flag_mapping(flags, mapping_name, mapping_from, mapping_to):
6464
f = macos_x86_open_flags
6565
elif ql.ostype == QL_OS.FREEBSD:
6666
f = freebsd_x86_open_flags
67+
elif ql.ostype == QL_OS.WINDOWS:
68+
f = windows_x86_open_flags
6769
elif ql.ostype == QL_OS.QNX:
6870
f = qnx_arm64_open_flags
6971

@@ -73,6 +75,8 @@ def flag_mapping(flags, mapping_name, mapping_from, mapping_to):
7375
t = macos_x86_open_flags
7476
elif ql.platform_os == QL_OS.FREEBSD:
7577
t = freebsd_x86_open_flags
78+
elif ql.platform_os == QL_OS.WINDOWS:
79+
t = windows_x86_open_flags
7680

7781
if f == t:
7882
return flags

0 commit comments

Comments
 (0)