Bitdefender Hypervisor Memory Introspection
hook_msr.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_MSR_H_
6 #define _HOOK_MSR_H_
7 
8 #include "introtypes.h"
9 
10 
22 typedef INTSTATUS
24  _In_ DWORD Msr,
25  _In_ DWORD Flags,
26  _Out_ INTRO_ACTION *Action,
27  _In_opt_ void *Context,
28  _In_opt_ QWORD OriginalValue,
29  _Inout_opt_ QWORD *NewValue
30  );
31 
32 
36 typedef struct _MSR_HOOK_STATE
37 {
41 
42 
46 typedef struct _HOOK_MSR
47 {
54  void *Context;
56 
57 
58 //
59 // MSR hooks related API
60 //
63  _In_ DWORD Msr,
64  _In_ DWORD Flags,
66  _In_opt_ void *Context,
67  _Out_opt_ void **Hook
68  );
69 
72  _In_ HOOK_MSR *Hook
73  );
74 
77  void
78  );
79 
82  void
83  );
84 
87  void
88  );
89 
90 #endif // _HOOK_MSR_H_
#define _In_opt_
Definition: intro_sal.h:16
struct _HOOK_MSR HOOK_MSR
_Bool BOOLEAN
Definition: intro_types.h:58
#define _Out_
Definition: intro_sal.h:22
long long INT64
Definition: intro_types.h:45
#define _In_
Definition: intro_sal.h:21
PFUNC_MsrReadWriteHookCallback Callback
The callback.
Definition: hook_msr.h:53
INTSTATUS IntHookMsrInit(void)
Initialize the model specific registers hook state.
Definition: hook_msr.c:262
int INTSTATUS
The status data type.
Definition: introstatus.h:24
LIST_ENTRY Link
List entry element.
Definition: hook_msr.h:48
INT64 HooksCount
Total number of MSR hooks.
Definition: hook_msr.h:39
#define _Inout_opt_
Definition: intro_sal.h:31
#define _Out_opt_
Definition: intro_sal.h:30
unsigned long long QWORD
Definition: intro_types.h:53
INTSTATUS IntHookMsrRemoveHook(HOOK_MSR *Hook)
Remove a model specific register hook.
Definition: hook_msr.c:138
LIST_HEAD MsrHooksList
The list of MSR hooks.
Definition: hook_msr.h:38
uint32_t DWORD
Definition: intro_types.h:49
DWORD Msr
The hooked MSR.
Definition: hook_msr.h:49
BOOLEAN WasEnabled
True if MSR exiting for this MSR was already enabled.
Definition: hook_msr.h:51
enum _INTRO_ACTION INTRO_ACTION
Event actions.
INTSTATUS IntHookMsrSetHook(DWORD Msr, DWORD Flags, PFUNC_MsrReadWriteHookCallback Callback, void *Context, void **Hook)
Set a model-specific register write hook.
Definition: hook_msr.c:11
struct _HOOK_MSR * PHOOK_MSR
INTSTATUS IntHookMsrCommit(void)
Commit the model specific register hooks.
Definition: hook_msr.c:224
INTSTATUS(* PFUNC_MsrReadWriteHookCallback)(DWORD Msr, DWORD Flags, INTRO_ACTION *Action, void *Context, QWORD OriginalValue, QWORD *NewValue)
Model specific register access callback.
Definition: hook_msr.h:23
BOOLEAN Disabled
True if this hook has been removed/disabled.
Definition: hook_msr.h:52
struct _MSR_HOOK_STATE * PMSR_HOOK_STATE
DWORD Flags
Access flags. See IG_MSR_HOOK_TYPE.
Definition: hook_msr.h:50
struct _MSR_HOOK_STATE MSR_HOOK_STATE
INTSTATUS IntHookMsrUninit(void)
Uninit the model specific register hooks state.
Definition: hook_msr.c:285
void * Context
Optional context.
Definition: hook_msr.h:54