Chameleon

Chameleon Commit Details

Date:2018-10-14 20:00:06 (3 months 9 days ago)
Author:ErmaC
Commit:2913
Parents: 2912
Message:Installer improvements (credits to: Micky1979)
Changes:
M/trunk/i386/libsaio/disk.c
M/branches/ErmaC/Enoch/i386/libsaio/disk.c

File differences

trunk/i386/libsaio/disk.c
17131713
17141714
17151715
1716
17161717
17171718
17181719
......
17401741
17411742
17421743
1743
1744
17441745
17451746
17461747
......
17491750
17501751
17511752
1752
1753
17531754
17541755
17551756
......
17571758
17581759
17591760
1760
1761
17611762
1763
17621764
17631765
17641766
......
17741776
17751777
17761778
1777
1779
17781780
17791781
17801782
......
18241826
18251827
18261828
1829
1830
1831
1832
1833
1834
18271835
18281836
18291837
......
18581866
18591867
18601868
1861
1869
18621870
18631871
18641872
......
18871895
18881896
18891897
1898
1899
1900
18901901
1891
1902
18921903
18931904
18941905
......
19091920
19101921
19111922
1923
1924
19121925
19131926
19141927
......
19301943
19311944
19321945
1933
1946
19341947
19351948
19361949
19371950
19381951
19391952
1953
19401954
19411955
19421956
......
19531967
19541968
19551969
1956
1970
19571971
19581972
19591973
......
19611975
19621976
19631977
1978
1979
1980
1981
1982
1983
1984
1985
19641986
19651987
1988
1989
1990
1991
1992
1993
1994
19661995
19671996
19681997
......
19732002
19742003
19752004
1976
2005
19772006
19782007
19792008
......
19842013
19852014
19862015
1987
2016
19882017
19892018
19902019
......
19932022
19942023
19952024
1996
2025
19972026
19982027
19992028
......
20032032
20042033
20052034
2035
2036
2037
2038
2039
2040
2041
20062042
20072043
20082044
2009
2045
20102046
20112047
20122048
......
20152051
20162052
20172053
2018
2054
20192055
20202056
20212057
char *SierraPattern= "Install%20macOS%20Sierra";// Install macOS Sierra
char *HSierraPattern= "Install%20macOS%20High%20Sierra";// Install macOS High Sierra
char *HSierraPatternB= "Install%20macOS%2010.13";// Install macOS 10.13
char *MojavePattern= "Install%20macOS%20Mojave";// Install macOS Mojave
/*
* Only look for OS Version on HFS+
// is an installer or a system to Upgrade OSX?
snprintf(dirSpec, sizeof(dirSpec), "hd(%d,%d)/.IAProductInfo", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &configFile))
if (loadConfigFile(dirSpec, &configFile) == 0)
{
valid = true;
}
{
// is createinstallmedia?
snprintf(dirSpec, sizeof(dirSpec), "hd(%d,%d)/.IABootFilesSystemVersion.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &configFile))
if (loadConfigFile(dirSpec, &configFile) == 0)
{
valid = false;
}
{
// if not exist probably is a vanilla installer made w/o createinstallermedia method
snprintf(dirSpec, sizeof(dirSpec), "hd(%d,%d)/.IABootFiles/com.apple.Boot.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &configFile))
if (loadConfigFile(dirSpec, &configFile) == 0)
{
strncpy(bvr->comAppleBoot, dirSpec, strlen(dirSpec));
valid = true;
}
else
* we don't know the real OS version, but "Kernel Flags" key contain the URL path to the app..
* and we try to see if contain a match for our patterns ("Install%20OS%20X%20El%20Capitan" = 10.11)
*/
if (getValueForKey("Kernel Flags", &val, &len, &configFile))
if (getValueForKey(kKernelFlagsKey, &val, &len, &configFile))
{
if(strstr(val, LionPattern))
{
fakeOSVersionInt = 13;
valid = true;
}
else if(strstr(val, MojavePattern))
{
fakeOSVersion = "10.14";
fakeOSVersionInt = 14;
valid = true;
}
else
{
valid = false;
len = 0; val = 0;
// 10.9 and later use "/OS X Install Data" folder
snprintf(dirSpec, sizeof(dirSpec), "hd(%d,%d)/OS X Install Data/com.apple.Boot.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &configFile))
if (loadConfigFile(dirSpec, &configFile) == 0)
{
/*
* bad is that we can't find what is the exactly Major OS version..
case 13:
fakeOSVersion = "10.13";
break;
case 14:
fakeOSVersion = "10.14";
break;
default:
fakeOSVersion = "10.13";
fakeOSVersion = "10.14";
break;
}
strncpy( bvr->OSFullVer, fakeOSVersion, strlen(fakeOSVersion) );
bvr->OSisOSXUpgrade = true;
strncpy( bvr->OSBuildVer, "UPGRADE", strlen("UPGRADE") );
strncpy(bvr->comAppleBoot, dirSpec, strlen(dirSpec));
return true;
}
}
* Not valid? 10.8 and older use "/Mac OS X Install Data" folder..
*/
snprintf(dirSpec, sizeof(dirSpec), "hd(%d,%d)/Mac OS X Install Data/com.apple.Boot.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &configFile))
if (loadConfigFile(dirSpec, &configFile) == 0)
{
fakeOSVersion = "10.8"; // fake the OS version using 10.8.. just to find the kernelcache path for 10.7 and 10.8..
strncpy( bvr->OSFullVer, fakeOSVersion, strlen(fakeOSVersion) );
bvr->OSisMacOSXUpgrade = true;
// again no SystemVersion.plist, so no build version.. but is usefull to know that is a System upgrade..
strncpy( bvr->OSBuildVer, "UPGRADE", strlen("UPGRADE") );
strncpy(bvr->comAppleBoot, dirSpec, strlen(dirSpec));
return true;
}
}
"hd(%d,%d)/macOS Install Data/Locked Files/Boot Files/SystemVersion.plist",
BIOS_DEV_UNIT(bvr),
bvr->part_no);
if (!loadConfigFile(dirSpec, &configFile))
if (loadConfigFile(dirSpec, &configFile) == 0)
{
if (getValueForKey(kProductVersion, &val, &len, &configFile))
{
strncpy( bvr->OSFullVer, val, len );
bvr->OSFullVer[len] = '\0'; /* null character manually added */
// getValueForKey uses const char for val
// so copy it and trim
*str = '\0';
strncat(str, val, MIN(len, 5));
if(str[4] == '.')
{
str[4] = '\0';
}
bvr->OSisOSXUpgrade = true;
strncpy( bvr->OSBuildVer, "UPGRADE", strlen("UPGRADE") );
len = 0; val = 0;
snprintf(dirSpec, sizeof(dirSpec), "hd(%d,%d)/macOS Install Data/Locked Files/Boot Files/com.apple.Boot.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (loadConfigFile(dirSpec, &configFile) == 0)
{
strncpy(bvr->comAppleBoot, dirSpec, strlen(dirSpec));
}
return true;
}
}
// OS X Installer createinstallermedia method for 10.9 and newer.
snprintf(dirSpec, sizeof(dirSpec), "hd(%d,%d)/.IABootFilesSystemVersion.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &configFile))
if (loadConfigFile(dirSpec, &configFile) == 0)
{
bvr->OSisInstaller = true;
valid = true;
{
snprintf(dirSpec, sizeof(dirSpec), "hd(%d,%d)/System/Library/CoreServices/SystemVersion.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &configFile))
if (loadConfigFile(dirSpec, &configFile) == 0)
{
valid = true;
}
// OS X Server
snprintf(dirSpec, sizeof(dirSpec), "hd(%d,%d)/System/Library/CoreServices/ServerVersion.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &configFile))
if (loadConfigFile(dirSpec, &configFile) == 0)
{
bvr->OSisServer = true;
valid = true;
if (!valid)
{
len = 0; val = 0;
snprintf(dirSpec, sizeof(dirSpec), "hd(%d,%d)/com.apple.recovery.boot/com.apple.Boot.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (loadConfigFile(dirSpec, &configFile) == 0)
{
strncpy(bvr->comAppleBoot, dirSpec, strlen(dirSpec));
}
// OS X Recovery
sprintf(dirSpec, "hd(%d,%d)/com.apple.recovery.boot/SystemVersion.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &configFile))
if (loadConfigFile(dirSpec, &configFile) == 0)
{
bvr->OSisRecovery = true;
valid = true;
if (valid)
{
len = 0; val = 0;
// ProductVersion
if (getValueForKey(kProductVersion, &val, &len, &configFile))
{
branches/ErmaC/Enoch/i386/libsaio/disk.c
17131713
17141714
17151715
1716
17161717
17171718
17181719
......
17401741
17411742
17421743
1743
1744
17441745
17451746
17461747
......
17491750
17501751
17511752
1752
1753
17531754
17541755
17551756
......
17571758
17581759
17591760
1760
1761
17611762
1763
17621764
17631765
17641766
......
17741776
17751777
17761778
1777
1779
17781780
17791781
17801782
......
18241826
18251827
18261828
1829
1830
1831
1832
1833
1834
18271835
18281836
18291837
......
18581866
18591867
18601868
1861
1869
18621870
18631871
18641872
......
18871895
18881896
18891897
1898
1899
1900
18901901
1891
1902
18921903
18931904
18941905
......
19091920
19101921
19111922
1923
1924
19121925
19131926
19141927
......
19301943
19311944
19321945
1933
1946
19341947
19351948
19361949
19371950
19381951
19391952
1953
19401954
19411955
19421956
......
19531967
19541968
19551969
1956
1970
19571971
19581972
19591973
......
19611975
19621976
19631977
1978
1979
1980
1981
1982
1983
1984
1985
19641986
19651987
1988
1989
1990
1991
1992
1993
1994
19661995
19671996
19681997
......
19732002
19742003
19752004
1976
2005
19772006
19782007
19792008
......
19842013
19852014
19862015
1987
2016
19882017
19892018
19902019
......
19932022
19942023
19952024
1996
2025
19972026
19982027
19992028
......
20032032
20042033
20052034
2035
2036
2037
2038
2039
2040
2041
20062042
20072043
20082044
2009
2045
20102046
20112047
20122048
......
20152051
20162052
20172053
2018
2054
20192055
20202056
20212057
char *SierraPattern= "Install%20macOS%20Sierra";// Install macOS Sierra
char *HSierraPattern= "Install%20macOS%20High%20Sierra";// Install macOS High Sierra
char *HSierraPatternB= "Install%20macOS%2010.13";// Install macOS 10.13
char *MojavePattern= "Install%20macOS%20Mojave";// Install macOS Mojave
/*
* Only look for OS Version on HFS+
// is an installer or a system to Upgrade OSX?
snprintf(dirSpec, sizeof(dirSpec), "hd(%d,%d)/.IAProductInfo", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &configFile))
if (loadConfigFile(dirSpec, &configFile) == 0)
{
valid = true;
}
{
// is createinstallmedia?
snprintf(dirSpec, sizeof(dirSpec), "hd(%d,%d)/.IABootFilesSystemVersion.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &configFile))
if (loadConfigFile(dirSpec, &configFile) == 0)
{
valid = false;
}
{
// if not exist probably is a vanilla installer made w/o createinstallermedia method
snprintf(dirSpec, sizeof(dirSpec), "hd(%d,%d)/.IABootFiles/com.apple.Boot.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &configFile))
if (loadConfigFile(dirSpec, &configFile) == 0)
{
strncpy(bvr->comAppleBoot, dirSpec, strlen(dirSpec));
valid = true;
}
else
* we don't know the real OS version, but "Kernel Flags" key contain the URL path to the app..
* and we try to see if contain a match for our patterns ("Install%20OS%20X%20El%20Capitan" = 10.11)
*/
if (getValueForKey("Kernel Flags", &val, &len, &configFile))
if (getValueForKey(kKernelFlagsKey, &val, &len, &configFile))
{
if(strstr(val, LionPattern))
{
fakeOSVersionInt = 13;
valid = true;
}
else if(strstr(val, MojavePattern))
{
fakeOSVersion = "10.14";
fakeOSVersionInt = 14;
valid = true;
}
else
{
valid = false;
len = 0; val = 0;
// 10.9 and later use "/OS X Install Data" folder
snprintf(dirSpec, sizeof(dirSpec), "hd(%d,%d)/OS X Install Data/com.apple.Boot.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &configFile))
if (loadConfigFile(dirSpec, &configFile) == 0)
{
/*
* bad is that we can't find what is the exactly Major OS version..
case 13:
fakeOSVersion = "10.13";
break;
case 14:
fakeOSVersion = "10.14";
break;
default:
fakeOSVersion = "10.13";
fakeOSVersion = "10.14";
break;
}
strncpy( bvr->OSFullVer, fakeOSVersion, strlen(fakeOSVersion) );
bvr->OSisOSXUpgrade = true;
strncpy( bvr->OSBuildVer, "UPGRADE", strlen("UPGRADE") );
strncpy(bvr->comAppleBoot, dirSpec, strlen(dirSpec));
return true;
}
}
* Not valid? 10.8 and older use "/Mac OS X Install Data" folder..
*/
snprintf(dirSpec, sizeof(dirSpec), "hd(%d,%d)/Mac OS X Install Data/com.apple.Boot.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &configFile))
if (loadConfigFile(dirSpec, &configFile) == 0)
{
fakeOSVersion = "10.8"; // fake the OS version using 10.8.. just to find the kernelcache path for 10.7 and 10.8..
strncpy( bvr->OSFullVer, fakeOSVersion, strlen(fakeOSVersion) );
bvr->OSisMacOSXUpgrade = true;
// again no SystemVersion.plist, so no build version.. but is usefull to know that is a System upgrade..
strncpy( bvr->OSBuildVer, "UPGRADE", strlen("UPGRADE") );
strncpy(bvr->comAppleBoot, dirSpec, strlen(dirSpec));
return true;
}
}
"hd(%d,%d)/macOS Install Data/Locked Files/Boot Files/SystemVersion.plist",
BIOS_DEV_UNIT(bvr),
bvr->part_no);
if (!loadConfigFile(dirSpec, &configFile))
if (loadConfigFile(dirSpec, &configFile) == 0)
{
if (getValueForKey(kProductVersion, &val, &len, &configFile))
{
strncpy( bvr->OSFullVer, val, len );
bvr->OSFullVer[len] = '\0'; /* null character manually added */
// getValueForKey uses const char for val
// so copy it and trim
*str = '\0';
strncat(str, val, MIN(len, 5));
if(str[4] == '.')
{
str[4] = '\0';
}
bvr->OSisOSXUpgrade = true;
strncpy( bvr->OSBuildVer, "UPGRADE", strlen("UPGRADE") );
len = 0; val = 0;
snprintf(dirSpec, sizeof(dirSpec), "hd(%d,%d)/macOS Install Data/Locked Files/Boot Files/com.apple.Boot.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (loadConfigFile(dirSpec, &configFile) == 0)
{
strncpy(bvr->comAppleBoot, dirSpec, strlen(dirSpec));
}
return true;
}
}
// OS X Installer createinstallermedia method for 10.9 and newer.
snprintf(dirSpec, sizeof(dirSpec), "hd(%d,%d)/.IABootFilesSystemVersion.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &configFile))
if (loadConfigFile(dirSpec, &configFile) == 0)
{
bvr->OSisInstaller = true;
valid = true;
{
snprintf(dirSpec, sizeof(dirSpec), "hd(%d,%d)/System/Library/CoreServices/SystemVersion.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &configFile))
if (loadConfigFile(dirSpec, &configFile) == 0)
{
valid = true;
}
// OS X Server
snprintf(dirSpec, sizeof(dirSpec), "hd(%d,%d)/System/Library/CoreServices/ServerVersion.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &configFile))
if (loadConfigFile(dirSpec, &configFile) == 0)
{
bvr->OSisServer = true;
valid = true;
if (!valid)
{
len = 0; val = 0;
snprintf(dirSpec, sizeof(dirSpec), "hd(%d,%d)/com.apple.recovery.boot/com.apple.Boot.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (loadConfigFile(dirSpec, &configFile) == 0)
{
strncpy(bvr->comAppleBoot, dirSpec, strlen(dirSpec));
}
// OS X Recovery
sprintf(dirSpec, "hd(%d,%d)/com.apple.recovery.boot/SystemVersion.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &configFile))
if (loadConfigFile(dirSpec, &configFile) == 0)
{
bvr->OSisRecovery = true;
valid = true;
if (valid)
{
len = 0; val = 0;
// ProductVersion
if (getValueForKey(kProductVersion, &val, &len, &configFile))
{

Archive Download the corresponding diff file

Revision: 2913