Skip to content

Commit 0e2e88b

Browse files
committed
Corrected Lilu initialisation itself in a similar way to plugin initialisation
1 parent 4cf198d commit 0e2e88b

File tree

7 files changed

+24
-30
lines changed

7 files changed

+24
-30
lines changed

Lilu/Headers/kern_api.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ class LiluAPI {
3939
UnsupportedFeature,
4040
IncompatibleOS,
4141
Disabled,
42-
TooLate
42+
TooLate,
43+
Offline
4344
};
4445

4546
/**

Lilu/Headers/plugin_start.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ extern bool ADDPR(startSuccess);
4141
class EXPORT PRODUCT_NAME : public IOService {
4242
OSDeclareDefaultStructors(PRODUCT_NAME)
4343
public:
44-
bool init(OSDictionary *dict) override;
4544
IOService *probe(IOService *provider, SInt32 *score) override;
4645
bool start(IOService *provider) override;
4746
void stop(IOService *provider) override;

Lilu/Library/plugin_start.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,6 @@ bool ADDPR(debugEnabled) = false;
2222

2323
OSDefineMetaClassAndStructors(PRODUCT_NAME, IOService)
2424

25-
bool PRODUCT_NAME::init(OSDictionary *dict) {
26-
if (!IOService::init(dict)) {
27-
SYSLOG("init", "failed to initalise the parent");
28-
return false;
29-
}
30-
31-
return true;
32-
}
33-
3425
IOService *PRODUCT_NAME::probe(IOService *provider, SInt32 *score) {
3526
auto service = IOService::probe(provider, score);
3627
return ADDPR(startSuccess) ? service : nullptr;

Lilu/PrivateHeaders/kern_config.hpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,17 @@ class Configuration {
118118
* Debug for all plugins and Lilu itself
119119
*/
120120
bool debugForAll {false};
121-
121+
122122
/**
123-
* Initialisation status
123+
* Load status (are we allowed to do anything?)
124+
*/
125+
bool startSuccess {false};
126+
127+
/**
128+
* Initialisation status (are we done initialising?)
124129
*/
125130
bool initialised {false};
126-
131+
127132
/**
128133
* User patcher
129134
*/

Lilu/PrivateHeaders/kern_start.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
class EXPORT PRODUCT_NAME : public IOService {
1818
OSDeclareDefaultStructors(PRODUCT_NAME)
1919
public:
20-
bool init(OSDictionary *dict) override;
20+
IOService *probe(IOService *provider, SInt32 *score) override;
2121
bool start(IOService *provider) override;
2222
void stop(IOService *provider) override;
2323
};

Lilu/Sources/kern_api.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ void LiluAPI::deinit() {
3333
}
3434

3535
LiluAPI::Error LiluAPI::requestAccess(size_t version, bool check) {
36+
if (!config.startSuccess)
37+
return Error::Offline;
38+
3639
constexpr size_t currversion = parseModuleVersion(xStringify(MODULE_VERSION));
3740
if (version > currversion) {
3841
return Error::UnsupportedFeature;

Lilu/Sources/kern_start.cpp

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,9 @@
1818

1919
OSDefineMetaClassAndStructors(PRODUCT_NAME, IOService)
2020

21-
bool PRODUCT_NAME::init(OSDictionary *dict) {
22-
if (!IOService::init(dict)) {
23-
SYSLOG("init", "failed to initalise the parent");
24-
return false;
25-
}
26-
27-
return config.getBootArguments();
21+
IOService *PRODUCT_NAME::probe(IOService *provider, SInt32 *score) {
22+
auto service = IOService::probe(provider, score);
23+
return config.startSuccess ? service : nullptr;
2824
}
2925

3026
bool PRODUCT_NAME::start(IOService *provider) {
@@ -33,7 +29,7 @@ bool PRODUCT_NAME::start(IOService *provider) {
3329
return false;
3430
}
3531

36-
return true;
32+
return config.startSuccess;
3733
}
3834

3935
void PRODUCT_NAME::stop(IOService *provider) {
@@ -170,16 +166,15 @@ extern "C" kern_return_t kern_start(kmod_info_t * ki, void *d) {
170166

171167
lilu.init();
172168

173-
if (config.policy.registerPolicy()) {
174-
return KERN_SUCCESS;
175-
}
176-
177-
SYSLOG("init", "failed to register the policy");
169+
if (config.policy.registerPolicy())
170+
config.startSuccess = true;
171+
else
172+
SYSLOG("init", "failed to register the policy");
178173
}
179174

180-
return KERN_FAILURE;
175+
return KERN_SUCCESS;
181176
}
182177

183178
extern "C" kern_return_t kern_stop(kmod_info_t *ki, void *d) {
184-
return KERN_FAILURE;
179+
return config.startSuccess ? KERN_FAILURE : KERN_SUCCESS;
185180
}

0 commit comments

Comments
 (0)