Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Additional Constants and Structures #52

Merged
merged 3 commits into from
Jan 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions pywincffi/core/cdefs/headers/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions pywincffi/core/cdefs/headers/structs.h
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
4 changes: 4 additions & 0 deletions pywincffi/core/cdefs/sources/main.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#include <io.h>
#include <windows.h>

// 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);
}