Hristo Bojinov | db314d6 | 2010-08-02 10:29:49 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef _MINELF_RETOUCH |
| 18 | #define _MINELF_RETOUCH |
| 19 | |
| 20 | #include <stdbool.h> |
| 21 | #include <sys/types.h> |
| 22 | |
| 23 | typedef struct { |
| 24 | char tag[8]; /* "RETOUCH ", not zero-terminated */ |
| 25 | uint32_t blob_size; /* in bytes, located right before this struct */ |
| 26 | } retouch_info_t __attribute__((packed)); |
| 27 | |
Hristo Bojinov | db314d6 | 2010-08-02 10:29:49 -0700 | [diff] [blame] | 28 | #define RETOUCH_DONT_MASK 0 |
| 29 | #define RETOUCH_DO_MASK 1 |
| 30 | |
| 31 | #define RETOUCH_DATA_ERROR 0 // This is bad. Should not happen. |
| 32 | #define RETOUCH_DATA_MATCHED 1 // Up to an uniform random offset. |
| 33 | #define RETOUCH_DATA_MISMATCHED 2 // Partially randomized, or total mess. |
| 34 | #define RETOUCH_DATA_NOTAPPLICABLE 3 // Not retouched. Only when inferring. |
| 35 | |
| 36 | // Mask retouching in-memory. Used before apply_patch[_check]. |
| 37 | // Also used to determine status of retouching after a crash. |
| 38 | // |
| 39 | // If desired_offset is not NULL, then apply retouching instead, |
| 40 | // and return that in retouch_offset. |
| 41 | int retouch_mask_data(uint8_t *binary_object, |
| 42 | int32_t binary_size, |
| 43 | int32_t *desired_offset, |
| 44 | int32_t *retouch_offset); |
| 45 | #endif |