MCPcopy Create free account
hub / github.com/HoShiMin/Kernel-Bridge / DevirtualizeAllProcessors

Function DevirtualizeAllProcessors

Kernel-Bridge/API/Hypervisor.cpp:228–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

226 }
227
228 static bool DevirtualizeAllProcessors()
229 {
230 ULONG ProcessorsCount = KeQueryActiveProcessorCountEx(ALL_PROCESSOR_GROUPS);
231 void** PrivateVmDataArray = VirtualMemory::AllocArray<void*>(ProcessorsCount);
232
233 KeIpiGenericCall([](ULONG_PTR Arg) -> ULONG_PTR
234 {
235 void** PrivateVmDataArray = reinterpret_cast<void**>(Arg);
236 ULONG CurrentProcessor = KeGetCurrentProcessorNumber();
237 void* PrivateVmData = NULL;
238 bool Status = DevirtualizeProcessor(OUT PrivateVmData);
239 PrivateVmDataArray[CurrentProcessor] = PrivateVmData; // Data buffer to free
240 return static_cast<ULONG_PTR>(Status);
241 }, reinterpret_cast<ULONG_PTR>(PrivateVmDataArray));
242
243 CPU_VENDOR vendor = GetCpuVendor();
244
245 for (ULONG i = 0; i < ProcessorsCount; ++i)
246 {
247 if (PrivateVmDataArray[i])
248 {
249 if (vendor == CPU_VENDOR::cpuIntel)
250 {
251 VMX::FreePrivateVmData(PrivateVmDataArray[i]);
252 }
253 else
254 {
255 Supplementation::FreePhys(PrivateVmDataArray[i]);
256 }
257 }
258 }
259
260 g_IsVirtualized = false;
261
262 return true;
263 }
264}
265
266namespace SVM

Callers 2

VirtualizeAllProcessorsFunction · 0.85
DevirtualizeFunction · 0.85

Calls 4

DevirtualizeProcessorFunction · 0.85
GetCpuVendorFunction · 0.85
FreePrivateVmDataFunction · 0.85
FreePhysFunction · 0.85

Tested by

no test coverage detected