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 : // Declares an event to represent a HeapCreate function call.
16 : #ifndef SYZYGY_BARD_EVENTS_HEAP_CREATE_EVENT_H_
17 : #define SYZYGY_BARD_EVENTS_HEAP_CREATE_EVENT_H_
18 :
19 : #include <windows.h>
20 :
21 : #include "base/memory/scoped_ptr.h"
22 : #include "syzygy/bard/event.h"
23 :
24 : namespace bard {
25 : namespace events {
26 :
27 : // An event that wraps a call to HeapCreate, to be played against a
28 : // HeapBackdrop.
29 : class HeapCreateEvent : public EventInterface {
30 : public:
31 : HeapCreateEvent(DWORD options,
32 : SIZE_T initial_size,
33 : SIZE_T maximum_size,
34 : HANDLE trace_heap);
35 :
36 : // @name EventInterface implementation.
37 : // @{
38 E : EventType type() const override { return kHeapCreateEvent; }
39 : bool Play(void* backdrop) override;
40 : bool Equals(const EventInterface* rhs) const override;
41 : // @}
42 :
43 : // @name Serialization methods.
44 : // @{
45 : static bool Save(const EventInterface* const event,
46 : core::OutArchive* out_archive);
47 : static scoped_ptr<HeapCreateEvent> Load(core::InArchive* in_archive);
48 : // @}
49 :
50 : // @name Accessors.
51 : // @{
52 : DWORD options() const { return options_; }
53 : SIZE_T initial_size() const { return initial_size_; }
54 : SIZE_T maximum_size() const { return maximum_size_; }
55 E : HANDLE trace_heap() const { return trace_heap_; }
56 : // @}
57 :
58 : private:
59 : // Arguments to HeapCreate.
60 : DWORD options_;
61 : SIZE_T initial_size_;
62 : SIZE_T maximum_size_;
63 :
64 : // Recorded return value.
65 : HANDLE trace_heap_;
66 :
67 : DISALLOW_COPY_AND_ASSIGN(HeapCreateEvent);
68 : };
69 :
70 : } // namespace events
71 : } // namespace bard
72 :
73 : #endif // SYZYGY_BARD_EVENTS_HEAP_CREATE_EVENT_H_
|