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 HeapReAlloc function call.
16 : #ifndef SYZYGY_BARD_EVENTS_HEAP_REALLOC_EVENT_H_
17 : #define SYZYGY_BARD_EVENTS_HEAP_REALLOC_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 HeapReAlloc, to be played against a
28 : // HeapBackdrop.
29 : class HeapReAllocEvent : public EventInterface {
30 : public:
31 : HeapReAllocEvent(HANDLE trace_heap,
32 : DWORD flags,
33 : LPVOID trace_alloc,
34 : SIZE_T bytes,
35 : LPVOID trace_realloc);
36 :
37 : // @name EventInterface implementation.
38 : // @{
39 E : EventType type() const override { return kHeapReAllocEvent; }
40 : bool Play(void* backdrop) override;
41 : bool Equals(const EventInterface* rhs) const override;
42 : // @}
43 :
44 : // @name Serialization methods.
45 : // @{
46 : static bool Save(const EventInterface* const event,
47 : core::OutArchive* out_archive);
48 : static scoped_ptr<HeapReAllocEvent> Load(core::InArchive* in_archive);
49 : // @}
50 :
51 : // @name Accessors.
52 : // @{
53 E : HANDLE trace_heap() const { return trace_heap_; }
54 : DWORD flags() const { return flags_; }
55 E : LPVOID trace_alloc() const { return trace_alloc_; }
56 : SIZE_T bytes() const { return bytes_; }
57 E : LPVOID trace_realloc() const { return trace_realloc_; }
58 : // @}
59 :
60 : private:
61 : // Arguments to HeapReAlloc.
62 : HANDLE trace_heap_;
63 : DWORD flags_;
64 : LPVOID trace_alloc_;
65 : SIZE_T bytes_;
66 :
67 : // Recorded return value.
68 : LPVOID trace_realloc_;
69 :
70 : DISALLOW_COPY_AND_ASSIGN(HeapReAllocEvent);
71 : };
72 :
73 : } // namespace events
74 : } // namespace bard
75 :
76 : #endif // SYZYGY_BARD_EVENTS_HEAP_REALLOC_EVENT_H_
|