Skip to content

Commit

Permalink
support FILE_GENERIC_* access modes
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-phylum authored and elicn committed Feb 7, 2024
1 parent c6de544 commit 766972d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
18 changes: 18 additions & 0 deletions qiling/os/windows/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,24 @@
CRYPT_STRING_BASE64REQUESTHEADER = 3
# ...

# File Access Rights Constants
# https://learn.microsoft.com/en-us/windows/win32/fileio/file-access-rights-constants
FILE_ADD_FILE = 0x0002
FILE_ADD_SUBDIRECTORY = 0x0004
FILE_APPEND_DATA = 0x0004
FILE_CREATE_PIPE_INSTANCE = 0x0004
FILE_DELETE_CHILD = 0x0040
FILE_EXECUTE = 0x0020
FILE_LIST_DIRECTORY = 0x0001
FILE_READ_ATTRIBUTES = 0x0080
FILE_READ_DATA = 0x0001
FILE_READ_EA = 0x0008
FILE_TRAVERSE = 0x0020
FILE_WRITE_ATTRIBUTES = 0x0100
FILE_WRITE_DATA = 0x0002
FILE_WRITE_EA = 0x0010
# ...

# File Attribtues Constantsc
# https://docs.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants
FILE_ATTRIBUTE_ARCHIVE = 0x0020
Expand Down
6 changes: 3 additions & 3 deletions qiling/os/windows/dlls/kernel32/fileapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,11 @@ def _CreateFile(ql: Qiling, address: int, params):
# hTemplateFile = params["hTemplateFile"]

# access mask DesiredAccess
perm_write = dwDesiredAccess & GENERIC_WRITE
perm_read = dwDesiredAccess & GENERIC_READ
perm_write = dwDesiredAccess & (GENERIC_WRITE | FILE_WRITE_DATA)
perm_read = dwDesiredAccess & (GENERIC_READ | FILE_READ_DATA)

# TODO: unused
perm_exec = dwDesiredAccess & GENERIC_EXECUTE
perm_exec = dwDesiredAccess & (GENERIC_EXECUTE | FILE_EXECUTE)

# only open file if it exists. error otherwise
open_existing = (
Expand Down

0 comments on commit 766972d

Please sign in to comment.