muteki
Loading...
Searching...
No Matches
devio.h
Go to the documentation of this file.
1/*
2 * Copyright 2021-present dogtopus
3 * SPDX-License-Identifier: MIT
4 */
5
11#ifndef __MUTEKI_DEVIO_H__
12#define __MUTEKI_DEVIO_H__
13
14#include <muteki/common.h>
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
24#define DEVIO_DESC_MAGIC (0x48435842u)
25
30typedef void devio_backend_t;
31
35typedef struct {
39 char path[80];
51 unsigned int device_id;
59 int access;
63 int shmode;
71 unsigned int flags_upper;
75 unsigned int flags_lower;
79 unsigned int magic;
84} devio_descriptor_t; // 0x7c bytes
85
86// TODO stubbed definition. Fully implement this later.
87typedef char device_service_t[0x4c];
88
93#define DEVIO_DESC_INVALID ((devio_descriptor_t *) 0xffffffff)
94
111 const char *pathname,
112 unsigned int access,
113 unsigned int shmode,
114 void *secattr,
115 unsigned int on_noentry,
116 unsigned int flags,
117 void *template_file
118);
119
132extern bool ReadFile(devio_descriptor_t *devfd, void *buf, size_t size, size_t *actual_size, void *overlapped);
133
146extern bool WriteFile(devio_descriptor_t *devfd, const void *buf,size_t size, size_t *actual_size, void *overlapped);
147
163extern bool DeviceIoControl(
164 devio_descriptor_t *devfd,
165 int request,
166 const void *in,
167 int inlen,
168 void *out,
169 int outlen,
170 int *retlen,
171 void *overlapped
172);
173
182extern bool CloseHandle(devio_descriptor_t *devfd);
183
184#ifdef __cplusplus
185} // extern "C"
186#endif
187
188#endif // __MUTEKI_DEVIO_H__urn Whether the operation was successful.
Common include file for all muteki-shims headers.
devio_descriptor_t * CreateFile(const char *pathname, unsigned int access, unsigned int shmode, void *secattr, unsigned int on_noentry, unsigned int flags, void *template_file)
Open or create a file/device by its pathname.
bool DeviceIoControl(devio_descriptor_t *devfd, int request, const void *in, int inlen, void *out, int outlen, int *retlen, void *overlapped)
Send an IOCTL request to a device IO descriptor devfd.
bool ReadFile(devio_descriptor_t *devfd, void *buf, size_t size, size_t *actual_size, void *overlapped)
Read/receive data from a device IO descriptor.
void devio_backend_t
Catchall device IO backend type.
Definition devio.h:30
bool WriteFile(devio_descriptor_t *devfd, const void *buf, size_t size, size_t *actual_size, void *overlapped)
Write/send data to a device IO descriptor.
bool CloseHandle(devio_descriptor_t *devfd)
Close a device IO descriptor.
The device IO descriptor.
Definition devio.h:35
int on_noentry
Behavior on no entry.
Definition devio.h:67
int unk_0x78
Unknown.
Definition devio.h:83
devio_backend_t * backend
Backend of this descriptor. Can be a file descriptor or a service.
Definition devio.h:43
int refcount
Reference counter.
Definition devio.h:55
unsigned int magic
Descriptor magic. Always BXCH.
Definition devio.h:79
unsigned int flags_upper
Upper 16-bit of the flags.
Definition devio.h:71
unsigned int device_id
Device ID if this descriptor is device-backed.
Definition devio.h:51
int unk_0x54
Unknown.
Definition devio.h:47
unsigned int flags_lower
Lower 16-bit of the flags.
Definition devio.h:75
int shmode
Sharing mode.
Definition devio.h:63
int access
Access mode.
Definition devio.h:59