Added "UnloadDriver" function

This commit is contained in:
Alex 2022-12-17 18:21:28 +02:00
parent ed49b3ab7c
commit 32e8eecc69
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD
2 changed files with 23 additions and 0 deletions

View File

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

View File

@ -64,6 +64,7 @@ namespace Driver
public:
Vector<DriverFile *> 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();