diff --git a/Core/Driver/Driver.cpp b/Core/Driver/Driver.cpp index 8bb5f07..cf45f33 100644 --- a/Core/Driver/Driver.cpp +++ b/Core/Driver/Driver.cpp @@ -48,6 +48,28 @@ namespace Driver } } + bool Driver::UnloadDriver(unsigned long DUID) + { + foreach (DriverFile *drv in DriverManager->GetDrivers()) + if (drv->DriverUID == DUID) + { + KernelCallback callback; + memset(&callback, 0, sizeof(KernelCallback)); + callback.Reason = StopReason; + debug("Stopping & unloading driver %ld [%#lx]", drv->DriverUID, drv->Address); + DriverManager->IOCB(drv->DriverUID, (void *)&callback); + + for (size_t i = 0; i < sizeof(drv->InterruptHook) / sizeof(drv->InterruptHook[0]); i++) + { + if (!drv->InterruptHook[i]) + continue; + delete drv->InterruptHook[i]; + } + return true; + } + return false; + } + int Driver::IOCB(unsigned long DUID, void *KCB) { foreach (auto var in Drivers) diff --git a/include/driver.hpp b/include/driver.hpp index 4d21652..76a3a65 100644 --- a/include/driver.hpp +++ b/include/driver.hpp @@ -64,6 +64,7 @@ namespace Driver public: Vector GetDrivers() { return Drivers; } void UnloadAllDrivers(); + bool UnloadDriver(unsigned long DUID); int IOCB(unsigned long DUID, /* KernelCallback */ void *KCB); DriverCode LoadDriver(uint64_t DriverAddress, uint64_t Size); DriverCode StartDrivers();