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 HeapDestroy function call.
16 : #ifndef SYZYGY_BARD_EVENTS_HEAP_DESTROY_EVENT_H_
17 : #define SYZYGY_BARD_EVENTS_HEAP_DESTROY_EVENT_H_
18 :
19 : #include <windows.h>
20 : #include <memory>
21 :
22 : #include "syzygy/bard/event.h"
23 :
24 : namespace bard {
25 : namespace events {
26 :
27 : // An event that wraps a call to HeapDestroy, to be played against a
28 : // HeapBackdrop.
29 : class HeapDestroyEvent : public EventInterface {
30 : public:
31 : HeapDestroyEvent(uint32_t stack_trace_id,
32 : HANDLE trace_heap,
33 : BOOL trace_succeeded);
34 :
35 : // @name EventInterface implementation.
36 : // @{
37 E : EventType type() const override { return kHeapDestroyEvent; }
38 : bool Play(void* backdrop) override;
39 : // @}
40 :
41 : // @name Serialization methods.
42 : // @{
43 : static bool Save(const EventInterface* const event,
44 : core::OutArchive* out_archive);
45 : static std::unique_ptr<HeapDestroyEvent> Load(core::InArchive* in_archive);
46 : bool Equals(const EventInterface* rhs) const override;
47 : // @}
48 :
49 : // @name Accessors.
50 : // @{
51 : uint32_t stack_trace_id() const { return stack_trace_id_; }
52 E : HANDLE trace_heap() const { return trace_heap_; }
53 : BOOL trace_succeeded() const { return trace_succeeded_; }
54 : // @}
55 :
56 : private:
57 : // The stack trace ID that will be used during playback.
58 : uint32_t stack_trace_id_;
59 :
60 : // Argument to HeapDestory.
61 : HANDLE trace_heap_;
62 :
63 : // Recorded return value.
64 : BOOL trace_succeeded_;
65 :
66 : DISALLOW_COPY_AND_ASSIGN(HeapDestroyEvent);
67 : };
68 :
69 : } // namespace events
70 : } // namespace bard
71 :
72 : #endif // SYZYGY_BARD_EVENTS_HEAP_DESTROY_EVENT_H_
|