1 : // Copyright 2014 Google Inc. All Rights Reserved.
2 : //
3 : // Licensed under the Apache License, Version 2.0 (the "License");
4 : // you may not use this file except in compliance with the License.
5 : // You may obtain a copy of the License at
6 : //
7 : // http://www.apache.org/licenses/LICENSE-2.0
8 : //
9 : // Unless required by applicable law or agreed to in writing, software
10 : // distributed under the License is distributed on an "AS IS" BASIS,
11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : // See the License for the specific language governing permissions and
13 : // limitations under the License.
14 :
15 : #include "syzygy/agent/asan/block_utils.h"
16 :
17 : #include "syzygy/agent/asan/page_protection_helpers.h"
18 :
19 : namespace agent {
20 : namespace asan {
21 :
22 E : bool IsBlockCorrupt(const uint8* block_header, BlockInfo* block_info) {
23 : // If no output structure is provided then use a local one.
24 E : BlockInfo local_block_info = {};
25 E : if (block_info == NULL) {
26 E : block_info = &local_block_info;
27 E : } else {
28 i : ::memset(block_info, 0, sizeof(BlockInfo));
29 : }
30 :
31 : if (!GetBlockInfo(block_header, block_info) ||
32 : block_info->header->magic != kBlockHeaderMagic ||
33 E : !BlockChecksumIsValid(*block_info)) {
34 E : return true;
35 : }
36 E : return false;
37 E : }
38 :
39 : } // namespace asan
40 : } // namespace agent
|