]> wimlib.net Git - wimlib/blob - include/wimlib/win32_common.h
2921caaa2796b4c85a4220f7a32f00b6d5d69f95
[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 /* ntdll functions  */
25
26 extern NTSTATUS (WINAPI *func_NtCreateFile)(PHANDLE FileHandle,
27                                             ACCESS_MASK DesiredAccess,
28                                             POBJECT_ATTRIBUTES ObjectAttributes,
29                                             PIO_STATUS_BLOCK IoStatusBlock,
30                                             PLARGE_INTEGER AllocationSize,
31                                             ULONG FileAttributes,
32                                             ULONG ShareAccess,
33                                             ULONG CreateDisposition,
34                                             ULONG CreateOptions,
35                                             PVOID EaBuffer,
36                                             ULONG EaLength);
37
38 extern NTSTATUS (WINAPI *func_NtOpenFile) (PHANDLE FileHandle,
39                                            ACCESS_MASK DesiredAccess,
40                                            POBJECT_ATTRIBUTES ObjectAttributes,
41                                            PIO_STATUS_BLOCK IoStatusBlock,
42                                            ULONG ShareAccess,
43                                            ULONG OpenOptions);
44
45 extern NTSTATUS (WINAPI *func_NtReadFile) (HANDLE FileHandle,
46                                            HANDLE Event,
47                                            PIO_APC_ROUTINE ApcRoutine,
48                                            PVOID ApcContext,
49                                            PIO_STATUS_BLOCK IoStatusBlock,
50                                            PVOID Buffer,
51                                            ULONG Length,
52                                            PLARGE_INTEGER ByteOffset,
53                                            PULONG Key);
54
55 extern NTSTATUS (WINAPI *func_NtWriteFile) (HANDLE FileHandle,
56                                             HANDLE Event,
57                                             PIO_APC_ROUTINE ApcRoutine,
58                                             PVOID ApcContext,
59                                             PIO_STATUS_BLOCK IoStatusBlock,
60                                             PVOID Buffer,
61                                             ULONG Length,
62                                             PLARGE_INTEGER ByteOffset,
63                                             PULONG Key);
64
65 extern NTSTATUS (WINAPI *func_NtQueryInformationFile)(HANDLE FileHandle,
66                                                       PIO_STATUS_BLOCK IoStatusBlock,
67                                                       PVOID FileInformation,
68                                                       ULONG Length,
69                                                       FILE_INFORMATION_CLASS FileInformationClass);
70
71 extern NTSTATUS (WINAPI *func_NtQuerySecurityObject)(HANDLE handle,
72                                                      SECURITY_INFORMATION SecurityInformation,
73                                                      PSECURITY_DESCRIPTOR SecurityDescriptor,
74                                                      ULONG Length,
75                                                      PULONG LengthNeeded);
76
77 extern NTSTATUS (WINAPI *func_NtQueryDirectoryFile) (HANDLE FileHandle,
78                                                      HANDLE Event,
79                                                      PIO_APC_ROUTINE ApcRoutine,
80                                                      PVOID ApcContext,
81                                                      PIO_STATUS_BLOCK IoStatusBlock,
82                                                      PVOID FileInformation,
83                                                      ULONG Length,
84                                                      FILE_INFORMATION_CLASS FileInformationClass,
85                                                      BOOLEAN ReturnSingleEntry,
86                                                      PUNICODE_STRING FileName,
87                                                      BOOLEAN RestartScan);
88
89 extern NTSTATUS (WINAPI *func_NtQueryVolumeInformationFile) (HANDLE FileHandle,
90                                                              PIO_STATUS_BLOCK IoStatusBlock,
91                                                              PVOID FsInformation,
92                                                              ULONG Length,
93                                                              FS_INFORMATION_CLASS FsInformationClass);
94
95 extern NTSTATUS (WINAPI *func_NtSetInformationFile)(HANDLE FileHandle,
96                                                     PIO_STATUS_BLOCK IoStatusBlock,
97                                                     PVOID FileInformation,
98                                                     ULONG Length,
99                                                     FILE_INFORMATION_CLASS FileInformationClass);
100
101 extern NTSTATUS (WINAPI *func_NtSetSecurityObject)(HANDLE Handle,
102                                                    SECURITY_INFORMATION SecurityInformation,
103                                                    PSECURITY_DESCRIPTOR SecurityDescriptor);
104
105 extern NTSTATUS (WINAPI *func_NtFsControlFile) (HANDLE FileHandle,
106                                                 HANDLE Event,
107                                                 PIO_APC_ROUTINE ApcRoutine,
108                                                 PVOID ApcContext,
109                                                 PIO_STATUS_BLOCK IoStatusBlock,
110                                                 ULONG FsControlCode,
111                                                 PVOID InputBuffer,
112                                                 ULONG InputBufferLength,
113                                                 PVOID OutputBuffer,
114                                                 ULONG OutputBufferLength);
115
116 extern NTSTATUS (WINAPI *func_NtClose) (HANDLE Handle);
117
118 extern DWORD (WINAPI *func_RtlNtStatusToDosError)(NTSTATUS status);
119
120 typedef struct _RTLP_CURDIR_REF {
121         LONG RefCount;
122         HANDLE Handle;
123 } RTLP_CURDIR_REF, *PRTLP_CURDIR_REF;
124
125 typedef struct _RTL_RELATIVE_NAME_U {
126         UNICODE_STRING RelativeName;
127         HANDLE ContainingDirectory;
128         PRTLP_CURDIR_REF CurDirRef;
129 } RTL_RELATIVE_NAME_U, *PRTL_RELATIVE_NAME_U;
130
131 extern BOOLEAN (WINAPI *func_RtlDosPathNameToNtPathName_U)
132                 (IN PCWSTR DosName,
133                  OUT PUNICODE_STRING NtName,
134                  OUT PCWSTR *PartName,
135                  OUT PRTL_RELATIVE_NAME_U RelativeName);
136
137 extern NTSTATUS (WINAPI *func_RtlDosPathNameToNtPathName_U_WithStatus)
138                 (IN PCWSTR DosName,
139                  OUT PUNICODE_STRING NtName,
140                  OUT PCWSTR *PartName,
141                  OUT PRTL_RELATIVE_NAME_U RelativeName);
142
143 extern NTSTATUS (WINAPI *func_RtlCreateSystemVolumeInformationFolder)
144                         (PCUNICODE_STRING VolumeRootPath);
145
146
147 extern bool
148 windows_version_is_at_least(unsigned major, unsigned minor);
149
150 #define running_on_windows_xp_or_later() \
151                         windows_version_is_at_least(5, 1)
152
153 #define running_on_windows_vista_or_later() \
154                         windows_version_is_at_least(6, 0)
155
156 #define running_on_windows_7_or_later() \
157                         windows_version_is_at_least(6, 1)
158
159
160
161 #endif /* _WIMLIB_WIN32_COMMON_H */