47 ioctl_add_module(
char *
file, int64_t len)
54 ALERT(
"IOCTL_ADD_MODULE: too many modules have been loaded\n");
61 ALERT(
"IOCTL_ADD_MODULE: failed to allocate memory for the module\n");
71 ALERT(
"IOCTL_ADD_MODULE: common_add_module failed: %p - %s\n",
72 (
void *)ret, ec_to_str(ret));
81 DEBUG(
"IOCTL_ADD_MODULE: succeeded\n");
88 ALERT(
"IOCTL_ADD_MODULE: failed\n");
93 ioctl_unload_vmm(
void)
102 ALERT(
"IOCTL_UNLOAD_VMM: common_unload_vmm failed: %p - %s\n",
103 (
void *)ret, ec_to_str(ret));
114 DEBUG(
"IOCTL_UNLOAD_VMM: succeeded\n");
127 ALERT(
"IOCTL_LOAD_VMM: ioctl_load_vmm failed: %p - %s\n",
128 (
void *)ret, ec_to_str(ret));
132 DEBUG(
"IOCTL_LOAD_VMM: succeeded\n");
150 ALERT(
"IOCTL_STOP_VMM: ioctl_stop_vmm failed: %p - %s\n",
151 (
void *)ret, ec_to_str(ret));
156 DEBUG(
"IOCTL_STOP_VMM: succeeded\n");
162 ioctl_start_vmm(
void)
169 ALERT(
"IOCTL_START_VMM: ioctl_start_vmm failed: %p - %s\n",
170 (
void *)ret, ec_to_str(ret));
174 DEBUG(
"IOCTL_START_VMM: succeeded\n");
192 ALERT(
"IOCTL_DUMP_VMM: common_dump_vmm failed: %p - %s\n",
193 (
void *)ret, ec_to_str(ret));
199 DEBUG(
"IOCTL_DUMP_VMM: succeeded\n");
204 ioctl_vmm_status(int64_t *status)
210 ALERT(
"IOCTL_VMM_STATUS: common_vmm_status failed: NULL\n");
214 *status = vmm_status;
216 DEBUG(
"IOCTL_VMM_STATUS: succeeded\n");
221 ioctl_set_cpuid(uint64_t *
cpuid)
225 ALERT(
"IOCTL_SET_CPUID: failed with len == NULL\n");
231 DEBUG(
"IOCTL_SET_CPUID: succeeded\n");
236 ioctl_set_vcpuid(uint64_t *
vcpuid)
240 ALERT(
"IOCTL_SET_VCPUID: failed with len == NULL\n");
246 DEBUG(
"IOCTL_SET_VCPUID: succeeded\n");
258 ALERT(
"IOCTL_VMCALL: common_vmcall failed: %p - %s\n", \
259 (
void *)ret, ec_to_str(ret));
269 _In_ WDFDEVICE Device
274 WDF_IO_QUEUE_CONFIG queueConfig;
276 WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(
278 WdfIoQueueDispatchParallel
284 status = WdfIoQueueCreate(Device, &queueConfig, WDF_NO_OBJECT_ATTRIBUTES, &queue);
285 if (!NT_SUCCESS(status))
290 ALERT(
"common_init failed\n");
291 return STATUS_ACCESS_DENIED;
294 DEBUG(
"bareflankQueueInitialize: success\n");
295 return STATUS_SUCCESS;
301 _In_ WDFREQUEST Request,
302 _In_
size_t OutputBufferLength,
303 _In_
size_t InputBufferLength,
304 _In_ ULONG IoControlCode
315 UNREFERENCED_PARAMETER(Queue);
317 if (InputBufferLength != 0)
319 status = WdfRequestRetrieveInputBuffer(Request, InputBufferLength, &in, &in_size);
321 if (!NT_SUCCESS(status))
325 if (OutputBufferLength != 0)
327 status = WdfRequestRetrieveOutputBuffer(Request, OutputBufferLength, &out, &out_size);
329 if (!NT_SUCCESS(status))
333 switch (IoControlCode)
335 case IOCTL_ADD_MODULE:
336 ret = ioctl_add_module((
char *)in, (int64_t)in_size);
340 ret = ioctl_load_vmm();
343 case IOCTL_UNLOAD_VMM:
344 ret = ioctl_unload_vmm();
347 case IOCTL_START_VMM:
348 ret = ioctl_start_vmm();
352 ret = ioctl_stop_vmm();
359 case IOCTL_VMM_STATUS:
360 ret = ioctl_vmm_status((int64_t *)out);
363 case IOCTL_SET_CPUID:
364 ret = ioctl_set_cpuid((uint64_t *)in);
367 case IOCTL_SET_VCPUID:
368 ret = ioctl_set_vcpuid((uint64_t *)in);
379 if (OutputBufferLength != 0)
380 WdfRequestSetInformation(Request, out_size);
385 WdfRequestComplete(Request, STATUS_SUCCESS);
390 WdfRequestComplete(Request, STATUS_ACCESS_DENIED);
397 _In_ WDFREQUEST Request,
398 _In_ ULONG ActionFlags
401 UNREFERENCED_PARAMETER(Queue);
402 UNREFERENCED_PARAMETER(ActionFlags);
404 WdfRequestComplete(Request, STATUS_SUCCESS);
constexpr const auto cpuid
int64_t common_add_module(const char *file, uint64_t fsize)
int64_t common_load_vmm(void)
int64_t unsigned long void * data
int64_t common_dump_vmm(struct debug_ring_resources_t **drr, uint64_t vcpuid)
VOID bareflankEvtIoDeviceControl(_In_ WDFQUEUE Queue, _In_ WDFREQUEST Request, _In_ size_t OutputBufferLength, _In_ size_t InputBufferLength, _In_ ULONG IoControlCode)
debug_ring_resources_t * drr
NTSTATUS bareflankQueueInitialize(_In_ WDFDEVICE Device)
constexpr const auto size
int64_t common_vmcall(struct vmcall_registers_t *regs, uint64_t cpuid)
int64_t common_stop_vmm(void)
int64_t common_start_vmm(void)
int64_t common_init(void)
struct pmodule_t pmodules[MAX_NUM_MODULES]
int64_t common_unload_vmm(void)
VOID bareflankEvtIoStop(_In_ WDFQUEUE Queue, _In_ WDFREQUEST Request, _In_ ULONG ActionFlags)
int64_t common_vmm_status(void)