Chameleon

Chameleon Commit Details

Date:2015-01-26 01:19:59 (4 years 6 months ago)
Author:ErmaC
Commit:2560
Parents: 2559
Message:Added MacOSVerCurrent and MacOSVer2Int function to use instead of macros, fixed bug in gDarwinBuildVerStr extracting.
Changes:
M/trunk/i386/boot2/drivers.c
M/trunk/i386/libsaio/saio_types.h
M/trunk/i386/libsaio/bootargs.h
M/trunk/i386/boot2/boot.c
M/trunk/i386/boot2/boot.h
M/trunk/CHANGES
M/trunk/i386/libsaio/saio_internal.h
M/trunk/i386/boot2/options.c

File differences

trunk/i386/libsaio/bootargs.h
222222
223223
224224
225
226
227225
} boot_args_pre_lion;
extern char gMacOSVersion[8];
#endif /* _PEXPERT_I386_BOOT_H */
trunk/i386/libsaio/saio_types.h
182182
183183
184184
185
185
186
186187
187188
188189
......
209210
210211
211212
212
213
213214
214
215
215216
216217
217218
BVRef dir_bvr;/* volume reference */
};
#define BVSTRLEN 32
#define BVSTRLEN 36 // changed from 32 to 36 due to gpt partition name length
#define OSVERSTRLEN 9
struct BootVolume {
BVRefnext;/* list linkage pointer */
charaltlabel[BVSTRLEN];/* alternate partition volume label */
boolfiltered;/* newFilteredBVChain() will set to TRUE */
boolvisible;/* will shown in the device list */
charOSVersion[8];
charOSVersion[OSVERSTRLEN]; /* Null terminated string from '/System/Library/CoreServices/SystemVersion.plist/ProductVersion' e.g. "10.10.10" - hope will not reach e.g. 111.222.333 soon:) If so, OSVERSTRLEN 9 change to 12 */
boolOSisServer;/* 1 = OS X server , 0 = OS X client */
boolOSisInstaller;/* 1 = OS X Install partition / recover partition , 0 = OS X Install */
boolOSisInstaller;/* 1 = OS X Install partition / recovery partition , 0 = OS X Install */
};
trunk/i386/libsaio/saio_internal.h
223223
224224
225225
226
227
228
229
230
226231
// Base64-decode.c
char *BASE64Decode(const char* src, int in_len, int* out_len);
// options.c
extern char gMacOSVersion[OSVERSTRLEN];
extern uint32_t MacOSVerCurrent;
extern uint32_t MacOSVer2Int(const char *osver);
#endif /* !__LIBSAIO_SAIO_INTERNAL_H */
trunk/i386/boot2/drivers.c
116116
117117
118118
119
120
119
120
121121
122122
123123
......
981981
982982
983983
984
985
986
987
984
985
986
987
988
989
988990
989
991
992
993
994
995
996
997
998
990999
9911000
9921001
static char*gFileSpec;
static char*gTempSpec;
static char*gFileName;
// Bungo
char *gDarwinBuildVerStr = "Darwin Kernel Version";
// Bungo:
char gDarwinBuildVerStr[256] = "Darwin Kernel Version";
/*static*/ unsigned long
Adler32( unsigned char *buffer, long length )
ret = ThinFatFile(&binary, &len);
}
// Bungo: no range checking, sorry
size = 0;
while (memcmp((uint8_t *)binary + size, (uint8_t *)gDarwinBuildVerStr, 21)) {
size++;
// Bungo: scan binary for Darwin Kernel Version string
uint32_t offset = 0;
strncpy(gDarwinBuildVerStr, "Darwin Kernel Version", sizeof(gDarwinBuildVerStr));
while ((offset < 0xFFFFFFFF - (uint32_t)binary - 256) && memcmp(binary + offset, gDarwinBuildVerStr, 21))
{
offset++;
}
gDarwinBuildVerStr = (char *)binary + size;
if (offset < 0xFFFFFFFF - (uint32_t)binary - 256)
{
strncpy(gDarwinBuildVerStr, (char *)(binary + offset), sizeof(gDarwinBuildVerStr));
}
else
{
strcat(gDarwinBuildVerStr, ": Unknown");
}
// Notify modules that the kernel has been decompressed, thinned and is about to be decoded
execute_hook("DecodeKernel", (void *)binary, NULL, NULL, NULL);
trunk/i386/boot2/boot.c
8484
8585
8686
87
8887
8988
9089
......
871870
872871
873872
873
874
875
876
877
878
874879
875880
876881
chargRootDevice[ROOT_DEVICE_SIZE];
chargMKextName[512];
chargMacOSVersion[8];
intbvCount = 0;
intgDeviceCount = 0;
//intmenucount = 0;
}
}
uint32_t getMacOSVerCurrent()
{
MacOSVerCurrent = MacOSVer2Int(gBootVolume->OSVersion);
return MacOSVerCurrent;
}
#define BASE 65521L /* largest prime smaller than 65536 */
#define NMAX 5000
// NMAX (was 5521) the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1
trunk/i386/boot2/boot.h
231231
232232
233233
234
234
235
236
235237
236238
237239
......
277279
278280
279281
280
281
282
283
282284
283285
284286
extern void initialize_runtime();
extern void common_boot(int biosdev);
bool checkOSVersion(const char * version);
extern bool checkOSVersion(const char * version);
extern uint32_t getMacOSVerCurrent();
/*
* usb.c
*/
extern long LoadDrivers(char * dirSpec);
extern long DecodeKernel(void *binary, entry_t *rentry, char **raddr, int *rsize);
typedef long (*FileLoadDrivers_t)(char *dirSpec, long plugin);
// Bungo
extern char *gDarwinBuildVerStr;
// Bungo:
extern char gDarwinBuildVerStr[256];
/*!
Hookable function pointer called during the driver loading phase that
trunk/i386/boot2/options.c
3838
3939
4040
41
42
4143
4244
4345
......
6567
6668
6769
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
68117
69118
70119
#define DBG(x...)msglog(x)
#endif
chargMacOSVersion[OSVERSTRLEN];
uint32_tMacOSVerCurrent = 0;
boolshowBootBanner = true; //Azi:showinfo
static boolshouldboot = false;
//==========================================================================
// MacOSVer2Int - converts OS ver. string to uint32 (e.g "10.9.5" -> 0x0A090500) for easy comparing
uint32_t MacOSVer2Int(const char *osver)
{
uint32_t result = 0;
uint8_t *resptr = (uint8_t *)&result;
uint8_t len = strlen(osver);
uint8_t i, j, m;
#define CHR2UINT(c) ((uint8_t)(c - '0'))
#define ISDIGIT(c) ((c >= '0') && (c <= '9'))
#define ISDOT(c) (c == '.')
if (!osver || (len < 4) || (len > OSVERSTRLEN - 1) || !ISDIGIT(osver[0]) || !ISDOT(osver[2]) || !ISDIGIT(osver[len - 1]))
{
verbose("ERROR: wrong Mac OS version string syntax: '%s'\n", osver);
return 0;
}
for (i = 0, j = 3, m = 1; i < len; i++)
{
if (ISDIGIT(osver[i]))
{
resptr[j] = resptr[j] * m + CHR2UINT(osver[i]);
m = 10;
}
else if (ISDOT(osver[i]))
{
if (j > 0)
{
j--;
}
else
{
return 0;
}
m = 1;
}
else
{
return 0;
}
}
return result;
}
//==========================================================================
typedef struct {
int x;
int y;
trunk/CHANGES
1
2
13
24
35
- Bungo : Added MacOSVerCurrent and MacOSVer2Int function to use instead of macros.
- Bungo : Fixed bug in gDarwinBuildVerStr extracting.
- Bungo : Fixed fixedUUID function (convert.c smbios.c).
- Bungo : Added Logging start time.
- Bungo : Added getRTCdatetime() Int 1Ah function 02h - RTC service.

Archive Download the corresponding diff file

Revision: 2560