muteki
Loading...
Searching...
No Matches
devio.h File Reference

Device IO API. More...

#include <muteki/common.h>

Go to the source code of this file.

Data Structures

struct  devio_descriptor_t
 The device IO descriptor. More...
 

Macros

#define DEVIO_DESC_MAGIC   (0x48435842u)
 Magic for device IO descriptor.
 
#define DEVIO_DESC_INVALID   ((devio_descriptor_t *) 0xffffffff)
 Invalid descriptor.
 

Typedefs

typedef void devio_backend_t
 Catchall device IO backend type.
 
typedef char device_service_t[0x4c]
 

Functions

devio_descriptor_tCreateFile (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 ReadFile (devio_descriptor_t *devfd, void *buf, size_t size, size_t *actual_size, void *overlapped)
 Read/receive data from a device IO descriptor.
 
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 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 CloseHandle (devio_descriptor_t *devfd)
 Close a device IO descriptor.
 

Detailed Description

Device IO API.

Macro Definition Documentation

◆ DEVIO_DESC_INVALID

#define DEVIO_DESC_INVALID   ((devio_descriptor_t *) 0xffffffff)

Invalid descriptor.

This is usually returned by CreateFile() when an error occurred.

◆ DEVIO_DESC_MAGIC

#define DEVIO_DESC_MAGIC   (0x48435842u)

Magic for device IO descriptor.

The value is ASCII "BXCH".

Typedef Documentation

◆ devio_backend_t

typedef void devio_backend_t

Catchall device IO backend type.

Todo:
Add more details.

Function Documentation

◆ CloseHandle()

bool CloseHandle ( devio_descriptor_t devfd)
extern

Close a device IO descriptor.

Analogous to the Windows CloseHandle() API.

Syscall Number
0x102ad
Parameters
devfdDescriptor to close.
Return values
trueThe operation was completed successfully.
falseThe operation failed with error.

◆ CreateFile()

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 
)
extern

Open or create a file/device by its pathname.

Analogous to the Windows CreateFile() API.

Todo:
Documentation on accepted arguments are mostly based on speculations at this moment. More details and through verifications needed.
Syscall Number
0x102a7
Parameters
pathnameDOS 8.3 path to the file to be opened.
accessAccess flags.
shmodeFile sharing mode. (?)
secattrSeems to be ignored.
on_noentryBehavior when entry does not exist. (?)
flagsFlags and attributes of the file. (?)
template_fileSeems to be ignored.
Returns
Device IO descriptor.

◆ DeviceIoControl()

bool DeviceIoControl ( devio_descriptor_t devfd,
int  request,
const void *  in,
int  inlen,
void *  out,
int  outlen,
int *  retlen,
void *  overlapped 
)
extern

Send an IOCTL request to a device IO descriptor devfd.

Analogous to the Windows DeviceIoControl() API.

Syscall Number
0x102ac
Parameters
devfdDevice IO descriptor.
requestIOCTL request type.
inThe input buffer, or NULL if not applicable.
inlenThe size of the input buffer in bytes.
outThe output buffer, or NULL if not applicable.
outlenThe size of the output buffer in bytes.
retlenThe size of returned data (if applicable).
overlappedProbably ignored.
Return values
trueThe operation was completed successfully.
falseThe operation failed with error.

◆ ReadFile()

bool ReadFile ( devio_descriptor_t devfd,
void *  buf,
size_t  size,
size_t *  actual_size,
void *  overlapped 
)
extern

Read/receive data from a device IO descriptor.

Analogous to the Windows ReadFile() API.

Syscall Number
0x102a9
Parameters
devfdThe device IO descriptor.
[out]bufBuffer to hold data read from the descriptor.
sizeNumber of bytes to read.
[out]actual_sizeNumber of bytes actually read.
overlappedReserved.
Return values
trueThe operation was completed successfully.
falseThe operation failed with error.

◆ WriteFile()

bool WriteFile ( devio_descriptor_t devfd,
const void *  buf,
size_t  size,
size_t *  actual_size,
void *  overlapped 
)
extern

Write/send data to a device IO descriptor.

Analogous to the Windows WriteFile() API.

Syscall Number
0x102aa
Parameters
devfdThe device IO descriptor.
[in]bufBuffer to hold data to be written to the descriptor.
sizeNumber of bytes to write.
[out]actual_sizeNumber of bytes actually written.
overlappedReserved.
Return values
trueThe operation was completed successfully.
falseThe operation failed with error.