diff --git a/rEFIt_UEFI/Platform/FixBiosDsdt.cpp b/rEFIt_UEFI/Platform/FixBiosDsdt.cpp index 8decfb24b..204f078e6 100755 --- a/rEFIt_UEFI/Platform/FixBiosDsdt.cpp +++ b/rEFIt_UEFI/Platform/FixBiosDsdt.cpp @@ -1289,13 +1289,8 @@ BOOLEAN CmpPNP (UINT8 *dsdt, UINT32 j, UINT16 PNP) (dsdt[j + 9] == ((PNP & 0x00ff) >> 0))); } -template -INT32 CmpDev(UINT8 *dsdt, UINT32 i, const T& Name) +INT32 CmpDev(UINT8 *dsdt, UINT32 i, const char Name[4]) { - if ( Name.length() != 4 ) { - MsgLog("ATTENTION : CmpDev called with a %s with length() != 4 %ld\n", Name.data(), Name.length()); - return 0; - } if ((dsdt[i+0] == Name[0]) && (dsdt[i+1] == Name[1]) && (dsdt[i+2] == Name[2]) && (dsdt[i+3] == Name[3]) && (((dsdt[i-2] == 0x82) && (dsdt[i-3] == 0x5B) && (dsdt[i-1] < 0x40)) || @@ -1313,13 +1308,23 @@ INT32 CmpDev(UINT8 *dsdt, UINT32 i, const T& Name) return 0; } -INT32 CmpDev(UINT8 *dsdt, UINT32 i, CONST CHAR8* Name) +//template +INT32 CmpDev(UINT8 *dsdt, UINT32 i, const XString8& Name) { - if ( !Name ) { - MsgLog("ATTENTION : CmpDev called with a name == NULL\n"); + if ( Name.length() != 4 ) { + MsgLog("ATTENTION : CmpDev called with a %s with length() != 4 %ld\n", Name.data(), Name.length()); return 0; } - return CmpDev(dsdt, i, LString8(Name)); + return CmpDev(dsdt, i, Name.c_str()); +} + +INT32 CmpDev(UINT8 *dsdt, UINT32 i, const XBuffer& Name) +{ + if ( Name.size() != 4 ) { + MsgLog("ATTENTION : CmpDev called with a name whose size() != 4\n"); + return 0; + } + return CmpDev(dsdt, i, Name.CData()); } //the procedure can find BIN array UNSIGNED CHAR8 sizeof N inside part of large array "dsdt" size of len @@ -1811,7 +1816,7 @@ UINT32 FixAny (UINT8* dsdt, UINT32 len, const XBuffer ToFind, const XBuff } //new method. by goodwin_c -UINT32 FixRenameByBridge2 (UINT8* dsdt, UINT32 len, const XString8& TgtBrgName, const XBuffer& ToFind, const XBuffer& ToReplace) +UINT32 FixRenameByBridge2 (UINT8* dsdt, UINT32 len, const XBuffer& TgtBrgName, const XBuffer& ToFind, const XBuffer& ToReplace) { INT32 adr; BOOLEAN found = FALSE; diff --git a/rEFIt_UEFI/Platform/FixBiosDsdt.h b/rEFIt_UEFI/Platform/FixBiosDsdt.h index 8401018bd..15ced9d75 100644 --- a/rEFIt_UEFI/Platform/FixBiosDsdt.h +++ b/rEFIt_UEFI/Platform/FixBiosDsdt.h @@ -84,7 +84,7 @@ INT32 FindBin (UINT8 *dsdt, size_t len, const XBuffer& bin); UINT32 FixAny (UINT8* dsdt, UINT32 len, const XBuffer ToFind, const XBuffer ToReplace); -UINT32 FixRenameByBridge2 (UINT8* dsdt, UINT32 len, const XString8& TgtBrgName, const XBuffer& ToFind, const XBuffer& ToReplace); +UINT32 FixRenameByBridge2 (UINT8* dsdt, UINT32 len, const XBuffer& TgtBrgName, const XBuffer& ToFind, const XBuffer& ToReplace); diff --git a/rEFIt_UEFI/Platform/Settings.cpp b/rEFIt_UEFI/Platform/Settings.cpp index daec2cfa6..2d44dbfd5 100644 --- a/rEFIt_UEFI/Platform/Settings.cpp +++ b/rEFIt_UEFI/Platform/Settings.cpp @@ -4658,8 +4658,15 @@ static void getACPISettings(const TagDict *CfgDict) dsdtPatch.PatchDsdtReplace.stealValueFrom(data, Size); DBG(", lenToReplace: %zu", dsdtPatch.PatchDsdtReplace.size()); data = GetDataSetting (Prop2, "TgtBridge", &Size); - dsdtPatch.PatchDsdtTgt.stealValueFrom((char*)data); - DBG(", Target Bridge: %s\n", dsdtPatch.PatchDsdtTgt.c_str()); + if ( Size != 0 ) { + if ( Size != 4 ) { + DBG("\n TgtBridge must 4 bytes. It's %llu byte(s). Ignored\n", Size); + }else{ + dsdtPatch.PatchDsdtTgt.stealValueFrom(data, Size); + DBG(", Target Bridge: %c%c%c%c", dsdtPatch.PatchDsdtTgt[0], dsdtPatch.PatchDsdtTgt[1], dsdtPatch.PatchDsdtTgt[2], dsdtPatch.PatchDsdtTgt[3]); + } + } + DBG("\n"); if (!dsdtPatch.PatchDsdtMenuItem.BValue) { DBG(" patch disabled at config\n"); } diff --git a/rEFIt_UEFI/Platform/Settings.h b/rEFIt_UEFI/Platform/Settings.h index 48f230b9c..ba295fcbc 100644 --- a/rEFIt_UEFI/Platform/Settings.h +++ b/rEFIt_UEFI/Platform/Settings.h @@ -216,7 +216,7 @@ public : XBuffer PatchDsdtFind; XBuffer PatchDsdtReplace; XString8 PatchDsdtLabel; - XString8 PatchDsdtTgt; + XBuffer PatchDsdtTgt; INPUT_ITEM PatchDsdtMenuItem; DSDT_Patch() : PatchDsdtFind(), PatchDsdtReplace(), PatchDsdtLabel(), PatchDsdtTgt(), PatchDsdtMenuItem() { }