大网数据广告活动
安装更新与部署

Patching Selected Regions of a File

· 52CE 我爱测

When patching files having variable content, it may be necessary to retain selected regions of the target file to prevent the lost of critical information.

When patching files having variable content, it may be necessary to retain selected regions of the target file to prevent the lost of critical information. For example, some applications stamp user information into the executable file. Because the contents of the target file might depend upon the computer on which the application is installed, it becomes difficult to determine whether a particular file is a valid target for the patch. User information written in the target file can also be overwritten by a patch.

When you generate a patch creation properties (PCP) file with Msimsp.exe and PATCHWIZ.DLL, you can specify that the information in certain regions of the target file be ignored during patching. You can also specify that information in other regions of the target file be retained and copied to an offset location in the updated file. You specify which regions of the target file to ignore and which regions to retain when authoring the TargetFiles OptionalData, ExternalFiles, and FamilyFileRanges tables.

Use the RetainOffsets column of the TargetFiles OptionalData table and the RetainOffsets and RetainLengths columns of the FamilyFileRanges table to copy a range of information from the target file to an offset range in the updated file. The information in this range is retained. Specify the length of the range using the RetainLengths columns of the FamilyFileRanges table. The length of the retained range is the same in the target and updated files. Specify the offset of the range in the target file using the RetainOffsets column of the TargetFiles OptionalData table. Specify the offset of the range in the updated file using the RetainOffsets column of the FamilyFileRanges table. The range of the target file retained is therefore the value of RetainOffsets in the TargetFiles OptionalData table plus RetainLengths. This information gets copied to the update file in the range given by the value of RetainOffsets in the FamilyFileRanges tables plus RetainLengths. You can specify multiple ranges but the order of the lengths must match the order of the offsets.

Use the TargetFiles OptionalData table to ignore a range of the target file. Information in this range of the target file can still be overwritten by the patch. Specify the offset of the range in the IgnoreOffsets column and its length in the IgnoreLengths column. You can specify multiple ranges but the order of the lengths must match the order of the offsets.

The values in the lengths and offsets columns can be decimal or hexadecimal. PATCHWIZ.DLL treats the value as hexadecimal if it is prefixed by "0x". The columns are string columns, so PATCHWIZ.DLL converts the values to ULONGs. The length column specifies the length in bytes.

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。