mirror of
https://github.com/pumpitupdev/pumptools.git
synced 2026-09-28 17:58:01 +03:00
Appl new code style on whole code base
Use a similar code style to bemanitools though reduce indentation to 2 spaces. Also some other tweaks to be more similar to google style.
This commit is contained in:
@@ -10,96 +10,91 @@
|
||||
#include "util/log.h"
|
||||
|
||||
/* looks odd but hddd is intentional */
|
||||
static const char* patch_mount_proc_mount_file = "/dev/hddd /mnt/hd";
|
||||
static const char *patch_mount_proc_mount_file = "/dev/hddd /mnt/hd";
|
||||
|
||||
static FILE* patch_mount_file = NULL;
|
||||
static FILE *patch_mount_file = NULL;
|
||||
static bool patch_mount_eof;
|
||||
|
||||
static enum cnh_result patch_hdd_check_filehook(struct cnh_filehook_irp *irp)
|
||||
{
|
||||
enum cnh_result result;
|
||||
enum cnh_result result;
|
||||
|
||||
result = CNH_RESULT_SUCCESS;
|
||||
result = CNH_RESULT_SUCCESS;
|
||||
|
||||
assert(irp);
|
||||
assert(irp);
|
||||
|
||||
if (irp->op != CNH_FILEHOOK_IRP_OP_OPEN && irp->file != patch_mount_file) {
|
||||
if (irp->op != CNH_FILEHOOK_IRP_OP_OPEN && irp->file != patch_mount_file) {
|
||||
return cnh_filehook_invoke_next(irp);
|
||||
}
|
||||
|
||||
switch (irp->op) {
|
||||
case CNH_FILEHOOK_IRP_OP_OPEN: {
|
||||
if (!strcmp(irp->open_filename, "/proc/mounts")) {
|
||||
patch_mount_file = cnh_filehook_open_dummy_file_handle();
|
||||
irp->file = patch_mount_file;
|
||||
|
||||
patch_mount_eof = false;
|
||||
|
||||
log_debug("/proc/mounts opened: %p", irp->file);
|
||||
} else {
|
||||
return cnh_filehook_invoke_next(irp);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
switch (irp->op) {
|
||||
case CNH_FILEHOOK_IRP_OP_OPEN:
|
||||
{
|
||||
if (!strcmp(irp->open_filename, "/proc/mounts")) {
|
||||
patch_mount_file = cnh_filehook_open_dummy_file_handle();
|
||||
irp->file = patch_mount_file;
|
||||
case CNH_FILEHOOK_IRP_OP_FGETS: {
|
||||
size_t size;
|
||||
|
||||
patch_mount_eof = false;
|
||||
log_info("/proc/mounts fake read");
|
||||
|
||||
log_debug("/proc/mounts opened: %p", irp->file);
|
||||
} else {
|
||||
return cnh_filehook_invoke_next(irp);
|
||||
}
|
||||
size = strlen(patch_mount_proc_mount_file) + 1;
|
||||
|
||||
break;
|
||||
}
|
||||
/* +1: copy the null terminator, too */
|
||||
memcpy(
|
||||
&irp->read.bytes[irp->read.pos], patch_mount_proc_mount_file, size);
|
||||
irp->read.pos += size;
|
||||
|
||||
case CNH_FILEHOOK_IRP_OP_FGETS:
|
||||
{
|
||||
size_t size;
|
||||
patch_mount_eof = true;
|
||||
|
||||
log_info("/proc/mounts fake read");
|
||||
|
||||
size = strlen(patch_mount_proc_mount_file) + 1;
|
||||
|
||||
/* +1: copy the null terminator, too */
|
||||
memcpy(&irp->read.bytes[irp->read.pos], patch_mount_proc_mount_file, size);
|
||||
irp->read.pos += size;
|
||||
|
||||
patch_mount_eof = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CNH_FILEHOOK_IRP_OP_SEEK:
|
||||
{
|
||||
/* Ignore seeking */
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CNH_FILEHOOK_IRP_OP_TELL:
|
||||
{
|
||||
/* Return size */
|
||||
irp->tell_offset = strlen(patch_mount_proc_mount_file) + 1;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CNH_FILEHOOK_IRP_OP_EOF:
|
||||
{
|
||||
irp->eof = patch_mount_eof;
|
||||
break;
|
||||
}
|
||||
|
||||
case CNH_FILEHOOK_IRP_OP_CLOSE:
|
||||
{
|
||||
patch_mount_file = NULL;
|
||||
|
||||
/* Actually close dummy handle */
|
||||
return cnh_filehook_invoke_next(irp);
|
||||
}
|
||||
|
||||
default:
|
||||
log_warn("Unhandled file op: %d", irp->op);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
case CNH_FILEHOOK_IRP_OP_SEEK: {
|
||||
/* Ignore seeking */
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CNH_FILEHOOK_IRP_OP_TELL: {
|
||||
/* Return size */
|
||||
irp->tell_offset = strlen(patch_mount_proc_mount_file) + 1;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CNH_FILEHOOK_IRP_OP_EOF: {
|
||||
irp->eof = patch_mount_eof;
|
||||
break;
|
||||
}
|
||||
|
||||
case CNH_FILEHOOK_IRP_OP_CLOSE: {
|
||||
patch_mount_file = NULL;
|
||||
|
||||
/* Actually close dummy handle */
|
||||
return cnh_filehook_invoke_next(irp);
|
||||
}
|
||||
|
||||
default:
|
||||
log_warn("Unhandled file op: %d", irp->op);
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void patch_mounts_init(void)
|
||||
{
|
||||
cnh_filehook_push_handler(patch_hdd_check_filehook);
|
||||
log_info("Initialized");
|
||||
cnh_filehook_push_handler(patch_hdd_check_filehook);
|
||||
log_info("Initialized");
|
||||
}
|
||||
Reference in New Issue
Block a user