1 : // Copyright 2015 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 : #ifndef SYZYGY_REFINERY_VALIDATORS_VFTABLE_PTR_VALIDATOR_H_
16 : #define SYZYGY_REFINERY_VALIDATORS_VFTABLE_PTR_VALIDATOR_H_
17 :
18 : #include "base/macros.h"
19 : #include "base/containers/hash_tables.h"
20 : #include "base/memory/ref_counted.h"
21 : #include "syzygy/refinery/core/address.h"
22 : #include "syzygy/refinery/symbols/dia_symbol_provider.h"
23 : #include "syzygy/refinery/validators/validator.h"
24 :
25 m : namespace refinery {
26 :
27 : // A validator for vftable ptr values. This simple implementation validates
28 : // that an object's vftable ptr is within the valid set for the process.
29 : // TODO(manzagop): tighter checking of a vftable ptr's possible values.
30 m : class VftablePtrValidator : public Validator {
31 m : public:
32 m : VftablePtrValidator() {}
33 :
34 m : ValidationResult Validate(ProcessState* process_state,
35 m : ValidationReport* report) override;
36 :
37 m : protected:
38 : // Retrieves the set of vftable virtual addresses for @p process_state.
39 : // @param process_state the process_state.
40 : // @param vftable_vas on success, contains zero or more addresses.
41 : // @returns true on success, false on failure.
42 m : static bool GetVFTableVAs(
43 m : ProcessState* process_state,
44 m : scoped_refptr<DiaSymbolProvider> dia_symbol_provider,
45 m : base::hash_set<Address>* vftable_vas);
46 :
47 m : private:
48 m : DISALLOW_COPY_AND_ASSIGN(VftablePtrValidator);
49 m : };
50 :
51 m : } // namespace refinery
52 :
53 : #endif // SYZYGY_REFINERY_VALIDATORS_VFTABLE_PTR_VALIDATOR_H_
|