Chameleon

Chameleon Commit Details

Date:2015-01-26 01:06:26 (9 years 2 months ago)
Author:ErmaC
Commit:2559
Parents: 2558
Message:Fixed fixedUUID function (Credits to Bungo).
Changes:
M/trunk/i386/libsaio/smbios.h
M/trunk/CHANGES
M/trunk/i386/libsaio/smbios.c
M/trunk/i386/libsaio/convert.c

File differences

trunk/i386/libsaio/smbios.c
807807
808808
809809
810
810
811811
812812
813813
814814
815815
816816
817
817
818818
819819
820820
......
12691269
12701270
12711271
1272
1273
1272
1273
12741274
12751275
12761276
12771277
1278
1279
1280
1278
1279
1280
12811281
12821282
12831283
......
13151315
13161316
13171317
1318
1319
1318
1319
13201320
13211321
13221322
......
13981398
13991399
14001400
1401
1401
14021402
14031403
14041404
......
14491449
14501450
14511451
1452
1452
14531453
14541454
14551455
14561456
14571457
1458
1459
1460
1461
1462
1463
14641458
14651459
14661460
14671461
14681462
1469
1470
1471
1463
1464
1465
1466
1467
1468
14721469
14731470
1471
1472
1473
14741474
14751475
14761476
char *getSMBStringForField(SMBStructHeader *structHeader, uint8_t field)
{
if (!field)
if (!field || !structHeader)
{
return NULL;
}
uint8_t *stringPtr = (uint8_t *)structHeader + structHeader->length;
for (field--; field != 0 && strlen((char *)stringPtr) > 0;
for (field--; (field > 0) && (*stringPtr > 0) &&(*(uint16_t *)stringPtr != 0);
field--, stringPtr = (uint8_t *)((uint32_t)stringPtr + strlen((char *)stringPtr) + 1));
return (char *)stringPtr;
addSMBEndOfTable(structPtr);
}
// Bungo: does fix system uuid in SMBIOS (and EFI) instead of in EFI only
uint8_t *FixSystemUUID()
// Bungo: does fix system uuid in SMBIOS & EFI instead of in EFI (IODT/efi/platform/system-id) only
uint8_t *fixSystemUUID()
{
uint8_t *ptr = (uint8_t *)neweps->dmi.tableAddress;
SMBStructHeader *structHeader = (SMBStructHeader *)ptr;
int i, isZero, isOnes;
uint8_t FixedUUID[UUID_LEN] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F};
const char *sysId = getStringForKey(kSMBSystemInformationUUIDKey, SMBPlist);
uint8_t *ret = (uint8_t *)getUUIDFromString(sysId);
uint8_t fixedUUID[UUID_LEN] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF};
const char *sysId = getStringForKey(kSMBSystemInformationUUIDKey, SMBPlist); // try to get user's uuid from smbios.plist
uint8_t *ret = (uint8_t *)getUUIDFromString(sysId); // convert user's uuid from string
for (;(structHeader->type != kSMBTypeSystemInformation);) // find System Information Table (Type 1) in patched SMBIOS
{
if (isZero || isOnes) // if empty or setable...
{
verbose("No UUID present in SMBIOS System Information Table\n");
ret = FixedUUID; // ...set a fixed value for system-id = 000102030405060708090A0B0C0D0E0F
verbose("System UUID: incorrect or not present. Fixing [00112233-4455-6677-8899-AABBCCDDEEFF]\n");
ret = fixedUUID; // ...set a fixed value for system uuid: <00 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF>
}
memcpy(ptr, ret, UUID_LEN); // save uuid into the patched SMBIOS Table 1
memcpy((void *)neweps->dmi.tableAddress, buffer, tableLength);
Platform.UUID = FixSystemUUID(); // Bungo: fix System UUID
Platform.UUID = fixSystemUUID(); // Bungo: fix System UUID
neweps->dmi.checksum= 0;
neweps->dmi.checksum= 0x100 - checksum8(&neweps->dmi, sizeof(DMIEntryPoint));
switch (structHeader->type)
{
case kSMBTypeSystemInformation:
Platform.UUID = ((SMBSystemInformation *)structHeader)->uuid; // get factory system uuid
Platform.UUID = ((SMBSystemInformation *)structHeader)->uuid; // save factory system uuid
break;
case kSMBTypeSystemEnclosure: // Bungo: determine platform type
switch (((SMBSystemEnclosure *)structHeader)->chassisType)
{
case kSMBchassisDesktop:
case kSMBchassisLPDesktop:
case kSMBchassisAllInOne:
case kSMBchassisLunchBox:
PlatformType = 1; // desktop (iMac, MacMini)
break;
case kSMBchassisPortable:
case kSMBchassisLaptop:
case kSMBchassisNotebook:
case kSMBchassisHandHeld:
case kSMBchassisSubNotebook:
PlatformType = 2; // notebook (Mac Books)
break;
default:
PlatformType = 2; // notebook (MacBooks/Pros)
break;
case kSMBchassisMiniTower:
case kSMBchassisTower:
case kSMBchassisBlade:
case kSMBchassisBladeEnclosing:
PlatformType = 3; // workstation (Mac Pro, Xserve)
break;
default:
PlatformType = 1; // defulting to 1 desktop (iMac, MacMini)
break;
}
break;
trunk/i386/libsaio/smbios.h
239239
240240
241241
242
242243
244
243245
244246
245247
......
283285
284286
285287
286
288
287289
288290
289291
kSMBchassisSubNotebook = 0x0E,
// ... fill up if needed ;-)
kSMBchassisLunchBox = 0x10,
kSMBchassisMainServer = 0x11,
// ... fill up if needed ;-)
kSMBchassisBlade = 0x1C,
kSMBchassisBladeEnclosing = 0x1D
} MISC_CHASSIS_TYPE;
SMBByte height;// Height of the enclosure, in 'U's
SMBByte numberOfPowerCords;// Number of power cords associated with the enclosure or chassis
SMBByte containedElementCount;// Number of Contained Element record that follow, in the range 0 to 255
//SMBByte containedElementRecord;// Byte leght of each Contained Element record that follow, in the range 0 to 255
SMBByte containedElementRecord;// Byte leght of each Contained Element record that follow, in the range 0 to 255
//SMBByte containedElements;// Elements, possibly defined by other SMBIOS structures present in chassis
// 2.7+
//SMBString skuNumber;// Number of null-terminated string describing the chassis or enclosure SKU number
trunk/i386/libsaio/convert.c
2424
2525
2626
27
27
28
29
30
2831
32
33
34
35
36
37
38
2939
30
3140
3241
3342
/** Parse an UUID string into an (EFI_CHAR8*) buffer */
EFI_CHAR8* getUUIDFromString(const char *source)
{
if (!source) return 0;
if (!source)
{
return 0;
}
inti = strlen(source);
if (i != 36)
{ // e.g 00112233-4455-6677-8899-AABBCCDDEEFF
verbose("[ERROR] UUID='%s' has incorrect length=%d. Use format: 00112233-4455-6677-8899-AABBCCDDEEFF.\n", source, i);
return 0;
}
char*p = (char *)source;
inti;
charbuf[3];
static EFI_CHAR8 uuid[UUID_LEN+1] = "";
trunk/CHANGES
1
12
23
34
- Bungo : Fixed fixedUUID function (convert.c smbios.c).
- Bungo : Added Logging start time.
- Bungo : Added getRTCdatetime() Int 1Ah function 02h - RTC service.
- Zenith432 : Use caching with ExFat filesystem.

Archive Download the corresponding diff file

Revision: 2559