예제 #1
0
        // Warning: the sourceBytes byte[] will get zeroed out.
        public static unsafe byte[] CreatePatch(byte[] sourceBytes, byte[] targetBytes)
        {
            fixed(byte *pSourceBuf = sourceBytes)
            fixed(byte *pTargetBuf = targetBytes)
            {
                DeltaInput  ds = new DeltaInput(pSourceBuf, sourceBytes.Length, true);
                DeltaInput  dt = new DeltaInput(pTargetBuf, targetBytes.Length, true);
                DeltaOutput output;

                if (!CreateDeltaB(DeltaFileType.Executable,
                                  DeltaFlag.None,
                                  DeltaFlag.None,   // "reset flags"
                                  ds,
                                  dt,
                                  DeltaInput.Empty,
                                  DeltaInput.Empty,
                                  DeltaInput.Empty,
                                  IntPtr.Zero,
                                  AlgId.Crc32FromMsdelta,
                                  out output))
                {
                    throw new Win32Exception();
                }

                byte[] patchBytes = new byte[output.cbBuf.ToInt32()];
                Marshal.Copy(output.pBuf, patchBytes, 0, patchBytes.Length);
                DeltaFree(output.pBuf);
                return(patchBytes);
            }
        } // end CreatePatch()
예제 #2
0
 private static extern bool CreateDeltaB(
     DeltaFileType fileTypeSet,       // File type set.
     DeltaFlag setFlags,              // Set these flags.
     DeltaFlag resetFlags,            // Reset (suppress) these flags.
     DeltaInput source,               // Source memory block.
     DeltaInput target,               // Target memory block.
     DeltaInput sourceOptions,        // Memory block with source-specific options.
     DeltaInput targetOptions,        // Memory block with target-specific options.
     DeltaInput globalOptions,        // Memory block with global options.
     IntPtr targetFileTime,           // Target file time to use, null to use current time. (need this overload because the compiler can't convert from "null" to "ref FILETIME")
     AlgId hashAlgId,
     out DeltaOutput delta);
예제 #3
0
 private static extern bool CreateDeltaB(
     DeltaFileType fileTypeSet,                                           // File type set.
     DeltaFlag setFlags,                                                  // Set these flags.
     DeltaFlag resetFlags,                                                // Reset (suppress) these flags.
     DeltaInput source,                                                   // Source memory block.
     DeltaInput target,                                                   // Target memory block.
     DeltaInput sourceOptions,                                            // Memory block with source-specific options.
     DeltaInput targetOptions,                                            // Memory block with target-specific options.
     DeltaInput globalOptions,                                            // Memory block with global options.
     ref System.Runtime.InteropServices.ComTypes.FILETIME targetFileTime, // Target file time to use, null to use current time.
     AlgId hashAlgId,
     out DeltaOutput delta);
예제 #4
0
파일: Delta.cs 프로젝트: belav/roslyn
        public static unsafe byte[] ApplyPatch(byte[] sourceBytes, byte[] patchBytes)
        {
            fixed(byte *pSourceBuf = sourceBytes)
            fixed(byte *pPatchBuf = patchBytes)
            {
                var ds = new DeltaInput(pSourceBuf, sourceBytes.Length, true);
                var dp = new DeltaInput(pPatchBuf, patchBytes.Length, true);

                if (!ApplyDeltaB(DeltaApplyFlag.None, ds, dp, out var output))
                {
                    throw new Win32Exception();
                }

                var targetBytes = new byte[output.cbBuf.ToInt32()];

                Marshal.Copy(output.pBuf, targetBytes, 0, targetBytes.Length);
                DeltaFree(output.pBuf);
                return(targetBytes);
            }
        }
예제 #5
0
파일: Delta.cs 프로젝트: XieShuquan/roslyn
        public static unsafe byte[] ApplyPatch(byte[] sourceBytes, byte[] patchBytes)
        {
            fixed (byte* pSourceBuf = sourceBytes)
            fixed (byte* pPatchBuf = patchBytes)
            {
                DeltaInput ds = new DeltaInput(pSourceBuf, sourceBytes.Length, true);
                DeltaInput dp = new DeltaInput(pPatchBuf, patchBytes.Length, true);
                if (!ApplyDeltaB(DeltaApplyFlag.None,
                                  ds,
                                  dp,
                                  out var output))
                {
                    throw new Win32Exception();
                }

                byte[] targetBytes = new byte[output.cbBuf.ToInt32()];
                Marshal.Copy(output.pBuf, targetBytes, 0, targetBytes.Length);
                DeltaFree(output.pBuf);
                return targetBytes;
            }
        }
예제 #6
0
파일: Delta.cs 프로젝트: jkotas/roslyn
 private static extern bool ApplyDeltaB(
         DeltaApplyFlag applyFlags,
         DeltaInput source,
         DeltaInput delta,
         out DeltaOutput target);
예제 #7
0
파일: Delta.cs 프로젝트: belav/roslyn
 private static extern bool ApplyDeltaB(
     DeltaApplyFlag applyFlags,
     DeltaInput source,
     DeltaInput delta,
     out DeltaOutput target
     );