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 HeapSetInformation function call.
16 : #ifndef SYZYGY_BARD_EVENTS_HEAP_SET_INFORMATION_EVENT_H_
17 : #define SYZYGY_BARD_EVENTS_HEAP_SET_INFORMATION_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 HeapSetInformation, to be played against
28 : // a HeapBackdrop.
29 : class HeapSetInformationEvent : public EventInterface {
30 : public:
31 : HeapSetInformationEvent(uint32_t stack_trace_id,
32 : HANDLE trace_heap,
33 : HEAP_INFORMATION_CLASS info_class,
34 : PVOID info,
35 : SIZE_T info_length,
36 : BOOL trace_succeeded);
37 :
38 : // @name EventInterface implementation.
39 : // @{
40 E : EventType type() const override { return kHeapSetInformationEvent; }
41 : bool Play(void* backdrop) override;
42 : bool Equals(const EventInterface* rhs) const override;
43 : // @}
44 :
45 : // @name Serialization methods.
46 : // @{
47 : static bool Save(const EventInterface* const event,
48 : core::OutArchive* out_archive);
49 : static std::unique_ptr<HeapSetInformationEvent> Load(
50 : core::InArchive* in_archive);
51 : // @}
52 :
53 : // @name Accessors.
54 : // @{
55 : uint32_t stack_trace_id() const { return stack_trace_id_; }
56 E : HANDLE trace_heap() const { return trace_heap_; }
57 : HEAP_INFORMATION_CLASS info_class() const { return info_class_; }
58 : PVOID info() const { return info_; }
59 : SIZE_T info_length() const { return info_length_; }
60 : BOOL trace_succeeded() const { return trace_succeeded_; }
61 : // @}
62 :
63 : private:
64 : // The stack trace ID that will be used during playback.
65 : uint32_t stack_trace_id_;
66 :
67 : // Arguments to HeapSetInformation.
68 : HANDLE trace_heap_;
69 : HEAP_INFORMATION_CLASS info_class_;
70 : PVOID info_;
71 : SIZE_T info_length_;
72 :
73 : // Recorded return value.
74 : BOOL trace_succeeded_;
75 :
76 : DISALLOW_COPY_AND_ASSIGN(HeapSetInformationEvent);
77 : };
78 :
79 : } // namespace events
80 : } // namespace bard
81 :
82 : #endif // SYZYGY_BARD_EVENTS_HEAP_SET_INFORMATION_EVENT_H_
|