]> wimlib.net Git - wimlib/blob - include/wimlib/win32_common.h
df8b0cb7703df650d6d089d4631d2457e9b3cfc5
[wimlib] / include / wimlib / win32_common.h
1 /*
2  * win32_common.h - common header for Windows-specific files.  This always
3  * should be included first.
4  */
5
6 #ifndef _WIMLIB_WIN32_COMMON_H
7 #define _WIMLIB_WIN32_COMMON_H
8
9 #include <ntstatus.h>
10 #include <windows.h>
11 #include <winternl.h>
12
13 #ifdef ERROR
14 #  undef ERROR
15 #endif
16 #include "wimlib/win32.h"
17
18 /* ntdll definitions */
19
20 #define FILE_OPENED 0x00000001
21
22 typedef struct _RTLP_CURDIR_REF {
23         LONG RefCount;
24         HANDLE Handle;
25 } RTLP_CURDIR_REF, *PRTLP_CURDIR_REF;
26
27 typedef struct _RTL_RELATIVE_NAME_U {
28         UNICODE_STRING RelativeName;
29         HANDLE ContainingDirectory;
30         PRTLP_CURDIR_REF CurDirRef;
31 } RTL_RELATIVE_NAME_U, *PRTL_RELATIVE_NAME_U;
32
33 #define FSCTL_SET_PERSISTENT_VOLUME_STATE 0x90238
34
35 #define PERSISTENT_VOLUME_STATE_SHORT_NAME_CREATION_DISABLED 0x00000001
36
37 typedef struct _FILE_FS_PERSISTENT_VOLUME_INFORMATION {
38         ULONG VolumeFlags;
39         ULONG FlagMask;
40         ULONG Version;
41         ULONG Reserved;
42 } FILE_FS_PERSISTENT_VOLUME_INFORMATION, *PFILE_FS_PERSISTENT_VOLUME_INFORMATION;
43
44 /* ntdll functions  */
45
46 NTSTATUS
47 NTAPI
48 NtReadFile(IN HANDLE FileHandle,
49            IN HANDLE Event OPTIONAL,
50            IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
51            IN PVOID ApcContext OPTIONAL,
52            OUT PIO_STATUS_BLOCK IoStatusBlock,
53            OUT PVOID Buffer,
54            IN ULONG Length,
55            IN PLARGE_INTEGER ByteOffset OPTIONAL,
56            IN PULONG Key OPTIONAL);
57
58 NTSTATUS
59 NTAPI
60 NtWriteFile(IN HANDLE FileHandle,
61             IN HANDLE Event OPTIONAL,
62             IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
63             IN PVOID ApcContext OPTIONAL,
64             OUT PIO_STATUS_BLOCK IoStatusBlock,
65             IN PVOID Buffer,
66             IN ULONG Length,
67             IN PLARGE_INTEGER ByteOffset OPTIONAL,
68             IN PULONG Key OPTIONAL);
69
70 NTSTATUS
71 NTAPI
72 NtQueryDirectoryFile(IN HANDLE FileHandle,
73                      IN HANDLE EventHandle OPTIONAL,
74                      IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
75                      IN PVOID ApcContext OPTIONAL,
76                      OUT PIO_STATUS_BLOCK IoStatusBlock,
77                      OUT PVOID FileInformation,
78                      IN ULONG Length,
79                      IN FILE_INFORMATION_CLASS FileInformationClass,
80                      IN BOOLEAN ReturnSingleEntry,
81                      IN PUNICODE_STRING FileName OPTIONAL,
82                      IN BOOLEAN RestartScan);
83
84 NTSTATUS
85 NTAPI
86 NtQuerySecurityObject(IN HANDLE Handle,
87                       IN SECURITY_INFORMATION SecurityInformation,
88                       OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
89                       IN ULONG Length,
90                       OUT PULONG ResultLength);
91
92 NTSTATUS
93 NTAPI
94 NtSetSecurityObject(IN HANDLE Handle,
95                     IN SECURITY_INFORMATION SecurityInformation,
96                     IN PSECURITY_DESCRIPTOR SecurityDescriptor);
97
98 /* Dynamically loaded ntdll functions */
99
100 extern NTSTATUS (WINAPI *func_RtlDosPathNameToNtPathName_U_WithStatus)
101                 (IN PCWSTR DosName,
102                  OUT PUNICODE_STRING NtName,
103                  OUT PCWSTR *PartName,
104                  OUT PRTL_RELATIVE_NAME_U RelativeName);
105
106 extern NTSTATUS (WINAPI *func_RtlCreateSystemVolumeInformationFolder)
107                         (PCUNICODE_STRING VolumeRootPath);
108
109 /* Other utility functions */
110
111 extern int
112 win32_path_to_nt_path(const wchar_t *win32_path, UNICODE_STRING *nt_path);
113
114 extern int
115 win32_get_drive_path(const wchar_t *file_path, wchar_t drive_path[7]);
116
117 extern bool
118 win32_try_to_attach_wof(const wchar_t *drive);
119
120 extern void
121 win32_warning(DWORD err, const wchar_t *format, ...) _cold_attribute;
122
123 extern void
124 win32_error(DWORD err, const wchar_t *format, ...) _cold_attribute;
125
126 extern void
127 winnt_warning(NTSTATUS status, const wchar_t *format, ...) _cold_attribute;
128
129 extern void
130 winnt_error(NTSTATUS status, const wchar_t *format, ...) _cold_attribute;
131
132 extern NTSTATUS
133 winnt_fsctl(HANDLE h, u32 code, const void *in, u32 in_size,
134             void *out, u32 out_size_avail, u32 *actual_out_size_ret);
135
136 #endif /* _WIMLIB_WIN32_COMMON_H */