]> wimlib.net Git - wimlib/blob - include/wimlib/win32_common.h
Load NtOpenFile() and NtClose()
[wimlib] / include / wimlib / win32_common.h
1 #ifndef _WIMLIB_WIN32_COMMON_H
2 #define _WIMLIB_WIN32_COMMON_H
3
4 #include <windows.h>
5 #ifdef ERROR
6 #  undef ERROR
7 #endif
8
9 #include "wimlib/types.h"
10 #include "wimlib/win32.h"
11
12 #include <ntstatus.h>
13 #include <winternl.h>
14
15 extern void
16 set_errno_from_GetLastError(void);
17
18 extern void
19 set_errno_from_win32_error(DWORD err);
20
21 extern void
22 set_errno_from_nt_status(NTSTATUS status);
23
24 extern bool
25 win32_path_is_root_of_drive(const wchar_t *path);
26
27 extern int
28 win32_get_vol_flags(const wchar_t *path, unsigned *vol_flags_ret,
29                     bool *supports_SetFileShortName_ret);
30
31 extern HANDLE
32 win32_open_existing_file(const wchar_t *path, DWORD dwDesiredAccess);
33
34 /* Vista and later */
35 extern BOOL (WINAPI *func_CreateSymbolicLinkW)(const wchar_t *lpSymlinkFileName,
36                                                const wchar_t *lpTargetFileName,
37                                                DWORD dwFlags);
38
39 /* ntdll functions  */
40
41 extern NTSTATUS (WINAPI *func_NtOpenFile) (PHANDLE FileHandle,
42                                            ACCESS_MASK DesiredAccess,
43                                            POBJECT_ATTRIBUTES ObjectAttributes,
44                                            PIO_STATUS_BLOCK IoStatusBlock,
45                                            ULONG ShareAccess,
46                                            ULONG OpenOptions);
47
48 extern NTSTATUS (WINAPI *func_NtQueryInformationFile)(HANDLE FileHandle,
49                                                       PIO_STATUS_BLOCK IoStatusBlock,
50                                                       PVOID FileInformation,
51                                                       ULONG Length,
52                                                       FILE_INFORMATION_CLASS FileInformationClass);
53
54 extern NTSTATUS (WINAPI *func_NtQuerySecurityObject)(HANDLE handle,
55                                                      SECURITY_INFORMATION SecurityInformation,
56                                                      PSECURITY_DESCRIPTOR SecurityDescriptor,
57                                                      ULONG Length,
58                                                      PULONG LengthNeeded);
59
60 extern NTSTATUS (WINAPI *func_NtQueryDirectoryFile) (HANDLE FileHandle,
61                                                      HANDLE Event,
62                                                      PIO_APC_ROUTINE ApcRoutine,
63                                                      PVOID ApcContext,
64                                                      PIO_STATUS_BLOCK IoStatusBlock,
65                                                      PVOID FileInformation,
66                                                      ULONG Length,
67                                                      FILE_INFORMATION_CLASS FileInformationClass,
68                                                      BOOLEAN ReturnSingleEntry,
69                                                      PUNICODE_STRING FileName,
70                                                      BOOLEAN RestartScan);
71
72
73 extern NTSTATUS (WINAPI *func_NtSetSecurityObject)(HANDLE Handle,
74                                                    SECURITY_INFORMATION SecurityInformation,
75                                                    PSECURITY_DESCRIPTOR SecurityDescriptor);
76
77 extern NTSTATUS (WINAPI *func_NtClose) (HANDLE Handle);
78
79 extern DWORD (WINAPI *func_RtlNtStatusToDosError)(NTSTATUS status);
80
81 extern NTSTATUS (WINAPI *func_RtlCreateSystemVolumeInformationFolder)
82                         (PCUNICODE_STRING VolumeRootPath);
83
84
85 extern bool
86 windows_version_is_at_least(unsigned major, unsigned minor);
87
88 #define running_on_windows_xp_or_later() \
89                         windows_version_is_at_least(5, 1)
90
91 #define running_on_windows_vista_or_later() \
92                         windows_version_is_at_least(6, 0)
93
94 #define running_on_windows_7_or_later() \
95                         windows_version_is_at_least(6, 1)
96
97
98
99 #endif /* _WIMLIB_WIN32_COMMON_H */