Skip to content

Commit

Permalink
Corrected Lilu initialisation itself in a similar way to plugin initi…
Browse files Browse the repository at this point in the history
…alisation
  • Loading branch information
vit9696 committed Oct 7, 2017
1 parent 4cf198d commit 0e2e88b
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 30 deletions.
3 changes: 2 additions & 1 deletion Lilu/Headers/kern_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class LiluAPI {
UnsupportedFeature,
IncompatibleOS,
Disabled,
TooLate
TooLate,
Offline
};

/**
Expand Down
1 change: 0 additions & 1 deletion Lilu/Headers/plugin_start.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 0 additions & 9 deletions Lilu/Library/plugin_start.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 8 additions & 3 deletions Lilu/PrivateHeaders/kern_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
2 changes: 1 addition & 1 deletion Lilu/PrivateHeaders/kern_start.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
3 changes: 3 additions & 0 deletions Lilu/Sources/kern_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
25 changes: 10 additions & 15 deletions Lilu/Sources/kern_start.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -33,7 +29,7 @@ bool PRODUCT_NAME::start(IOService *provider) {
return false;
}

return true;
return config.startSuccess;
}

void PRODUCT_NAME::stop(IOService *provider) {
Expand Down Expand Up @@ -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;
}

0 comments on commit 0e2e88b

Please sign in to comment.