网站首页  词典首页

请输入您要查询的函数:

 

术语 setfilevaliddata
释义 SetFileValidData
语法:
C++
BOOL WINAPI SetFileValidData(
__in HANDLE hFile,
__in LONGLONG ValidDataLength
);
SetFileValidData功能
设置指定文件的有效数据的长度。这项功能是非常有用的非常有限的情况下。有关详细信息,请参见备注部分。
警告:如果没有适当的安全考虑,这个功能的使用可能影响数据隐私和安全。有关详细信息,请参见备注部分。
参数
hFile [in]
阿处理该文件。该文件必须已开放与GENERIC_WRITE访问权限,以及SE_MANAGE_VOLUME_NAME特权启用。有关更多信息,请参阅文件安全性和访问权限。
注意:文件不能一个网络文件,或者被压缩,稀疏,或交易。
ValidDataLength [in]
新的有效的数据长度。
此参数必须是一个积极的值比目前更大的有效数据的长度,但比当前文件的大小。
返回值
如果函数成功,返回值为非零。
如果函数失败,返回值为0。为了获得更多错误信息,调用GetLastError。
备注
该SetFileValidData函数设置文件的逻辑结果。要设置文件的大小,可以使用SetEndOfFile功能。物理文件的大小,也称为文件的末尾。
每个文件流具有以下属性:
文件大小:在一个文件中的数据大小,字节。
分配大小:该是一个磁盘上,这总是一个甚至多个文件簇大小分配的空间大小。
有效数据长度:在一个实际写入文件中的数据长度,字节。此值总是小于或等于文件的大小。
通常,SetFileValidData函数使用系统自己的私人数据级应用。并非所有的文件系统的使用有效的数据的长度。某些文件系统可以跟踪多个范围的有效数据。一般来说,大多数应用程序将永远不再需要调用这个函数。
该SetFileValidData功能可以使用户避免写作时灌装到一个文件nonsequentially零数据。该函数在文件中的数据,而写入文件有效。因此,虽然一些性能提升可能实现,在磁盘上的现有数据,先前存在的文件可以在无意中成为获得意想不到的读者。以下各段提供了这种潜在的安全和隐私问题的更详细的说明。
调用方必须具有SE_MANAGE_VOLUME_NAME特权启用打开一个文件时,最初。应用程序应该只调用文件,限制访问这些实体的SE_MANAGE_VOLUME_NAME访问SetFileValidData。应用程序必须确保该文件的不成文的范围是从来没有接触,或安全问题可能导致如下。
如果SetFileValidData是在文件中使用的,潜在的性能提升是相不填写的用零文件分配集群。因此,从文件中读取将返回所分配的簇任何含有可能来自其他用户的内容。这并不一定是在这一点上的安全问题,因为调用需要有SetFileValidData SE_MANAGE_VOLUME_NAME特权成功,并在磁盘上都可以通过这些用户读取数据。然而,这种调用者可以不经意间会暴露这个数据与其他用户无法获得SE_MANAGE_VOLUME_PRIVILEGE特权,如果以下条件成立:
如果该文件未打开的共享模式,否认其他读者,一个非特权用户可以打开和读取数据的暴露。
如果系统停止响应之前调用写完了ValidDataLength供应的呼吁,然后重新启动,这样的非特权用户可以打开该文件,并宣读公开内容。
如果SetFileValidData来电开盘充分严格的访问控制文件,以前的条件将不适用。然而,对于部分写入与SetFileValidData扩展文件(即,未完成写作到ValidDataLength提供的电话)还存在着另一种潜在的隐私或安全漏洞。管理员可以将文件复制到一个不正确的限制性ACL权限控制的对象,从而无意中暴露扩展地区的非法读取数据。
这是,除了性能方面的考虑,下面讨论的这些原因,SetFileValidData不通用推荐使用的原因。
有关安全和访问权限信息,请运行具有特权和文件安全性和访问权限。
您可以使用SetFileValidData函数创建在非常特殊的情况下,大的文件,使以后的文件I性能/ O可以比其他方法更好。特别是,如果文件的扩展部分大,将被写入随机,如数据库的应用类型,所花费的时间延长,并写入文件会比使用SetEndOfFile和写作随机更快。在大多数其他情况下,通常不会有什么性能提升使用SetFileValidData,有时也可以是一个性能损失。
要求:
最低支持client-Windows XP
最低支持serverWindows服务器2003
HeaderWinBase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
参见
文件管理函数
SetEndOfFile
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年9月3日
==英文原文==SetFileValidData Function
Sets the valid data length of the specified file. This function is useful in very limited scenarios. For more information, see the Remarks section.
Warning Use of this function without proper security considerations may compromise data privacy and security. For more information, see the Remarks section.
Syntax
C++
BOOL WINAPI SetFileValidData(
__in HANDLE hFile,
__in LONGLONG ValidDataLength
);
Parameters
hFile [in]
A handle to the file. The file must have been opened with the GENERIC_WRITE access right, and the SE_MANAGE_VOLUME_NAME privilege enabled. For more information, see File Security and Access Rights .
Note The file cannot be a network file, or be compressed, sparse, or transacted.
ValidDataLength [in]
The new valid data length.
This parameter must be a positive value that is greater than the current valid data length, but less than the current file size.
Return Value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is 0. To get extended error information, call GetLastError .
Remarks
The SetFileValidData function sets the logical end of a file. To set the size of a file, use the SetEndOfFile function. The physical file size is also referred to as the end of the file.
Each file stream has the following properties:
File size: the size of the data in a file, to the byte.
Allocation size: the size of the space that is allocated for a file on a disk, which is always an even multiple of the cluster size.
Valid data length: the length of the data in a file that is actually written, to the byte. This value is always less than or equal to the file size.
Typically, the SetFileValidData function is used by system-level applications on their own private data. Not all file systems use valid data length. Some file systems can track multiple valid data ranges. In general, most applications will never need to call this function.
The SetFileValidData function allows you to avoid filling data with zeros when writing nonsequentially to a file. The function makes the data in the file valid without writing to the file. As a result, although some performance gain may be realized, existing data on disk from previously existing files can inadvertently become available to unintended readers. The following paragraphs provide a more detailed description of this potential security and privacy issue.
A caller must have the SE_MANAGE_VOLUME_NAME privilege enabled when opening a file initially. Applications should call SetFileValidData only on files that restrict access to those entities that have SE_MANAGE_VOLUME_NAME access. The application must ensure that the unwritten ranges of the file are never exposed, or security issues can result as follows.
If SetFileValidData is used on a file, the potential performance gain is obtained by not filling the allocated clusters for the file with zeros. Therefore, reading from the file will return whatever the allocated clusters contain, potentially content from other users. This is not necessarily a security issue at this point, because the caller needs to have SE_MANAGE_VOLUME_NAME privilege for SetFileValidData to succeed, and all data on disk can be read by such users. However, this caller can inadvertently expose this data to other users that cannot acquire the SE_MANAGE_VOLUME_PRIVILEGE privilege if the following holds:
If the file was not opened with a sharing mode that denies other readers, a nonprivileged user can open it and read the exposed data.
If the system stops responding before the caller finishes writing up the ValidDataLength supplied in the call, then, on a reboot, such a nonprivileged user can open the file and read exposed content.
If the caller of SetFileValidData opened the file with adequately restrictive access control, the previous conditions would not apply. However, for partially written files extended with SetFileValidData (that is, writing was not completed up to the ValidDataLength supplied in the call) there exists yet another potential privacy or security vulnerability. An administrator could copy the file to a target that is not properly controlled with restrictive ACL permissions, thus inadvertently exposing the extended area's data to unauthorized reading.
It is for these reasons that SetFileValidData is not recommended for general purpose use, in addition to performance considerations, as discussed below.
For more information about security and access privileges, see Running with Special Privileges and File Security and Access Rights.
You can use the SetFileValidData function to create large files in very specific circumstances so that the performance of subsequent file I/O can be better than other methods. Specifically, if the extended portion of the file is large and will be written to randomly, such as in a database type of application, the time it takes to extend and write to the file will be faster than using SetEndOfFile and writing randomly. In most other situations, there is usually no performance gain to using SetFileValidData, and sometimes there can be a performance penalty.
Requirements
Minimum supported clientWindows XP
Minimum supported serverWindows Server 2003
HeaderWinBase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
See Also
File Management Functions
SetEndOfFile
Send comments about this topic to Microsoft
Build date: 9/3/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa365544(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 13:23:54