mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-11-23 11:35:19 +01:00
Merge branch 'master' of https://github.com/CloverHackyColor/CloverBootloader
This commit is contained in:
commit
8578de1abe
@ -1765,7 +1765,7 @@ typedef struct {
|
||||
UINT16 TotalWidth;
|
||||
UINT16 DataWidth;
|
||||
UINT16 Size;
|
||||
MEMORY_FORM_FACTOR FormFactor; ///< The enumeration value from MEMORY_FORM_FACTOR.
|
||||
UINT8 FormFactor; ///< The enumeration value from MEMORY_FORM_FACTOR.
|
||||
UINT8 DeviceSet;
|
||||
SMBIOS_TABLE_STRING DeviceLocator;
|
||||
SMBIOS_TABLE_STRING BankLocator;
|
||||
|
@ -311,7 +311,7 @@ EFI_STATUS ScanDeviceHandles(EFI_HANDLE ControllerHandle,
|
||||
Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, HandleCount, HandleBuffer);
|
||||
if (EFI_ERROR (Status)) goto Error;
|
||||
|
||||
*HandleType = (__typeof_am__(*HandleType))AllocatePool (*HandleCount * sizeof (UINT32));
|
||||
*HandleType = (__typeof_am__(*HandleType))AllocatePool (*HandleCount * sizeof (**HandleType));
|
||||
if (*HandleType == NULL) goto Error;
|
||||
|
||||
for (HandleIndex = 0; HandleIndex < *HandleCount; HandleIndex++) {
|
||||
|
@ -698,8 +698,8 @@ REFIT_VOLUME *FoundParentVolume(REFIT_VOLUME *Volume)
|
||||
return NULL; //don't search!
|
||||
}
|
||||
|
||||
for (VolumeIndex = 0; VolumeIndex < VolumesCount; VolumeIndex++) {
|
||||
Volume1 = Volumes[VolumeIndex];
|
||||
for (VolumeIndex = 0; VolumeIndex < Volumes.size(); VolumeIndex++) {
|
||||
Volume1 = &Volumes[VolumeIndex];
|
||||
if (Volume1 != Volume &&
|
||||
Volume1->WholeDiskBlockIO == Volume->WholeDiskBlockIO) {
|
||||
if (PartNumForVolume(Volume1) == SearchPartNum - 1) {
|
||||
|
@ -919,10 +919,10 @@ EFI_STATUS bootPBR(REFIT_VOLUME* volume, BOOLEAN SataReset)
|
||||
//
|
||||
DBG("Looking for parent disk of %s\n", FileDevicePathToStr(volume->DevicePath));
|
||||
BiosDriveNum = 0;
|
||||
for (i = 0; i < VolumesCount; i++) {
|
||||
if (Volumes[i] != volume && Volumes[i]->BlockIO == volume->WholeDiskBlockIO)
|
||||
for (i = 0; i < Volumes.size(); i++) {
|
||||
if (&Volumes[i] != volume && Volumes[i].BlockIO == volume->WholeDiskBlockIO)
|
||||
{
|
||||
BiosDriveNum = GetBiosDriveNumForVolume(Volumes[i]);
|
||||
BiosDriveNum = GetBiosDriveNumForVolume(&Volumes[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -334,8 +334,8 @@ ResetNativeNvram ()
|
||||
|
||||
if (gFirmwareClover || gDriversFlags.EmuVariableLoaded) {
|
||||
//DBG("Searching volumes for nvram.plist\n");
|
||||
for (VolumeIndex = 0; VolumeIndex < VolumesCount; ++VolumeIndex) {
|
||||
Volume = Volumes[VolumeIndex];
|
||||
for (VolumeIndex = 0; VolumeIndex < Volumes.size(); ++VolumeIndex) {
|
||||
Volume = &Volumes[VolumeIndex];
|
||||
|
||||
if (!Volume->RootDir) {
|
||||
continue;
|
||||
@ -889,8 +889,8 @@ LoadLatestNvramPlist ()
|
||||
LastModifTimeMs = 0;
|
||||
|
||||
// search all volumes
|
||||
for (UINTN Index = 0; Index < VolumesCount; ++Index) {
|
||||
Volume = Volumes[Index];
|
||||
for (UINTN Index = 0; Index < Volumes.size(); ++Index) {
|
||||
Volume = &Volumes[Index];
|
||||
|
||||
if (!Volume->RootDir) {
|
||||
continue;
|
||||
@ -1224,8 +1224,8 @@ FindStartupDiskVolume (
|
||||
//
|
||||
DiskVolume = NULL;
|
||||
DBG (" - searching for that disk\n");
|
||||
for (Index = 0; Index < (INTN)VolumesCount; ++Index) {
|
||||
Volume = Volumes[Index];
|
||||
for (UINTN Index = 0; Index < Volumes.size(); ++Index) {
|
||||
Volume = &Volumes[Index];
|
||||
if (BootVolumeDevicePathEqual (gEfiBootVolume, Volume->DevicePath)) {
|
||||
// that's the one
|
||||
DiskVolume = Volume;
|
||||
|
@ -82,6 +82,10 @@ extern "C" {
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "../cpp_foundation/XStringW.h"
|
||||
#include "../cpp_foundation/XArray.h"
|
||||
#include "../cpp_foundation/XObjArray.h"
|
||||
|
||||
#include "../refit/lib.h"
|
||||
#include "string.h"
|
||||
#include "boot.h"
|
||||
|
@ -431,7 +431,7 @@ ParseLoadOptions (
|
||||
AsciiConf = (__typeof__(AsciiConf))AllocateCopyPool (TailSize + 1, Start);
|
||||
if (AsciiConf != NULL) {
|
||||
*(AsciiConf + TailSize) = '\0';
|
||||
*Conf = (__typeof_am__(*Conf))AllocateZeroPool ((TailSize + 1) * sizeof (CHAR16));
|
||||
*Conf = (__typeof_am__(*Conf))AllocateZeroPool ((TailSize + 1) * sizeof(**Conf));
|
||||
AsciiStrToUnicodeStrS (AsciiConf, *Conf, TailSize);
|
||||
FreePool (AsciiConf);
|
||||
}
|
||||
@ -5074,7 +5074,8 @@ GetUserSettings(
|
||||
for (j = 0; j < PropCount; j++) {
|
||||
Prop3 = NULL;
|
||||
DevProps = *Child;
|
||||
*Child = (__typeof_am__(*Child))AllocateZeroPool(sizeof(DEV_PROPERTY));
|
||||
// *Child = (__typeof_am__(*Child))AllocateZeroPool(sizeof(**Child));
|
||||
*Child = new (__typeof_am__(**Child));
|
||||
(*Child)->Next = DevProps;
|
||||
|
||||
if (EFI_ERROR(GetElement(Prop2, j, &Prop3))) { // Prop3 -> <key>
|
||||
|
@ -1326,14 +1326,14 @@ VOID PatchTableType17()
|
||||
// Inject tables
|
||||
for (Index = 0; Index < gRAM.UserInUse; Index++) {
|
||||
UINTN UserIndex = channelMap[Index];
|
||||
UINT8 bank = (UINT8)Index / gRAM.UserChannels;
|
||||
UINT8 bank = (UINT8)(Index / gRAM.UserChannels);
|
||||
ZeroMem((VOID*)newSmbiosTable.Type17, MAX_TABLE_SIZE);
|
||||
newSmbiosTable.Type17->Hdr.Type = EFI_SMBIOS_TYPE_MEMORY_DEVICE;
|
||||
newSmbiosTable.Type17->Hdr.Length = sizeof(SMBIOS_TABLE_TYPE17);
|
||||
newSmbiosTable.Type17->TotalWidth = 0xFFFF;
|
||||
newSmbiosTable.Type17->DataWidth = 0xFFFF;
|
||||
newSmbiosTable.Type17->Hdr.Handle = (UINT16)(0x1100 + UserIndex);
|
||||
newSmbiosTable.Type17->FormFactor = gMobile ? MemoryFormFactorSodimm : MemoryFormFactorDimm;
|
||||
newSmbiosTable.Type17->FormFactor = (UINT8)(gMobile ? MemoryFormFactorSodimm : MemoryFormFactorDimm);
|
||||
newSmbiosTable.Type17->TypeDetail.Synchronous = TRUE;
|
||||
newSmbiosTable.Type17->DeviceSet = bank + 1;
|
||||
newSmbiosTable.Type17->MemoryArrayHandle = mHandle16;
|
||||
@ -1347,7 +1347,7 @@ VOID PatchTableType17()
|
||||
UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->DeviceLocator, (CHAR8*)&deviceLocator[0]);
|
||||
if ((gRAM.User[UserIndex].InUse) && (gRAM.User[UserIndex].ModuleSize > 0)) {
|
||||
if (iStrLen(gRAM.User[UserIndex].Vendor, 64) > 0) {
|
||||
CHAR8* vendor = (CHAR8*)AllocatePool(AsciiStrLen(gRAM.User[UserIndex].Vendor)+1); // this will never be freed. WIll be solved when using a string object.
|
||||
CHAR8* vendor = (CHAR8*)AllocatePool(AsciiStrLen(gRAM.User[UserIndex].Vendor)+1); // this will never be freed. Will be solved when using a string object.
|
||||
AsciiStrCpy(vendor, gRAM.User[UserIndex].Vendor);
|
||||
UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, vendor);
|
||||
gRAM.User[UserIndex].Vendor = vendor;
|
||||
@ -1617,7 +1617,7 @@ VOID PatchTableType17()
|
||||
}
|
||||
Once = TRUE;
|
||||
newSmbiosTable.Type17->Hdr.Handle = (UINT16)(0x1100 + Index);
|
||||
newSmbiosTable.Type17->FormFactor = gMobile ? MemoryFormFactorSodimm : MemoryFormFactorDimm;
|
||||
newSmbiosTable.Type17->FormFactor = (UINT8)(gMobile ? MemoryFormFactorSodimm : MemoryFormFactorDimm);
|
||||
newSmbiosTable.Type17->TypeDetail.Synchronous = TRUE;
|
||||
newSmbiosTable.Type17->DeviceSet = bank + 1;
|
||||
newSmbiosTable.Type17->MemoryArrayHandle = mHandle16;
|
||||
|
@ -11,7 +11,7 @@
|
||||
#if !defined(__XARRAY_H__)
|
||||
#define __XARRAY_H__
|
||||
|
||||
#include <Platform.h> // Only use angled for Platform, else, xcode project won't compile // for DebugLog
|
||||
//#include <Platform.h> // Only use angled for Platform, else, xcode project won't compile // for DebugLog
|
||||
//VOID EFIAPI DebugLog(IN INTN DebugMode, IN CONST CHAR8 *FormatString, ...); // To avoid include Platform just for this
|
||||
//extern "C" {
|
||||
// #include <Library/MemoryAllocationLib.h>
|
||||
@ -52,6 +52,18 @@ class XArray
|
||||
xsize Length() const { return m_len; }
|
||||
void SetLength(xsize l);
|
||||
|
||||
//low case functions like in std::vector
|
||||
xsize size() const { return m_len; }
|
||||
const TYPE& begin() const { return ElementAt(0); }
|
||||
TYPE& begin() { return ElementAt(0); }
|
||||
|
||||
const TYPE& end() const { return ElementAt(m_len - 1); }
|
||||
TYPE& end() { return ElementAt(m_len - 1); }
|
||||
|
||||
xsize insert(const TYPE newElement, xsize pos, xsize count = 1) { return Insert(newElement, pos, count); }
|
||||
|
||||
//--------------------------------------------------
|
||||
|
||||
const TYPE& ElementAt(xsize nIndex) const;
|
||||
TYPE& ElementAt(xsize nIndex);
|
||||
|
||||
@ -91,7 +103,8 @@ class XArray
|
||||
void RemoveAtIndex(xsize nIndex);
|
||||
void RemoveAtIndex(int nIndex);
|
||||
|
||||
void Empty();
|
||||
void setEmpty();
|
||||
bool isEmpty() const { return size() == 0; }
|
||||
|
||||
xsize IdxOf(TYPE& e) const;
|
||||
bool ExistIn(TYPE& e) const { return IdxOf(e) != MAX_XSIZE; }
|
||||
@ -138,7 +151,7 @@ const XArray<TYPE> &XArray<TYPE>::operator =(const XArray<TYPE> &anArray)
|
||||
{
|
||||
xsize ui;
|
||||
|
||||
Empty();
|
||||
setEmpty();
|
||||
for ( ui=0 ; ui<anArray.Length() ; ui+=1 ) AddCopy(anArray.Data() );
|
||||
return *this;
|
||||
}
|
||||
@ -327,7 +340,7 @@ void XArray<TYPE>::Remove(const TYPE *Element)
|
||||
|
||||
/* Empty() */
|
||||
template<class TYPE>
|
||||
void XArray<TYPE>::Empty()
|
||||
void XArray<TYPE>::setEmpty()
|
||||
{
|
||||
//printf("XArray Empty\n");
|
||||
m_len = 0;
|
||||
|
@ -11,7 +11,7 @@
|
||||
#if !defined(__XOBJARRAY_H__)
|
||||
#define __XOBJARRAY_H__
|
||||
|
||||
#include <Platform.h> // Only use angled for Platform, else, xcode project won't compile // for DebugLog
|
||||
//#include <Platform.h> // Only use angled for Platform, else, xcode project won't compile // for DebugLog
|
||||
//VOID EFIAPI DebugLog(IN INTN DebugMode, IN CONST CHAR8 *FormatString, ...); // To avoid include Platform just for this
|
||||
//extern "C" {
|
||||
// #include <Library/MemoryAllocationLib.h>
|
||||
@ -56,11 +56,12 @@ class XObjArrayNC
|
||||
xsize _getLen() const { return _Len; }
|
||||
|
||||
public:
|
||||
xsize Size() const { return _Size; }
|
||||
xsize Length() const { return _Len; }
|
||||
xsize AllocatedSize() const { return _Size; }
|
||||
xsize size() const { return _Len; }
|
||||
xsize length() const { return _Len; }
|
||||
|
||||
bool NotNull() const { return Length() > 0; }
|
||||
bool IsNull() const { return Length() == 0; }
|
||||
bool NotNull() const { return size() > 0; }
|
||||
bool IsNull() const { return size() == 0; }
|
||||
|
||||
const TYPE &ElementAt(xsize nIndex) const;
|
||||
TYPE &ElementAt(xsize nIndex);
|
||||
@ -156,8 +157,8 @@ XObjArray<TYPE>::XObjArray(const XObjArray<TYPE> &anObjArray)
|
||||
xsize ui;
|
||||
|
||||
XObjArrayNC<TYPE>::Init();
|
||||
this->CheckSize(anObjArray.Length(), (xsize)0);
|
||||
for ( ui=0 ; ui<anObjArray.Length() ; ui+=1 ) AddCopy(anObjArray.ElementAt(ui));
|
||||
this->CheckSize(anObjArray.size(), (xsize)0);
|
||||
for ( ui=0 ; ui<anObjArray.size() ; ui+=1 ) AddCopy(anObjArray.ElementAt(ui));
|
||||
}
|
||||
|
||||
/* operator = */
|
||||
@ -168,7 +169,7 @@ const XObjArray<TYPE> &XObjArray<TYPE>::operator =(const XObjArray<TYPE> &anObjA
|
||||
|
||||
XObjArrayNC<TYPE>::Empty();
|
||||
CheckSize(anObjArray.Length(), 0);
|
||||
for ( ui=0 ; ui<anObjArray.Length() ; ui+=1 ) AddCopy(anObjArray.ElementAt(ui));
|
||||
for ( ui=0 ; ui<anObjArray.size() ; ui+=1 ) AddCopy(anObjArray.ElementAt(ui));
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -212,7 +213,7 @@ template<class TYPE>
|
||||
const TYPE &XObjArrayNC<TYPE>::ElementAt(xsize index) const
|
||||
{
|
||||
if ( index >= _Len ) {
|
||||
DebugLog(2, "XObjArray<TYPE>::ElementAt(xsize) -> operator [] - index (%d) greater than length (%d)\n", index, _Len);
|
||||
DebugLog(2, "XObjArray<TYPE>::ElementAt(xsize) const -> operator [] - index (%d) greater than length (%d)\n", index, _Len);
|
||||
CpuDeadLoop();
|
||||
}
|
||||
return *((TYPE *)(_Data[index].Object));
|
||||
|
@ -42,10 +42,10 @@ XStringW XStringWArray::ConcatAll(XStringW Separator, XStringW Prefix, XStringW
|
||||
xsize i;
|
||||
XStringW s;
|
||||
|
||||
if ( Length() > 0 ) {
|
||||
if ( size() > 0 ) {
|
||||
s = Prefix;
|
||||
s += ElementAt(0);
|
||||
for ( i=1 ; i<Length() ; i+=1 ) {
|
||||
for ( i=1 ; i<size() ; i+=1 ) {
|
||||
s += Separator;
|
||||
s += ElementAt(i);
|
||||
}
|
||||
@ -58,8 +58,8 @@ bool XStringWArray::Equal(const XStringWArray &aStrings) const
|
||||
{
|
||||
xsize ui;
|
||||
|
||||
if ( Length() != aStrings.Length() ) return false;
|
||||
for ( ui=0 ; ui<Length() ; ui+=1 ) {
|
||||
if ( size() != aStrings.size() ) return false;
|
||||
for ( ui=0 ; ui<size() ; ui+=1 ) {
|
||||
if ( ElementAt(ui) != aStrings[ui] ) return false;
|
||||
}
|
||||
return true;
|
||||
@ -69,10 +69,10 @@ bool XStringWArray::Same(const XStringWArray &aStrings) const
|
||||
{
|
||||
xsize i;
|
||||
|
||||
for ( i=0 ; i<Length() ; i+=1 ) {
|
||||
for ( i=0 ; i<size() ; i+=1 ) {
|
||||
if ( !aStrings.Contains(ElementAt(i)) ) return false;
|
||||
}
|
||||
for ( i=0 ; i<aStrings.Length() ; i+=1 ) {
|
||||
for ( i=0 ; i<aStrings.size() ; i+=1 ) {
|
||||
if ( !Contains(aStrings.ElementAt(i)) ) return false;
|
||||
}
|
||||
return true;
|
||||
@ -82,7 +82,7 @@ bool XStringWArray::Contains(const XStringW &S) const
|
||||
{
|
||||
xsize i;
|
||||
|
||||
for ( i=0 ; i<Length() ; i+=1 ) {
|
||||
for ( i=0 ; i<size() ; i+=1 ) {
|
||||
if ( ElementAt(i) == S ) return true;
|
||||
}
|
||||
return false;
|
||||
@ -95,7 +95,7 @@ void XStringWArray::Add(const XStringWArray &aStrings)
|
||||
{
|
||||
xsize i;
|
||||
|
||||
for ( i=0 ; i<aStrings.Length() ; i+=1 ) {
|
||||
for ( i=0 ; i<aStrings.size() ; i+=1 ) {
|
||||
AddCopy(aStrings[i]);
|
||||
}
|
||||
}
|
||||
@ -109,7 +109,7 @@ void XStringWArray::AddID(const XStringWArray &aStrings)
|
||||
{
|
||||
xsize i;
|
||||
|
||||
for ( i=0 ; i<aStrings.Length() ; i+=1 ) {
|
||||
for ( i=0 ; i<aStrings.size() ; i+=1 ) {
|
||||
if ( !Contains(aStrings[i]) ) AddCopy(aStrings[i]);
|
||||
}
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ class XStringWArray : public XStringWArraySuper
|
||||
|
||||
|
||||
void SetNull() { Empty(); }
|
||||
bool IsNull() const { return Length() == 0 ; }
|
||||
bool NotNull() const { return Length() > 0 ; }
|
||||
bool IsNull() const { return size() == 0 ; }
|
||||
bool NotNull() const { return size() > 0 ; }
|
||||
|
||||
XStringW ConcatAll(XStringW Separator = L", ", XStringW Prefix = L"", XStringW Suffix = L"") const;
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
#ifndef __XTOOLSCOMMON_H__
|
||||
#define __XTOOLSCOMMON_H__
|
||||
|
||||
#include <Platform.h>
|
||||
|
||||
#define xsize UINTN
|
||||
#define MAX_XSIZE MAX_UINTN
|
||||
@ -14,8 +13,24 @@ extern xsize XBufferGrowByDefault;
|
||||
*/
|
||||
#define __XTOOLS_INT_CHECK__
|
||||
|
||||
extern "C" {
|
||||
#include <Library/BaseLib.h> // for CpuDeadLoop
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/BaseMemoryLib.h> // for CopyMen
|
||||
}
|
||||
#define Xalloc(AllocationSize) AllocatePool(AllocationSize)
|
||||
#define Xrealloc(OldSize, NewSize, OldBuffer) ReallocatePool(OldSize, NewSize, OldBuffer)
|
||||
#define Xfree(Buffer) FreePool(Buffer)
|
||||
#define Xmemmove(dest,source,count) CopyMem(dest, (void*)(source), count) // that has to handle overlapping memory (prefer memmove to memcpy).
|
||||
|
||||
|
||||
|
||||
// Declare here instead of include to avoid circular dependancy.
|
||||
VOID
|
||||
EFIAPI
|
||||
DebugLog (
|
||||
IN INTN DebugMode,
|
||||
IN CONST CHAR8 *FormatString, ...);
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -54,13 +54,13 @@ int XStringWArray_tests()
|
||||
if ( !array1.Same(array2) ) return 41; // Arrays are the same
|
||||
|
||||
array1.AddNoNull(L"3");
|
||||
if ( array1.Length() != 3 ) return 50;
|
||||
if ( array1.size() != 3 ) return 50;
|
||||
array1.AddNoNull(L"");
|
||||
if ( array1.Length() != 3 ) return 51;
|
||||
if ( array1.size() != 3 ) return 51;
|
||||
array1.AddEvenNull(XStringW());
|
||||
if ( array1.Length() != 4 ) return 52;
|
||||
if ( array1.size() != 4 ) return 52;
|
||||
array1.AddID(L"2");
|
||||
if ( array1.Length() != 4 ) return 53;
|
||||
if ( array1.size() != 4 ) return 53;
|
||||
|
||||
|
||||
return 0;
|
||||
|
@ -441,15 +441,15 @@ BOOLEAN AskUserForFilePathFromVolumes(IN CHAR16 *Title OPTIONAL, OUT EFI_DEVICE_
|
||||
return FALSE;
|
||||
}
|
||||
// Allocate entries
|
||||
Entries = (REFIT_MENU_ENTRY **)AllocateZeroPool(sizeof(REFIT_MENU_ENTRY *) + ((sizeof(REFIT_MENU_ENTRY *) + sizeof(REFIT_MENU_ENTRY)) * VolumesCount));
|
||||
Entries = (REFIT_MENU_ENTRY **)AllocateZeroPool(sizeof(REFIT_MENU_ENTRY *) + ((sizeof(REFIT_MENU_ENTRY *) + sizeof(REFIT_MENU_ENTRY)) * Volumes.size()));
|
||||
if (Entries == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
EntryPtr = (REFIT_MENU_ENTRY *)(Entries + (VolumesCount + 1));
|
||||
EntryPtr = (REFIT_MENU_ENTRY *)(Entries + (Volumes.size() + 1));
|
||||
// Create volume entries
|
||||
for (Index = 0; Index < VolumesCount; ++Index) {
|
||||
for (Index = 0; Index < Volumes.size(); ++Index) {
|
||||
REFIT_MENU_ENTRY *Entry;
|
||||
REFIT_VOLUME *Volume = Volumes[Index];
|
||||
REFIT_VOLUME *Volume = &Volumes[Index];
|
||||
if ((Volume == NULL) || (Volume->RootDir == NULL) ||
|
||||
((Volume->DevicePathString == NULL) && (Volume->VolName == NULL))) {
|
||||
continue;
|
||||
@ -474,9 +474,9 @@ BOOLEAN AskUserForFilePathFromVolumes(IN CHAR16 *Title OPTIONAL, OUT EFI_DEVICE_
|
||||
((MenuExit == MENU_EXIT_ENTER) || (MenuExit == MENU_EXIT_DETAILS))) {
|
||||
if (ChosenEntry->Tag >= TAG_OFFSET) {
|
||||
Index = (ChosenEntry->Tag - TAG_OFFSET);
|
||||
if (Index < VolumesCount) {
|
||||
if (Index < Volumes.size()) {
|
||||
// Run directory chooser menu
|
||||
if (!AskUserForFilePathFromDir(Title, Volumes[Index], NULL, Volumes[Index]->RootDir, Result)) {
|
||||
if (!AskUserForFilePathFromDir(Title, &Volumes[Index], NULL, Volumes[Index].RootDir, Result)) {
|
||||
continue;
|
||||
}
|
||||
Responded = TRUE;
|
||||
@ -502,8 +502,8 @@ BOOLEAN AskUserForFilePath(IN CHAR16 *Title OPTIONAL, IN EFI_DEVICE_PATH_PROTOCO
|
||||
if (DevicePathStr != NULL) {
|
||||
UINTN Index = 0;
|
||||
// Check the volumes for a match
|
||||
for (Index = 0; Index < VolumesCount; ++Index) {
|
||||
REFIT_VOLUME *Volume = Volumes[Index];
|
||||
for (Index = 0; Index < Volumes.size(); ++Index) {
|
||||
REFIT_VOLUME *Volume = &Volumes[Index];
|
||||
UINTN Length;
|
||||
if ((Volume == NULL) || (Volume->RootDir == NULL) ||
|
||||
(Volume->DevicePathString == NULL)) {
|
||||
|
@ -185,8 +185,8 @@ VOID ScanLegacy(VOID)
|
||||
|
||||
DBG("Scanning legacy ...\n");
|
||||
|
||||
for (VolumeIndex = 0; VolumeIndex < VolumesCount; VolumeIndex++) {
|
||||
Volume = Volumes[VolumeIndex];
|
||||
for (VolumeIndex = 0; VolumeIndex < Volumes.size(); VolumeIndex++) {
|
||||
Volume = &Volumes[VolumeIndex];
|
||||
if ((Volume->BootType != BOOTING_BY_PBR) &&
|
||||
(Volume->BootType != BOOTING_BY_MBR) &&
|
||||
(Volume->BootType != BOOTING_BY_CD)) {
|
||||
@ -232,10 +232,10 @@ VOID ScanLegacy(VOID)
|
||||
if (HideIfOthersFound) {
|
||||
// check for other bootable entries on the same disk
|
||||
//if PBR exists then Hide MBR
|
||||
for (VolumeIndex2 = 0; VolumeIndex2 < VolumesCount; VolumeIndex2++) {
|
||||
for (VolumeIndex2 = 0; VolumeIndex2 < Volumes.size(); VolumeIndex2++) {
|
||||
if (VolumeIndex2 != VolumeIndex &&
|
||||
Volumes[VolumeIndex2]->HasBootCode &&
|
||||
Volumes[VolumeIndex2]->WholeDiskBlockIO == Volume->BlockIO){
|
||||
Volumes[VolumeIndex2].HasBootCode &&
|
||||
Volumes[VolumeIndex2].WholeDiskBlockIO == Volume->BlockIO){
|
||||
ShowVolume = FALSE;
|
||||
// DBG("PBR volume at index %d\n", VolumeIndex2);
|
||||
break;
|
||||
@ -280,8 +280,8 @@ VOID AddCustomLegacy(VOID)
|
||||
if (Custom->Volume) {
|
||||
DBG("Custom legacy %d matching \"%s\" ...\n", i, Custom->Volume);
|
||||
}
|
||||
for (VolumeIndex = 0; VolumeIndex < VolumesCount; ++VolumeIndex) {
|
||||
Volume = Volumes[VolumeIndex];
|
||||
for (VolumeIndex = 0; VolumeIndex < Volumes.size(); ++VolumeIndex) {
|
||||
Volume = &Volumes[VolumeIndex];
|
||||
|
||||
DBG(" Checking volume \"%s\" (%s) ... ", Volume->VolName, Volume->DevicePathString);
|
||||
|
||||
@ -327,10 +327,10 @@ VOID AddCustomLegacy(VOID)
|
||||
if (HideIfOthersFound) {
|
||||
// check for other bootable entries on the same disk
|
||||
//if PBR exists then Hide MBR
|
||||
for (VolumeIndex2 = 0; VolumeIndex2 < VolumesCount; VolumeIndex2++) {
|
||||
for (VolumeIndex2 = 0; VolumeIndex2 < Volumes.size(); VolumeIndex2++) {
|
||||
if (VolumeIndex2 != VolumeIndex &&
|
||||
Volumes[VolumeIndex2]->HasBootCode &&
|
||||
Volumes[VolumeIndex2]->WholeDiskBlockIO == Volume->BlockIO) {
|
||||
Volumes[VolumeIndex2].HasBootCode &&
|
||||
Volumes[VolumeIndex2].WholeDiskBlockIO == Volume->BlockIO) {
|
||||
ShowVolume = FALSE;
|
||||
break;
|
||||
}
|
||||
|
@ -342,8 +342,8 @@ STATIC BOOLEAN isFirstRootUUID(REFIT_VOLUME *Volume)
|
||||
UINTN VolumeIndex;
|
||||
REFIT_VOLUME *scanedVolume;
|
||||
|
||||
for (VolumeIndex = 0; VolumeIndex < VolumesCount; VolumeIndex++) {
|
||||
scanedVolume = Volumes[VolumeIndex];
|
||||
for (VolumeIndex = 0; VolumeIndex < Volumes.size(); VolumeIndex++) {
|
||||
scanedVolume = &Volumes[VolumeIndex];
|
||||
|
||||
if (scanedVolume == Volume)
|
||||
return TRUE;
|
||||
@ -1075,8 +1075,8 @@ VOID ScanLoader(VOID)
|
||||
//DBG("Scanning loaders...\n");
|
||||
DbgHeader("ScanLoader");
|
||||
|
||||
for (VolumeIndex = 0; VolumeIndex < VolumesCount; VolumeIndex++) {
|
||||
Volume = Volumes[VolumeIndex];
|
||||
for (VolumeIndex = 0; VolumeIndex < Volumes.size(); VolumeIndex++) {
|
||||
Volume = &Volumes[VolumeIndex];
|
||||
if (Volume->RootDir == NULL) { // || Volume->VolName == NULL)
|
||||
//DBG(", no file system\n", VolumeIndex);
|
||||
continue;
|
||||
@ -1541,14 +1541,14 @@ STATIC VOID AddCustomEntry(IN UINTN CustomIndex,
|
||||
DBG("all volumes\n");
|
||||
}
|
||||
|
||||
for (VolumeIndex = 0; VolumeIndex < VolumesCount; ++VolumeIndex) {
|
||||
for (VolumeIndex = 0; VolumeIndex < Volumes.size(); ++VolumeIndex) {
|
||||
CUSTOM_LOADER_ENTRY *CustomSubEntry;
|
||||
LOADER_ENTRY *Entry = NULL;
|
||||
EG_IMAGE *Image, *DriveImage;
|
||||
EFI_GUID *Guid = NULL;
|
||||
UINT64 VolumeSize;
|
||||
|
||||
Volume = Volumes[VolumeIndex];
|
||||
Volume = &Volumes[VolumeIndex];
|
||||
if ((Volume == NULL) || (Volume->RootDir == NULL)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -205,8 +205,8 @@ VOID ScanTool(VOID)
|
||||
}
|
||||
|
||||
// if (!gFirmwareClover) { //Slice: I wish to extend functionality on emulated nvram
|
||||
for (VolumeIndex = 0; VolumeIndex < VolumesCount; VolumeIndex++) {
|
||||
Volume = Volumes[VolumeIndex];
|
||||
for (VolumeIndex = 0; VolumeIndex < Volumes.size(); VolumeIndex++) {
|
||||
Volume = &Volumes[VolumeIndex];
|
||||
if (!Volume->RootDir || !Volume->DeviceHandle) {
|
||||
continue;
|
||||
}
|
||||
@ -258,8 +258,8 @@ VOID AddCustomTool(VOID)
|
||||
if (Custom->Volume) {
|
||||
DBG("Custom tool %d matching \"%s\" ...\n", i, Custom->Volume);
|
||||
}
|
||||
for (VolumeIndex = 0; VolumeIndex < VolumesCount; ++VolumeIndex) {
|
||||
Volume = Volumes[VolumeIndex];
|
||||
for (VolumeIndex = 0; VolumeIndex < Volumes.size(); ++VolumeIndex) {
|
||||
Volume = &Volumes[VolumeIndex];
|
||||
|
||||
DBG(" Checking volume \"%s\" (%s) ... ", Volume->VolName, Volume->DevicePathString);
|
||||
|
||||
|
@ -13,19 +13,49 @@ XImage::XImage(UINTN W, UINTN H)
|
||||
Height = H;
|
||||
PixelData.CheckSize(GetWidth()*GetHeight());
|
||||
}
|
||||
#if 0
|
||||
UINT8 Smooth(UINT8* P, int a01, int a10, int a11, int a21, int a12, int dx, int dy, float scale)
|
||||
#if 1
|
||||
UINT8 Smooth(const UINT8* p, int a01, int a10, int a21, int a12, int dx, int dy, float scale)
|
||||
{
|
||||
return (UINT8)((*(p + a01) * (scale - dx) * 3 + *(p + a10) * (scale - dy) * 3 + *(p + a21) * dx * 3 +
|
||||
*(p + a12) * dy * 3 + *(p + a11) * 2 *scale) / (scale * 8));
|
||||
return (UINT8)((*(p + a01) * (scale - dx) * 3.f + *(p + a10) * (scale - dy) * 3.f + *(p + a21) * dx * 3.f +
|
||||
*(p + a12) * dy * 3.f + *(p) * 2.f *scale) / (scale * 8.f));
|
||||
}
|
||||
#endif
|
||||
|
||||
XImage::XImage(const XImage& Image, float scale)
|
||||
{
|
||||
Width = (UINTN)(Image.GetWidth() * scale);
|
||||
Height = (UINTN)(Image.GetHeight() * scale);
|
||||
int SrcWidth = Image.GetWidth();
|
||||
int SrcHeight = Image.GetHeight();
|
||||
Width = (UINTN)(SrcWidth * scale);
|
||||
Height = (UINTN)(SrcHeight * scale);
|
||||
PixelData.CheckSize(GetWidth()*GetHeight());
|
||||
if (scale < 1.e-4) return;
|
||||
|
||||
int Pixel = sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL);
|
||||
int Row = SrcWidth * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL);
|
||||
|
||||
const XArray<EFI_GRAPHICS_OUTPUT_BLT_PIXEL>& Source = Image.GetData();
|
||||
|
||||
for (size_t y = 0; y < Height; y++)
|
||||
{
|
||||
int ly = (int)(y / scale);
|
||||
int dy = (int)(y - ly * scale);
|
||||
for (size_t x = 0; x < Width; x++)
|
||||
{
|
||||
int lx = (int)(x / scale);
|
||||
int dx = (int)(x - lx * scale);
|
||||
int a01 = (x == 0) ? 0 : -Pixel;
|
||||
int a10 = (y == 0) ? 0 : -Row;
|
||||
int a21 = (x == Width - 1) ? 0 : Pixel;
|
||||
int a12 = (y == Height - 1) ? 0 : Row;
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL& dst = *GetPixelPtr(x, y);
|
||||
dst.Blue = Smooth(&Source[lx + ly * SrcWidth].Blue, a01, a10, a21, a12, dx, dy, scale);
|
||||
dst.Green = Smooth(&Source[lx + ly * SrcWidth].Green, a01, a10, a21, a12, dx, dy, scale);
|
||||
dst.Red = Smooth(&Source[lx + ly * SrcWidth].Red, a01, a10, a21, a12, dx, dy, scale);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
UINTN Offset = OFFSET_OF(EFI_GRAPHICS_OUTPUT_BLT_PIXEL, Blue);
|
||||
|
||||
@ -86,7 +116,7 @@ do { \
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
XImage::~XImage()
|
||||
{
|
||||
@ -260,7 +290,7 @@ void XImage::GetArea(UINTN x, UINTN y, UINTN W, UINTN H)
|
||||
UINT32 ScreenHeight = 0;
|
||||
UINT32 Depth = 0;
|
||||
UINT32 RefreshRate = 60;
|
||||
EFI_STATUS Status = UgaDraw->GetMode(UgaDraw, &LineWidth, &ScreenHeight, &Depth, &RefreshRate);
|
||||
Status = UgaDraw->GetMode(UgaDraw, &LineWidth, &ScreenHeight, &Depth, &RefreshRate);
|
||||
if (EFI_ERROR(Status)) {
|
||||
return; // graphics not available
|
||||
}
|
||||
@ -277,10 +307,10 @@ void XImage::GetArea(UINTN x, UINTN y, UINTN W, UINTN H)
|
||||
void XImage::Draw(int x, int y, float scale)
|
||||
{
|
||||
//prepare images
|
||||
INTN UGAWidth = 0;
|
||||
INTN UGAHeight = 0;
|
||||
egGetScreenSize(&UGAWidth, &UGAHeight);
|
||||
XImage Background(UGAWidth, UGAHeight);
|
||||
INTN ScreenWidth = 0;
|
||||
INTN ScreenHeight = 0;
|
||||
egGetScreenSize(&ScreenWidth, &ScreenHeight);
|
||||
XImage Background(ScreenWidth, ScreenHeight);
|
||||
Background.GetArea(x, y, Width, Height);
|
||||
XImage Top(*this, scale);
|
||||
Background.Compose(x, y, Top, true);
|
||||
|
@ -248,6 +248,9 @@ About uivector, ucvector and string:
|
||||
-They're not used in the interface, only internally in this file as static functions.
|
||||
-As with many other structs in this file, the init and cleanup functions serve as ctor and dtor.
|
||||
*/
|
||||
/*
|
||||
Replaced std::vector by XArray
|
||||
*/
|
||||
|
||||
#ifdef LODEPNG_COMPILE_ZLIB
|
||||
/*dynamic vector of unsigned ints*/
|
||||
@ -5855,7 +5858,7 @@ unsigned lodepng_encode(unsigned char** out, size_t* outsize,
|
||||
unsigned alread_added_id_text = 0;
|
||||
for(i = 0; i != info.text_num; ++i)
|
||||
{
|
||||
if(!strcmp(info.text_keys[i], "LodePNG"))
|
||||
if(!AsciiStrCmp(info.text_keys[i], "LodePNG"))
|
||||
{
|
||||
alread_added_id_text = 1;
|
||||
break;
|
||||
@ -6086,7 +6089,7 @@ namespace lodepng
|
||||
{
|
||||
|
||||
#ifdef LODEPNG_COMPILE_DISK
|
||||
unsigned load_file(std::vector<unsigned char>& buffer, const std::string& filename)
|
||||
unsigned load_file(XArray<unsigned char>& buffer, const std::string& filename)
|
||||
{
|
||||
long size = lodepng_filesize(filename.c_str());
|
||||
if(size < 0) return 78;
|
||||
@ -6095,15 +6098,15 @@ unsigned load_file(std::vector<unsigned char>& buffer, const std::string& filena
|
||||
}
|
||||
|
||||
/*write given buffer to the file, overwriting the file, it doesn't append to it.*/
|
||||
unsigned save_file(const std::vector<unsigned char>& buffer, const std::string& filename)
|
||||
unsigned save_file(const XArray<unsigned char>& buffer, const std::string& filename)
|
||||
{
|
||||
return lodepng_save_file(buffer.empty() ? 0 : &buffer[0], buffer.size(), filename.c_str());
|
||||
return lodepng_save_file(buffer.isEmpty() ? 0 : &buffer[0], buffer.size(), filename.c_str());
|
||||
}
|
||||
#endif /* LODEPNG_COMPILE_DISK */
|
||||
|
||||
#ifdef LODEPNG_COMPILE_ZLIB
|
||||
#ifdef LODEPNG_COMPILE_DECODER
|
||||
unsigned decompress(std::vector<unsigned char>& out, const unsigned char* in, size_t insize,
|
||||
unsigned decompress(XArray<unsigned char>& out, const unsigned char* in, size_t insize,
|
||||
const LodePNGDecompressSettings& settings)
|
||||
{
|
||||
unsigned char* buffer = 0;
|
||||
@ -6111,21 +6114,22 @@ unsigned decompress(std::vector<unsigned char>& out, const unsigned char* in, si
|
||||
unsigned error = zlib_decompress(&buffer, &buffersize, in, insize, &settings);
|
||||
if(buffer)
|
||||
{
|
||||
out.insert(out.end(), &buffer[0], &buffer[buffersize]);
|
||||
// out.insert(out.end(), &buffer[0], &buffer[buffersize]);
|
||||
out.AddArray(buffer, buffersize);
|
||||
lodepng_free(buffer);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
unsigned decompress(std::vector<unsigned char>& out, const std::vector<unsigned char>& in,
|
||||
unsigned decompress(XArray<unsigned char>& out, const XArray<unsigned char>& in,
|
||||
const LodePNGDecompressSettings& settings)
|
||||
{
|
||||
return decompress(out, in.empty() ? 0 : &in[0], in.size(), settings);
|
||||
return decompress(out, in.isEmpty() ? 0 : &in[0], in.size(), settings);
|
||||
}
|
||||
#endif /* LODEPNG_COMPILE_DECODER */
|
||||
|
||||
#ifdef LODEPNG_COMPILE_ENCODER
|
||||
unsigned compress(std::vector<unsigned char>& out, const unsigned char* in, size_t insize,
|
||||
unsigned compress(XArray<unsigned char>& out, const unsigned char* in, size_t insize,
|
||||
const LodePNGCompressSettings& settings)
|
||||
{
|
||||
unsigned char* buffer = 0;
|
||||
@ -6133,16 +6137,17 @@ unsigned compress(std::vector<unsigned char>& out, const unsigned char* in, size
|
||||
unsigned error = zlib_compress(&buffer, &buffersize, in, insize, &settings);
|
||||
if(buffer)
|
||||
{
|
||||
out.insert(out.end(), &buffer[0], &buffer[buffersize]);
|
||||
// out.insert(out.end(), &buffer[0], &buffer[buffersize]);
|
||||
out.AddArray(buffer, buffersize);
|
||||
lodepng_free(buffer);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
unsigned compress(std::vector<unsigned char>& out, const std::vector<unsigned char>& in,
|
||||
unsigned compress(XArray<unsigned char>& out, const XArray<unsigned char>& in,
|
||||
const LodePNGCompressSettings& settings)
|
||||
{
|
||||
return compress(out, in.empty() ? 0 : &in[0], in.size(), settings);
|
||||
return compress(out, in.isEmpty() ? 0 : &in[0], in.size(), settings);
|
||||
}
|
||||
#endif /* LODEPNG_COMPILE_ENCODER */
|
||||
#endif /* LODEPNG_COMPILE_ZLIB */
|
||||
@ -6174,7 +6179,7 @@ State& State::operator=(const State& other)
|
||||
|
||||
#ifdef LODEPNG_COMPILE_DECODER
|
||||
|
||||
unsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h, const unsigned char* in,
|
||||
unsigned decode(XArray<unsigned char>& out, unsigned& w, unsigned& h, const unsigned char* in,
|
||||
size_t insize, LodePNGColorType colortype, unsigned bitdepth)
|
||||
{
|
||||
unsigned char* buffer;
|
||||
@ -6185,19 +6190,20 @@ unsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h, const
|
||||
state.info_raw.colortype = colortype;
|
||||
state.info_raw.bitdepth = bitdepth;
|
||||
size_t buffersize = lodepng_get_raw_size(w, h, &state.info_raw);
|
||||
out.insert(out.end(), &buffer[0], &buffer[buffersize]);
|
||||
// out.insert(out.end(), &buffer[0], &buffer[buffersize]);
|
||||
out.AddArray(buffer, buffersize);
|
||||
lodepng_free(buffer);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
unsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h,
|
||||
const std::vector<unsigned char>& in, LodePNGColorType colortype, unsigned bitdepth)
|
||||
unsigned decode(XArray<unsigned char>& out, unsigned& w, unsigned& h,
|
||||
const XArray<unsigned char>& in, LodePNGColorType colortype, unsigned bitdepth)
|
||||
{
|
||||
return decode(out, w, h, in.empty() ? 0 : &in[0], (unsigned)in.size(), colortype, bitdepth);
|
||||
return decode(out, w, h, in.isEmpty() ? 0 : &in[0], (unsigned)in.size(), colortype, bitdepth);
|
||||
}
|
||||
|
||||
unsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h,
|
||||
unsigned decode(XArray<unsigned char>& out, unsigned& w, unsigned& h,
|
||||
State& state,
|
||||
const unsigned char* in, size_t insize)
|
||||
{
|
||||
@ -6206,24 +6212,25 @@ unsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h,
|
||||
if(buffer && !error)
|
||||
{
|
||||
size_t buffersize = lodepng_get_raw_size(w, h, &state.info_raw);
|
||||
out.insert(out.end(), &buffer[0], &buffer[buffersize]);
|
||||
// out.insert(out.end(), &buffer[0], &buffer[buffersize]);
|
||||
out.AddArray(buffer, buffersize);
|
||||
}
|
||||
lodepng_free(buffer);
|
||||
return error;
|
||||
}
|
||||
|
||||
unsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h,
|
||||
unsigned decode(XArray<unsigned char>& out, unsigned& w, unsigned& h,
|
||||
State& state,
|
||||
const std::vector<unsigned char>& in)
|
||||
const XArray<unsigned char>& in)
|
||||
{
|
||||
return decode(out, w, h, state, in.empty() ? 0 : &in[0], in.size());
|
||||
return decode(out, w, h, state, in.isEmpty() ? 0 : &in[0], in.size());
|
||||
}
|
||||
|
||||
#ifdef LODEPNG_COMPILE_DISK
|
||||
unsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h, const std::string& filename,
|
||||
unsigned decode(XArray<unsigned char>& out, unsigned& w, unsigned& h, const std::string& filename,
|
||||
LodePNGColorType colortype, unsigned bitdepth)
|
||||
{
|
||||
std::vector<unsigned char> buffer;
|
||||
XArray<unsigned char> buffer;
|
||||
unsigned error = load_file(buffer, filename);
|
||||
if(error) return error;
|
||||
return decode(out, w, h, buffer, colortype, bitdepth);
|
||||
@ -6232,7 +6239,7 @@ unsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h, const
|
||||
#endif /* LODEPNG_COMPILE_DISK */
|
||||
|
||||
#ifdef LODEPNG_COMPILE_ENCODER
|
||||
unsigned encode(std::vector<unsigned char>& out, const unsigned char* in, unsigned w, unsigned h,
|
||||
unsigned encode(XArray<unsigned char>& out, const unsigned char* in, unsigned w, unsigned h,
|
||||
LodePNGColorType colortype, unsigned bitdepth)
|
||||
{
|
||||
unsigned char* buffer;
|
||||
@ -6240,21 +6247,22 @@ unsigned encode(std::vector<unsigned char>& out, const unsigned char* in, unsign
|
||||
unsigned error = lodepng_encode_memory(&buffer, &buffersize, in, w, h, colortype, bitdepth);
|
||||
if(buffer)
|
||||
{
|
||||
out.insert(out.end(), &buffer[0], &buffer[buffersize]);
|
||||
// out.insert(out.end(), &buffer[0], &buffer[buffersize]);
|
||||
out.AddArray(buffer, buffersize);
|
||||
lodepng_free(buffer);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
unsigned encode(std::vector<unsigned char>& out,
|
||||
const std::vector<unsigned char>& in, unsigned w, unsigned h,
|
||||
unsigned encode(XArray<unsigned char>& out,
|
||||
const XArray<unsigned char>& in, unsigned w, unsigned h,
|
||||
LodePNGColorType colortype, unsigned bitdepth)
|
||||
{
|
||||
if(lodepng_get_raw_size_lct(w, h, colortype, bitdepth) > in.size()) return 84;
|
||||
return encode(out, in.empty() ? 0 : &in[0], w, h, colortype, bitdepth);
|
||||
return encode(out, in.isEmpty() ? 0 : &in[0], w, h, colortype, bitdepth);
|
||||
}
|
||||
|
||||
unsigned encode(std::vector<unsigned char>& out,
|
||||
unsigned encode(XArray<unsigned char>& out,
|
||||
const unsigned char* in, unsigned w, unsigned h,
|
||||
State& state)
|
||||
{
|
||||
@ -6263,18 +6271,19 @@ unsigned encode(std::vector<unsigned char>& out,
|
||||
unsigned error = lodepng_encode(&buffer, &buffersize, in, w, h, &state);
|
||||
if(buffer)
|
||||
{
|
||||
out.insert(out.end(), &buffer[0], &buffer[buffersize]);
|
||||
// out.insert(out.end(), &buffer[0], &buffer[buffersize]);
|
||||
out.AddArray(buffer, buffersize);
|
||||
lodepng_free(buffer);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
unsigned encode(std::vector<unsigned char>& out,
|
||||
const std::vector<unsigned char>& in, unsigned w, unsigned h,
|
||||
unsigned encode(XArray<unsigned char>& out,
|
||||
const XArray<unsigned char>& in, unsigned w, unsigned h,
|
||||
State& state)
|
||||
{
|
||||
if(lodepng_get_raw_size(w, h, &state.info_raw) > in.size()) return 84;
|
||||
return encode(out, in.empty() ? 0 : &in[0], w, h, state);
|
||||
return encode(out, in.isEmpty() ? 0 : &in[0], w, h, state);
|
||||
}
|
||||
|
||||
#ifdef LODEPNG_COMPILE_DISK
|
||||
@ -6282,18 +6291,18 @@ unsigned encode(const std::string& filename,
|
||||
const unsigned char* in, unsigned w, unsigned h,
|
||||
LodePNGColorType colortype, unsigned bitdepth)
|
||||
{
|
||||
std::vector<unsigned char> buffer;
|
||||
XArray<unsigned char> buffer;
|
||||
unsigned error = encode(buffer, in, w, h, colortype, bitdepth);
|
||||
if(!error) error = save_file(buffer, filename);
|
||||
return error;
|
||||
}
|
||||
|
||||
unsigned encode(const std::string& filename,
|
||||
const std::vector<unsigned char>& in, unsigned w, unsigned h,
|
||||
const XArray<unsigned char>& in, unsigned w, unsigned h,
|
||||
LodePNGColorType colortype, unsigned bitdepth)
|
||||
{
|
||||
if(lodepng_get_raw_size_lct(w, h, colortype, bitdepth) > in.size()) return 84;
|
||||
return encode(filename, in.empty() ? 0 : &in[0], w, h, colortype, bitdepth);
|
||||
return encode(filename, in.isEmpty() ? 0 : &in[0], w, h, colortype, bitdepth);
|
||||
}
|
||||
#endif /* LODEPNG_COMPILE_DISK */
|
||||
#endif /* LODEPNG_COMPILE_ENCODER */
|
||||
|
@ -29,13 +29,16 @@ freely, subject to the following restrictions:
|
||||
|
||||
//MODSNI v
|
||||
#include <Uefi.h>
|
||||
#include "../cpp_foundation/XToolsCommon.h"
|
||||
#include "../cpp_foundation/XArray.h"
|
||||
|
||||
|
||||
//#define LODEPNG_NO_COMPILE_DECODER
|
||||
#define LODEPNG_NO_COMPILE_DISK
|
||||
//#define LODEPNG_NO_COMPILE_ALLOCATORS
|
||||
//#define LODEPNG_NO_COMPILE_ERROR_TEXT
|
||||
#define LODEPNG_NO_COMPILE_ANCILLARY_CHUNKS
|
||||
#define LODEPNG_NO_COMPILE_CPP
|
||||
//#define LODEPNG_NO_COMPILE_ANCILLARY_CHUNKS
|
||||
//#define LODEPNG_NO_COMPILE_CPP
|
||||
|
||||
// Microsoft compiler has built-in size_t
|
||||
//#if !defined(_MSC_VER)
|
||||
@ -224,33 +227,33 @@ unsigned lodepng_encode24_file(const char* filename,
|
||||
namespace lodepng
|
||||
{
|
||||
#ifdef LODEPNG_COMPILE_DECODER
|
||||
/*Same as lodepng_decode_memory, but decodes to an std::vector. The colortype
|
||||
/*Same as lodepng_decode_memory, but decodes to an XArray. The colortype
|
||||
is the format to output the pixels to. Default is RGBA 8-bit per channel.*/
|
||||
unsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h,
|
||||
unsigned decode(XArray<unsigned char>& out, unsigned& w, unsigned& h,
|
||||
const unsigned char* in, size_t insize,
|
||||
LodePNGColorType colortype = LCT_RGBA, unsigned bitdepth = 8);
|
||||
unsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h,
|
||||
const std::vector<unsigned char>& in,
|
||||
unsigned decode(XArray<unsigned char>& out, unsigned& w, unsigned& h,
|
||||
const XArray<unsigned char>& in,
|
||||
LodePNGColorType colortype = LCT_RGBA, unsigned bitdepth = 8);
|
||||
#ifdef LODEPNG_COMPILE_DISK
|
||||
/*
|
||||
Converts PNG file from disk to raw pixel data in memory.
|
||||
Same as the other decode functions, but instead takes a filename as input.
|
||||
*/
|
||||
unsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h,
|
||||
unsigned decode(XArray<unsigned char>& out, unsigned& w, unsigned& h,
|
||||
const std::string& filename,
|
||||
LodePNGColorType colortype = LCT_RGBA, unsigned bitdepth = 8);
|
||||
#endif /* LODEPNG_COMPILE_DISK */
|
||||
#endif /* LODEPNG_COMPILE_DECODER */
|
||||
|
||||
#ifdef LODEPNG_COMPILE_ENCODER
|
||||
/*Same as lodepng_encode_memory, but encodes to an std::vector. colortype
|
||||
/*Same as lodepng_encode_memory, but encodes to an XArray. colortype
|
||||
is that of the raw input data. The output PNG color type will be auto chosen.*/
|
||||
unsigned encode(std::vector<unsigned char>& out,
|
||||
unsigned encode(XArray<unsigned char>& out,
|
||||
const unsigned char* in, unsigned w, unsigned h,
|
||||
LodePNGColorType colortype = LCT_RGBA, unsigned bitdepth = 8);
|
||||
unsigned encode(std::vector<unsigned char>& out,
|
||||
const std::vector<unsigned char>& in, unsigned w, unsigned h,
|
||||
unsigned encode(XArray<unsigned char>& out,
|
||||
const XArray<unsigned char>& in, unsigned w, unsigned h,
|
||||
LodePNGColorType colortype = LCT_RGBA, unsigned bitdepth = 8);
|
||||
#ifdef LODEPNG_COMPILE_DISK
|
||||
/*
|
||||
@ -262,7 +265,7 @@ unsigned encode(const std::string& filename,
|
||||
const unsigned char* in, unsigned w, unsigned h,
|
||||
LodePNGColorType colortype = LCT_RGBA, unsigned bitdepth = 8);
|
||||
unsigned encode(const std::string& filename,
|
||||
const std::vector<unsigned char>& in, unsigned w, unsigned h,
|
||||
const XArray<unsigned char>& in, unsigned w, unsigned h,
|
||||
LodePNGColorType colortype = LCT_RGBA, unsigned bitdepth = 8);
|
||||
#endif /* LODEPNG_COMPILE_DISK */
|
||||
#endif /* LODEPNG_COMPILE_ENCODER */
|
||||
@ -838,7 +841,7 @@ unsigned lodepng_save_file(const unsigned char* buffer, size_t buffersize, const
|
||||
#endif /*LODEPNG_COMPILE_DISK*/
|
||||
|
||||
#ifdef LODEPNG_COMPILE_CPP
|
||||
/* The LodePNG C++ wrapper uses std::vectors instead of manually allocated memory buffers. */
|
||||
/* The LodePNG C++ wrapper uses XArrays instead of manually allocated memory buffers. */
|
||||
namespace lodepng
|
||||
{
|
||||
#ifdef LODEPNG_COMPILE_PNG
|
||||
@ -853,57 +856,57 @@ class State : public LodePNGState
|
||||
|
||||
#ifdef LODEPNG_COMPILE_DECODER
|
||||
/* Same as other lodepng::decode, but using a State for more settings and information. */
|
||||
unsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h,
|
||||
unsigned decode(XArray<unsigned char>& out, unsigned& w, unsigned& h,
|
||||
State& state,
|
||||
const unsigned char* in, size_t insize);
|
||||
unsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h,
|
||||
unsigned decode(XArray<unsigned char>& out, unsigned& w, unsigned& h,
|
||||
State& state,
|
||||
const std::vector<unsigned char>& in);
|
||||
const XArray<unsigned char>& in);
|
||||
#endif /*LODEPNG_COMPILE_DECODER*/
|
||||
|
||||
#ifdef LODEPNG_COMPILE_ENCODER
|
||||
/* Same as other lodepng::encode, but using a State for more settings and information. */
|
||||
unsigned encode(std::vector<unsigned char>& out,
|
||||
unsigned encode(XArray<unsigned char>& out,
|
||||
const unsigned char* in, unsigned w, unsigned h,
|
||||
State& state);
|
||||
unsigned encode(std::vector<unsigned char>& out,
|
||||
const std::vector<unsigned char>& in, unsigned w, unsigned h,
|
||||
unsigned encode(XArray<unsigned char>& out,
|
||||
const XArray<unsigned char>& in, unsigned w, unsigned h,
|
||||
State& state);
|
||||
#endif /*LODEPNG_COMPILE_ENCODER*/
|
||||
|
||||
#ifdef LODEPNG_COMPILE_DISK
|
||||
/*
|
||||
Load a file from disk into an std::vector.
|
||||
Load a file from disk into an XArray.
|
||||
return value: error code (0 means ok)
|
||||
*/
|
||||
unsigned load_file(std::vector<unsigned char>& buffer, const std::string& filename);
|
||||
unsigned load_file(XArray<unsigned char>& buffer, const std::string& filename);
|
||||
|
||||
/*
|
||||
Save the binary data in an std::vector to a file on disk. The file is overwritten
|
||||
Save the binary data in an XArray to a file on disk. The file is overwritten
|
||||
without warning.
|
||||
*/
|
||||
unsigned save_file(const std::vector<unsigned char>& buffer, const std::string& filename);
|
||||
unsigned save_file(const XArray<unsigned char>& buffer, const std::string& filename);
|
||||
#endif /* LODEPNG_COMPILE_DISK */
|
||||
#endif /* LODEPNG_COMPILE_PNG */
|
||||
|
||||
#ifdef LODEPNG_COMPILE_ZLIB
|
||||
#ifdef LODEPNG_COMPILE_DECODER
|
||||
/* Zlib-decompress an unsigned char buffer */
|
||||
unsigned decompress(std::vector<unsigned char>& out, const unsigned char* in, size_t insize,
|
||||
unsigned decompress(XArray<unsigned char>& out, const unsigned char* in, size_t insize,
|
||||
const LodePNGDecompressSettings& settings = lodepng_default_decompress_settings);
|
||||
|
||||
/* Zlib-decompress an std::vector */
|
||||
unsigned decompress(std::vector<unsigned char>& out, const std::vector<unsigned char>& in,
|
||||
/* Zlib-decompress an XArray */
|
||||
unsigned decompress(XArray<unsigned char>& out, const XArray<unsigned char>& in,
|
||||
const LodePNGDecompressSettings& settings = lodepng_default_decompress_settings);
|
||||
#endif /* LODEPNG_COMPILE_DECODER */
|
||||
|
||||
#ifdef LODEPNG_COMPILE_ENCODER
|
||||
/* Zlib-compress an unsigned char buffer */
|
||||
unsigned compress(std::vector<unsigned char>& out, const unsigned char* in, size_t insize,
|
||||
unsigned compress(XArray<unsigned char>& out, const unsigned char* in, size_t insize,
|
||||
const LodePNGCompressSettings& settings = lodepng_default_compress_settings);
|
||||
|
||||
/* Zlib-compress an std::vector */
|
||||
unsigned compress(std::vector<unsigned char>& out, const std::vector<unsigned char>& in,
|
||||
/* Zlib-compress an XArray */
|
||||
unsigned compress(XArray<unsigned char>& out, const XArray<unsigned char>& in,
|
||||
const LodePNGCompressSettings& settings = lodepng_default_compress_settings);
|
||||
#endif /* LODEPNG_COMPILE_ENCODER */
|
||||
#endif /* LODEPNG_COMPILE_ZLIB */
|
||||
@ -1058,7 +1061,7 @@ The C version uses buffers allocated with alloc that you need to free()
|
||||
yourself. You need to use init and cleanup functions for each struct whenever
|
||||
using a struct from the C version to avoid exploits and memory leaks.
|
||||
|
||||
The C++ version has extra functions with std::vectors in the interface and the
|
||||
The C++ version has extra functions with XArrays in the interface and the
|
||||
lodepng::State class which is a LodePNGState with constructor and destructor.
|
||||
|
||||
These files work without modification for both C and C++ compilers because all
|
||||
@ -1492,7 +1495,7 @@ encoder and decoder, this makes a large difference.
|
||||
|
||||
Make sure that LodePNG is compiled with the same compiler of the same version
|
||||
and with the same settings as the rest of the program, or the interfaces with
|
||||
std::vectors and std::strings in C++ can be incompatible.
|
||||
XArrays and std::strings in C++ can be incompatible.
|
||||
|
||||
CHAR_BITS must be 8 or higher, because LodePNG uses unsigned chars for octets.
|
||||
|
||||
@ -1555,7 +1558,7 @@ int main(int argc, char *argv[])
|
||||
const char* filename = argc > 1 ? argv[1] : "test.png";
|
||||
|
||||
//load and decode
|
||||
std::vector<unsigned char> image;
|
||||
XArray<unsigned char> image;
|
||||
unsigned width, height;
|
||||
unsigned error = lodepng::decode(image, width, height, filename);
|
||||
|
||||
@ -1672,7 +1675,7 @@ symbol.
|
||||
*) 21 jul 2007: deflate code placed in new namespace separate from zlib code
|
||||
*) 08 jun 2007: fixed bug with 2- and 4-bit color, and small interlaced images
|
||||
*) 04 jun 2007: improved support for Visual Studio 2005: crash with accessing
|
||||
invalid std::vector element [0] fixed, and level 3 and 4 warnings removed
|
||||
invalid XArray element [0] fixed, and level 3 and 4 warnings removed
|
||||
*) 02 jun 2007: made the encoder add a tag with version by default
|
||||
*) 27 may 2007: zlib and png code separated (but still in the same file),
|
||||
simple encoder/decoder functions added for more simple usage cases
|
||||
@ -1726,7 +1729,7 @@ symbol.
|
||||
in LodePNG namespace. Changed the order of the parameters. Rewrote the
|
||||
documentation in the header. Renamed files to lodepng.cpp and lodepng.h
|
||||
*) 22 apr 2006: Optimized and improved some code
|
||||
*) 07 sep 2005: (!) Changed to std::vector interface
|
||||
*) 07 sep 2005: (!) Changed to XArray interface
|
||||
*) 12 aug 2005: Initial release (C++, decoder only)
|
||||
|
||||
|
||||
|
@ -81,8 +81,8 @@
|
||||
libeg/VectorGraphics.cpp
|
||||
libeg/libeg.h
|
||||
libeg/libegint.h
|
||||
libeg/XImage.cpp
|
||||
libeg/XImage.h
|
||||
# libeg/XImage.cpp
|
||||
# libeg/XImage.h
|
||||
Platform/AcpiPatcher.cpp
|
||||
Platform/ati_reg.h
|
||||
Platform/AmlGenerator.cpp
|
||||
|
@ -71,8 +71,9 @@ EFI_FILE *OemThemeDir = NULL;
|
||||
|
||||
|
||||
REFIT_VOLUME *SelfVolume = NULL;
|
||||
REFIT_VOLUME **Volumes = NULL;
|
||||
UINTN VolumesCount = 0;
|
||||
//REFIT_VOLUME **Volumes = NULL;
|
||||
//UINTN VolumesCount = 0;
|
||||
XObjArray<REFIT_VOLUME> Volumes;
|
||||
//
|
||||
// Unicode collation protocol interface
|
||||
//
|
||||
@ -334,19 +335,19 @@ BOOLEAN IsEmbeddedTheme()
|
||||
//
|
||||
// list functions
|
||||
//
|
||||
|
||||
VOID CreateList(OUT VOID ***ListPtr, OUT UINTN *ElementCount, IN UINTN InitialElementCount)
|
||||
{
|
||||
UINTN AllocateCount;
|
||||
|
||||
*ElementCount = InitialElementCount;
|
||||
if (*ElementCount > 0) {
|
||||
AllocateCount = (*ElementCount + 7) & ~7; // next multiple of 8
|
||||
*ListPtr = (__typeof_am__(*ListPtr))AllocatePool(sizeof(VOID *) * AllocateCount);
|
||||
} else {
|
||||
*ListPtr = NULL;
|
||||
}
|
||||
}
|
||||
//
|
||||
//VOID CreateList(OUT VOID ***ListPtr, OUT UINTN *ElementCount, IN UINTN InitialElementCount)
|
||||
//{
|
||||
// UINTN AllocateCount;
|
||||
//
|
||||
// *ElementCount = InitialElementCount;
|
||||
// if (*ElementCount > 0) {
|
||||
// AllocateCount = (*ElementCount + 7) & ~7; // next multiple of 8
|
||||
// *ListPtr = (__typeof_am__(*ListPtr))AllocatePool(sizeof(VOID *) * AllocateCount);
|
||||
// } else {
|
||||
// *ListPtr = NULL;
|
||||
// }
|
||||
//}
|
||||
|
||||
VOID AddListElement(IN OUT VOID ***ListPtr, IN OUT UINTN *ElementCount, IN VOID *NewElement)
|
||||
{
|
||||
@ -1077,7 +1078,7 @@ static VOID ScanExtendedPartition(REFIT_VOLUME *WholeDiskVolume, MBR_PARTITION_I
|
||||
} else {
|
||||
|
||||
// found a logical partition
|
||||
Volume = (__typeof__(Volume))AllocateZeroPool(sizeof(REFIT_VOLUME));
|
||||
Volume = (__typeof__(Volume))AllocateZeroPool(sizeof(*Volume));
|
||||
Volume->DiskKind = WholeDiskVolume->DiskKind;
|
||||
Volume->IsMbrPartition = TRUE;
|
||||
Volume->MbrPartitionIndex = LogicalPartitionIndex++;
|
||||
@ -1092,7 +1093,8 @@ static VOID ScanExtendedPartition(REFIT_VOLUME *WholeDiskVolume, MBR_PARTITION_I
|
||||
if (!Bootable)
|
||||
Volume->HasBootCode = FALSE;
|
||||
|
||||
AddListElement((VOID ***) &Volumes, &VolumesCount, Volume);
|
||||
Volumes.AddReference(Volume, true);
|
||||
// AddListElement((VOID ***) &Volumes, &VolumesCount, Volume);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1105,7 +1107,7 @@ VOID ScanVolumes(VOID)
|
||||
UINTN HandleCount = 0;
|
||||
UINTN HandleIndex;
|
||||
EFI_HANDLE *Handles = NULL;
|
||||
REFIT_VOLUME *Volume, *WholeDiskVolume;
|
||||
REFIT_VOLUME *WholeDiskVolume;
|
||||
UINTN VolumeIndex, VolumeIndex2;
|
||||
MBR_PARTITION_INFO *MbrTable;
|
||||
UINTN PartitionIndex;
|
||||
@ -1127,7 +1129,7 @@ VOID ScanVolumes(VOID)
|
||||
// first pass: collect information about all handles
|
||||
for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {
|
||||
|
||||
Volume = (__typeof__(Volume))AllocateZeroPool(sizeof(REFIT_VOLUME));
|
||||
REFIT_VOLUME* Volume = (__typeof__(Volume))AllocateZeroPool(sizeof(*Volume));
|
||||
Volume->LegacyOS = (__typeof__(Volume->LegacyOS))AllocateZeroPool(sizeof(LEGACY_OS));
|
||||
Volume->DeviceHandle = Handles[HandleIndex];
|
||||
if (Volume->DeviceHandle == SelfDeviceHandle) {
|
||||
@ -1140,8 +1142,8 @@ VOID ScanVolumes(VOID)
|
||||
|
||||
Status = ScanVolume(Volume);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
|
||||
AddListElement((VOID ***) &Volumes, &VolumesCount, Volume);
|
||||
Volumes.AddReference(Volume, true);
|
||||
// AddListElement((VOID ***) &Volumes, &VolumesCount, Volume);
|
||||
if (!gSettings.ShowHiddenEntries) {
|
||||
for (HVi = 0; HVi < gSettings.HVCount; HVi++) {
|
||||
if (StriStr(Volume->DevicePathString, gSettings.HVHideStrings[HVi]) ||
|
||||
@ -1186,8 +1188,8 @@ VOID ScanVolumes(VOID)
|
||||
}
|
||||
|
||||
// second pass: relate partitions and whole disk devices
|
||||
for (VolumeIndex = 0; VolumeIndex < VolumesCount; VolumeIndex++) {
|
||||
Volume = Volumes[VolumeIndex];
|
||||
for (VolumeIndex = 0; VolumeIndex < Volumes.size(); VolumeIndex++) {
|
||||
REFIT_VOLUME* Volume = &Volumes[VolumeIndex];
|
||||
|
||||
// check MBR partition table for extended partitions
|
||||
if (Volume->BlockIO != NULL && Volume->WholeDiskBlockIO != NULL &&
|
||||
@ -1206,10 +1208,10 @@ VOID ScanVolumes(VOID)
|
||||
WholeDiskVolume = NULL;
|
||||
if (Volume->BlockIO != NULL && Volume->WholeDiskBlockIO != NULL &&
|
||||
Volume->BlockIO != Volume->WholeDiskBlockIO) {
|
||||
for (VolumeIndex2 = 0; VolumeIndex2 < VolumesCount; VolumeIndex2++) {
|
||||
if (Volumes[VolumeIndex2]->BlockIO == Volume->WholeDiskBlockIO &&
|
||||
Volumes[VolumeIndex2]->BlockIOOffset == 0)
|
||||
WholeDiskVolume = Volumes[VolumeIndex2];
|
||||
for (VolumeIndex2 = 0; VolumeIndex2 < Volumes.size(); VolumeIndex2++) {
|
||||
if (Volumes[VolumeIndex2].BlockIO == Volume->WholeDiskBlockIO &&
|
||||
Volumes[VolumeIndex2].BlockIOOffset == 0)
|
||||
WholeDiskVolume = &Volumes[VolumeIndex2];
|
||||
}
|
||||
}
|
||||
if (WholeDiskVolume != NULL && WholeDiskVolume->MbrPartitionTable != NULL) {
|
||||
@ -1263,8 +1265,8 @@ static VOID UninitVolumes(VOID)
|
||||
REFIT_VOLUME *Volume;
|
||||
UINTN VolumeIndex;
|
||||
|
||||
for (VolumeIndex = 0; VolumeIndex < VolumesCount; VolumeIndex++) {
|
||||
Volume = Volumes[VolumeIndex];
|
||||
for (VolumeIndex = 0; VolumeIndex < Volumes.size(); VolumeIndex++) {
|
||||
Volume = &Volumes[VolumeIndex];
|
||||
|
||||
if (Volume->RootDir != NULL) {
|
||||
Volume->RootDir->Close(Volume->RootDir);
|
||||
@ -1277,13 +1279,7 @@ static VOID UninitVolumes(VOID)
|
||||
Volume->WholeDiskDeviceHandle = NULL;
|
||||
FreePool(Volume);
|
||||
}
|
||||
|
||||
if (Volumes != NULL) {
|
||||
FreePool(Volumes);
|
||||
Volumes = NULL;
|
||||
}
|
||||
VolumesCount = 0;
|
||||
|
||||
Volumes.Empty();
|
||||
}
|
||||
|
||||
VOID ReinitVolumes(VOID)
|
||||
@ -1295,8 +1291,8 @@ VOID ReinitVolumes(VOID)
|
||||
EFI_DEVICE_PATH *RemainingDevicePath;
|
||||
EFI_HANDLE DeviceHandle, WholeDiskHandle;
|
||||
|
||||
for (VolumeIndex = 0; VolumeIndex < VolumesCount; VolumeIndex++) {
|
||||
Volume = Volumes[VolumeIndex];
|
||||
for (VolumeIndex = 0; VolumeIndex < Volumes.size(); VolumeIndex++) {
|
||||
Volume = &Volumes[VolumeIndex];
|
||||
if (!Volume) {
|
||||
continue;
|
||||
}
|
||||
@ -1337,7 +1333,10 @@ VOID ReinitVolumes(VOID)
|
||||
// CheckError(Status, L"from LocateDevicePath");
|
||||
}
|
||||
}
|
||||
VolumesCount = VolumesFound;
|
||||
// Jief : I'm not sure to understand the next line. Why would we change the count when we didn't change the array.
|
||||
// This code is not currently not used.
|
||||
// Beware if you want to reuse this.
|
||||
// VolumesCount = VolumesFound;
|
||||
}
|
||||
|
||||
REFIT_VOLUME *FindVolumeByName(IN CHAR16 *VolName)
|
||||
@ -1349,8 +1348,8 @@ REFIT_VOLUME *FindVolumeByName(IN CHAR16 *VolName)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (VolumeIndex = 0; VolumeIndex < VolumesCount; VolumeIndex++) {
|
||||
Volume = Volumes[VolumeIndex];
|
||||
for (VolumeIndex = 0; VolumeIndex < Volumes.size(); VolumeIndex++) {
|
||||
Volume = &Volumes[VolumeIndex];
|
||||
if (!Volume) {
|
||||
continue;
|
||||
}
|
||||
|
@ -68,6 +68,7 @@
|
||||
// Experimental <--
|
||||
|
||||
#include "libeg.h"
|
||||
#include "../cpp_foundation/XObjArray.h"
|
||||
|
||||
#define REFIT_DEBUG (2)
|
||||
#define Print if ((!GlobalConfig.Quiet) || (GlobalConfig.TextOnly)) Print
|
||||
@ -693,8 +694,8 @@ extern BOOLEAN MainAnime;
|
||||
extern GUI_ANIME *GuiAnime;
|
||||
|
||||
extern REFIT_VOLUME *SelfVolume;
|
||||
extern REFIT_VOLUME **Volumes;
|
||||
extern UINTN VolumesCount;
|
||||
extern XObjArray<REFIT_VOLUME> Volumes;
|
||||
//extern UINTN VolumesCount;
|
||||
|
||||
extern EG_IMAGE *Banner;
|
||||
extern EG_IMAGE *BigBack;
|
||||
|
@ -630,7 +630,7 @@ static VOID StartLoader(IN LOADER_ENTRY *Entry)
|
||||
font = nextFont;
|
||||
}
|
||||
nsvg__deleteParser(mainParser);
|
||||
destruct_globals_objects(NULL);
|
||||
//destruct_globals_objects(NULL); //we can't destruct our globals here. We need, for example, Volumes.
|
||||
|
||||
//DumpKernelAndKextPatches(Entry->KernelAndKextPatches);
|
||||
|
||||
@ -1847,9 +1847,9 @@ UINT8 *APFSContainer_Support(VOID) {
|
||||
EFI_GUID *TmpUUID = NULL;
|
||||
|
||||
//Fill APFSUUIDBank
|
||||
APFSUUIDBank = (__typeof__(APFSUUIDBank))AllocateZeroPool(0x10*VolumesCount);
|
||||
for (VolumeIndex = 0; VolumeIndex < VolumesCount; VolumeIndex++) {
|
||||
Volume = Volumes[VolumeIndex];
|
||||
APFSUUIDBank = (__typeof__(APFSUUIDBank))AllocateZeroPool(0x10*Volumes.size());
|
||||
for (VolumeIndex = 0; VolumeIndex < Volumes.size(); VolumeIndex++) {
|
||||
Volume = &Volumes[VolumeIndex];
|
||||
//Check that current volume - apfs partition
|
||||
if ((TmpUUID = APFSPartitionUUIDExtract(Volume->DevicePath)) != NULL){
|
||||
CopyMem(APFSUUIDBank+APFSUUIDBankCounter*0x10,(UINT8 *)TmpUUID,0x10);
|
||||
|
@ -4353,7 +4353,7 @@ UINTN RunMenu(IN REFIT_MENU_SCREEN *Screen, OUT REFIT_MENU_ENTRY **ChosenEntry)
|
||||
VOID NewEntry(REFIT_MENU_ENTRY **Entry, REFIT_MENU_SCREEN **SubScreen, ACTION AtClick, UINTN ID, CONST CHAR8 *Title)
|
||||
{
|
||||
//create entry
|
||||
*Entry = (__typeof_am__(*Entry))AllocateZeroPool(sizeof(LOADER_ENTRY));
|
||||
*Entry = (__typeof_am__(*Entry))AllocateZeroPool(sizeof(LOADER_ENTRY)); // carefull, **Entry is not a LOADER_ENTRY. Don't use sizeof.
|
||||
if (Title) {
|
||||
(*Entry)->Title = PoolPrint(L"%a", Title);
|
||||
} else {
|
||||
@ -4364,7 +4364,7 @@ VOID NewEntry(REFIT_MENU_ENTRY **Entry, REFIT_MENU_SCREEN **SubScreen, ACTION At
|
||||
(*Entry)->Tag = TAG_OPTIONS;
|
||||
(*Entry)->AtClick = AtClick;
|
||||
// create the submenu
|
||||
*SubScreen = (__typeof_am__(*SubScreen))AllocateZeroPool(sizeof(REFIT_MENU_SCREEN));
|
||||
*SubScreen = (__typeof_am__(*SubScreen))AllocateZeroPool(sizeof(**SubScreen));
|
||||
(*SubScreen)->Title = (*Entry)->Title;
|
||||
(*SubScreen)->TitleImage = (*Entry)->Image;
|
||||
(*SubScreen)->ID = ID;
|
||||
|
Loading…
Reference in New Issue
Block a user