From f60ac1e67cddb51899129e0bcd09a334e89ad495 Mon Sep 17 00:00:00 2001 From: Oliver Palmer Date: Sat, 30 Jan 2016 11:34:10 -0500 Subject: [PATCH 1/3] adding several new SECURITY_, PIPE_, and FILE_ constants --- pywincffi/core/cdefs/headers/constants.h | 65 ++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/pywincffi/core/cdefs/headers/constants.h b/pywincffi/core/cdefs/headers/constants.h index f4ffacd..29516c9 100644 --- a/pywincffi/core/cdefs/headers/constants.h +++ b/pywincffi/core/cdefs/headers/constants.h @@ -29,15 +29,80 @@ // Flags for pywincffi.kernel32.io (may be shared with other modules too) #define SYNCHRONIZE ... +#define FILE_GENERIC_READ ... +#define FILE_GENERIC_WRITE ... +#define FILE_GENERIC_EXECUTE ... +#define FILE_ADD_FILE ... +#define FILE_ADD_SUBDIRECTORY ... +#define FILE_ALL_ACCESS ... +#define FILE_APPEND_DATA ... +#define FILE_CREATE_PIPE_INSTANCE ... +#define FILE_DELETE_CHILD ... +#define FILE_EXECUTE ... +#define FILE_LIST_DIRECTORY ... +#define FILE_READ_ATTRIBUTES ... +#define FILE_READ_DATA ... +#define FILE_READ_EA ... +#define FILE_TRAVERSE ... +#define FILE_WRITE_ATTRIBUTES ... +#define FILE_WRITE_DATA ... +#define FILE_WRITE_EA ... +#define FILE_SHARE_DELETE ... +#define FILE_SHARE_READ ... +#define FILE_SHARE_WRITE ... +#define FILE_ATTRIBUTE_ARCHIVE ... +#define FILE_ATTRIBUTE_ENCRYPTED ... +#define FILE_ATTRIBUTE_HIDDEN ... +#define FILE_ATTRIBUTE_NORMAL ... +#define FILE_ATTRIBUTE_OFFLINE ... +#define FILE_ATTRIBUTE_READONLY ... +#define FILE_ATTRIBUTE_SYSTEM ... +#define FILE_ATTRIBUTE_TEMPORARY ... +#define FILE_FLAG_BACKUP_SEMANTICS ... +#define FILE_FLAG_DELETE_ON_CLOSE ... +#define FILE_FLAG_NO_BUFFERING ... +#define FILE_FLAG_OPEN_NO_RECALL ... +#define FILE_FLAG_OPEN_REPARSE_POINT ... +#define FILE_FLAG_OVERLAPPED ... +#define FILE_FLAG_POSIX_SEMANTICS ... +#define FILE_FLAG_RANDOM_ACCESS ... +#define FILE_FLAG_SESSION_AWARE ... +#define FILE_FLAG_SEQUENTIAL_SCAN ... +#define FILE_FLAG_WRITE_THROUGH ... +#define CREATE_ALWAYS ... +#define CREATE_NEW ... +#define OPEN_ALWAYS ... +#define OPEN_EXISTING ... +#define TRUNCATE_EXISTING ... + +// Flags for pywincffi.kernel32.pipe (may be shared with other modules too) #define PIPE_TYPE_MESSAGE ... #define PIPE_READMODE_BYTE ... #define PIPE_READMODE_MESSAGE ... #define PIPE_WAIT ... #define PIPE_NOWAIT ... +#define PIPE_CLIENT_END ... +#define PIPE_SERVER_END ... +#define PIPE_TYPE_BYTE ... +#define PIPE_TYPE_MESSAGE ... + +// General security +#define SECURITY_ANONYMOUS ... +#define SECURITY_CONTEXT_TRACKING ... +#define SECURITY_DELEGATION ... +#define SECURITY_EFFECTIVE_ONLY ... +#define SECURITY_IDENTIFICATION ... +#define SECURITY_IMPERSONATION ... +#define STANDARD_RIGHTS_READ ... +#define STANDARD_RIGHTS_WRITE ... +#define GENERIC_ALL ... +#define GENERIC_READ ... +#define GENERIC_WRITE ... // Errors #define ERROR_INVALID_PARAMETER ... #define ERROR_ACCESS_DENIED ... +#define ERROR_ALREADY_EXISTS ... // For the moment, we can't define this here. When cffi // parses the header this returns -1 and cffi seems to From e5afc1d9feeb819df6766131977e14a19a91a2de Mon Sep 17 00:00:00 2001 From: Oliver Palmer Date: Sat, 30 Jan 2016 11:34:50 -0500 Subject: [PATCH 2/3] adding _FILETIME and _BY_HANDLE_FILE_INFORMATION Also adding some comments with pointers to the original structures on MSDN. --- pywincffi/core/cdefs/headers/structs.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/pywincffi/core/cdefs/headers/structs.h b/pywincffi/core/cdefs/headers/structs.h index 5cdf3c0..da50033 100644 --- a/pywincffi/core/cdefs/headers/structs.h +++ b/pywincffi/core/cdefs/headers/structs.h @@ -1,15 +1,18 @@ + // // NOTE: The tests for this file, tests/test_core/test_cdefs/test_structs.py // depend on a struct's names to follow this format: // } NAME, NAME, NAME; // +// https://msdn.microsoft.com/en-us/library/aa379560 typedef struct _SECURITY_ATTRIBUTES { DWORD nLength; LPVOID lpSecurityDescriptor; BOOL bInheritHandle; } SECURITY_ATTRIBUTES, *PSECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES; +// https://msdn.microsoft.com/en-us/library/ms684342 typedef struct _OVERLAPPED { ULONG_PTR Internal; ULONG_PTR InternalHigh; @@ -22,3 +25,23 @@ typedef struct _OVERLAPPED { }; HANDLE hEvent; } OVERLAPPED, *LPOVERLAPPED; + +// https://msdn.microsoft.com/en-us/library/ms724284 +typedef struct _FILETIME { + DWORD dwLowDateTime; + DWORD dwHighDateTime; +} FILETIME, *PFILETIME; + +// https://msdn.microsoft.com/en-us/library/aa363788 +typedef struct _BY_HANDLE_FILE_INFORMATION { + DWORD dwFileAttributes; + FILETIME ftCreationTime; + FILETIME ftLastAccessTime; + FILETIME ftLastWriteTime; + DWORD dwVolumeSerialNumber; + DWORD nFileSizeHigh; + DWORD nFileSizeLow; + DWORD nNumberOfLinks; + DWORD nFileIndexHigh; + DWORD nFileIndexLow; +} BY_HANDLE_FILE_INFORMATION, *PBY_HANDLE_FILE_INFORMATION, *LPBY_HANDLE_FILE_INFORMATION; From e22ea596502a2ccf454e0186ffc13304c7f298e3 Mon Sep 17 00:00:00 2001 From: Oliver Palmer Date: Sat, 30 Jan 2016 12:01:01 -0500 Subject: [PATCH 3/3] adding missing FILE_FLAG_SESSION_AWARE --- pywincffi/core/cdefs/sources/main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pywincffi/core/cdefs/sources/main.c b/pywincffi/core/cdefs/sources/main.c index 04c01a3..46ffed6 100644 --- a/pywincffi/core/cdefs/sources/main.c +++ b/pywincffi/core/cdefs/sources/main.c @@ -1,6 +1,10 @@ #include #include +// Extra constants which are not defined in all versions of Windows or +// that pywincffi creates. +static const int FILE_FLAG_SESSION_AWARE = 0x00800000; + HANDLE handle_from_fd(int fd) { return (HANDLE)_get_osfhandle(fd); }