Bitdefender Hypervisor Memory Introspection
hook_object.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Bitdefender
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 #ifndef _HOOK_STRUCTURE_H_
6 #define _HOOK_STRUCTURE_H_
7 
8 #include "guests.h"
9 
10 typedef struct _HOOK_HEADER HOOK_HEADER;
11 
12 
17 {
26 
30 
31 
37 {
43  void **Hooks;
44 
46  PHOOK_OBJECT_DESCRIPTOR Object;
48 
49 
53 typedef struct _HOOK_OBJECTS_STATE
54 {
58 
59 
60 //
61 // API
62 //
66  _In_ QWORD Cr3,
67  _Out_ void **Object
68  );
69 
72  _In_ void *Object,
73  _In_ QWORD Cr3,
74  _In_ QWORD Gla,
75  _In_ SIZE_T Length,
76  _In_ BYTE Type,
77  _In_ void *Callback,
78  _In_opt_ void *Context,
81  );
82 
87  );
88 
93  );
94 
95 void *
97  _In_ QWORD Gva,
98  _In_ void *HookObject,
99  _In_ BYTE HookType
100  );
101 
102 INTSTATUS
104  void
105  );
106 
107 INTSTATUS
109  void
110  );
111 
112 INTSTATUS
114  void
115  );
116 
117 #endif // _HOOK_STRUCTURE_H_
LIST_HEAD RemovedRegions
All the removed regions are inserted here. The regions must be committed in the exact same order they...
Definition: hook_object.h:22
#define _In_opt_
Definition: intro_sal.h:16
#define _Out_
Definition: intro_sal.h:22
_Bool BOOLEAN
Definition: intro_types.h:58
uint8_t BYTE
Definition: intro_types.h:47
INTSTATUS IntHookObjectDestroy(HOOK_OBJECT_DESCRIPTOR **Object, DWORD Flags)
Destroy an entire hook object. All regions belonging to this object will be removed.
Definition: hook_object.c:357
void ** Hooks
Array of hooks. They will usually be HOOK_GVA objects.
Definition: hook_object.h:43
#define _In_
Definition: intro_sal.h:21
struct _HOOK_OBJECTS_STATE * PHOOK_OBJECT_STATE
PHOOK_OBJECT_DESCRIPTOR Object
Parent object. Optional, but it is strongly recommended to link a region to an object.
Definition: hook_object.h:46
DWORD ObjectType
One of the INTRO_OBJECT_TYPE values.
Definition: hook_object.h:23
int INTSTATUS
The status data type.
Definition: introstatus.h:24
BOOLEAN ObjectsRemoved
True whenever an object has been removed.
Definition: hook_object.h:56
QWORD HookStart
Guest virtual address of the hooked region.
Definition: hook_object.h:40
void * IntHookObjectFindRegion(QWORD Gva, void *HookObject, BYTE HookType)
Searches for a region of hooked memory inside the provided hook object.
Definition: hook_object.c:424
struct _HOOK_REGION_DESCRIPTOR HOOK_REGION_DESCRIPTOR
#define _Inout_
Definition: intro_sal.h:20
#define _Out_opt_
Definition: intro_sal.h:30
QWORD HookLength
Length of the hooked region. May span multiple pages.
Definition: hook_object.h:41
BOOLEAN RegionsRemoved
True if regions have been removed from this object (used by the commit function). ...
Definition: hook_object.h:28
unsigned long long QWORD
Definition: intro_types.h:53
INTSTATUS IntHookObjectInit(void)
Initialize the hook object system.
Definition: hook_object.c:598
DWORD Flags
Hook flags.
Definition: hook_object.h:25
LIST_ENTRY Link
The list entry element.
Definition: hook_object.h:18
HOOK_HEADER Header
The hook header.
Definition: hook_object.h:38
INTSTATUS IntHookObjectUninit(void)
Uninit the hook object system.
Definition: hook_object.c:614
struct _HOOK_OBJECT_DESCRIPTOR HOOK_OBJECT_DESCRIPTOR
INTSTATUS IntHookObjectRemoveRegion(HOOK_REGION_DESCRIPTOR **Region, DWORD Flags)
Remove a hooked region of memory.
Definition: hook_object.c:309
uint32_t DWORD
Definition: intro_types.h:49
struct _HOOK_OBJECTS_STATE HOOK_OBJECT_STATE
INTSTATUS IntHookObjectCommit(void)
Commit removed hook objects and regions.
Definition: hook_object.c:525
struct _HOOK_REGION_DESCRIPTOR * PHOOK_REGION_DESCRIPTOR
LIST_HEAD Objects
List of objects.
Definition: hook_object.h:55
INTSTATUS IntHookObjectHookRegion(void *Object, QWORD Cr3, QWORD Gla, SIZE_T Length, BYTE Type, void *Callback, void *Context, DWORD Flags, HOOK_REGION_DESCRIPTOR **Region)
Hook a contiguous region of virtual memory inside the provided virtual address space.
Definition: hook_object.c:132
QWORD Cr3
The CR3 of the object. If this is a kernel object, Cr3 must be 0.
Definition: hook_object.h:24
LIST_ENTRY Link
The list entry element.
Definition: hook_object.h:39
struct _HOOK_OBJECT_DESCRIPTOR * PHOOK_OBJECT_DESCRIPTOR
INTSTATUS IntHookObjectCreate(DWORD ObjectType, QWORD Cr3, void **Object)
Create a new hook object.
Definition: hook_object.c:81
DWORD HooksCount
Number of hooks set for this region of memory.
Definition: hook_object.h:42
size_t SIZE_T
Definition: intro_types.h:60