2

I am using BackupRead and BackupWrite to implement a file synchronization between 2 folders.

I can use them on files and folders without any issue. But when I want to use them on a reparse point, BackupWrite fails with an access denied error.

The original reparse point is retrieved without error with BackupRead. The buffer has 2 streams: one for the security data, and one for the reparse data. I can see in the latter the target of the reparse point. The file I am trying to create does not exist and FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT is passed to CreateFile.

So, my question is: what is the way to open a file so that BackupWrite succeeds to restore a reparse point?

Opal
  • 81,889
  • 28
  • 189
  • 210
v77
  • 216
  • 1
  • 14

1 Answers1

3

I finally found 2 issues:

  • If the reparse point is for a directory, the new reparse point must be first created as a directory.

  • We need to enable "SeRestorePrivilege" or "SeCreateSymbolicLinkPrivilege" for the current process (through OpenProcessToken, LookupPrivilegeValue and AdjustTokenPrivileges), even if the administrative privileges have been granted.

v77
  • 216
  • 1
  • 14
  • What do you mean, *the new reparse point must be first created as a directory*? I offloaded some directories from `C:\ProgramData` to `D:\ProgramData` and now `procmon.exe` says NVIDIA Installer is getting some `ACCESS DENIED` errors. Can you help with that? – André Chalella Jun 27 '15 at 06:16
  • BackupWrite creates the reparse point if this latter targets a file but not if the target is a directory. For a directory, you need first to create the directory, and then let BackupWrite create the reparse point onto this directory. – v77 Jun 27 '15 at 17:31