@@ -97,6 +97,64 @@ internal static extern IntPtr OpenProcess(
9797
9898 [ DllImport ( "Kernel32.dll" , SetLastError = true ) ]
9999 internal static extern bool EndUpdateResource ( IntPtr handle , bool discard ) ;
100+
101+ #nullable enable
102+ /// <summary>
103+ /// The ApplyDelta function use the specified delta and source files to create a new copy of the target file.
104+ /// </summary>
105+ /// <param name="applyFlags">Either DELTA_FLAG_NONE or DELTA_APPLY_FLAG_ALLOW_PA19.</param>
106+ /// <param name="sourceName">The name of the source file to which the delta is to be applied.</param>
107+ /// <param name="deltaName">The name of the delta to be applied to the source file.</param>
108+ /// <param name="targetName">The name of the target file that is to be created.</param>
109+ /// <returns>
110+ /// Returns TRUE on success or FALSE otherwise.
111+ /// </returns>
112+ /// <remarks>
113+ /// http://msdn.microsoft.com/en-us/library/bb417345.aspx#applydeltaaw
114+ /// </remarks>
115+ [ DllImport ( "msdelta.dll" , CharSet = CharSet . Unicode , SetLastError = true ) ]
116+ [ return : MarshalAs ( UnmanagedType . Bool ) ]
117+ internal static extern bool ApplyDelta (
118+ [ MarshalAs ( UnmanagedType . I8 ) ] ApplyFlags applyFlags ,
119+ string sourceName ,
120+ string deltaName ,
121+ string targetName ) ;
122+
123+ /// <summary>
124+ /// The CreateDelta function creates a delta from the specified source and target files and write the output delta to the designated file name.
125+ /// </summary>
126+ /// <param name="fileTypeSet">The file type set used for Create.</param>
127+ /// <param name="setFlags">The file type set used for Create.</param>
128+ /// <param name="resetFlags">The file type set used for Create.</param>
129+ /// <param name="sourceName">The file type set used for Create.</param>
130+ /// <param name="targetName">The name of the target against which the source is compared.</param>
131+ /// <param name="sourceOptionsName">Reserved. Pass NULL.</param>
132+ /// <param name="targetOptionsName">Reserved. Pass NULL.</param>
133+ /// <param name="globalOptions">Reserved. Pass a DELTA_INPUT structure with lpStart set to NULL and uSize set to 0.</param>
134+ /// <param name="targetFileTime">The time stamp set on the target file after delta Apply. If NULL, the timestamp of the target file during delta Create will be used.</param>
135+ /// <param name="hashAlgId">ALG_ID of the algorithm to be used to generate the target signature.</param>
136+ /// <param name="deltaName">The name of the delta file to be created.</param>
137+ /// <returns>
138+ /// Returns TRUE on success or FALSE otherwise.
139+ /// </returns>
140+ /// <remarks>
141+ /// http://msdn.microsoft.com/en-us/library/bb417345.aspx#createdeltaaw
142+ /// </remarks>
143+ [ DllImport ( "msdelta.dll" , CharSet = CharSet . Unicode , SetLastError = true ) ]
144+ [ return : MarshalAs ( UnmanagedType . Bool ) ]
145+ internal static extern bool CreateDelta (
146+ [ MarshalAs ( UnmanagedType . I8 ) ] FileTypeSet fileTypeSet ,
147+ [ MarshalAs ( UnmanagedType . I8 ) ] CreateFlags setFlags ,
148+ [ MarshalAs ( UnmanagedType . I8 ) ] CreateFlags resetFlags ,
149+ string sourceName ,
150+ string targetName ,
151+ string ? sourceOptionsName ,
152+ string ? targetOptionsName ,
153+ DeltaInput globalOptions ,
154+ IntPtr targetFileTime ,
155+ [ MarshalAs ( UnmanagedType . U4 ) ] HashAlgId hashAlgId ,
156+ string deltaName ) ;
157+ #nullable restore
100158 }
101159
102160 [ Flags ]
@@ -196,4 +254,68 @@ public enum StandardHandles : int {
196254 STD_OUTPUT_HANDLE = - 11 ,
197255 STD_ERROR_HANDLE = - 12 ,
198256 }
257+
258+ /// <remarks>
259+ /// http://msdn.microsoft.com/en-us/library/bb417345.aspx#deltaflagtypeflags
260+ /// </remarks>
261+ internal enum ApplyFlags : long
262+ {
263+ /// <summary>Indicates no special handling.</summary>
264+ None = 0 ,
265+
266+ /// <summary>Allow MSDelta to apply deltas created using PatchAPI.</summary>
267+ AllowLegacy = 1 ,
268+ }
269+
270+ /// <remarks>
271+ /// http://msdn.microsoft.com/en-us/library/bb417345.aspx#filetypesets
272+ /// </remarks>
273+ [ Flags ]
274+ internal enum FileTypeSet : long
275+ {
276+ /// <summary>
277+ /// File type set that includes I386, IA64 and AMD64 Portable Executable (PE) files. Others are treated as raw.
278+ /// </summary>
279+ Executables = 0x0FL ,
280+ }
281+
282+ /// <remarks>
283+ /// http://msdn.microsoft.com/en-us/library/bb417345.aspx#deltaflagtypeflags
284+ /// </remarks>
285+ internal enum CreateFlags : long
286+ {
287+ /// <summary>Indicates no special handling.</summary>
288+ None = 0 ,
289+
290+ /// <summary>Allow the source, target and delta files to exceed the default size limit.</summary>
291+ IgnoreFileSizeLimit = 1 << 17 ,
292+ }
293+
294+ /// <remarks>
295+ /// http://msdn.microsoft.com/en-us/library/bb417345.aspx#deltainputstructure
296+ /// </remarks>
297+ [ StructLayout ( LayoutKind . Sequential ) ]
298+ internal struct DeltaInput
299+ {
300+ /// <summary>Memory address non-editable input buffer.</summary>
301+ public IntPtr Start ;
302+
303+ /// <summary>Size of the memory buffer in bytes.</summary>
304+ public IntPtr Size ;
305+
306+ /// <summary>
307+ /// Defines whether MSDelta is allowed to edit the input buffer. If you make the input editable, the buffer will
308+ /// be zeroed at function return. However this will cause most MSDelta functions to use less memory.
309+ /// </summary>
310+ [ MarshalAs ( UnmanagedType . Bool ) ] public bool Editable ;
311+ }
312+
313+ internal enum HashAlgId
314+ {
315+ /// <summary>No signature.</summary>
316+ None = 0 ,
317+
318+ /// <summary>32-bit CRC defined in msdelta.dll.</summary>
319+ Crc32 = 32 ,
320+ }
199321}
0 commit comments