xref: /aosp_15_r20/external/zucchini/zucchini_apply.h (revision a03ca8b91e029cd15055c20c78c2e087c84792e4)
1*a03ca8b9SKrzysztof Kosiński // Copyright 2017 The Chromium Authors. All rights reserved.
2*a03ca8b9SKrzysztof Kosiński // Use of this source code is governed by a BSD-style license that can be
3*a03ca8b9SKrzysztof Kosiński // found in the LICENSE file.
4*a03ca8b9SKrzysztof Kosiński 
5*a03ca8b9SKrzysztof Kosiński #ifndef COMPONENTS_ZUCCHINI_ZUCCHINI_APPLY_H_
6*a03ca8b9SKrzysztof Kosiński #define COMPONENTS_ZUCCHINI_ZUCCHINI_APPLY_H_
7*a03ca8b9SKrzysztof Kosiński 
8*a03ca8b9SKrzysztof Kosiński #include "components/zucchini/image_utils.h"
9*a03ca8b9SKrzysztof Kosiński #include "components/zucchini/patch_reader.h"
10*a03ca8b9SKrzysztof Kosiński #include "components/zucchini/zucchini.h"
11*a03ca8b9SKrzysztof Kosiński 
12*a03ca8b9SKrzysztof Kosiński namespace zucchini {
13*a03ca8b9SKrzysztof Kosiński 
14*a03ca8b9SKrzysztof Kosiński // Reads equivalences from |patch_reader| to form preliminary |new_image|,
15*a03ca8b9SKrzysztof Kosiński // copying regions from |old_image| and writing extra data from |patch_reader|.
16*a03ca8b9SKrzysztof Kosiński bool ApplyEquivalenceAndExtraData(ConstBufferView old_image,
17*a03ca8b9SKrzysztof Kosiński                                   const PatchElementReader& patch_reader,
18*a03ca8b9SKrzysztof Kosiński                                   MutableBufferView new_image);
19*a03ca8b9SKrzysztof Kosiński 
20*a03ca8b9SKrzysztof Kosiński // Reads raw delta from |patch_reader| and applies corrections to |new_image|.
21*a03ca8b9SKrzysztof Kosiński bool ApplyRawDelta(const PatchElementReader& patch_reader,
22*a03ca8b9SKrzysztof Kosiński                    MutableBufferView new_image);
23*a03ca8b9SKrzysztof Kosiński 
24*a03ca8b9SKrzysztof Kosiński // Corrects references in |new_image| by projecting references from |old_image|
25*a03ca8b9SKrzysztof Kosiński // and applying corrections from |patch_reader|. Both |old_image| and
26*a03ca8b9SKrzysztof Kosiński // |new_image| are matching elements associated with |exe_type|.
27*a03ca8b9SKrzysztof Kosiński bool ApplyReferencesCorrection(ExecutableType exe_type,
28*a03ca8b9SKrzysztof Kosiński                                ConstBufferView old_image,
29*a03ca8b9SKrzysztof Kosiński                                const PatchElementReader& patch_reader,
30*a03ca8b9SKrzysztof Kosiński                                MutableBufferView new_image);
31*a03ca8b9SKrzysztof Kosiński 
32*a03ca8b9SKrzysztof Kosiński // Applies patch element with type |exe_type| from |patch_reader| on |old_image|
33*a03ca8b9SKrzysztof Kosiński // to produce |new_image|.
34*a03ca8b9SKrzysztof Kosiński bool ApplyElement(ExecutableType exe_type,
35*a03ca8b9SKrzysztof Kosiński                   ConstBufferView old_image,
36*a03ca8b9SKrzysztof Kosiński                   const PatchElementReader& patch_reader,
37*a03ca8b9SKrzysztof Kosiński                   MutableBufferView new_image);
38*a03ca8b9SKrzysztof Kosiński 
39*a03ca8b9SKrzysztof Kosiński }  // namespace zucchini
40*a03ca8b9SKrzysztof Kosiński 
41*a03ca8b9SKrzysztof Kosiński #endif  // COMPONENTS_ZUCCHINI_ZUCCHINI_APPLY_H_
42