38 SP_INTERFACE_DEVICE_DETAIL_DATA *deviceDetailData =
nullptr;
40 SP_DEVINFO_DATA devInfo;
41 devInfo.cbSize =
sizeof(SP_DEVINFO_DATA);
43 SP_INTERFACE_DEVICE_DATA ifInfo;
44 ifInfo.cbSize =
sizeof(SP_INTERFACE_DEVICE_DATA);
46 hDevInfo = SetupDiGetClassDevs(&GUID_DEVINTERFACE_bareflank, 0, 0, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT);
47 if (hDevInfo == INVALID_HANDLE_VALUE)
50 if (SetupDiEnumDeviceInfo(hDevInfo, 0, &devInfo) ==
false)
51 return INVALID_HANDLE_VALUE;
53 if (SetupDiEnumDeviceInterfaces(hDevInfo, &devInfo, &(GUID_DEVINTERFACE_bareflank), 0, &ifInfo) ==
false)
54 return INVALID_HANDLE_VALUE;
56 DWORD requiredSize = 0;
58 if (SetupDiGetDeviceInterfaceDetail(hDevInfo, &ifInfo, NULL, 0, &requiredSize, NULL) ==
true)
59 return INVALID_HANDLE_VALUE;
61 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
62 return INVALID_HANDLE_VALUE;
64 deviceDetailData =
static_cast<SP_INTERFACE_DEVICE_DETAIL_DATA *
>(
malloc(requiredSize));
66 if (deviceDetailData ==
nullptr)
67 return INVALID_HANDLE_VALUE;
69 auto ___ = gsl::finally([&]
70 {
free(deviceDetailData); });
72 deviceDetailData->cbSize =
sizeof(SP_INTERFACE_DEVICE_DETAIL_DATA);
74 if (SetupDiGetDeviceInterfaceDetail(hDevInfo, &ifInfo, deviceDetailData, requiredSize, NULL, NULL) ==
false)
75 return INVALID_HANDLE_VALUE;
77 return CreateFile(deviceDetailData->DevicePath,
78 GENERIC_READ | GENERIC_WRITE,
82 FILE_ATTRIBUTE_NORMAL,
89 if (!DeviceIoControl(fd, request, NULL, 0, NULL, 0, NULL, NULL))
98 if (!DeviceIoControl(fd, request, NULL, 0, data, size, NULL, NULL))
107 if (!DeviceIoControl(fd, request, const_cast<void *>(data), size, NULL, 0, NULL, NULL))
116 if (!DeviceIoControl(fd, request, data, size, data, size, NULL, NULL))
127 fd(INVALID_HANDLE_VALUE)
133 if (fd != INVALID_HANDLE_VALUE)
144 #pragma GCC diagnostic push 145 #pragma GCC diagnostic ignored "-Wconversion" 146 #pragma GCC diagnostic ignored "-Wsign-conversion" 188 if (bf_write_ioctl(fd, IOCTL_SET_VCPUID, &vcpuid,
sizeof(vcpuid)) ==
BF_IOCTL_FAILURE)
191 if (bf_read_ioctl(fd, IOCTL_DUMP_VMM, drr,
sizeof(*drr)) ==
BF_IOCTL_FAILURE)
198 if (bf_read_ioctl(fd, IOCTL_VMM_STATUS, status,
sizeof(*status)) ==
BF_IOCTL_FAILURE)
205 if (bf_write_ioctl(fd, IOCTL_SET_CPUID, &cpuid,
sizeof(cpuid)) ==
BF_IOCTL_FAILURE)
212 #pragma GCC diagnostic pop virtual void call_ioctl_stop_vmm()
int64_t unsigned long request
int64_t bf_read_ioctl(int64_t fd, unsigned long request, void *data)
virtual void call_ioctl_load_vmm()
int64_t unsigned long void * data
void * malloc(size_t size)
int64_t bf_read_write_ioctl(HANDLE fd, DWORD request, void *data, DWORD size)
virtual void call_ioctl_vmm_status(gsl::not_null< status_pointer > status)
debug_ring_resources_t * drr
constexpr const auto size
virtual void call_ioctl_start_vmm()
virtual void call_ioctl_dump_vmm(gsl::not_null< drr_pointer > drr, vcpuid_type vcpuid)
#define driver_inaccessible(a)
int64_t bf_write_ioctl(int64_t fd, unsigned long request, const void *data)
~ioctl_private() override
virtual void call_ioctl_vmcall(gsl::not_null< registers_pointer > regs, cpuid_type cpuid)
virtual void call_ioctl_add_module(gsl::not_null< module_data_type > data)
int64_t bf_send_ioctl(int64_t fd, unsigned long request)
virtual void call_ioctl_unload_vmm()