diff --git a/Lilu/Headers/kern_api.hpp b/Lilu/Headers/kern_api.hpp index c682de95..5aaa9762 100644 --- a/Lilu/Headers/kern_api.hpp +++ b/Lilu/Headers/kern_api.hpp @@ -39,7 +39,8 @@ class LiluAPI { UnsupportedFeature, IncompatibleOS, Disabled, - TooLate + TooLate, + Offline }; /** diff --git a/Lilu/Headers/plugin_start.hpp b/Lilu/Headers/plugin_start.hpp index 42be1478..0f190b1d 100644 --- a/Lilu/Headers/plugin_start.hpp +++ b/Lilu/Headers/plugin_start.hpp @@ -41,7 +41,6 @@ extern bool ADDPR(startSuccess); class EXPORT PRODUCT_NAME : public IOService { OSDeclareDefaultStructors(PRODUCT_NAME) public: - bool init(OSDictionary *dict) override; IOService *probe(IOService *provider, SInt32 *score) override; bool start(IOService *provider) override; void stop(IOService *provider) override; diff --git a/Lilu/Library/plugin_start.cpp b/Lilu/Library/plugin_start.cpp index d04c182d..3f3fe180 100644 --- a/Lilu/Library/plugin_start.cpp +++ b/Lilu/Library/plugin_start.cpp @@ -22,15 +22,6 @@ bool ADDPR(debugEnabled) = false; OSDefineMetaClassAndStructors(PRODUCT_NAME, IOService) -bool PRODUCT_NAME::init(OSDictionary *dict) { - if (!IOService::init(dict)) { - SYSLOG("init", "failed to initalise the parent"); - return false; - } - - return true; -} - IOService *PRODUCT_NAME::probe(IOService *provider, SInt32 *score) { auto service = IOService::probe(provider, score); return ADDPR(startSuccess) ? service : nullptr; diff --git a/Lilu/PrivateHeaders/kern_config.hpp b/Lilu/PrivateHeaders/kern_config.hpp index 7c81d221..a4cd14ea 100644 --- a/Lilu/PrivateHeaders/kern_config.hpp +++ b/Lilu/PrivateHeaders/kern_config.hpp @@ -118,12 +118,17 @@ class Configuration { * Debug for all plugins and Lilu itself */ bool debugForAll {false}; - + /** - * Initialisation status + * Load status (are we allowed to do anything?) + */ + bool startSuccess {false}; + + /** + * Initialisation status (are we done initialising?) */ bool initialised {false}; - + /** * User patcher */ diff --git a/Lilu/PrivateHeaders/kern_start.hpp b/Lilu/PrivateHeaders/kern_start.hpp index 9855dbf0..82a48805 100644 --- a/Lilu/PrivateHeaders/kern_start.hpp +++ b/Lilu/PrivateHeaders/kern_start.hpp @@ -17,7 +17,7 @@ class EXPORT PRODUCT_NAME : public IOService { OSDeclareDefaultStructors(PRODUCT_NAME) public: - bool init(OSDictionary *dict) override; + IOService *probe(IOService *provider, SInt32 *score) override; bool start(IOService *provider) override; void stop(IOService *provider) override; }; diff --git a/Lilu/Sources/kern_api.cpp b/Lilu/Sources/kern_api.cpp index 2dbaab01..29d3364b 100644 --- a/Lilu/Sources/kern_api.cpp +++ b/Lilu/Sources/kern_api.cpp @@ -33,6 +33,9 @@ void LiluAPI::deinit() { } LiluAPI::Error LiluAPI::requestAccess(size_t version, bool check) { + if (!config.startSuccess) + return Error::Offline; + constexpr size_t currversion = parseModuleVersion(xStringify(MODULE_VERSION)); if (version > currversion) { return Error::UnsupportedFeature; diff --git a/Lilu/Sources/kern_start.cpp b/Lilu/Sources/kern_start.cpp index 0f5c631f..9bb86f72 100644 --- a/Lilu/Sources/kern_start.cpp +++ b/Lilu/Sources/kern_start.cpp @@ -18,13 +18,9 @@ OSDefineMetaClassAndStructors(PRODUCT_NAME, IOService) -bool PRODUCT_NAME::init(OSDictionary *dict) { - if (!IOService::init(dict)) { - SYSLOG("init", "failed to initalise the parent"); - return false; - } - - return config.getBootArguments(); +IOService *PRODUCT_NAME::probe(IOService *provider, SInt32 *score) { + auto service = IOService::probe(provider, score); + return config.startSuccess ? service : nullptr; } bool PRODUCT_NAME::start(IOService *provider) { @@ -33,7 +29,7 @@ bool PRODUCT_NAME::start(IOService *provider) { return false; } - return true; + return config.startSuccess; } void PRODUCT_NAME::stop(IOService *provider) { @@ -170,16 +166,15 @@ extern "C" kern_return_t kern_start(kmod_info_t * ki, void *d) { lilu.init(); - if (config.policy.registerPolicy()) { - return KERN_SUCCESS; - } - - SYSLOG("init", "failed to register the policy"); + if (config.policy.registerPolicy()) + config.startSuccess = true; + else + SYSLOG("init", "failed to register the policy"); } - return KERN_FAILURE; + return KERN_SUCCESS; } extern "C" kern_return_t kern_stop(kmod_info_t *ki, void *d) { - return KERN_FAILURE; + return config.startSuccess ? KERN_FAILURE : KERN_SUCCESS; }