include/wimlib/win32_common.h \
include/wimlib/win32_vss.h \
include/wimlib/wof.h
+PLATFORM_LIBS = -lmsvcrt -lntdll
else
libwim_la_SOURCES += src/unix_apply.c \
src/unix_capture.c
+PLATFORM_LIBS =
endif
libwim_la_CFLAGS = \
$(LIBNTFS_3G_LIBS) \
$(LIBFUSE_LIBS) \
$(LIBRT_LIBS) \
- $(LIBCRYPTO_LIBS)
+ $(LIBCRYPTO_LIBS) \
+ $(PLATFORM_LIBS)
if ENABLE_SSSE3_SHA1
libwim_la_SOURCES += src/sha1-ssse3.asm
#ifdef ERROR
# undef ERROR
#endif
-#include "wimlib/types.h"
#include "wimlib/win32.h"
-/* ntdll functions */
-
-extern NTSTATUS (WINAPI *func_NtCreateFile)(PHANDLE FileHandle,
- ACCESS_MASK DesiredAccess,
- POBJECT_ATTRIBUTES ObjectAttributes,
- PIO_STATUS_BLOCK IoStatusBlock,
- PLARGE_INTEGER AllocationSize,
- ULONG FileAttributes,
- ULONG ShareAccess,
- ULONG CreateDisposition,
- ULONG CreateOptions,
- PVOID EaBuffer,
- ULONG EaLength);
-
-#ifndef FILE_OPENED
-# define FILE_OPENED 0x00000001
-#endif
+/* ntdll definitions */
-extern NTSTATUS (WINAPI *func_NtOpenFile) (PHANDLE FileHandle,
- ACCESS_MASK DesiredAccess,
- POBJECT_ATTRIBUTES ObjectAttributes,
- PIO_STATUS_BLOCK IoStatusBlock,
- ULONG ShareAccess,
- ULONG OpenOptions);
-
-extern NTSTATUS (WINAPI *func_NtReadFile) (HANDLE FileHandle,
- HANDLE Event,
- PIO_APC_ROUTINE ApcRoutine,
- PVOID ApcContext,
- PIO_STATUS_BLOCK IoStatusBlock,
- PVOID Buffer,
- ULONG Length,
- PLARGE_INTEGER ByteOffset,
- PULONG Key);
-
-extern NTSTATUS (WINAPI *func_NtWriteFile) (HANDLE FileHandle,
- HANDLE Event,
- PIO_APC_ROUTINE ApcRoutine,
- PVOID ApcContext,
- PIO_STATUS_BLOCK IoStatusBlock,
- PVOID Buffer,
- ULONG Length,
- PLARGE_INTEGER ByteOffset,
- PULONG Key);
-
-extern NTSTATUS (WINAPI *func_NtQueryInformationFile)(HANDLE FileHandle,
- PIO_STATUS_BLOCK IoStatusBlock,
- PVOID FileInformation,
- ULONG Length,
- FILE_INFORMATION_CLASS FileInformationClass);
-
-extern NTSTATUS (WINAPI *func_NtQuerySecurityObject)(HANDLE handle,
- SECURITY_INFORMATION SecurityInformation,
- PSECURITY_DESCRIPTOR SecurityDescriptor,
- ULONG Length,
- PULONG LengthNeeded);
-
-extern NTSTATUS (WINAPI *func_NtQueryDirectoryFile) (HANDLE FileHandle,
- HANDLE Event,
- PIO_APC_ROUTINE ApcRoutine,
- PVOID ApcContext,
- PIO_STATUS_BLOCK IoStatusBlock,
- PVOID FileInformation,
- ULONG Length,
- FILE_INFORMATION_CLASS FileInformationClass,
- BOOLEAN ReturnSingleEntry,
- PUNICODE_STRING FileName,
- BOOLEAN RestartScan);
-
-extern NTSTATUS (WINAPI *func_NtQueryVolumeInformationFile) (HANDLE FileHandle,
- PIO_STATUS_BLOCK IoStatusBlock,
- PVOID FsInformation,
- ULONG Length,
- FS_INFORMATION_CLASS FsInformationClass);
-
-extern NTSTATUS (WINAPI *func_NtSetInformationFile)(HANDLE FileHandle,
- PIO_STATUS_BLOCK IoStatusBlock,
- PVOID FileInformation,
- ULONG Length,
- FILE_INFORMATION_CLASS FileInformationClass);
-
-extern NTSTATUS (WINAPI *func_NtSetSecurityObject)(HANDLE Handle,
- SECURITY_INFORMATION SecurityInformation,
- PSECURITY_DESCRIPTOR SecurityDescriptor);
-
-extern NTSTATUS (WINAPI *func_NtClose) (HANDLE Handle);
-
-extern DWORD (WINAPI *func_RtlNtStatusToDosError)(NTSTATUS status);
+#define FILE_OPENED 0x00000001
typedef struct _RTLP_CURDIR_REF {
LONG RefCount;
PRTLP_CURDIR_REF CurDirRef;
} RTL_RELATIVE_NAME_U, *PRTL_RELATIVE_NAME_U;
-extern BOOLEAN (WINAPI *func_RtlDosPathNameToNtPathName_U)
- (IN PCWSTR DosName,
- OUT PUNICODE_STRING NtName,
- OUT PCWSTR *PartName,
- OUT PRTL_RELATIVE_NAME_U RelativeName);
-
-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);
-
#define FSCTL_SET_PERSISTENT_VOLUME_STATE 0x90238
#define PERSISTENT_VOLUME_STATE_SHORT_NAME_CREATION_DISABLED 0x00000001
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);
+
+/* 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_path_to_nt_path(const wchar_t *win32_path, UNICODE_STRING *nt_path);
status = (*func_RtlCreateSystemVolumeInformationFolder)(&str);
- err2 = (*func_RtlNtStatusToDosError)(status);
+ err2 = RtlNtStatusToDosError(status);
if (err2 == ERROR_SUCCESS) {
if (!already_retried) {
already_retried = true;
/* Don't use FILE_OPEN_REPARSE_POINT here; we want the extraction to
* happen at the directory "pointed to" by the reparse point. */
- status = (*func_NtCreateFile)(&ctx->h_target,
- FILE_TRAVERSE,
- &ctx->attr,
- &ctx->iosb,
- NULL,
- 0,
- FILE_SHARE_VALID_FLAGS,
- FILE_OPEN_IF,
- FILE_DIRECTORY_FILE |
- FILE_OPEN_FOR_BACKUP_INTENT,
- NULL,
- 0);
+ status = NtCreateFile(&ctx->h_target,
+ FILE_TRAVERSE,
+ &ctx->attr,
+ &ctx->iosb,
+ NULL,
+ 0,
+ FILE_SHARE_VALID_FLAGS,
+ FILE_OPEN_IF,
+ FILE_DIRECTORY_FILE |
+ FILE_OPEN_FOR_BACKUP_INTENT,
+ NULL,
+ 0);
if (!NT_SUCCESS(status)) {
winnt_error(status, L"Can't open or create directory \"%ls\"",
ctx->common.target);
close_target_directory(struct win32_apply_ctx *ctx)
{
if (ctx->h_target) {
- (*func_NtClose)(ctx->h_target);
+ NtClose(ctx->h_target);
ctx->h_target = NULL;
ctx->attr.RootDirectory = NULL;
}
/* Get current attributes */
- status = (*func_NtQueryInformationFile)(h, &ctx->iosb,
- &info, sizeof(info),
- FileBasicInformation);
+ status = NtQueryInformationFile(h, &ctx->iosb, &info, sizeof(info),
+ FileBasicInformation);
if (NT_SUCCESS(status) &&
compressed == !!(info.FileAttributes & FILE_ATTRIBUTE_COMPRESSED))
{
ctx->pathbuf.Length = ((u8 *)end - (u8 *)ctx->pathbuf.Buffer);
/* Open the conflicting file (by short name). */
- status = (*func_NtOpenFile)(&h, GENERIC_WRITE | DELETE,
- &ctx->attr, &ctx->iosb,
- FILE_SHARE_VALID_FLAGS,
- FILE_OPEN_REPARSE_POINT | FILE_OPEN_FOR_BACKUP_INTENT);
+ status = NtOpenFile(&h, GENERIC_WRITE | DELETE,
+ &ctx->attr, &ctx->iosb,
+ FILE_SHARE_VALID_FLAGS,
+ FILE_OPEN_REPARSE_POINT | FILE_OPEN_FOR_BACKUP_INTENT);
if (!NT_SUCCESS(status)) {
winnt_warning(status, L"Can't open \"%ls\"", current_path(ctx));
goto out;
/* Try to remove the short name on the conflicting file. */
retry:
- status = (*func_NtSetInformationFile)(h, &ctx->iosb, info, bufsize,
- FileShortNameInformation);
+ status = NtSetInformationFile(h, &ctx->iosb, info, bufsize,
+ FileShortNameInformation);
if (status == STATUS_INVALID_PARAMETER && !retried) {
retried = true;
goto retry;
}
- (*func_NtClose)(h);
+ NtClose(h);
out:
build_extraction_path(dentry, ctx);
return status;
memcpy(info->FileName, dentry->d_short_name, dentry->d_short_name_nbytes);
retry:
- status = (*func_NtSetInformationFile)(h, &ctx->iosb, info, bufsize,
- FileShortNameInformation);
+ status = NtSetInformationFile(h, &ctx->iosb, info, bufsize,
+ FileShortNameInformation);
if (NT_SUCCESS(status))
return 0;
ULONG CreateOptions,
struct win32_apply_ctx *ctx)
{
- return (*func_NtCreateFile)(FileHandle,
- DesiredAccess | SYNCHRONIZE,
- &ctx->attr,
- &ctx->iosb,
- AllocationSize,
- FileAttributes,
- FILE_SHARE_VALID_FLAGS,
- CreateDisposition,
- CreateOptions |
- FILE_OPEN_FOR_BACKUP_INTENT |
- FILE_OPEN_REPARSE_POINT,
- NULL,
- 0);
+ return NtCreateFile(FileHandle,
+ DesiredAccess | SYNCHRONIZE,
+ &ctx->attr,
+ &ctx->iosb,
+ AllocationSize,
+ FileAttributes,
+ FILE_SHARE_VALID_FLAGS,
+ CreateDisposition,
+ CreateOptions |
+ FILE_OPEN_FOR_BACKUP_INTENT |
+ FILE_OPEN_REPARSE_POINT,
+ NULL,
+ 0);
}
/* Like do_create_file(), but builds the extraction path of the @dentry first.
FILE_BASIC_INFORMATION basic_info =
{ .FileAttributes = FILE_ATTRIBUTE_NORMAL };
- status = (*func_NtSetInformationFile)(h, &ctx->iosb,
- &basic_info,
- sizeof(basic_info),
- FileBasicInformation);
+ status = NtSetInformationFile(h, &ctx->iosb, &basic_info,
+ sizeof(basic_info),
+ FileBasicInformation);
if (!NT_SUCCESS(status)) {
winnt_error(status, L"Can't reset attributes of \"%ls\" "
"to prepare for deletion", current_path(ctx));
- (*func_NtClose)(h);
+ NtClose(h);
return WIMLIB_ERR_SET_ATTRIBUTES;
}
FILE_DISPOSITION_INFORMATION disp_info =
{ .DoDeleteFile = TRUE };
- status = (*func_NtSetInformationFile)(h, &ctx->iosb,
- &disp_info,
- sizeof(disp_info),
- FileDispositionInformation);
+ status = NtSetInformationFile(h, &ctx->iosb, &disp_info,
+ sizeof(disp_info),
+ FileDispositionInformation);
if (!NT_SUCCESS(status)) {
winnt_error(status, L"Can't set delete-on-close "
"disposition on \"%ls\"", current_path(ctx));
- (*func_NtClose)(h);
+ NtClose(h);
return WIMLIB_ERR_SET_ATTRIBUTES;
}
}
- status = (*func_NtClose)(h);
+ status = NtClose(h);
if (unlikely(!NT_SUCCESS(status))) {
winnt_error(status, L"Error closing \"%ls\" after setting "
"delete-on-close disposition", current_path(ctx));
status = winnt_fsctl(h, FSCTL_SET_REPARSE_POINT,
rpbuf, rpbuflen, NULL, 0, NULL);
- (*func_NtClose)(h);
+ NtClose(h);
if (NT_SUCCESS(status))
return 0;
if (ret)
return ret;
- (*func_NtClose)(h);
+ NtClose(h);
}
}
if (!(ctx->common.extract_flags & WIMLIB_EXTRACT_FLAG_NO_ATTRIBUTES)) {
FILE_BASIC_INFORMATION basic_info =
{ .FileAttributes = FILE_ATTRIBUTE_NORMAL };
- (*func_NtSetInformationFile)(h, &ctx->iosb, &basic_info,
- sizeof(basic_info),
- FileBasicInformation);
+ NtSetInformationFile(h, &ctx->iosb, &basic_info,
+ sizeof(basic_info),
+ FileBasicInformation);
}
/* Also try to remove the directory's DACL. This isn't supposed
.Sacl = 0,
.Dacl = 0,
};
- (*func_NtSetSecurityObject)(h, DACL_SECURITY_INFORMATION,
- (void *)&desc);
+ NtSetSecurityObject(h, DACL_SECURITY_INFORMATION,
+ (void *)&desc);
}
}
ret = adjust_compression_attribute(h, dentry, ctx);
out:
- (*func_NtClose)(h);
+ NtClose(h);
return ret;
}
return 0;
out_close:
- (*func_NtClose)(h);
+ NtClose(h);
out:
return ret;
}
* STATUS_INFO_LENGTH_MISMATCH when FileNameLength
* happens to be 2 */
- status = (*func_NtSetInformationFile)(h, &ctx->iosb,
- info, bufsize,
- FileLinkInformation);
+ status = NtSetInformationFile(h, &ctx->iosb, info, bufsize,
+ FileLinkInformation);
if (NT_SUCCESS(status))
return 0;
winnt_error(status, L"Failed to create link \"%ls\"",
if (ret)
return ret;
- (*func_NtClose)(h2);
+ NtClose(h2);
return 0;
}
}
if (!ret && unlikely(ctx->common.extract_flags & WIMLIB_EXTRACT_FLAG_WIMBOOT))
ret = set_backed_from_wim(h, inode, ctx);
- (*func_NtClose)(h);
+ NtClose(h);
return ret;
}
close_handles(struct win32_apply_ctx *ctx)
{
for (unsigned i = 0; i < ctx->num_open_handles; i++)
- (*func_NtClose)(ctx->open_handles[i]);
+ NtClose(ctx->open_handles[i]);
}
/* Prepare to read the next blob, which has size @blob_size, into an in-memory
/* Allocate space for the data. */
alloc_info.AllocationSize.QuadPart = blob->size;
- (*func_NtSetInformationFile)(h, &ctx->iosb,
- &alloc_info, sizeof(alloc_info),
- FileAllocationInformation);
+ NtSetInformationFile(h, &ctx->iosb, &alloc_info, sizeof(alloc_info),
+ FileAllocationInformation);
return 0;
}
while (bytes_remaining) {
ULONG count = min(0xFFFFFFFF, bytes_remaining);
- status = (*func_NtWriteFile)(ctx->open_handles[i],
- NULL, NULL, NULL,
- &ctx->iosb, bufptr, count,
- NULL, NULL);
+ status = NtWriteFile(ctx->open_handles[i],
+ NULL, NULL, NULL,
+ &ctx->iosb, bufptr, count,
+ NULL, NULL);
if (!NT_SUCCESS(status)) {
winnt_error(status, L"Error writing data to target volume");
return WIMLIB_ERR_WRITE;
}
}
- (*func_NtClose)(h);
+ NtClose(h);
return status;
}
*/
retry:
- status = (*func_NtSetSecurityObject)(h, info, desc);
+ status = NtSetSecurityObject(h, info, desc);
if (NT_SUCCESS(status))
goto out_maybe_free_desc;
info.FileAttributes = FILE_ATTRIBUTE_NORMAL;
}
- status = (*func_NtSetInformationFile)(h, &ctx->iosb,
- &info, sizeof(info),
- FileBasicInformation);
+ status = NtSetInformationFile(h, &ctx->iosb, &info, sizeof(info),
+ FileBasicInformation);
/* On FAT volumes we get STATUS_INVALID_PARAMETER if we try to set
* attributes on the root directory. (Apparently because FAT doesn't
* actually have a place to store those attributes!) */
ret = do_apply_metadata_to_file(h, inode, ctx);
- (*func_NtClose)(h);
+ NtClose(h);
return ret;
}
options |= FILE_SEQUENTIAL_ONLY;
}
retry:
- status = (*func_NtOpenFile)(h_ret, perms, &attr, &iosb,
- FILE_SHARE_VALID_FLAGS, options);
+ status = NtOpenFile(h_ret, perms, &attr, &iosb,
+ FILE_SHARE_VALID_FLAGS, options);
if (!NT_SUCCESS(status)) {
/* Try requesting fewer permissions */
if (status == STATUS_ACCESS_DENIED ||
u64 bytes_remaining;
int ret;
- status = (*func_NtOpenFile)(&h, FILE_READ_DATA | SYNCHRONIZE,
- &attr, &iosb,
- FILE_SHARE_VALID_FLAGS,
- FILE_OPEN_REPARSE_POINT |
- FILE_OPEN_FOR_BACKUP_INTENT |
- FILE_SYNCHRONOUS_IO_NONALERT |
- FILE_SEQUENTIAL_ONLY |
- (file->is_file_id ? FILE_OPEN_BY_FILE_ID : 0));
+ status = NtOpenFile(&h, FILE_READ_DATA | SYNCHRONIZE,
+ &attr, &iosb,
+ FILE_SHARE_VALID_FLAGS,
+ FILE_OPEN_REPARSE_POINT |
+ FILE_OPEN_FOR_BACKUP_INTENT |
+ FILE_SYNCHRONOUS_IO_NONALERT |
+ FILE_SEQUENTIAL_ONLY |
+ (file->is_file_id ? FILE_OPEN_BY_FILE_ID : 0));
if (unlikely(!NT_SUCCESS(status))) {
if (status == STATUS_SHARING_VIOLATION) {
ERROR("Can't open %ls for reading:\n"
count = min(sizeof(buf), bytes_remaining);
retry_read:
- status = (*func_NtReadFile)(h, NULL, NULL, NULL,
- &iosb, buf, count, NULL, NULL);
+ status = NtReadFile(h, NULL, NULL, NULL,
+ &iosb, buf, count, NULL, NULL);
if (unlikely(!NT_SUCCESS(status))) {
if (status == STATUS_END_OF_FILE) {
ERROR("%ls: File was concurrently truncated",
if (ret)
break;
}
- (*func_NtClose)(h);
+ NtClose(h);
return ret;
}
u8 buf[128] _aligned_attribute(8);
const FILE_NAME_INFORMATION *info;
- status = (*func_NtQueryInformationFile)(h, &iosb, buf, sizeof(buf),
- FileAlternateNameInformation);
+ status = NtQueryInformationFile(h, &iosb, buf, sizeof(buf),
+ FileAlternateNameInformation);
info = (const FILE_NAME_INFORMATION *)buf;
if (NT_SUCCESS(status) && info->FileNameLength != 0) {
dentry->d_short_name = utf16le_dupz(info->FileName,
* ntdll function and therefore not officially part of the Win32 API.
* Oh well.
*/
- while (!(NT_SUCCESS(status = (*func_NtQuerySecurityObject)(h,
- requestedInformation,
- (PSECURITY_DESCRIPTOR)buf,
- bufsize,
- &len_needed))))
+ while (!NT_SUCCESS(status = NtQuerySecurityObject(h,
+ requestedInformation,
+ (PSECURITY_DESCRIPTOR)buf,
+ bufsize,
+ &len_needed)))
{
switch (status) {
case STATUS_BUFFER_TOO_SMALL:
/* Using NtQueryDirectoryFile() we can re-use the same open handle,
* which we opened with FILE_FLAG_BACKUP_SEMANTICS. */
- while (NT_SUCCESS(status = (*func_NtQueryDirectoryFile)(h, NULL, NULL, NULL,
- &iosb, buf, bufsize,
- FileNamesInformation,
- FALSE, NULL, FALSE)))
+ while (NT_SUCCESS(status = NtQueryDirectoryFile(h, NULL, NULL, NULL,
+ &iosb, buf, bufsize,
+ FileNamesInformation,
+ FALSE, NULL, FALSE)))
{
const FILE_NAMES_INFORMATION *info = buf;
for (;;) {
FILE_INTERNAL_INFORMATION int_info;
FILE_FS_VOLUME_INFORMATION vol_info;
- status = (*func_NtQueryInformationFile)(h, &iosb,
- &int_info, sizeof(int_info),
- FileInternalInformation);
+ status = NtQueryInformationFile(h, &iosb, &int_info, sizeof(int_info),
+ FileInternalInformation);
if (!NT_SUCCESS(status))
return false;
if (int_info.IndexNumber.QuadPart != ino)
return false;
- status = (*func_NtQueryVolumeInformationFile)(h, &iosb,
- &vol_info, sizeof(vol_info),
- FileFsVolumeInformation);
+ status = NtQueryVolumeInformationFile(h, &iosb,
+ &vol_info, sizeof(vol_info),
+ FileFsVolumeInformation);
if (!(NT_SUCCESS(status) || status == STATUS_BUFFER_OVERFLOW))
return false;
name.MaximumLength = name.Length;
/* Try opening the file */
- status = (*func_NtOpenFile) (&h,
- FILE_READ_ATTRIBUTES | FILE_TRAVERSE,
- &attr,
- &iosb,
- FILE_SHARE_VALID_FLAGS,
- FILE_OPEN_FOR_BACKUP_INTENT);
+ status = NtOpenFile(&h,
+ FILE_READ_ATTRIBUTES | FILE_TRAVERSE,
+ &attr,
+ &iosb,
+ FILE_SHARE_VALID_FLAGS,
+ FILE_OPEN_FOR_BACKUP_INTENT);
if (NT_SUCCESS(status)) {
/* Reset root directory */
if (attr.RootDirectory)
- (*func_NtClose)(attr.RootDirectory);
+ NtClose(attr.RootDirectory);
attr.RootDirectory = h;
name.Buffer = (wchar_t *)p;
name.Length = 0;
out_close_root_dir:
if (attr.RootDirectory)
- (*func_NtClose)(attr.RootDirectory);
+ NtClose(attr.RootDirectory);
while (p > target && *(p - 1) == L'\\')
p--;
return p;
goto unnamed_only;
/* Get a buffer containing the stream information. */
- while (!NT_SUCCESS(status = (*func_NtQueryInformationFile)(h,
- &iosb,
- buf,
- bufsize,
- FileStreamInformation)))
+ while (!NT_SUCCESS(status = NtQueryInformationFile(h,
+ &iosb,
+ buf,
+ bufsize,
+ FileStreamInformation)))
{
switch (status) {
NTSTATUS status;
FILE_ALL_INFORMATION all_info;
- status = (*func_NtQueryInformationFile)(h, &iosb, &all_info,
- sizeof(all_info),
- FileAllInformation);
+ status = NtQueryInformationFile(h, &iosb, &all_info, sizeof(all_info),
+ FileAllInformation);
if (unlikely(!NT_SUCCESS(status) && status != STATUS_BUFFER_OVERFLOW))
return status;
NTSTATUS status;
/* Get volume flags */
- status = (*func_NtQueryVolumeInformationFile)(h, &iosb, attr_info,
- sizeof(_attr_info),
- FileFsAttributeInformation);
+ status = NtQueryVolumeInformationFile(h, &iosb, attr_info,
+ sizeof(_attr_info),
+ FileFsAttributeInformation);
if (NT_SUCCESS(status)) {
ctx->vol_flags = attr_info->FileSystemAttributes;
ctx->is_ntfs = (attr_info->FileSystemNameLength == 4 * sizeof(wchar_t)) &&
}
/* Get volume ID. */
- status = (*func_NtQueryVolumeInformationFile)(h, &iosb, &vol_info,
- sizeof(vol_info),
- FileFsVolumeInformation);
+ status = NtQueryVolumeInformationFile(h, &iosb, &vol_info,
+ sizeof(vol_info),
+ FileFsVolumeInformation);
if ((NT_SUCCESS(status) || status == STATUS_BUFFER_OVERFLOW) &&
(iosb.Information >= offsetof(FILE_FS_VOLUME_INFORMATION,
VolumeSerialNumber) +
* ERROR_SHARING_VIOLATION if there are any open handles to the
* file, we have to close the file and re-open it later if
* needed. */
- (*func_NtClose)(h);
+ NtClose(h);
h = NULL;
ret = winnt_scan_efsrpc_raw_data(inode, full_path,
full_path_nchars, ctx);
/* Re-open the directory with FILE_LIST_DIRECTORY access. */
if (h) {
- (*func_NtClose)(h);
+ NtClose(h);
h = NULL;
}
status = winnt_openat(cur_dir, relative_path,
ret = do_capture_progress(ctx->params, WIMLIB_SCAN_DENTRY_EXCLUDED, NULL);
out:
if (likely(h))
- (*func_NtClose)(h);
+ NtClose(h);
if (unlikely(ret)) {
free_dentry_tree(root, ctx->params->blob_table);
root = NULL;
ret = 0;
out:
FREE(out);
- (*func_NtClose)(h);
+ NtClose(h);
return ret;
}
goto out;
}
ret = winnt_load_security_descriptor(h, inode, path, ctx);
- (*func_NtClose)(h);
+ NtClose(h);
if (ret)
goto out;
get_volume_information(h, path, &ctx);
- (*func_NtClose)(h);
+ NtClose(h);
#ifdef ENABLE_FAST_MFT_SCAN
if (ctx.is_ntfs && !_wgetenv(L"WIMLIB_DISABLE_QUERY_FILE_LAYOUT")) {
/* ntdll.dll */
-NTSTATUS (WINAPI *func_NtCreateFile)(PHANDLE FileHandle,
- ACCESS_MASK DesiredAccess,
- POBJECT_ATTRIBUTES ObjectAttributes,
- PIO_STATUS_BLOCK IoStatusBlock,
- PLARGE_INTEGER AllocationSize,
- ULONG FileAttributes,
- ULONG ShareAccess,
- ULONG CreateDisposition,
- ULONG CreateOptions,
- PVOID EaBuffer,
- ULONG EaLength);
-
-NTSTATUS (WINAPI *func_NtOpenFile) (PHANDLE FileHandle,
- ACCESS_MASK DesiredAccess,
- POBJECT_ATTRIBUTES ObjectAttributes,
- PIO_STATUS_BLOCK IoStatusBlock,
- ULONG ShareAccess,
- ULONG OpenOptions);
-
-NTSTATUS (WINAPI *func_NtReadFile) (HANDLE FileHandle,
- HANDLE Event,
- PIO_APC_ROUTINE ApcRoutine,
- PVOID ApcContext,
- PIO_STATUS_BLOCK IoStatusBlock,
- PVOID Buffer,
- ULONG Length,
- PLARGE_INTEGER ByteOffset,
- PULONG Key);
-
-NTSTATUS (WINAPI *func_NtWriteFile) (HANDLE FileHandle,
- HANDLE Event,
- PIO_APC_ROUTINE ApcRoutine,
- PVOID ApcContext,
- PIO_STATUS_BLOCK IoStatusBlock,
- PVOID Buffer,
- ULONG Length,
- PLARGE_INTEGER ByteOffset,
- PULONG Key);
-
-NTSTATUS (WINAPI *func_NtQueryInformationFile)(HANDLE FileHandle,
- PIO_STATUS_BLOCK IoStatusBlock,
- PVOID FileInformation,
- ULONG Length,
- FILE_INFORMATION_CLASS FileInformationClass);
-
-NTSTATUS (WINAPI *func_NtQuerySecurityObject)(HANDLE handle,
- SECURITY_INFORMATION SecurityInformation,
- PSECURITY_DESCRIPTOR SecurityDescriptor,
- ULONG Length,
- PULONG LengthNeeded);
-
-NTSTATUS (WINAPI *func_NtQueryDirectoryFile) (HANDLE FileHandle,
- HANDLE Event,
- PIO_APC_ROUTINE ApcRoutine,
- PVOID ApcContext,
- PIO_STATUS_BLOCK IoStatusBlock,
- PVOID FileInformation,
- ULONG Length,
- FILE_INFORMATION_CLASS FileInformationClass,
- BOOLEAN ReturnSingleEntry,
- PUNICODE_STRING FileName,
- BOOLEAN RestartScan);
-
-NTSTATUS (WINAPI *func_NtQueryVolumeInformationFile) (HANDLE FileHandle,
- PIO_STATUS_BLOCK IoStatusBlock,
- PVOID FsInformation,
- ULONG Length,
- FS_INFORMATION_CLASS FsInformationClass);
-
-NTSTATUS (WINAPI *func_NtSetInformationFile)(HANDLE FileHandle,
- PIO_STATUS_BLOCK IoStatusBlock,
- PVOID FileInformation,
- ULONG Length,
- FILE_INFORMATION_CLASS FileInformationClass);
-
-NTSTATUS (WINAPI *func_NtSetSecurityObject)(HANDLE Handle,
- SECURITY_INFORMATION SecurityInformation,
- PSECURITY_DESCRIPTOR SecurityDescriptor);
-
-static NTSTATUS (WINAPI *func_NtFsControlFile) (HANDLE FileHandle,
- HANDLE Event,
- PIO_APC_ROUTINE ApcRoutine,
- PVOID ApcContext,
- PIO_STATUS_BLOCK IoStatusBlock,
- ULONG FsControlCode,
- PVOID InputBuffer,
- ULONG InputBufferLength,
- PVOID OutputBuffer,
- ULONG OutputBufferLength);
-
-static NTSTATUS (WINAPI *func_NtWaitForSingleObject) (HANDLE Handle,
- BOOLEAN Alertable,
- PLARGE_INTEGER Timeout);
-
-NTSTATUS (WINAPI *func_NtClose) (HANDLE Handle);
-
-DWORD (WINAPI *func_RtlNtStatusToDosError)(NTSTATUS status);
-
-BOOLEAN (WINAPI *func_RtlDosPathNameToNtPathName_U)
- (IN PCWSTR DosName,
- OUT PUNICODE_STRING NtName,
- OUT PCWSTR *PartName,
- OUT PRTL_RELATIVE_NAME_U RelativeName);
-
NTSTATUS (WINAPI *func_RtlDosPathNameToNtPathName_U_WithStatus)
(IN PCWSTR DosName,
OUT PUNICODE_STRING NtName,
struct dll_spec ntdll_spec = {
.name = L"ntdll.dll",
.syms = {
- DLL_SYM(NtCreateFile, true),
- DLL_SYM(NtOpenFile, true),
- DLL_SYM(NtReadFile, true),
- DLL_SYM(NtWriteFile, true),
- DLL_SYM(NtQueryInformationFile, true),
- DLL_SYM(NtQuerySecurityObject, true),
- DLL_SYM(NtQueryDirectoryFile, true),
- DLL_SYM(NtQueryVolumeInformationFile, true),
- DLL_SYM(NtSetInformationFile, true),
- DLL_SYM(NtSetSecurityObject, true),
- DLL_SYM(NtFsControlFile, true),
- DLL_SYM(NtWaitForSingleObject, true),
- DLL_SYM(NtClose, true),
- DLL_SYM(RtlNtStatusToDosError, true),
DLL_SYM(RtlCreateSystemVolumeInformationFolder, false),
- DLL_SYM(RtlDosPathNameToNtPathName_U, true),
DLL_SYM(RtlDosPathNameToNtPathName_U_WithStatus, false), /* Not present on XP */
{NULL, NULL},
},
nt_path,
NULL, NULL);
} else {
- if ((*func_RtlDosPathNameToNtPathName_U)(win32_path, nt_path,
- NULL, NULL))
+ if (RtlDosPathNameToNtPathName_U(win32_path, nt_path, NULL, NULL))
status = STATUS_SUCCESS;
else
status = STATUS_NO_MEMORY;
IO_STATUS_BLOCK iosb;
NTSTATUS status;
- status = (*func_NtFsControlFile)(h, NULL, NULL, NULL, &iosb, code,
- (void *)in, in_size,
- out, out_size_avail);
+ status = NtFsControlFile(h, NULL, NULL, NULL, &iosb, code,
+ (void *)in, in_size, out, out_size_avail);
if (status == STATUS_PENDING) {
/* Beware: this case is often encountered with remote
* filesystems, but rarely with local filesystems. */
- status = (*func_NtWaitForSingleObject)(h, FALSE, NULL);
+ status = NtWaitForSingleObject(h, FALSE, NULL);
if (NT_SUCCESS(status)) {
status = iosb.Status;
} else {