X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=include%2Fwimlib%2Fwin32_common.h;h=cbdacd320cd64507d4529fd155ff723db9c1bddb;hb=d2bbd33f82880b553f5a0ea9f7d98a2cfc399542;hp=ebd0564d7ccf15c7b3d80f11c46638cf839931f6;hpb=e8c3ca2d1d0cac3d64985b45a9f654d2029a7518;p=wimlib diff --git a/include/wimlib/win32_common.h b/include/wimlib/win32_common.h index ebd0564d..cbdacd32 100644 --- a/include/wimlib/win32_common.h +++ b/include/wimlib/win32_common.h @@ -1,61 +1,143 @@ +/* + * win32_common.h - common header for Windows-specific files. This always + * should be included first. + */ + #ifndef _WIMLIB_WIN32_COMMON_H #define _WIMLIB_WIN32_COMMON_H +#include #include +#include + #ifdef ERROR # undef ERROR #endif - -#include "wimlib/types.h" #include "wimlib/win32.h" - -#ifdef ENABLE_ERROR_MESSAGES -extern void -win32_error(DWORD err_code); -#else -static inline void -win32_error(DWORD err_code) -{ -} -#endif - -extern void -set_errno_from_GetLastError(void); +/* ntdll definitions */ + +#define FILE_OPENED 0x00000001 + +typedef struct _RTLP_CURDIR_REF { + LONG RefCount; + HANDLE Handle; +} RTLP_CURDIR_REF, *PRTLP_CURDIR_REF; + +typedef struct _RTL_RELATIVE_NAME_U { + UNICODE_STRING RelativeName; + HANDLE ContainingDirectory; + PRTLP_CURDIR_REF CurDirRef; +} RTL_RELATIVE_NAME_U, *PRTL_RELATIVE_NAME_U; + +#define FSCTL_SET_PERSISTENT_VOLUME_STATE 0x90238 + +#define PERSISTENT_VOLUME_STATE_SHORT_NAME_CREATION_DISABLED 0x00000001 + +typedef struct _FILE_FS_PERSISTENT_VOLUME_INFORMATION { + ULONG VolumeFlags; + ULONG FlagMask; + ULONG Version; + ULONG Reserved; +} FILE_FS_PERSISTENT_VOLUME_INFORMATION, *PFILE_FS_PERSISTENT_VOLUME_INFORMATION; + +/* ntdll functions */ + +NTSTATUS +NTAPI +NtReadFile(IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID Buffer, + IN ULONG Length, + IN PLARGE_INTEGER ByteOffset OPTIONAL, + IN PULONG Key OPTIONAL); + +NTSTATUS +NTAPI +NtWriteFile(IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PVOID Buffer, + IN ULONG Length, + IN PLARGE_INTEGER ByteOffset OPTIONAL, + IN PULONG Key OPTIONAL); + +NTSTATUS +NTAPI +NtQueryDirectoryFile(IN HANDLE FileHandle, + IN HANDLE EventHandle OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID FileInformation, + IN ULONG Length, + IN FILE_INFORMATION_CLASS FileInformationClass, + IN BOOLEAN ReturnSingleEntry, + IN PUNICODE_STRING FileName OPTIONAL, + IN BOOLEAN RestartScan); + +NTSTATUS +NTAPI +NtQuerySecurityObject(IN HANDLE Handle, + IN SECURITY_INFORMATION SecurityInformation, + OUT PSECURITY_DESCRIPTOR SecurityDescriptor, + IN ULONG Length, + OUT PULONG ResultLength); + +NTSTATUS +NTAPI +NtSetSecurityObject(IN HANDLE Handle, + IN SECURITY_INFORMATION SecurityInformation, + IN PSECURITY_DESCRIPTOR SecurityDescriptor); + +NTSTATUS +NTAPI +NtOpenSymbolicLinkObject(PHANDLE LinkHandle, + ACCESS_MASK DesiredAccess, + POBJECT_ATTRIBUTES ObjectAttributes); + + +/* Dynamically loaded ntdll functions */ + +extern NTSTATUS (WINAPI *func_RtlDosPathNameToNtPathName_U_WithStatus) + (IN PCWSTR DosName, + OUT PUNICODE_STRING NtName, + OUT PCWSTR *PartName, + OUT PRTL_RELATIVE_NAME_U RelativeName); + +extern NTSTATUS (WINAPI *func_RtlCreateSystemVolumeInformationFolder) + (PCUNICODE_STRING VolumeRootPath); + +/* Other utility functions */ extern int -win32_error_to_errno(DWORD err_code); +win32_path_to_nt_path(const wchar_t *win32_path, UNICODE_STRING *nt_path); extern int -win32_get_vol_flags(const wchar_t *path, unsigned *vol_flags_ret); - -extern HANDLE -win32_open_existing_file(const wchar_t *path, DWORD dwDesiredAccess); - -extern HANDLE -win32_open_file_data_only(const wchar_t *path); - -extern HANDLE (WINAPI *win32func_FindFirstStreamW)(LPCWSTR lpFileName, - STREAM_INFO_LEVELS InfoLevel, - LPVOID lpFindStreamData, - DWORD dwFlags); - -/* Vista and later */ -extern BOOL (WINAPI *win32func_FindNextStreamW)(HANDLE hFindStream, - LPVOID lpFindStreamData); +win32_get_drive_path(const wchar_t *file_path, wchar_t drive_path[7]); extern bool -windows_version_is_at_least(unsigned major, unsigned minor); +win32_try_to_attach_wof(const wchar_t *drive); -#define running_on_windows_xp_or_later() \ - windows_version_is_at_least(5, 1) +extern void +win32_warning(DWORD err, const wchar_t *format, ...) _cold_attribute; -#define running_on_windows_vista_or_later() \ - windows_version_is_at_least(6, 0) +extern void +win32_error(DWORD err, const wchar_t *format, ...) _cold_attribute; -#define running_on_windows_7_or_later() \ - windows_version_is_at_least(6, 1) +extern void +winnt_warning(NTSTATUS status, const wchar_t *format, ...) _cold_attribute; +extern void +winnt_error(NTSTATUS status, const wchar_t *format, ...) _cold_attribute; +extern NTSTATUS +winnt_fsctl(HANDLE h, u32 code, const void *in, u32 in_size, + void *out, u32 out_size_avail, u32 *actual_out_size_ret); #endif /* _WIMLIB_WIN32_COMMON_H */