Remove panic at start if there is no kexts dir.

This commit is contained in:
jief666 2020-10-05 12:14:35 +03:00
parent dcd17ca8cd
commit d12acc1ec5
3 changed files with 31 additions and 17 deletions

View File

@ -116,19 +116,29 @@ EFI_STATUS SelfOem::_initialize()
DBG("Oem dir = %ls\n", (*this).getOemFullPath().wc_str());
Status = m_OemDir->Open(m_OemDir, &m_KextsDir, KEXTS_DIRNAME.wc_str(), EFI_FILE_MODE_READ, 0);
if ( Status != EFI_SUCCESS && Status != EFI_NOT_FOUND ) {
panic("Cannot open kexts dir %ls\\%ls : %s", getOemFullPath().wc_str(), KEXTS_DIRNAME.wc_str(), efiStrError(Status));
if ( EFI_ERROR(Status) ) {
DBG("Cannot open %ls\\%ls : %s", getOemFullPath().wc_str(), KEXTS_DIRNAME.wc_str(), efiStrError(Status));
}
if ( Status == EFI_NOT_FOUND ) {
// if ( Status != EFI_SUCCESS && Status != EFI_NOT_FOUND ) {
// panic("Cannot open kexts dir %ls\\%ls : %s", getOemFullPath().wc_str(), KEXTS_DIRNAME.wc_str(), efiStrError(Status));
// }
if ( EFI_ERROR(Status) ) {
Status = self.getCloverDir().Open(&self.getCloverDir(), &m_KextsDir, KEXTS_DIRNAME.wc_str(), EFI_FILE_MODE_READ, 0);
if ( EFI_ERROR(Status) ) panic("Cannot open kexts dir at '%ls\\%ls'", self.getCloverDirPathAsXStringW().wc_str(), KEXTS_DIRNAME.wc_str());
m_KextsPathRelToSelfDir = KEXTS_DIRNAME;
m_KextsFullPath.SWPrintf("%ls\\%ls", self.getCloverDirPathAsXStringW().wc_str(), KEXTS_DIRNAME.wc_str());
if ( EFI_ERROR(Status) ) {
DBG("Cannot open %ls\\%ls : %s", self.getCloverDirPathAsXStringW().wc_str(), KEXTS_DIRNAME.wc_str(), efiStrError(Status));
//panic("Cannot open kexts dir at '%ls\\%ls'", self.getCloverDirPathAsXStringW().wc_str(), KEXTS_DIRNAME.wc_str());
m_KextsDir = NULL;
m_KextsPathRelToSelfDir.setEmpty();
m_KextsFullPath.setEmpty();
}else{
m_KextsPathRelToSelfDir = KEXTS_DIRNAME;
m_KextsFullPath.SWPrintf("%ls\\%ls", self.getCloverDirPathAsXStringW().wc_str(), KEXTS_DIRNAME.wc_str());
}
}else{
m_KextsPathRelToSelfDir.SWPrintf("%ls\\%ls", getOemPathRelToSelfDir().wc_str(), KEXTS_DIRNAME.wc_str());
m_KextsFullPath.SWPrintf("%ls\\%ls", getOemFullPath().wc_str(), KEXTS_DIRNAME.wc_str());
}
DBG("Kexts dir = '%ls'\n", getKextsFullPath().wc_str());
DBG("Kexts dir = '%ls'\n", m_KextsFullPath.wc_str()); // do not use 'getKextsFullPath()', it could panic
return EFI_SUCCESS;
}

View File

@ -47,9 +47,10 @@ public:
const XStringW& getOemPathRelToSelfDir() { return m_OemPathRelToSelfDir; }
const XStringW& getOemFullPath() { return m_OemFulPath; }
const EFI_FILE& getKextsDir() { return *m_KextsDir; }
const XStringW& getKextsPathRelToSelfDir() { return m_KextsPathRelToSelfDir; }
const XStringW& getKextsFullPath() { return m_KextsFullPath; }
bool isKextsDirFound() { return m_KextsDir != NULL; }
const EFI_FILE& getKextsDir() { if ( m_KextsDir == NULL) panic("Kexts dir wasn't found at initialization"); return *m_KextsDir; }
const XStringW& getKextsPathRelToSelfDir() { if ( m_KextsDir == NULL) panic("Kexts dir wasn't found at initialization"); return m_KextsPathRelToSelfDir; }
const XStringW& getKextsFullPath() { if ( m_KextsDir == NULL) panic("Kexts dir wasn't found at initialization"); return m_KextsFullPath; }
};

View File

@ -3303,15 +3303,17 @@ void InitKextList()
}
// KextsPath = SWPrintf("%ls\\kexts", OEMPath.wc_str());
// Iterate over kexts directory
DirIterOpen(&selfOem.getKextsDir(), NULL, &KextsIter);
while (DirIterNext(&KextsIter, 1, L"*", &FolderEntry)) {
if (FolderEntry->FileName[0] == L'.') {
continue;
if ( selfOem.isKextsDirFound() ) {
// Iterate over kexts directory
DirIterOpen(&selfOem.getKextsDir(), NULL, &KextsIter);
while (DirIterNext(&KextsIter, 1, L"*", &FolderEntry)) {
if (FolderEntry->FileName[0] == L'.') {
continue;
}
GetListOfInjectKext(FolderEntry->FileName);
}
GetListOfInjectKext(FolderEntry->FileName);
DirIterClose(&KextsIter);
}
DirIterClose(&KextsIter);
}
#define CONFIG_THEME_FILENAME L"theme.plist"
@ -8058,6 +8060,7 @@ SaveSettings ()
XStringW GetOtherKextsDir (BOOLEAN On)
{
if ( !selfOem.isKextsDirFound() ) return NullXStringW;
if ( FileExists(&selfOem.getKextsDir(), On ? L"Other" : L"Off") ) {
return On ? L"Other"_XSW : L"Off"_XSW;
}