Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: syzygy/refinery/process_state/process_state_util.cc

Issue 1475083002: [Refinery] Introduce TypePropagatorAnalyzer - pointer types. (Closed) Base URL: https://github.com/google/syzygy.git@master
Patch Set: Final nit Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 Google Inc. All Rights Reserved. 1 // Copyright 2015 Google Inc. All Rights Reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with 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 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 bool ModuleLayerAccessor::GetModuleSignature(const Address va, 65 bool ModuleLayerAccessor::GetModuleSignature(const Address va,
66 pe::PEFile::Signature* signature) { 66 pe::PEFile::Signature* signature) {
67 DCHECK(signature); 67 DCHECK(signature);
68 68
69 // Find the module record corresponding to the virtual address. 69 // Find the module record corresponding to the virtual address.
70 ModuleRecordPtr module_record; 70 ModuleRecordPtr module_record;
71 if (!process_state_->FindSingleRecord(va, &module_record)) 71 if (!process_state_->FindSingleRecord(va, &module_record))
72 return false; 72 return false;
73 73
74 // Retrieve the signature. 74 // Retrieve the signature.
75 ModuleLayerPtr layer;
76 process_state_->FindOrCreateLayer(&layer);
77 const Module& module = module_record->data(); 75 const Module& module = module_record->data();
78 if (!layer->mutable_data()->Find(module.module_id(), signature)) 76 if (!GetModuleSignature(module.module_id(), signature))
79 return false; 77 return false;
80 78
81 // Set the signature's address. 79 // Set the signature's address.
82 const AddressRange& module_range = module_record->range(); 80 const AddressRange& module_range = module_record->range();
83 if (!base::IsValueInRangeForNumericType<uint32>(module_range.start())) { 81 if (!base::IsValueInRangeForNumericType<uint32>(module_range.start())) {
84 LOG(ERROR) << "PE::Signature doesn't support 64bit addresses. Address: " 82 LOG(ERROR) << "PE::Signature doesn't support 64bit addresses. Address: "
85 << module_range.start(); 83 << module_range.start();
86 return false; 84 return false;
87 } 85 }
88 signature->base_address = 86 signature->base_address =
89 core::AbsoluteAddress(base::checked_cast<uint32>(module_range.start())); 87 core::AbsoluteAddress(base::checked_cast<uint32>(module_range.start()));
90 88
91 return true; 89 return true;
92 } 90 }
93 91
92 bool ModuleLayerAccessor::GetModuleSignature(const ModuleId id,
93 pe::PEFile::Signature* signature) {
94 DCHECK_NE(kNoModuleId, id);
95 DCHECK(signature);
96
97 ModuleLayerPtr layer;
98 process_state_->FindOrCreateLayer(&layer);
99 return layer->data().Find(id, signature);
100 }
101
102 ModuleId ModuleLayerAccessor::GetModuleId(const Address va) {
103 ModuleRecordPtr module_record;
104 if (!process_state_->FindSingleRecord(va, &module_record))
105 return kNoModuleId;
106 return module_record->data().module_id();
107 }
108
109 ModuleId ModuleLayerAccessor::GetModuleId(
110 const pe::PEFile::Signature& signature) {
111 ModuleLayerPtr layer;
112 process_state_->FindOrCreateLayer(&layer);
113 return layer->data().Find(signature);
114 }
115
94 bool AddTypedBlockRecord(const AddressRange& range, 116 bool AddTypedBlockRecord(const AddressRange& range,
95 base::StringPiece16 data_name, 117 base::StringPiece16 data_name,
96 base::StringPiece16 type_name, 118 ModuleId module_id,
119 TypeId type_id,
97 ProcessState* process_state) { 120 ProcessState* process_state) {
98 DCHECK(range.IsValid()); 121 DCHECK(range.IsValid());
99 DCHECK(process_state); 122 DCHECK(process_state);
100 123
101 TypedBlock* typedblock_proto = CreateRecord<TypedBlock>(range, process_state); 124 TypedBlock* typedblock_proto = CreateRecord<TypedBlock>(range, process_state);
102 125
103 std::string data_name_narrow; 126 std::string data_name_narrow;
104 if (!base::UTF16ToUTF8(data_name.data(), data_name.size(), &data_name_narrow)) 127 if (!base::UTF16ToUTF8(data_name.data(), data_name.size(), &data_name_narrow))
105 return false; 128 return false;
106 typedblock_proto->set_data_name(data_name_narrow); 129 typedblock_proto->set_data_name(data_name_narrow);
107 130
108 std::string type_name_narrow; 131 typedblock_proto->set_module_id(module_id);
109 if (!base::UTF16ToUTF8(type_name.data(), type_name.size(), &type_name_narrow)) 132 typedblock_proto->set_type_id(type_id);
110 return false;
111 typedblock_proto->set_type_name(type_name_narrow);
112 133
113 return true; 134 return true;
114 } 135 }
115 136
116 } // namespace refinery 137 } // namespace refinery
OLDNEW
« no previous file with comments | « syzygy/refinery/process_state/process_state_util.h ('k') | syzygy/refinery/process_state/process_state_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698