Bitdefender Hypervisor Memory Introspection
swapmem.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Bitdefender
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 #ifndef _SWAPMEM_H_
6 #define _SWAPMEM_H_
7 
8 #include "introtypes.h"
9 
12 #define SWAPMEM_FLAG_ASYNC_CALL 0x00000001
13 #define SWAPMEM_FLAG_ENTRY_XD 0x00000002
16 
17 
19 #define SWAPMEM_OPT_NO_FAULT 0x00000001
20 #define SWAPMEM_OPT_UM_FAULT 0x00000002
22 #define SWAPMEM_OPT_KM_FAULT 0x00000004
26 #define SWAPMEM_OPT_BP_FAULT 0x00000010
28 #define SWAPMEM_OPT_RW_FAULT 0x00000020
30 #define SWAPMEM_OPT_NO_DUPS 0x80000000
32 
33 
34 
51 typedef INTSTATUS
53  _In_ void *Context,
54  _In_ QWORD Cr3,
55  _In_ QWORD VirtualAddress,
56  _In_ QWORD PhysicalAddress,
57  _In_reads_bytes_(DataSize) void *Data,
58  _In_ DWORD DataSize,
59  _In_ DWORD Flags
60  );
61 
62 
79 typedef INTSTATUS
81  _In_ void *Context,
82  _In_ QWORD Cr3,
83  _In_ QWORD VirtualAddress
84  );
85 
86 
87 //
88 // API
89 //
92  _In_ QWORD Cr3,
93  _In_ QWORD VirtualAddress,
94  _In_ DWORD Length,
95  _In_ DWORD Options,
96  _In_opt_ void *Context,
97  _In_opt_ DWORD ContextTag,
100  _Out_opt_ void **SwapHandle
101  );
102 
103 INTSTATUS
105  void
106  );
107 
108 void
110  _In_ QWORD VirtualAddress
111  );
112 
113 void
115  void
116  );
117 
118 INTSTATUS
120  _In_ void *Transaction
121  );
122 
123 INTSTATUS
125  _In_ QWORD Cr3
126  );
127 
128 INTSTATUS
130  void
131  );
132 
133 INTSTATUS
135  void
136  );
137 
138 void
140  void
141  );
142 
143 #endif // _SWAPMEM_H_
#define _In_opt_
Definition: intro_sal.h:16
INTSTATUS IntSwapMemRemoveTransactionsForVaSpace(QWORD Cr3)
Remove all transactions initiated for a virtual address space.
Definition: swapmem.c:982
#define _In_
Definition: intro_sal.h:21
INTSTATUS IntSwapMemReadData(QWORD Cr3, QWORD VirtualAddress, DWORD Length, DWORD Options, void *Context, DWORD ContextTag, PFUNC_PagesReadCallback Callback, PFUNC_PreInjectCallback PreInject, void **SwapHandle)
Reads a region of guest virtual memory, and calls the indicated callback when all the data is availab...
Definition: swapmem.c:417
void IntSwapMemCancelPendingPF(QWORD VirtualAddress)
Cancel a pending PF.
Definition: swapmem.c:879
int INTSTATUS
The status data type.
Definition: introstatus.h:24
INTSTATUS(* PFUNC_PagesReadCallback)(void *Context, QWORD Cr3, QWORD VirtualAddress, QWORD PhysicalAddress, void *Data, DWORD DataSize, DWORD Flags)
Called when all the required data is available.
Definition: swapmem.h:52
void IntSwapMemDump(void)
Dump all active transactions & pages.
Definition: swapmem.c:1066
INTSTATUS IntSwapMemInit(void)
Init the swapmem system.
Definition: swapmem.c:1026
INTSTATUS IntSwapMemUnInit(void)
Uninit the swapmem system.
Definition: swapmem.c:1044
INTSTATUS IntSwapMemRemoveTransaction(void *Transaction)
Remove a transaction.
Definition: swapmem.c:942
#define _Out_opt_
Definition: intro_sal.h:30
unsigned long long QWORD
Definition: intro_types.h:53
INTSTATUS IntSwapMemInjectPendingPF(void)
Inject a PF for a pending page.
Definition: swapmem.c:698
uint32_t DWORD
Definition: intro_types.h:49
#define _In_reads_bytes_(expr)
Definition: intro_sal.h:25
INTSTATUS(* PFUNC_PreInjectCallback)(void *Context, QWORD Cr3, QWORD VirtualAddress)
Called before injecting a PF inside the guest.
Definition: swapmem.h:80
void IntSwapMemReinjectFailedPF(void)
Reinject timed-out PFs.
Definition: swapmem.c:913