Skip to content

Latest commit

 

History

History
164 lines (119 loc) · 6.71 KB

nf-winbase-backupwrite.md

File metadata and controls

164 lines (119 loc) · 6.71 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:winbase.BackupWrite
BackupWrite function (winbase.h)
Restore a file or directory that was backed up using BackupRead.
BackupWrite
BackupWrite function [Backup]
_win32_backupwrite
backup.backupwrite
base.backupwrite
winbase/BackupWrite
backup\backupwrite.htm
Backup
92befb48-68eb-4af3-b58a-c5e17bf14098
12/05/2018
BackupWrite, BackupWrite function [Backup], _win32_backupwrite, backup.backupwrite, base.backupwrite, winbase/BackupWrite
winbase.h
Windows.h
Windows
Windows XP [desktop apps only]
Windows Server 2003 [desktop apps only]
Kernel32.lib
Kernel32.dll
Windows
19H1
BackupWrite
winbase/BackupWrite
c++
APIRef
kbSyntax
DllExport
Kernel32.dll
API-MS-Win-Core-Kernel32-Legacy-l1-1-0.dll
kernel32legacy.dll
API-MS-Win-Core-Kernel32-Legacy-l1-1-1.dll
API-MS-Win-Core-Kernel32-Legacy-l1-1-2.dll
API-MS-Win-DownLevel-Kernel32-l2-1-0.dll
API-MS-Win-Core-Kernel32-Legacy-L1-1-3.dll
API-MS-Win-Core-Kernel32-Legacy-L1-1-4.dll
API-MS-Win-Core-Kernel32-Legacy-L1-1-5.dll
BackupWrite

BackupWrite function

-description

The BackupWrite function can be used to restore a file or directory that was backed up using BackupRead. Use the ReadFile function to get a stream of data from the backup medium, then use BackupWrite to write the data to the specified file or directory.

-parameters

-param hFile [in]

Handle to the file or directory to be restored. To obtain the handle, call the CreateFile function. The SACLs are not restored unless the file handle was created with the ACCESS_SYSTEM_SECURITY access right. To ensure that the integrity ACEs are restored correctly, the file handle must also have been created with the WRITE_OWNER access right. For more information, see File security and access rights.

The handle must be synchronous (nonoverlapped). This means that the FILE_FLAG_OVERLAPPED flag must not be set when CreateFile is called. This function does not validate that the handle it receives is synchronous, so it does not return an error code for a synchronous handle, but calling it with an asynchronous (overlapped) handle can result in subtle errors that are very difficult to debug.

The BackupWrite function may fail if CreateFile was called with the flag FILE_FLAG_NO_BUFFERING. In this case, the GetLastError function returns the value ERROR_INVALID_PARAMETER.

-param lpBuffer [in]

Pointer to a buffer that the function writes data from.

-param nNumberOfBytesToWrite [in]

Size of the buffer, in bytes. The buffer size must be greater than the size of a WIN32_STREAM_ID structure.

-param lpNumberOfBytesWritten [out]

Pointer to a variable that receives the number of bytes written.

-param bAbort [in]

Indicates whether you have finished using BackupWrite on the handle. While you are restoring the file, specify this parameter as FALSE. After you are done using BackupWrite, you must call BackupWrite one more time specifying TRUE for this parameter and passing the appropriate lpContext. lpContext must be passed when bAbort is TRUE; all other parameters are ignored.

-param bProcessSecurity [in]

Specifies whether the function will restore the access-control list (ACL) data for the file or directory.

If bProcessSecurity is TRUE, you need to specify WRITE_OWNER and WRITE_DAC access when opening the file or directory handle. If the handle does not have those access rights, the operating system denies access to the ACL data, and ACL data restoration will not occur.

-param lpContext [out]

Pointer to a variable that receives a pointer to an internal data structure used by BackupWrite to maintain context information during a restore operation.

You must set the variable pointed to by lpContext to NULL before the first call to BackupWrite for the specified file or directory. The function allocates memory for the data structure, and then sets the variable to point to that structure. You must not change lpContext or the variable that it points to between calls to BackupWrite.

To release the memory used by the data structure, call BackupWrite with the bAbort parameter set to TRUE when the restore operation is complete.

-returns

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero, indicating that an I/O error occurred. To get extended error information, call GetLastError.

-remarks

This function is not intended for use in restoring files encrypted under the Encrypted File System. Use WriteEncryptedFileRaw for that purpose.

The data read from the backup medium must be substreams separated by WIN32_STREAM_ID structures.

The BACKUP_LINK stream type lets you restore files with hard links.

-see-also

BackupRead

BackupSeek

CreateFile

WIN32_STREAM_ID

WriteEncryptedFileRaw