28 #include <sys/ioctl.h> 79 IOServiceClose(m_connect);
82 void ioctl_private::ioctl_write(bf_ioctl_t *
in, bf_ioctl_t *
out)
84 size_t inStructSize =
sizeof(bf_ioctl_t);
85 size_t outStructSize =
sizeof(bf_ioctl_t);
88 IOConnectCallStructMethod(m_connect, 1, in, inStructSize, out, &outStructSize);
91 void ioctl_private::ioctl_read(bf_ioctl_t *
in, bf_ioctl_t *
out)
93 size_t inStructSize =
sizeof(bf_ioctl_t);
94 size_t outStructSize =
sizeof(bf_ioctl_t);
97 IOConnectCallStructMethod(m_connect, 1, in, inStructSize, out, &outStructSize);
103 io_iterator_t iterator;
104 io_service_t service;
105 kern_return_t kernResult = IOServiceGetMatchingServices(kIOMasterPortDefault, IOServiceMatching(
"org_bareflank_osx"), &iterator);
108 if (kernResult != KERN_SUCCESS)
114 if ((service = IOIteratorNext(iterator)) != IO_OBJECT_NULL)
118 kernResult = IOServiceOpen(service, mach_task_self(), 0, &m_connect);
121 if (kernResult != KERN_SUCCESS)
130 ioctl_private::bf_write_ioctl(
int fd, uint32_t cmd,
void *arg)
134 bf_ioctl_t
in = { 0, 0, 0 };
135 bf_ioctl_t
out = { 0, 0, 0 };
141 ioctl_write(&in, &out);
147 ioctl_private::bf_read_ioctl(
int fd, uint32_t cmd,
void *arg)
151 bf_ioctl_t
in = { 0, 0, 0 };
152 bf_ioctl_t
out = { 0, 0, 0 };
158 ioctl_write(&in, &out);
164 ioctl_private::bf_send_ioctl(
int fd, uint32_t cmd)
168 bf_ioctl_t
in = { 0, 0, 0 };
169 bf_ioctl_t
out = { 0, 0, 0 };
175 ioctl_write(&in, &out);
189 if (bf_write_ioctl(fd, IOCTL_ADD_MODULE_LENGTH, &len) < 0)
201 if (bf_write_ioctl(fd, IOCTL_ADD_MODULE, (
void *)data) < 0)
210 if (bf_send_ioctl(fd, IOCTL_LOAD_VMM) < 0)
219 if (bf_send_ioctl(fd, IOCTL_UNLOAD_VMM) < 0)
228 if (bf_send_ioctl(fd, IOCTL_START_VMM) < 0)
237 if (bf_send_ioctl(fd, IOCTL_STOP_VMM) < 0)
249 if (bf_read_ioctl(fd, IOCTL_DUMP_VMM, drr) < 0)
258 if (status ==
nullptr)
261 if (bf_read_ioctl(fd, IOCTL_VMM_STATUS, status) < 0)
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
virtual void call_ioctl_add_module_length(module_len_type len)
virtual void call_ioctl_vmm_status(gsl::not_null< status_pointer > status)
debug_ring_resources_t * drr
virtual void call_ioctl_start_vmm()
virtual void call_ioctl_dump_vmm(gsl::not_null< drr_pointer > drr, vcpuid_type vcpuid)
int64_t bf_write_ioctl(int64_t fd, unsigned long request, const void *data)
~ioctl_private() override
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()
#define unknown_command(a)