stuck
stuck

Reputation: 2291

how to open a file by fileID and then use BackupRead API?

I'd like to open up a file by ID and then use the resulting handle in the Win32 API BackupRead()

Is this possible? I'm not certain if its 'okay' to use handles that come from NtCreateFile() in other Win32 APIs?

For example, may I do this

NtCreateFile(&handle, ..., FILE_OPEN_BY_FILE_ID, ....)
BackupFile(handle, ....)

I'm somewhat bothered by using NtCreateFile, it's well documented on MSDN but they also mention compatibility problems could occur

Any ideas?

Upvotes: 0

Views: 891

Answers (1)

mbarthelemy
mbarthelemy

Reputation: 12913

I'm not sure I have 100% understood what your problem is, and I don't know any function named BackupFile().

If what you want is reusing handles from NTCreateFile() with BackupRead(), it should be perfectly fine to do so, provided the file handle was opened with the right flags & permissions.

Be sure to call NTCreateFile with the FILE_OPEN_FOR_BACKUP_INTENT flag:

NtCreateFile(&handle, ..., FILE_OPEN_BY_FILE_ID|FILE_OPEN_FOR_BACKUP_INTENT, ....)

If you plan to pass the resulting handle to BackupRead().

Upvotes: 1

Related Questions