94#define STRING_LENGTH 0x400
99 PWSTR PendingOperations, BufferWrite;
103 WCHAR PendingOperationsBuffer[
sizeof(
L"PendingFileRenameOperations") /
sizeof(
WCHAR) + 6];
106 L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Session Manager");
111 PendingOperations =
L"PendingFileRenameOperations";
116 sizeof(PendingOperationsBuffer),
117 L"PendingFileRenameOperations%d", KeyId);
118 PendingOperations = PendingOperationsBuffer;
123 &SessionManagerString,
159 &PendingOperationsString,
200 BufferBegin = PartialInfo->
Data;
205 RtlCopyMemory(BufferWrite, ExistingPath->Buffer, ExistingPath->Length);
206 BufferWrite += ExistingPath->Length /
sizeof(
WCHAR);
211 RtlCopyMemory(BufferWrite, NewPath->Buffer, NewPath->Length);
212 BufferWrite += NewPath->Length /
sizeof(
WCHAR);
220 &PendingOperationsString,
243 PWSTR AbsolutePath, EndOfName;
244 USHORT AbsolutePathLength, NameLength;
250 DPRINT(
"BasepGetComputerNameFromNtPath(%wZ, %p, %p, %lu)\n",
251 NewPath, NewHandle, ComputerName, ComputerNameLength);
257 if (NewPath->Length <= UncString.
Length)
263 AbsolutePath = &NewPath->Buffer[UncString.
Length /
sizeof(
WCHAR)];
264 AbsolutePathLength = NewPath->Length - UncString.
Length;
274 Letter = NewPath->Buffer[4];
302 AbsolutePath =
Path + 1;
344 AbsolutePathLength = 0;
348 EndOfName = AbsolutePath;
349 if (AbsolutePathLength)
351 for (NameLength = 0; NameLength < AbsolutePathLength; NameLength +=
sizeof(
WCHAR))
354 if (EndOfName[0] ==
L'\\')
359 else if (EndOfName[0] ==
L'.')
368 NameLength = EndOfName - AbsolutePath;
383 *ComputerNameLength = NameLength /
sizeof(
WCHAR);
415 DPRINT(
"BasepNotifyTrackingService(%p, %p, %p, %wZ)\n",
419 ComputerNameLength =
ARRAYSIZE(ComputerName);
425 FileTrackingInfo.ObjectInformationLength = 0;
430 RtlInitEmptyAnsiString(&ComputerNameStringA,
431 ComputerNameStringBuffer,
432 sizeof(ComputerNameStringBuffer));
441 RtlCopyMemory(FileTrackingInfo.ObjectInformation, ComputerNameStringA.Buffer, ComputerNameStringA.Length);
442 FileTrackingInfo.ObjectInformation[ComputerNameStringA.Length] =
ANSI_NULL;
443 FileTrackingInfo.ObjectInformationLength = ComputerNameStringA.Length + 1;
447 FileTrackingInfo.DestinationFile = NewHandle;
453 sizeof(FileTrackingInfo),
483 sizeof(FileBasicInfo),
499 sizeof(FileBasicInfo),
516 *ExistingHandle = hFullWrite;
522 sizeof(FileTrackingInfo),
534 sizeof(FileBasicInfo),
561 ULONG IntShareAccess;
567 RtlInitEmptyUnicodeString(RelativeNtName,
NULL, 0);
577 *NtName = RelativeNtName->Buffer;
687 if (!dwCallbackReason)
689 if (StreamBytesTransferred.QuadPart == StreamSize.QuadPart)
698 Ret =
Context->UserRoutine(TotalFileSize,
699 TotalBytesTransferred,
701 StreamBytesTransferred,
733 BOOL Ret =
FALSE, ReplaceIfExists, DelayUntilReboot, AttemptReopenWithoutReparse;
735 DPRINT(
"MoveFileWithProgressW(%S, %S, %p, %p, %x)\n",
736 lpExistingFileName, lpNewFileName, lpProgressRoutine, lpData,
dwFlags);
768 AttemptReopenWithoutReparse =
TRUE;
784 if (DelayUntilReboot &&
790 AttemptReopenWithoutReparse =
FALSE;
817 AttemptReopenWithoutReparse =
FALSE;
829 AttemptReopenWithoutReparse =
FALSE;
834 if (AttemptReopenWithoutReparse)
850 if (DelayUntilReboot && !lpNewFileName)
862 if (DelayUntilReboot)
865 if (ReplaceIfExists && NewPathU.
Length)
868 if (NewBuffer ==
NULL)
879 NewPathU.
Buffer = NewBuffer;
921 if (RenameInfo ==
NULL)
955 DPRINT1(
"Forcing copy, renaming not supported by FSD\n");
1177 UNICODE_STRING ReplacedFileNameW, ReplacementFileNameW, BackupFileNameW;
1179 if (!lpReplacedFileName || !lpReplacementFileName || lpExclude || lpReserved ||
1180 (dwReplaceFlags & ~(REPLACEFILE_WRITE_THROUGH | REPLACEFILE_IGNORE_MERGE_ERRORS)))
1197 if (lpBackupFileName)
1212 ReplacementFileNameW.
Buffer,
1214 dwReplaceFlags, 0, 0);
1216 if (lpBackupFileName)
1233 LPCWSTR lpReplacementFileName,
1235 DWORD dwReplaceFlags,
1251 FIXME(
"Ignoring flags %x\n", dwReplaceFlags);
1254 if (!lpReplacedFileName || !lpReplacementFileName)
1261 if(lpBackupFileName)
1361 if (hReplaced)
NtClose(hReplaced);
1362 if (hReplacement)
NtClose(hReplacement);
1365 if (NtReplacementName.
Buffer)
1367 if (NtReplacedName.
Buffer)
1373 TRACE(
"ReplaceFileW failed (error=%lu)\n",
Error);
1389 LPWSTR RelativeSource, RelativeDestination;
1398 DPRINT(
"PrivMoveFileIdentityW(%S, %S, %x)\n", lpSource, lpDestination,
dwFlags);
1401 RtlInitEmptyUnicodeString(&NtSource,
NULL, 0);
1402 RelativeSource =
NULL;
1404 RtlInitEmptyUnicodeString(&NtDestination,
NULL, 0);
1405 RelativeDestination =
NULL;
1428 &ObjectAttributesSource,
1447 RtlFreeHeap(RtlGetProcessHeap(), 0, RelativeSource);
1448 RelativeSource =
NULL;
1457 SourceAccess &= ~FILE_WRITE_DATA;
1479 &RelativeDestination,
1481 &ObjectAttributesDestination,
1498 if (RelativeDestination)
1500 RtlFreeHeap(RtlGetProcessHeap(), 0, RelativeDestination);
1501 RelativeDestination =
NULL;
1510 DestAccess &= ~FILE_WRITE_DATA;
1523 sizeof(SourceInformation),
1528 RtlZeroMemory(&DestinationInformation,
sizeof(DestinationInformation));
1534 &DestinationInformation,
1535 sizeof(DestinationInformation),
1559 &ObjectAttributesSource,
1578 RtlFreeHeap(RtlGetProcessHeap(), 0, RelativeSource);
1580 if (RelativeDestination)
1581 RtlFreeHeap(RtlGetProcessHeap(), 0, RelativeDestination);
1592 &FileDispositionInfo,
1593 sizeof(FileDispositionInfo),
PRTL_UNICODE_STRING_BUFFER Path
#define FILE_NON_DIRECTORY_FILE
#define FILE_DELETE_ON_CLOSE
#define DEBUG_CHANNEL(args)
BOOL Query(LPCTSTR *ServiceArgs, DWORD ArgCount, BOOL bExtended)
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)
BOOL WINAPI GetComputerNameW(LPWSTR lpBuffer, LPDWORD lpnSize)
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
#define STATUS_NOT_IMPLEMENTED
#define ERROR_NOT_ENOUGH_MEMORY
#define NT_SUCCESS(StatCode)
#define ERROR_INVALID_PARAMETER
#define INVALID_HANDLE_VALUE
#define FILE_ATTRIBUTE_NORMAL
DWORD WINAPI QueryDosDeviceW(LPCWSTR lpDeviceName, LPWSTR lpTargetPath, DWORD ucchMax)
BOOL WINAPI CopyFileW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName, IN BOOL bFailIfExists)
BOOL BasepCopyFileExW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName, IN LPPROGRESS_ROUTINE lpProgressRoutine OPTIONAL, IN LPVOID lpData OPTIONAL, IN LPBOOL pbCancel OPTIONAL, IN DWORD dwCopyFlags, IN DWORD dwBasepFlags, OUT LPHANDLE lpExistingHandle, OUT LPHANDLE lpNewHandle)
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
BOOL WINAPI FlushFileBuffers(IN HANDLE hFile)
BOOL WINAPI SetEndOfFile(HANDLE hFile)
struct _COPY_PROGRESS_CONTEXT COPY_PROGRESS_CONTEXT
BOOL WINAPI MoveFileWithProgressW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName, IN LPPROGRESS_ROUTINE lpProgressRoutine, IN LPVOID lpData, IN DWORD dwFlags)
BOOL WINAPI MoveFileA(IN LPCSTR lpExistingFileName, IN LPCSTR lpNewFileName)
BOOL WINAPI ReplaceFileA(IN LPCSTR lpReplacedFileName, IN LPCSTR lpReplacementFileName, IN LPCSTR lpBackupFileName OPTIONAL, IN DWORD dwReplaceFlags, IN LPVOID lpExclude, IN LPVOID lpReserved)
BOOL WINAPI MoveFileExA(IN LPCSTR lpExistingFileName, IN LPCSTR lpNewFileName OPTIONAL, IN DWORD dwFlags)
BOOL WINAPI ReplaceFileW(LPCWSTR lpReplacedFileName, LPCWSTR lpReplacementFileName, LPCWSTR lpBackupFileName, DWORD dwReplaceFlags, LPVOID lpExclude, LPVOID lpReserved)
NTSTATUS WINAPI BasepMoveFileDelayed(_In_ PUNICODE_STRING ExistingPath, _In_ PUNICODE_STRING NewPath, _In_ INT KeyId, _In_ BOOL CreateIfNotFound)
Adds an entry in the "PendingFileRenameOperations" registry value, that is parsed at boot-time by SMS...
DWORD WINAPI BasepMoveFileCopyProgress(IN LARGE_INTEGER TotalFileSize, IN LARGE_INTEGER TotalBytesTransferred, IN LARGE_INTEGER StreamSize, IN LARGE_INTEGER StreamBytesTransferred, IN DWORD dwStreamNumber, IN DWORD dwCallbackReason, IN HANDLE hSourceFile, IN HANDLE hDestinationFile, IN LPVOID lpData OPTIONAL)
NTSTATUS WINAPI BasepOpenFileForMove(IN LPCWSTR File, OUT PUNICODE_STRING RelativeNtName, OUT LPWSTR *NtName, OUT PHANDLE FileHandle, OUT POBJECT_ATTRIBUTES ObjectAttributes, IN ACCESS_MASK DesiredAccess, IN ULONG ShareAccess, IN ULONG OpenOptions)
BOOL WINAPI MoveFileExW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName OPTIONAL, IN DWORD dwFlags)
struct _COPY_PROGRESS_CONTEXT * PCOPY_PROGRESS_CONTEXT
BOOL WINAPI MoveFileWithProgressA(IN LPCSTR lpExistingFileName, IN LPCSTR lpNewFileName OPTIONAL, IN LPPROGRESS_ROUTINE lpProgressRoutine OPTIONAL, IN LPVOID lpData OPTIONAL, IN DWORD dwFlags)
BOOL WINAPI MoveFileW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName)
BOOL WINAPI PrivMoveFileIdentityW(IN LPCWSTR lpSource, IN LPCWSTR lpDestination, IN DWORD dwFlags)
DWORD WINAPI BasepGetComputerNameFromNtPath(IN PUNICODE_STRING NewPath, IN HANDLE NewHandle, OUT PWSTR ComputerName, IN OUT PULONG ComputerNameLength)
NTSTATUS WINAPI BasepNotifyTrackingService(IN OUT PHANDLE ExistingHandle, IN POBJECT_ATTRIBUTES ObjectAttributes, IN HANDLE NewHandle, IN PUNICODE_STRING NewPath)
BOOLEAN WINAPI Basep8BitStringToDynamicUnicodeString(OUT PUNICODE_STRING UnicodeString, IN LPCSTR String)
static const WCHAR Cleanup[]
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK _In_ USHORT ShareAccess
#define UNIMPLEMENTED_DBGBREAK(...)
#define MOVEFILE_WRITE_THROUGH
#define MOVEFILE_REPLACE_EXISTING
#define MOVEFILE_COPY_ALLOWED
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE _In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Out_ PIO_STATUS_BLOCK _In_opt_ PLARGE_INTEGER _In_ ULONG FileAttributes
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
@ FileTrackingInformation
@ FileAttributeTagInformation
@ FileDispositionInformation
#define FILE_OPEN_REPARSE_POINT
#define FILE_SYNCHRONOUS_IO_NONALERT
#define FILE_WRITE_THROUGH
#define FILE_OPEN_NO_RECALL
#define FILE_OPEN_FOR_BACKUP_INTENT
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
#define OBJ_CASE_INSENSITIVE
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
#define PRIV_ALLOW_NON_TRACKABLE
#define PRIV_DELETE_ON_SUCCESS
#define FILE_ATTRIBUTE_DEVICE
#define ERROR_FILE_NOT_FOUND
static OUT PIO_STATUS_BLOCK IoStatusBlock
#define InitializeObjectAttributes(p, n, a, r, s)
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE _Out_ PUINT _In_ UINT _In_ NDIS_HANDLE _In_ NDIS_HANDLE _In_ PNDIS_STRING _In_ UINT OpenOptions
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToOemString(POEM_STRING DestinationString, PCUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI ULONG NTAPI RtlIsDosDeviceName_U(_In_ PCWSTR Name)
VOID NTAPI RtlReleaseRelativeName(_In_ PRTL_RELATIVE_NAME_U RelativeName)
NTSYSAPI RTL_PATH_TYPE NTAPI RtlDetermineDosPathNameType_U(_In_ PCWSTR Path)
NTSYSAPI BOOLEAN NTAPI RtlDosPathNameToRelativeNtPathName_U(_In_ PCWSTR DosName, _Out_ PUNICODE_STRING NtName, _Out_ PCWSTR *PartName, _Out_ PRTL_RELATIVE_NAME_U RelativeName)
NTSYSAPI BOOLEAN NTAPI RtlDosPathNameToNtPathName_U(_In_opt_z_ PCWSTR DosPathName, _Out_ PUNICODE_STRING NtPathName, _Out_opt_ PCWSTR *NtFileNamePart, _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo)
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)
NTSYSAPI NTSTATUS NTAPI NtSetValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN ULONG TitleIndex OPTIONAL, IN ULONG Type, IN PVOID Data, IN ULONG DataSize)
#define FILE_ATTRIBUTE_READONLY
@ KeyValuePartialInformation
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
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
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 NtQueryValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, IN PVOID KeyValueInformation, IN ULONG Length, IN PULONG ResultLength)
NTSYSAPI NTSTATUS NTAPI NtQueryInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, OUT PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
#define REG_OPTION_NON_VOLATILE
#define FILE_SHARE_DELETE
#define REG_OPTION_BACKUP_RESTORE
#define FILE_WRITE_ATTRIBUTES
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
struct _KEY_VALUE_PARTIAL_INFORMATION * PKEY_VALUE_PARTIAL_INFORMATION
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSYSAPI BOOLEAN NTAPI RtlPrefixUnicodeString(IN PUNICODE_STRING String1, IN PUNICODE_STRING String2, IN BOOLEAN CaseInSensitive)
NTSTATUS NTAPI NtCreateKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN ULONG TitleIndex, IN PUNICODE_STRING Class OPTIONAL, IN ULONG CreateOptions, OUT PULONG Disposition OPTIONAL)
#define FILE_ATTRIBUTE_REPARSE_POINT
#define STATUS_NOT_SAME_DEVICE
NTSTRSAFEVAPI RtlStringCbPrintfW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
DWORD BaseSetLastNTError(IN NTSTATUS Status)
#define STATUS_END_OF_FILE
#define STATUS_BUFFER_TOO_SMALL
#define STATUS_BUFFER_OVERFLOW
NTSTATUS NTAPI NtReadFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer, ULONG Length, PLARGE_INTEGER ByteOffset, PULONG Key)
PULONG MinorVersion OPTIONAL
LPPROGRESS_ROUTINE UserRoutine
UNICODE_STRING RelativeName
HANDLE ContainingDirectory
#define RTL_CONSTANT_STRING(s)
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define STATUS_ACCESS_DENIED
#define STATUS_OBJECT_PATH_NOT_FOUND
#define STATUS_INVALID_PARAMETER
#define STATUS_OBJECT_NAME_COLLISION
#define STATUS_SHARING_VIOLATION
#define STATUS_INSUFFICIENT_RESOURCES
#define STATUS_OBJECT_NAME_NOT_FOUND
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
#define COPY_FILE_FAIL_IF_EXISTS
DWORD WINAPI GetLastError(void)
#define COPY_FILE_OPEN_SOURCE_FOR_WRITE
DWORD(WINAPI * LPPROGRESS_ROUTINE)(_In_ LARGE_INTEGER, _In_ LARGE_INTEGER, _In_ LARGE_INTEGER, _In_ LARGE_INTEGER, _In_ DWORD, _In_ DWORD, _In_ HANDLE, _In_ HANDLE, _In_opt_ LPVOID)
#define MOVEFILE_FAIL_IF_NOT_TRACKABLE
#define MOVEFILE_CREATE_HARDLINK
#define MOVEFILE_DELAY_UNTIL_REBOOT
#define MAX_COMPUTERNAME_LENGTH
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
#define ERROR_BUFFER_OVERFLOW
#define ERROR_PATH_NOT_FOUND
#define ERROR_BAD_PATHNAME
#define ERROR_UNABLE_TO_REMOVE_REPLACED
_Must_inspect_result_ __drv_aliasesMem PDEVICE_OBJECT _In_ PDEVICE_OBJECT TargetDevice
struct _FILE_TRACKING_INFORMATION FILE_TRACKING_INFORMATION
#define IO_REPARSE_TAG_MOUNT_POINT