OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/safe_browsing/incident_reporting/module_integrity_verif
ier_win.h" | 5 #include "chrome/browser/safe_browsing/incident_reporting/module_integrity_verif
ier_win.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <string> | 10 #include <string> |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 ptrdiff_t range_size, | 132 ptrdiff_t range_size, |
133 ModuleVerificationState* state) { | 133 ModuleVerificationState* state) { |
134 int bytes_different = 0; | 134 int bytes_different = 0; |
135 std::vector<Export>::const_iterator export_it = state->exports.begin(); | 135 std::vector<Export>::const_iterator export_it = state->exports.begin(); |
136 | 136 |
137 for (uint8_t* end = mem_start + range_size; mem_start < end; | 137 for (uint8_t* end = mem_start + range_size; mem_start < end; |
138 ++mem_start, ++disk_start) { | 138 ++mem_start, ++disk_start) { |
139 if (*disk_start == *mem_start) | 139 if (*disk_start == *mem_start) |
140 continue; | 140 continue; |
141 | 141 |
142 auto modification = state->module_state->add_modification(); | 142 auto* modification = state->module_state->add_modification(); |
143 // Store the address at which the modification starts on disk, relative to | 143 // Store the address at which the modification starts on disk, relative to |
144 // the beginning of the image. | 144 // the beginning of the image. |
145 modification->set_file_offset( | 145 modification->set_file_offset( |
146 disk_start - reinterpret_cast<uint8_t*>(state->disk_peimage.module())); | 146 disk_start - reinterpret_cast<uint8_t*>(state->disk_peimage.module())); |
147 | 147 |
148 // Find the export containing this modification. | 148 // Find the export containing this modification. |
149 std::vector<Export>::const_iterator modified_export_it = | 149 std::vector<Export>::const_iterator modified_export_it = |
150 FindModifiedExport(mem_start, export_it, state->exports.end()); | 150 FindModifiedExport(mem_start, export_it, state->exports.end()); |
151 // No later byte can belong to an earlier export. | 151 // No later byte can belong to an earlier export. |
152 export_it = modified_export_it; | 152 export_it = modified_export_it; |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 // entire module was scanned and understood. | 381 // entire module was scanned and understood. |
382 if (state.bytes_different) | 382 if (state.bytes_different) |
383 module_state->set_modified_state(ModuleState::MODULE_STATE_MODIFIED); | 383 module_state->set_modified_state(ModuleState::MODULE_STATE_MODIFIED); |
384 else if (!state.unknown_reloc_type && scan_complete) | 384 else if (!state.unknown_reloc_type && scan_complete) |
385 module_state->set_modified_state(ModuleState::MODULE_STATE_UNMODIFIED); | 385 module_state->set_modified_state(ModuleState::MODULE_STATE_UNMODIFIED); |
386 | 386 |
387 return scan_complete; | 387 return scan_complete; |
388 } | 388 } |
389 | 389 |
390 } // namespace safe_browsing | 390 } // namespace safe_browsing |
OLD | NEW |