Chameleon

Chameleon Commit Details

Date:2011-07-14 16:44:00 (8 years 4 days ago)
Author:armel cadet-petit
Commit:1159
Parents: 1158
Message:fixed a possible issue with kernelpatcher
Changes:
M/branches/cparm/i386/modules/KernelPatcher/kernel_patcher.c
M/branches/cparm/i386/boot2/boot.c

File differences

branches/cparm/i386/boot2/boot.c
552552
553553
554554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
555
605556
606
607
608
609
610
611
612
613
614
615
616
617
618
619
557
558
620559
621560
622561
readSMBIOS(thePlatformName); // read smbios Platform Name
if (!getValueForBootKey(bootArgs->CommandLine, kIgnorePrelinkKern, &val, &len)) {
/*if(gMacOSVersion[3] == '7'){
sprintf(gBootKernelCacheFile, "%s", kDefaultCachePath);
}
else if(gMacOSVersion[3] <= '6')
{
PlatformInfo *platformInfo = malloc(sizeof(PlatformInfo));
if (platformInfo) {
bzero(platformInfo, sizeof(PlatformInfo));
if (gPlatformName)
strlcpy(platformInfo->platformName,gPlatformName, sizeof(platformInfo->platformName)+1);
if (gRootDevice) {
char *rootPath_p = platformInfo->rootPath;
int len = strlen(gRootDevice) + 1;
if ((unsigned)len > sizeof(platformInfo->rootPath)) {
len = sizeof(platformInfo->rootPath);
}
memcpy(rootPath_p, gRootDevice,len);
rootPath_p += len;
len = strlen(bootInfo->bootFile);
if ((unsigned)(rootPath_p - platformInfo->rootPath + len) >=
sizeof(platformInfo->rootPath)) {
len = sizeof(platformInfo->rootPath) -
(rootPath_p - platformInfo->rootPath);
}
memcpy(rootPath_p, bootInfo->bootFile, len);
}
if (!platformInfo->platformName[0] || !platformInfo->rootPath[0]) {
platformInfo->platformName[0] = platformInfo->rootPath[0] = 0;
}
//memcpy(gRootPath,platformInfo->rootPath, sizeof(platformInfo->rootPath));
bootInfo->adler32 = OSSwapHostToBigInt32(local_adler32((unsigned char *)platformInfo, sizeof(*platformInfo)));
free(platformInfo);
}
DBG("Adler32: %08lX\n",bootInfo->adler32);
if (!getValueForBootKey(bootArgs->CommandLine, kIgnorePrelinkKern, &val, &len)) {
if (gMacOSVersion[3] < '6') {
sprintf(gBootKernelCacheFile, "%s.%08lX", "/System/Library/Caches/com.apple.kernelcaches/kernelcache",bootInfo->adler32);
ret = GetFileInfo(NULL, gBootKernelCacheFile, &flags, &cachetime);
if ((ret != 0) || ((flags & kFileTypeMask) != kFileTypeFlat)) {
bootInfo->adler32 = 0;
sprintf(gBootKernelCacheFile, "%s", "/System/Library/Caches/com.apple.kernelcaches/kernelcache");
}
} else
sprintf(gBootKernelCacheFile, "%s_%s.%08lX", kDefaultCachePath, (archCpuType == CPU_TYPE_I386) ? "i386" : "x86_64", bootInfo->adler32); //Snow Leopard
}*/
getKernelCachePath();
getKernelCachePath();
}
// Check for cache file.
branches/cparm/i386/modules/KernelPatcher/kernel_patcher.c
229229
230230
231231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249232
250233
251234
......
261244
262245
263246
264
247
248
249
265250
266
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
267274
268
269
270
271
272
273
275
276
274277
275278
276279
**/
void patch_cpuid_set_info_all(void* kernelData)
{
// AnV: Extra cpuid fix for spoofing Nehalem CPU for i5/i9
switch(Platform->CPU.Family)
{
case 0x1E: /* Intel i5 */
case 0x2C: /* Intel i9 */
if(determineKernelArchitecture(kernelData) == KERNEL_32)
{
patch_cpuid_set_info_32(kernelData, CPUFAMILY_INTEL_NEHALEM, CPUID_MODEL_NEHALEM);
}
else
{
patch_cpuid_set_info_64(kernelData, CPUFAMILY_INTEL_NEHALEM, CPUID_MODEL_NEHALEM);
}
break;
}
switch(Platform->CPU.Model)
{
case CPUID_MODEL_ATOM:
break;
default:
if(determineKernelArchitecture(kernelData) == KERNEL_32)
{
// AnV: Extra cpuid fix for spoofing Nehalem CPU for i5/i9
switch(Platform->CPU.Family)
{
patch_cpuid_set_info_32(kernelData, 0, 0);
case 0x1E: /* Intel i5 */
case 0x2C: /* Intel i9 */
if(determineKernelArchitecture(kernelData) == KERNEL_32)
{
patch_cpuid_set_info_32(kernelData, CPUFAMILY_INTEL_NEHALEM, CPUID_MODEL_NEHALEM);
}
else
{
patch_cpuid_set_info_64(kernelData, CPUFAMILY_INTEL_NEHALEM, CPUID_MODEL_NEHALEM);
}
break;
default:
if(determineKernelArchitecture(kernelData) == KERNEL_32)
{
patch_cpuid_set_info_32(kernelData, 0, 0);
}
else
{
patch_cpuid_set_info_64(kernelData, 0, 0);
}
break;
}
else
{
patch_cpuid_set_info_64(kernelData, 0, 0);
}
break;
break;
}
}
}

Archive Download the corresponding diff file

Revision: 1159