Make GetSizeInBytes() in XImage public.

Change ParseXML first parameter to UINT8 to avoid casts.
This commit is contained in:
jief 2023-11-07 11:02:22 +01:00
parent c1ce6aa406
commit 0130602198
11 changed files with 33 additions and 37 deletions

View File

@ -411,7 +411,7 @@ GetSleepImageLocation(IN REFIT_VOLUME *Volume, REFIT_VOLUME **SleepImageVolume,
if (!EFI_ERROR(Status)) { if (!EFI_ERROR(Status)) {
TagDict* PrefDict; TagDict* PrefDict;
Status = ParseXML((const CHAR8*)PrefBuffer, &PrefDict, PrefBufferLen); Status = ParseXML(PrefBuffer, &PrefDict, PrefBufferLen);
if (!EFI_ERROR(Status)) { if (!EFI_ERROR(Status)) {
const TagDict* dict = PrefDict->dictPropertyForKey("Custom Profile"); const TagDict* dict = PrefDict->dictPropertyForKey("Custom Profile");
if (dict) { if (dict) {

View File

@ -36,15 +36,15 @@ XStringW GetBundleVersion(const XStringW& pathUnderSelf)
EFI_STATUS Status; EFI_STATUS Status;
XStringW CFBundleVersion; XStringW CFBundleVersion;
XStringW InfoPlistPath; XStringW InfoPlistPath;
CHAR8* InfoPlistPtr = NULL; UINT8* InfoPlistPtr = NULL;
TagDict* InfoPlistDict = NULL; TagDict* InfoPlistDict = NULL;
const TagStruct* Prop = NULL; const TagStruct* Prop = NULL;
UINTN Size; UINTN Size;
InfoPlistPath = SWPrintf("%ls\\%ls", pathUnderSelf.wc_str(), L"Contents\\Info.plist"); InfoPlistPath = SWPrintf("%ls\\%ls", pathUnderSelf.wc_str(), L"Contents\\Info.plist");
Status = egLoadFile(&self.getCloverDir(), InfoPlistPath.wc_str(), (UINT8**)&InfoPlistPtr, &Size); Status = egLoadFile(&self.getCloverDir(), InfoPlistPath.wc_str(), &InfoPlistPtr, &Size);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
InfoPlistPath = SWPrintf("%ls\\%ls", pathUnderSelf.wc_str(), L"Info.plist"); InfoPlistPath = SWPrintf("%ls\\%ls", pathUnderSelf.wc_str(), L"Info.plist");
Status = egLoadFile(&self.getCloverDir(), InfoPlistPath.wc_str(), (UINT8**)&InfoPlistPtr, &Size); Status = egLoadFile(&self.getCloverDir(), InfoPlistPath.wc_str(), &InfoPlistPtr, &Size);
} }
if(!EFI_ERROR(Status)) { if(!EFI_ERROR(Status)) {
//DBG("about to parse xml file %ls\n", InfoPlistPath.wc_str()); //DBG("about to parse xml file %ls\n", InfoPlistPath.wc_str());

View File

@ -893,7 +893,7 @@ LoadNvramPlist(
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
CHAR8 *NvramPtr = NULL; UINT8 *NvramPtr = NULL;
UINTN Size = 0; UINTN Size = 0;
DBG(" begin load gNvramDict=0x%llX\n", (uintptr_t)gNvramDict); DBG(" begin load gNvramDict=0x%llX\n", (uintptr_t)gNvramDict);
@ -918,7 +918,7 @@ LoadNvramPlist(
// //
// parse it into gNvramDict // parse it into gNvramDict
// //
Status = ParseXML((const CHAR8*)NvramPtr, &gNvramDict, Size); Status = ParseXML(NvramPtr, &gNvramDict, Size);
if(Status != EFI_SUCCESS) { if(Status != EFI_SUCCESS) {
DBG(" parsing error\n"); DBG(" parsing error\n");
} }

View File

@ -16,7 +16,7 @@ EFI_STATUS
GetRootUUID (IN REFIT_VOLUME *Volume) GetRootUUID (IN REFIT_VOLUME *Volume)
{ {
EFI_STATUS Status; EFI_STATUS Status;
CHAR8 *PlistBuffer; UINT8 *PlistBuffer;
UINTN PlistLen; UINTN PlistLen;
TagDict* Dict; TagDict* Dict;
const TagStruct* Prop; const TagStruct* Prop;
@ -62,25 +62,25 @@ GetRootUUID (IN REFIT_VOLUME *Volume)
// Playing Rock, Paper, Scissors to chose which settings to load. // Playing Rock, Paper, Scissors to chose which settings to load.
if (HasRock && HasPaper && HasScissors) { if (HasRock && HasPaper && HasScissors) {
// Rock wins when all three are around // Rock wins when all three are around
Status = egLoadFile(Volume->RootDir, SystemPlistR, (UINT8 **)&PlistBuffer, &PlistLen); Status = egLoadFile(Volume->RootDir, SystemPlistR, &PlistBuffer, &PlistLen);
} else if (HasRock && HasPaper) { } else if (HasRock && HasPaper) {
// Paper beats rock // Paper beats rock
Status = egLoadFile(Volume->RootDir, SystemPlistP, (UINT8 **)&PlistBuffer, &PlistLen); Status = egLoadFile(Volume->RootDir, SystemPlistP, &PlistBuffer, &PlistLen);
} else if (HasRock && HasScissors) { } else if (HasRock && HasScissors) {
// Rock beats scissors // Rock beats scissors
Status = egLoadFile(Volume->RootDir, SystemPlistR, (UINT8 **)&PlistBuffer, &PlistLen); Status = egLoadFile(Volume->RootDir, SystemPlistR, &PlistBuffer, &PlistLen);
} else if (HasPaper && HasScissors) { } else if (HasPaper && HasScissors) {
// Scissors beat paper // Scissors beat paper
Status = egLoadFile(Volume->RootDir, SystemPlistS, (UINT8 **)&PlistBuffer, &PlistLen); Status = egLoadFile(Volume->RootDir, SystemPlistS, &PlistBuffer, &PlistLen);
} else if (HasPaper) { } else if (HasPaper) {
// No match // No match
Status = egLoadFile(Volume->RootDir, SystemPlistP, (UINT8 **)&PlistBuffer, &PlistLen); Status = egLoadFile(Volume->RootDir, SystemPlistP, &PlistBuffer, &PlistLen);
} else if (HasScissors) { } else if (HasScissors) {
// No match // No match
Status = egLoadFile(Volume->RootDir, SystemPlistS, (UINT8 **)&PlistBuffer, &PlistLen); Status = egLoadFile(Volume->RootDir, SystemPlistS, &PlistBuffer, &PlistLen);
} else { } else {
// Rock wins by default // Rock wins by default
Status = egLoadFile(Volume->RootDir, SystemPlistR, (UINT8 **)&PlistBuffer, &PlistLen); Status = egLoadFile(Volume->RootDir, SystemPlistR, &PlistBuffer, &PlistLen);
} }
if (!EFI_ERROR(Status)) { if (!EFI_ERROR(Status)) {

View File

@ -174,7 +174,7 @@ TagDict* LOADER_ENTRY::getInfoPlist(const EFI_FILE* Root, const XStringW& infoPl
Status = egLoadFile(Root, infoPlistPath.wc_str(), &infoDictBuffer, &infoDictBufferLength); Status = egLoadFile(Root, infoPlistPath.wc_str(), &infoDictBuffer, &infoDictBufferLength);
if (!EFI_ERROR(Status)) { //double check if (!EFI_ERROR(Status)) { //double check
if( ParseXML((CHAR8*)infoDictBuffer, &dict, infoDictBufferLength)!=0 ) { if( ParseXML(infoDictBuffer, &dict, infoDictBufferLength)!=0 ) {
MsgLog("Failed to parse Info.plist: %ls\n", infoPlistPath.wc_str()); MsgLog("Failed to parse Info.plist: %ls\n", infoPlistPath.wc_str());
dict = NULL; dict = NULL;
} }

View File

@ -63,7 +63,7 @@ public:
EFI_STATUS EFI_STATUS
ParseXML( ParseXML(
CONST CHAR8 *buffer, CONST UINT8 *buffer,
TagDict** dict, TagDict** dict,
size_t bufSize size_t bufSize
); );

View File

@ -134,7 +134,7 @@ XBool TagStruct::isFalseOrNn() const
// tag pointer and returns the end of the dic, or returns ?? if not found. // tag pointer and returns the end of the dic, or returns ?? if not found.
// //
EFI_STATUS ParseXML(const CHAR8* buffer, TagDict** dict, size_t bufSize) EFI_STATUS ParseXML(const UINT8* buffer, TagDict** dict, size_t bufSize)
{ {
EFI_STATUS Status; EFI_STATUS Status;
UINT32 length = 0; UINT32 length = 0;
@ -147,7 +147,7 @@ EFI_STATUS ParseXML(const CHAR8* buffer, TagDict** dict, size_t bufSize)
if (bufSize) { if (bufSize) {
bufferSize = bufSize; bufferSize = bufSize;
} else { } else {
bufferSize = (UINT32)strlen(buffer); bufferSize = (UINT32)strlen((CHAR8*)buffer);
} }
DBG("buffer size=%ld\n", bufferSize); DBG("buffer size=%ld\n", bufferSize);
if(dict == NULL) { if(dict == NULL) {

View File

@ -911,12 +911,12 @@ kk</string> \
int ParseXML_tests() int ParseXML_tests()
{ {
TagDict* dict = NULL; TagDict* dict = NULL;
EFI_STATUS Status = ParseXML(config_all, &dict, (UINT32)strlen(config_all)); EFI_STATUS Status = ParseXML((UINT8*)config_all, &dict, (UINT32)strlen(config_all));
if ( !EFI_ERROR(Status) ) { if ( !EFI_ERROR(Status) ) {
XString8 s; XString8 s;
dict->sprintf(0, &s); dict->sprintf(0, &s);
TagDict* dict2 = NULL; TagDict* dict2 = NULL;
Status = ParseXML(s.c_str(), &dict2, s.length()); Status = ParseXML((UINT8*)s.c_str(), &dict2, s.length());
if ( !EFI_ERROR(Status) ) { if ( !EFI_ERROR(Status) ) {
if ( !(*dict).debugIsEqual(*dict2, "plist"_XS8) ) { if ( !(*dict).debugIsEqual(*dict2, "plist"_XS8) ) {
// printf("%s", s.c_str()); // printf("%s", s.c_str());

View File

@ -455,7 +455,7 @@ MacOsVersion GetOSVersion(int LoaderType, const EFI_GUID& APFSTargetUUID, const
XString8 OSVersion; XString8 OSVersion;
XString8 BuildVersion; XString8 BuildVersion;
EFI_STATUS Status = EFI_NOT_FOUND; EFI_STATUS Status = EFI_NOT_FOUND;
CHAR8* PlistBuffer = NULL; UINT8* PlistBuffer = NULL;
UINTN PlistLen; UINTN PlistLen;
TagDict* Dict = NULL; TagDict* Dict = NULL;
const TagDict* DictPointer = NULL; const TagDict* DictPointer = NULL;
@ -479,7 +479,7 @@ MacOsVersion GetOSVersion(int LoaderType, const EFI_GUID& APFSTargetUUID, const
} }
if ( plist.notEmpty() ) { // found macOS System if ( plist.notEmpty() ) { // found macOS System
Status = egLoadFile(Volume->RootDir, plist.wc_str(), (UINT8 **)&PlistBuffer, &PlistLen); Status = egLoadFile(Volume->RootDir, plist.wc_str(), &PlistBuffer, &PlistLen);
if (!EFI_ERROR(Status) && PlistBuffer != NULL && ParseXML(PlistBuffer, &Dict, 0) == EFI_SUCCESS) { if (!EFI_ERROR(Status) && PlistBuffer != NULL && ParseXML(PlistBuffer, &Dict, 0) == EFI_SUCCESS) {
Prop = Dict->propertyForKey("ProductVersion"); Prop = Dict->propertyForKey("ProductVersion");
if ( Prop != NULL ) { if ( Prop != NULL ) {
@ -533,7 +533,7 @@ MacOsVersion GetOSVersion(int LoaderType, const EFI_GUID& APFSTargetUUID, const
} }
} }
if (FileExists (Volume->RootDir, InstallerPlist)) { if (FileExists (Volume->RootDir, InstallerPlist)) {
Status = egLoadFile(Volume->RootDir, InstallerPlist.wc_str(), (UINT8 **)&PlistBuffer, &PlistLen); Status = egLoadFile(Volume->RootDir, InstallerPlist.wc_str(), &PlistBuffer, &PlistLen);
if (!EFI_ERROR(Status) && PlistBuffer != NULL && ParseXML(PlistBuffer, &Dict, 0) == EFI_SUCCESS) { if (!EFI_ERROR(Status) && PlistBuffer != NULL && ParseXML(PlistBuffer, &Dict, 0) == EFI_SUCCESS) {
Prop = Dict->propertyForKey("ProductVersion"); Prop = Dict->propertyForKey("ProductVersion");
if ( Prop != NULL ) { if ( Prop != NULL ) {
@ -572,7 +572,7 @@ MacOsVersion GetOSVersion(int LoaderType, const EFI_GUID& APFSTargetUUID, const
if (OSVersion.isEmpty()) { if (OSVersion.isEmpty()) {
InstallerPlist = SWPrintf("\\.IABootFiles\\com.apple.Boot.plist"); // 10.9 - ... InstallerPlist = SWPrintf("\\.IABootFiles\\com.apple.Boot.plist"); // 10.9 - ...
if (FileExists (Volume->RootDir, InstallerPlist)) { if (FileExists (Volume->RootDir, InstallerPlist)) {
Status = egLoadFile(Volume->RootDir, InstallerPlist.wc_str(), (UINT8 **)&PlistBuffer, &PlistLen); Status = egLoadFile(Volume->RootDir, InstallerPlist.wc_str(), &PlistBuffer, &PlistLen);
if (!EFI_ERROR(Status) && PlistBuffer != NULL && ParseXML(PlistBuffer, &Dict, 0) == EFI_SUCCESS) { if (!EFI_ERROR(Status) && PlistBuffer != NULL && ParseXML(PlistBuffer, &Dict, 0) == EFI_SUCCESS) {
Prop = Dict->propertyForKey("Kernel Flags"); Prop = Dict->propertyForKey("Kernel Flags");
if ( Prop != NULL ) { if ( Prop != NULL ) {
@ -637,7 +637,7 @@ MacOsVersion GetOSVersion(int LoaderType, const EFI_GUID& APFSTargetUUID, const
} }
} }
if (FileExists (Volume->RootDir, InstallerPlist)) { if (FileExists (Volume->RootDir, InstallerPlist)) {
Status = egLoadFile(Volume->RootDir, InstallerPlist.wc_str(), (UINT8 **)&PlistBuffer, &PlistLen); Status = egLoadFile(Volume->RootDir, InstallerPlist.wc_str(), &PlistBuffer, &PlistLen);
if (!EFI_ERROR(Status) && PlistBuffer != NULL && ParseXML(PlistBuffer, &Dict, 0) == EFI_SUCCESS) { if (!EFI_ERROR(Status) && PlistBuffer != NULL && ParseXML(PlistBuffer, &Dict, 0) == EFI_SUCCESS) {
Prop = Dict->propertyForKey("ProductVersion"); Prop = Dict->propertyForKey("ProductVersion");
if ( Prop != NULL ) { if ( Prop != NULL ) {
@ -751,7 +751,7 @@ MacOsVersion GetOSVersion(int LoaderType, const EFI_GUID& APFSTargetUUID, const
if ( plist.notEmpty() ) { // found macOS System if ( plist.notEmpty() ) { // found macOS System
Status = egLoadFile(Volume->RootDir, plist.wc_str(), (UINT8 **)&PlistBuffer, &PlistLen); Status = egLoadFile(Volume->RootDir, plist.wc_str(), &PlistBuffer, &PlistLen);
if (!EFI_ERROR(Status) && PlistBuffer != NULL && ParseXML(PlistBuffer, &Dict, 0) == EFI_SUCCESS) { if (!EFI_ERROR(Status) && PlistBuffer != NULL && ParseXML(PlistBuffer, &Dict, 0) == EFI_SUCCESS) {
Prop = Dict->propertyForKey("ProductVersion"); Prop = Dict->propertyForKey("ProductVersion");
if ( Prop != NULL ) { if ( Prop != NULL ) {
@ -796,7 +796,7 @@ MacOsVersion GetOSVersion(int LoaderType, const EFI_GUID& APFSTargetUUID, const
// Detect exact version for OS X Recovery // Detect exact version for OS X Recovery
if ( plist.notEmpty() ) { // found macOS System if ( plist.notEmpty() ) { // found macOS System
Status = egLoadFile(Volume->RootDir, plist.wc_str(), (UINT8 **)&PlistBuffer, &PlistLen); Status = egLoadFile(Volume->RootDir, plist.wc_str(), &PlistBuffer, &PlistLen);
if (!EFI_ERROR(Status) && PlistBuffer != NULL && ParseXML(PlistBuffer, &Dict, 0) == EFI_SUCCESS) { if (!EFI_ERROR(Status) && PlistBuffer != NULL && ParseXML(PlistBuffer, &Dict, 0) == EFI_SUCCESS) {
Prop = Dict->propertyForKey("ProductVersion"); Prop = Dict->propertyForKey("ProductVersion");
if ( Prop != NULL ) { if ( Prop != NULL ) {
@ -1717,12 +1717,12 @@ XString8 GetAuthRootDmg(const EFI_FILE& dir, const XStringW& path)
XStringW plist = SWPrintf("%ls\\com.apple.Boot.plist", path.wc_str()); XStringW plist = SWPrintf("%ls\\com.apple.Boot.plist", path.wc_str());
if ( !FileExists(dir, plist) ) return NullXString8; if ( !FileExists(dir, plist) ) return NullXString8;
CHAR8* PlistBuffer = NULL; UINT8* PlistBuffer = NULL;
UINTN PlistLen; UINTN PlistLen;
TagDict* Dict = NULL; TagDict* Dict = NULL;
const TagStruct* Prop = NULL; const TagStruct* Prop = NULL;
EFI_STATUS Status = egLoadFile(&dir, plist.wc_str(), (UINT8 **)&PlistBuffer, &PlistLen); EFI_STATUS Status = egLoadFile(&dir, plist.wc_str(), &PlistBuffer, &PlistLen);
if (!EFI_ERROR(Status) && PlistBuffer != NULL && ParseXML(PlistBuffer, &Dict, 0) == EFI_SUCCESS) if (!EFI_ERROR(Status) && PlistBuffer != NULL && ParseXML(PlistBuffer, &Dict, 0) == EFI_SUCCESS)
{ {
Prop = Dict->propertyForKey("Kernel Flags"); Prop = Dict->propertyForKey("Kernel Flags");
@ -1764,12 +1764,12 @@ MacOsVersion GetMacOSVersionFromFolder(const EFI_FILE& dir, const XStringW& path
} }
if ( plist.notEmpty() ) { // found macOS System if ( plist.notEmpty() ) { // found macOS System
CHAR8* PlistBuffer = NULL; UINT8* PlistBuffer = NULL;
UINTN PlistLen; UINTN PlistLen;
TagDict* Dict = NULL; TagDict* Dict = NULL;
const TagStruct* Prop = NULL; const TagStruct* Prop = NULL;
EFI_STATUS Status = egLoadFile(&dir, plist.wc_str(), (UINT8 **)&PlistBuffer, &PlistLen); EFI_STATUS Status = egLoadFile(&dir, plist.wc_str(), &PlistBuffer, &PlistLen);
if (!EFI_ERROR(Status) && PlistBuffer != NULL && ParseXML(PlistBuffer, &Dict, 0) == EFI_SUCCESS) { if (!EFI_ERROR(Status) && PlistBuffer != NULL && ParseXML(PlistBuffer, &Dict, 0) == EFI_SUCCESS) {
Prop = Dict->propertyForKey("ProductVersion"); Prop = Dict->propertyForKey("ProductVersion");
if ( Prop != NULL ) { if ( Prop != NULL ) {

View File

@ -54,11 +54,7 @@ public:
XImage& operator= (const XImage& other); XImage& operator= (const XImage& other);
protected:
UINTN GetSizeInBytes() const; //in bytes UINTN GetSizeInBytes() const; //in bytes
public:
void setSizeInPixels(UINTN W, UINTN H); void setSizeInPixels(UINTN W, UINTN H);
const XArray<EFI_GRAPHICS_OUTPUT_BLT_PIXEL>& GetData() const; const XArray<EFI_GRAPHICS_OUTPUT_BLT_PIXEL>& GetData() const;

View File

@ -372,9 +372,9 @@ TagDict* XTheme::LoadTheme(const XStringW& TestTheme)
DBG("Using vector theme '%ls' (%ls)\n", TestTheme.wc_str(), m_ThemePath.wc_str()); DBG("Using vector theme '%ls' (%ls)\n", TestTheme.wc_str(), m_ThemePath.wc_str());
} }
} else { } else {
Status = egLoadFile(ThemeDir, CONFIG_THEME_FILENAME, (UINT8**)&ThemePtr, &Size); Status = egLoadFile(ThemeDir, CONFIG_THEME_FILENAME, &ThemePtr, &Size);
if (!EFI_ERROR(Status) && (ThemePtr != NULL) && (Size != 0)) { if (!EFI_ERROR(Status) && (ThemePtr != NULL) && (Size != 0)) {
Status = ParseXML((CHAR8*)ThemePtr, &ThemeDict, 0); Status = ParseXML(ThemePtr, &ThemeDict, 0);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
ThemeDict = NULL; ThemeDict = NULL;
} }