20#define _SEH2_LEAVE goto __SEH2_FINALLY__label;
21#define _SEH2_FINALLY __SEH2_FINALLY__label:
104 DPRINT(
"PathName: %wZ\n", &PathNameU);
130 DPRINT(
"Create: %wZ\n", &PathNameU);
186 DPRINT1(
"NtQueryInformationFile failed with Status 0x%08lx\n",
Status);
200 DPRINT1(
"NtSetInformationFile failed with Status 0x%08lx\n",
Status);
246 SIZE_T SourceSectionSize = 0;
299 DPRINT1(
"NtCreateSection failed: %x, %S\n",
Status, SourceFileName);
315 DPRINT1(
"NtMapViewOfSection failed: %x, %S\n",
Status, SourceFileName);
422 DPRINT1(
"NtWriteFile failed: %x:%x, iosb: %p src: %p, size: %x\n",
516 if (RenameInfo ==
NULL)
551 DPRINT1(
"Forcing copy, renaming not supported by FSD\n");
589 IN ULONG NumberOfPathComponents,
599 while (NumberOfPathComponents--)
605 cchPathLen =
min(cchPathSize,
wcslen(PathBuffer));
606 if (cchPathLen >= cchPathSize)
636 IN ULONG NumberOfPathComponents,
644 NumberOfPathComponents,
652 IN ULONG NumberOfPathComponents,
661 va_start(PathComponentsList, NumberOfPathComponents);
663 NumberOfPathComponents,
665 va_end(PathComponentsList);
674 IN ULONG NumberOfPathComponents,
685 va_start(PathComponentsList, NumberOfPathComponents);
687 NumberOfPathComponents,
689 va_end(PathComponentsList);
726 DPRINT(
"Failed to open %s '%wZ', Status 0x%08lx\n",
776 ULONG DiskNumber, PartNumber;
788 DPRINT1(
"'%S' : Not a possible hard disk device.\n", NtPath);
797 DPRINT1(
"'%S' : expected a number! Not a regular hard disk device.\n",
Path);
805 DPRINT1(
"'%S' : expected a path separator!\n",
Path);
811 DPRINT1(
"The path only specified a hard disk (and nothing else, like a partition...), so we stop there.\n");
820 DPRINT1(
"'%S' : unexpected format!\n", NtPath);
839 DPRINT1(
"'%S' : expected a path separator!\n",
Path);
844 *pPartNumber = PartNumber;
848 *pDiskNumber = DiskNumber;
934 DPRINT(
"NtQueryInformationFile() failed (Status 0x%08lx)\n",
Status);
938 if (
FileInfo.EndOfFile.HighPart != 0)
1002 *SectionHandle =
NULL;
1014 DPRINT1(
"Failed to create a memory section for file 0x%p (Status 0x%08lx)\n",
1033 DPRINT1(
"Failed to map a view for file 0x%p (Status 0x%08lx)\n",
1036 *SectionHandle =
NULL;
1068 DPRINT1(
"NtUnmapViewOfSection(0x%p) failed (Status 0x%08lx)\n",
1075 DPRINT1(
"NtClose(0x%p) failed (Status 0x%08lx)\n",
NTSTATUS NTAPI NtUnmapViewOfSection(IN HANDLE ProcessHandle, IN PVOID BaseAddress)
NTSTATUS NTAPI NtCreateSection(OUT PHANDLE SectionHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN PLARGE_INTEGER MaximumSize OPTIONAL, IN ULONG SectionPageProtection OPTIONAL, IN ULONG AllocationAttributes, IN HANDLE FileHandle OPTIONAL)
NTSTATUS NTAPI NtMapViewOfSection(IN HANDLE SectionHandle, IN HANDLE ProcessHandle, IN OUT PVOID *BaseAddress, IN ULONG_PTR ZeroBits, IN SIZE_T CommitSize, IN OUT PLARGE_INTEGER SectionOffset OPTIONAL, IN OUT PSIZE_T ViewSize, IN SECTION_INHERIT InheritDisposition, IN ULONG AllocationType, IN ULONG Protect)
static HANDLE DirectoryHandle
PRTL_UNICODE_STRING_BUFFER Path
#define OBJ_NAME_PATH_SEPARATOR
#define FILE_DIRECTORY_FILE
#define FILE_NON_DIRECTORY_FILE
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
_In_ PSCSI_REQUEST_BLOCK _Out_ NTSTATUS _Inout_ BOOLEAN * Retry
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
#define NT_SUCCESS(StatCode)
#define FILE_ATTRIBUTE_NORMAL
IN PDCB IN PCCB IN VBO IN OUT PULONG OUT PDIRENT OUT PBCB OUT PVBO ByteOffset
struct _FileName FileName
BOOLEAN DoesPathExist(_In_opt_ HANDLE RootDirectory, _In_ PCWSTR PathName, _In_ BOOLEAN IsDirectory)
NTSTATUS CombinePaths(OUT PWSTR PathBuffer, IN SIZE_T cchPathSize, IN ULONG NumberOfPathComponents, IN ...)
NTSTATUS MapFile(_In_ HANDLE FileHandle, _Out_ PHANDLE SectionHandle, _Out_ PVOID *BaseAddress, _In_ BOOLEAN ReadWriteAccess)
Maps an opened file in memory.
static NTSTATUS SetupCreateSingleDirectory(_In_ PCUNICODE_STRING DirectoryName)
BOOLEAN DoesFileExist_2(IN PCWSTR PathName OPTIONAL, IN PCWSTR FileName)
BOOLEAN NtPathToDiskPartComponents(IN PCWSTR NtPath, OUT PULONG pDiskNumber, OUT PULONG pPartNumber, OUT PCWSTR *PathComponent OPTIONAL)
NTSTATUS OpenAndMapFile(_In_opt_ HANDLE RootDirectory, _In_ PCWSTR PathNameToFile, _Out_opt_ PHANDLE FileHandle, _Out_opt_ PULONG FileSize, _Out_ PHANDLE SectionHandle, _Out_ PVOID *BaseAddress, _In_ BOOLEAN ReadWriteAccess)
Opens and maps a file in memory.
NTSTATUS ConcatPathsV(IN OUT PWSTR PathBuffer, IN SIZE_T cchPathSize, IN ULONG NumberOfPathComponents, IN va_list PathComponentsList)
NTSTATUS CombinePathsV(OUT PWSTR PathBuffer, IN SIZE_T cchPathSize, IN ULONG NumberOfPathComponents, IN va_list PathComponentsList)
NTSTATUS SetupMoveFile(IN PCWSTR ExistingFileName, IN PCWSTR NewFileName, IN ULONG Flags)
NTSTATUS SetupCreateDirectory(_In_ PCWSTR PathName)
Create a new directory, specified by the given path. Any intermediate non-existing directory is creat...
NTSTATUS ConcatPaths(IN OUT PWSTR PathBuffer, IN SIZE_T cchPathSize, IN ULONG NumberOfPathComponents, IN ...)
BOOLEAN UnMapFile(_In_ HANDLE SectionHandle, _In_ PVOID BaseAddress)
Unmaps a mapped file by section.
NTSTATUS SetupCopyFile(IN PCWSTR SourceFileName, IN PCWSTR DestinationFileName, IN BOOLEAN FailIfExists)
NTSTATUS SetupDeleteFile(IN PCWSTR FileName, IN BOOLEAN ForceDelete)
BOOLEAN DoesPathExist_UStr(_In_opt_ HANDLE RootDirectory, _In_ PCUNICODE_STRING PathName, _In_ BOOLEAN IsDirectory)
#define MOVEFILE_WRITE_THROUGH
#define MOVEFILE_REPLACE_EXISTING
#define DoesFileExist(RootDirectory, FileName)
#define MOVEFILE_COPY_ALLOWED
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
@ FileEndOfFileInformation
@ FileDispositionInformation
#define FILE_OVERWRITE_IF
#define FILE_SYNCHRONOUS_IO_NONALERT
#define FILE_NO_INTERMEDIATE_BUFFERING
#define FILE_WRITE_THROUGH
#define FILE_SEQUENTIAL_ONLY
#define FILE_OPEN_FOR_BACKUP_INTENT
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define OBJ_CASE_INSENSITIVE
static OUT PIO_STATUS_BLOCK IoStatusBlock
static OUT PIO_STATUS_BLOCK OUT PVOID FileInformation
#define InitializeObjectAttributes(p, n, a, r, s)
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_opt_ PLARGE_INTEGER _In_ ULONG SectionPageProtection
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T ViewSize
__kernel_entry _Inout_ _Inout_ PSIZE_T RegionSize
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
#define SECTION_MAP_WRITE
NTSYSAPI NTSTATUS NTAPI NtWriteFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID WriteBuffer, IN ULONG WriteBufferLength, IN PLARGE_INTEGER FileOffset OPTIONAL, IN PULONG LockOperationKey OPTIONAL)
#define FILE_READ_ATTRIBUTES
#define FILE_LIST_DIRECTORY
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define NtCurrentProcess()
NTSYSAPI NTSTATUS NTAPI NtSetInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
NTSYSAPI NTSTATUS NTAPI NtQueryInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, OUT PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
#define FILE_SHARE_DELETE
#define FILE_WRITE_ATTRIBUTES
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
#define FILE_ATTRIBUTE_DIRECTORY
NTSTATUS NTAPI NtCreateFile(OUT PHANDLE FileHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK IoStatusBlock, IN PLARGE_INTEGER AllocationSize OPTIONAL, IN ULONG FileAttributes, IN ULONG ShareAccess, IN ULONG CreateDisposition, IN ULONG CreateOptions, IN PVOID EaBuffer OPTIONAL, IN ULONG EaLength)
#define FILE_GENERIC_READ
#define FILE_GENERIC_WRITE
#define STANDARD_RIGHTS_REQUIRED
#define STATUS_NOT_IMPLEMENTED
#define STATUS_NOT_SAME_DEVICE
NTSTRSAFEAPI RtlStringCchCatW(_Inout_updates_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
#define FileStandardInformation
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define STATUS_BUFFER_OVERFLOW
PULONG MinorVersion OPTIONAL
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define STATUS_ACCESS_DENIED
#define STATUS_INVALID_PARAMETER
struct _LARGE_INTEGER::@2299 u
_Must_inspect_result_ _In_ ULONG Flags