Chameleon

Chameleon Commit Details

Date:2010-10-25 03:57:17 (8 years 8 months ago)
Author:Evan Lojewski
Commit:612
Parents: 611
Message:Fixed replace_string, fixed device id calculations for patches (wrong bitshift amount)
Changes:
M/branches/meklort/i386/modules/KextPatcher/hex_editor.c
M/branches/meklort/i386/modules/KextPatcher/kext_patcher.c

File differences

branches/meklort/i386/modules/KextPatcher/kext_patcher.c
143143
144144
145145
146
147146
148147
149148
......
344343
345344
346345
347
346
348347
349348
350349
......
392391
393392
394393
395
394
396395
397
398
399
400
401
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
402422
403
404
405
406
407
408
409
410
411423
412424
413425
......
435447
436448
437449
438
450
439451
440452
441453
......
507519
508520
509521
510
522
511523
512524
513525
......
588600
589601
590602
591
592
603
593604
594605
595
596
606
607
597608
598609
599610
......
629640
630641
631642
632
643
644
633645
634
635
646
647
648
636649
637650
638651
......
661674
662675
663676
664
677
665678
666679
667680
{
patch_hda_codec <<= 4;
patch_hda_codec |= chartohex(hda_codec[index]);
len--;
index++;
}
}
DBG("Loading %s, length %d, version 0x%x\n", filespec, length, version);
DBG("Loading %s, version 0x%x\n", filespec, version);
//getc();
}
pci_dt_t* current = arg1;
if(current)
{
if(current->class_id == PCI_CLASS_DISPLAY_VGA)
switch(current->class_id)
{
if(current->vendor_id == 0x8086 && current->device_id == 0x27AE)
{
// TODO: patche based on dev id.
patch_gma_deviceid = current->device_id;
}
case PCI_CLASS_DISPLAY_VGA:
if(current->vendor_id == 0x8086 &&
(
current->device_id == 0x27AE ||
/*
current->device_id == 0xA001 ||
current->device_id == 0xA002 ||
current->device_id == 0xA011 ||
current->device_id == 0xA012
*/
)
)
{
patch_gma_deviceid = current->device_id;
}
break;
case PCI_CLASS_NETWORK_OTHER:
// Patch BCM43xx
if(current->vendor_id == 0x14E4 && ((current->device_id & 0xFF00) == 0x4300))
{
patch_bcm_deviceid = current->device_id;
}
break;
}
else if(current->class_id == PCI_CLASS_NETWORK_OTHER)
{
// Patch BCM43xx
if(current->vendor_id == 0x14E4 && ((current->device_id & 0xFF00) == 0x4300))
{
patch_bcm_deviceid = current->device_id;
}
}
}
}
// TODO: verify string doesn't exist first.
replace_string(orig_string, new_str, plistbuffer + XMLCastStringOffset(match_class), 1024);
replace_string(orig_string, new_str, plistbuffer + XMLCastStringOffset(match_class), 10240);
return true;
DBG("Inflated result is %d, in: %d bytes, out: %d bytes, full: %d\n", zlib_result, zstream.total_in, zstream.total_out, full_size);
replace_word(0x10EC | (find_codec << 8), 0xE10EC | (patch_hda_codec << 8), executable, zstream.total_out);
replace_word(0x10EC | (find_codec << 16), 0xE10EC | (patch_hda_codec << 16), executable, zstream.total_out);
if (zstream_inited) inflateEnd(&zstream);
TagPtr replace =XMLGetElement(match_names, 1);// Modify the second entry
char* orig_string = XMLCastString(replace);
DBG("Attemting to replace '%s' with '%s'\n", orig_string, new_str);
// TODO: verify string doesn't exist first.
replace_string(orig_string, new_str, plistbuffer + XMLCastStringOffset(replace), 1024);
replace_string(orig_string, new_str, plistbuffer + XMLCastStringOffset(replace), 10240);
return true;
}
#endif
offset =XMLCastStringOffset(XMLGetProperty(personality, (const char*)"IOPCIPrimaryMatch"));
replace_string("0x27A28086", "0x27AE8086", plistbuffer + offset, 1024);
char* newstring = malloc(strlen("0x27A28086") + 1);
sprintf(newstring, "0x%04x", 0x8086 | (patch_gma_deviceid << 16));
DBG("Located kext %s\n", bundleID);
DBG("PCI Match offset = %d, string = %s\n", offset, pcimatch);
DBG("Replacing %s with %s\n", "0x27A28086", newstring);
replace_string("0x27A28086", newstring, plistbuffer + offset, 10240);
char* executable = malloc(full_size);
bzero(&zstream, sizeof(zstream));
DBG("Inflated result is %d, in: %d bytes, out: %d bytes, full: %d\n", zlib_result, zstream.total_in, zstream.total_out, full_size);
replace_word(0x27A28086, 0x27AE8086, executable, zstream.total_out);
replace_word(0x27A28086, 0x8086 | (patch_gma_deviceid << 16), executable, zstream.total_out);
if (zstream_inited) inflateEnd(&zstream);
branches/meklort/i386/modules/KextPatcher/hex_editor.c
8989
9090
9191
92
92
9393
length--;
str++;
}
strncpy(str, replace, strlen(replace) - 1);// don't copy the null char
strncpy(str, replace, strlen(replace));// don't copy the null char
}

Archive Download the corresponding diff file

Revision: 612