░▒▓████████████████████████████████▓▒░ ░▒▓█ ▓▒░ ░▒▓█ ~ S W A M P ~ ▓▒░ ░▒▓█ ▓▒░ ░▒▓████████████████████████████████▓▒░
pplmvsvm
LOCATION:
/usr/src/microsoft-dependency-agent-9.10.17/src/linux/bluechannel
☗ ROOT
↻ REFRESH
✎ CARVE FLESH
EDITING: bs_eventchannel.c
#include "../bs_driver.h" #include "version.h" #include "../../common/bluechannel.h" static int bluechannel_open(struct inode *inode, struct file *file); static ssize_t bluechannel_read(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos); static ssize_t bluechannel_write(struct file *file, const char __user *buffer, size_t buflen, loff_t *fpos); static int bluechannel_release(struct inode *inode, struct file *file); int bluechannel_debug=1; static char *bluechannel_version = COLLECTOR_VERSION "-r" COLLECTOR_REVISION; module_param(bluechannel_debug, int, S_IRUSR | S_IWUSR); module_param(bluechannel_version, charp, S_IRUSR); static struct file_operations bluechannel_fops = { .owner = THIS_MODULE, .open = bluechannel_open, .read = bluechannel_read, .write = bluechannel_write, .release = bluechannel_release, }; /* globals */ bluechannel_control_t bluechannel_control = { .ver_info = { ._api_version = BLUECHANNEL_LINK_API_VERSION, ._release = COLLECTOR_VERSION, ._revision = COLLECTOR_REVISION_NUM }, .unloadable = COMPLETION_INITIALIZER(bluechannel_control.unloadable), }; static struct miscdevice bluechannel_dev = { MISC_DYNAMIC_MINOR, "bluechannel", &bluechannel_fops }; static void cleanup(void) { bluechannel_common_fini(); if (bluechannel_dev.minor != MISC_DYNAMIC_MINOR) misc_deregister(&bluechannel_dev); memset(&bluechannel_dev, 0, sizeof(bluechannel_dev)); bluechannel_set_state(BLUECHANNEL_UNCONFIGURED); } static int __init init_driver(void) { int ret=0; info_msg("bluechannel: driver loading ver=" COLLECTOR_VERSION " rev=" COLLECTOR_REVISION); bs_init_spinlock(&bluechannel_control.state_lock); if (bluechannel_state_transition(BLUECHANNEL_UNCONFIGURED, BLUECHANNEL_CONFIGURING) == -1) { err_msg("bluechannel: unexpected driver state during init: 0x%x", bluechannel_control.bluechannel_state); return -EINVAL; } if ((ret = bluechannel_common_init()) != 0) { err_msg("bluechannel: unable to initialize the bc common layer"); cleanup(); return ret; } if ((ret = misc_register(&bluechannel_dev)) != 0) { err_msg("bluechannel: unable to register bluechannel misc device"); cleanup(); return ret; } bluechannel_set_state(BLUECHANNEL_READY); return ret; } static void __exit exit_driver(void) { bluechannel_set_state(BLUECHANNEL_UNCONFIGURING); cleanup(); bs_destroy_spinlock(&bluechannel_control.state_lock); info_msg("bluechannel: driver unloaded ver=" COLLECTOR_VERSION " rev=" COLLECTOR_REVISION); } module_init(init_driver); module_exit(exit_driver); MODULE_AUTHOR("Microsoft Corporation http://www.microsoft.com/oms"); MODULE_DESCRIPTION("Microsoft Dependency Agent Event Channel"); MODULE_LICENSE("Proprietary"); static int bluechannel_copy_user_to_kernel(void __user *src, void *dst, int len) { if (copy_from_user(dst, src, len)) return -1; return len; } static int bluechannel_copy_kernel_to_user(void *src, void __user *dst, int len) { if (copy_to_user(dst, src, len)) return -1; return len; } static int bluechannel_open(struct inode *inode, struct file *file) { bluechannel_context_t *chan=NULL; int ret = bluechannel_common_open(&chan); if (ret == 0) { file->private_data = chan; dbg_msg("bluechannel: channel open file=%p private=%p", file, file->private_data); } return ret; } static ssize_t bluechannel_read(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos) { bluechannel_context_t *chan_context = (bluechannel_context_t *)file->private_data; // Returns buflen for success, -errno on failure int ret = bluechannel_common_read(chan_context, (void*)buffer, buflen, bluechannel_copy_kernel_to_user); // Linux returns buflen for success, -errno on failure return ret; } static ssize_t bluechannel_write(struct file *file, const char __user *buffer, size_t buflen, loff_t *fpos) { bluechannel_context_t *chan_context = (bluechannel_context_t *)file->private_data; // Returns bytes written for success, -errno on failure return bluechannel_common_write(chan_context, (void*)buffer, buflen, bluechannel_copy_user_to_kernel); } static int bluechannel_release(struct inode *inode, struct file *file) { dbg_msg("bluechannel: channel release file=%p private=%p", file, file->private_data); bluechannel_common_close(file->private_data); file->private_data = NULL; return 0; }
CANCEL
Name
Type
Size
Modified
Actions
↩ ..
DIR
—
—
📄 bs_eventchannel.c
C
4.3 KB
2023-08-24 04:02
EDIT
📄 Makefile
?
1 KB
2023-08-24 04:02
EDIT
📄 version.h
H
269 B
2023-08-24 04:02
EDIT