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

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

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,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #ifndef SYZYGY_REFINERY_PROCESS_STATE_PROCESS_STATE_UTIL_H_ 15 #ifndef SYZYGY_REFINERY_PROCESS_STATE_PROCESS_STATE_UTIL_H_
16 #define SYZYGY_REFINERY_PROCESS_STATE_PROCESS_STATE_UTIL_H_ 16 #define SYZYGY_REFINERY_PROCESS_STATE_PROCESS_STATE_UTIL_H_
17 17
18 #include <string> 18 #include <string>
19 19
20 #include "base/strings/string_piece.h" 20 #include "base/strings/string_piece.h"
21 #include "syzygy/refinery/core/address.h" 21 #include "syzygy/refinery/core/address.h"
22 #include "syzygy/refinery/process_state/layer_data.h"
22 #include "syzygy/refinery/process_state/process_state.h" 23 #include "syzygy/refinery/process_state/process_state.h"
23 #include "syzygy/refinery/process_state/refinery.pb.h" 24 #include "syzygy/refinery/process_state/refinery.pb.h"
25 #include "syzygy/refinery/types/type.h"
24 26
25 namespace refinery { 27 namespace refinery {
26 28
27 using BytesLayerPtr = scoped_refptr<ProcessState::Layer<Bytes>>; 29 using BytesLayerPtr = scoped_refptr<ProcessState::Layer<Bytes>>;
28 using BytesRecordPtr = ProcessState::Layer<Bytes>::RecordPtr; 30 using BytesRecordPtr = ProcessState::Layer<Bytes>::RecordPtr;
29 31
30 using StackLayerPtr = scoped_refptr<ProcessState::Layer<Stack>>; 32 using StackLayerPtr = scoped_refptr<ProcessState::Layer<Stack>>;
31 using StackRecordPtr = ProcessState::Layer<Stack>::RecordPtr; 33 using StackRecordPtr = ProcessState::Layer<Stack>::RecordPtr;
32 34
33 using StackFrameLayerPtr = scoped_refptr<ProcessState::Layer<StackFrame>>; 35 using StackFrameLayerPtr = scoped_refptr<ProcessState::Layer<StackFrame>>;
34 using StackFrameRecordPtr = ProcessState::Layer<StackFrame>::RecordPtr; 36 using StackFrameRecordPtr = ProcessState::Layer<StackFrame>::RecordPtr;
35 37
36 using TypedBlockLayerPtr = scoped_refptr<ProcessState::Layer<TypedBlock>>; 38 using TypedBlockLayerPtr = scoped_refptr<ProcessState::Layer<TypedBlock>>;
37 using TypedBlockRecordPtr = ProcessState::Layer<TypedBlock>::RecordPtr; 39 using TypedBlockRecordPtr = ProcessState::Layer<TypedBlock>::RecordPtr;
38 40
39 using ModuleLayerPtr = scoped_refptr<ProcessState::Layer<Module>>; 41 using ModuleLayerPtr = scoped_refptr<ProcessState::Layer<Module>>;
40 using ModuleRecordPtr = ProcessState::Layer<Module>::RecordPtr; 42 using ModuleRecordPtr = ProcessState::Layer<Module>::RecordPtr;
41 43
42 // A class for interacting with a ProcessState's module layer. 44 // A class for interacting with a ProcessState's module layer.
43 class ModuleLayerAccessor { 45 class ModuleLayerAccessor {
44 public: 46 public:
45 explicit ModuleLayerAccessor(ProcessState* process_state); 47 explicit ModuleLayerAccessor(ProcessState* process_state);
46 48
47 // Adds a module instance record to the process state. Also updates the module 49 // Adds a module instance record to the process state. Also updates the module
48 // layer's data if the instance if for a new module. 50 // layer's data if the instance is for a new module.
51 // @note If the module is added to the layer's data, it is with a signature
52 // that has a load address of 0, as we fold multiple module instances to a
53 // single module identifier (and signature).
49 // @param range the module instance's memory range. 54 // @param range the module instance's memory range.
50 // @param checksum the module's checksum. 55 // @param checksum the module's checksum.
51 // @param timestamp the module's timestamp. 56 // @param timestamp the module's timestamp.
52 // @param path the module's path. 57 // @param path the module's path.
53 void AddModuleRecord(const AddressRange& range, 58 void AddModuleRecord(const AddressRange& range,
54 const uint32 checksum, 59 const uint32 checksum,
55 const uint32 timestamp, 60 const uint32 timestamp,
56 const std::wstring& path); 61 const std::wstring& path);
57 62
58 // Retrieves the signature of the module instance containing @p va. 63 // Retrieves the signature of the module instance containing @p va.
59 // @note On sucess, the signature's base address is set to the module 64 // @note On success, the signature's base address is set to the module
60 // instance's actual load address. 65 // instance's actual load address.
61 // @param va virtual address for which to get a module signature. 66 // @param va virtual address for which to get a module signature.
62 // @param signature on success, the module signature. 67 // @param signature on success, the module signature.
63 // @returns true on success, false on failure. 68 // @returns true on success, false on failure.
64 bool GetModuleSignature(const Address va, pe::PEFile::Signature* signature); 69 bool GetModuleSignature(const Address va, pe::PEFile::Signature* signature);
65 70
71 // Retrieves the signature of module @p id.
72 // @note On success, the returned signature's base address is 0.
73 // @param id module identifier for which to get a module signature.
74 // @param signature on success, the module signature.
75 // @returns true on success, false on failure.
76 bool GetModuleSignature(const ModuleId id, pe::PEFile::Signature* signature);
77
78 // Retrieves the module identifier corresponding to @p va.
79 // @param virtual address for which to get a module identifier.
80 // @returns the module identifier, or kNoModuleId if @p va does not correspond
81 // to a module.
82 ModuleId GetModuleId(const Address va);
83
84 // Retrieves the module identifier corresponding to @p signature.
85 // @param signature for which to get a module identifier.
86 // @returns the module identifier, or kNoModuleId if @p signature does not
87 // correspond to a module known to the process state.
88 ModuleId GetModuleId(const pe::PEFile::Signature& signature);
89
66 private: 90 private:
67 ProcessState* process_state_; // Not owned, must outlive this class. 91 ProcessState* process_state_; // Not owned, must outlive this class.
68 }; 92 };
69 93
94 // Adds a typed block record to @p process_state.
95 // TODO(manzagop): avoid adding typed block duplicates. Longer term we may
96 // introduce more complex handling (eg notions of certainty).
70 bool AddTypedBlockRecord(const AddressRange& range, 97 bool AddTypedBlockRecord(const AddressRange& range,
71 base::StringPiece16 data_name, 98 base::StringPiece16 data_name,
72 base::StringPiece16 type_name, 99 ModuleId module_id,
100 TypeId type_id,
73 ProcessState* process_state); 101 ProcessState* process_state);
74 102
75 } // namespace refinery 103 } // namespace refinery
76 104
77 #endif // SYZYGY_REFINERY_PROCESS_STATE_PROCESS_STATE_UTIL_H_ 105 #endif // SYZYGY_REFINERY_PROCESS_STATE_PROCESS_STATE_UTIL_H_
OLDNEW
« no previous file with comments | « syzygy/refinery/process_state/process_state.gyp ('k') | syzygy/refinery/process_state/process_state_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698